工作台图标

This commit is contained in:
2026-09-24 09:54:39 +08:00
parent e899b30562
commit 2078923deb
5 changed files with 157 additions and 52 deletions
+85 -16
View File
@@ -63,23 +63,92 @@ export function openHref(webPath, extra = {}) {
return true
}
const EMOJI = {
expense: '🧾', loan: '¥', leave: '休', trip: '✈', procurement: '购',
overtime: '加', outing: '出', card: '补', transfer: '转', regularize: '正',
resign: '离', layoff: '裁', seal: '章', receive: '领', clock: '📍',
todo: '☑', apply: '✎', report: '▤', salary: '💳', perf: '↗',
archive: '👤', notice: '📢', coop: '🤝', contacts: '☎',
bidding: '◎', project: '▣', finance: '◈', hr: '☰', contracts: '▤',
seals: '◆', crm: '◇', system: '⚙'
const BLUE = ['#1677FF', '#E8F1FF']
const CYAN = ['#0891B2', '#E6F7FB']
const GREEN = ['#16A34A', '#E8F8EF']
const ORANGE = ['#EA580C', '#FFF1E8']
const AMBER = ['#D97706', '#FFF6E8']
const VIOLET = ['#7C3AED', '#F3EEFF']
const ROSE = ['#E11D48', '#FFE8EE']
const TEAL = ['#0D9488', '#E6F7F4']
function tile(name, pair) {
return { name, color: pair[0], bg: pair[1] }
}
const TILES = {
expense: tile('money-circle', ORANGE),
loan: tile('wallet', AMBER),
leave: tile('calendar', GREEN),
trip: tile('location', BLUE),
procurement: tile('cart', ORANGE),
overtime: tile('time', AMBER),
outing: tile('location', CYAN),
card: tile('edit-1', ROSE),
transfer: tile('swap', VIOLET),
regularize: tile('check-circle', GREEN),
resign: tile('logout', ROSE),
layoff: tile('user-clear', ROSE),
seal: tile('secured', AMBER),
receive: tile('goods', TEAL),
clock: tile('location', BLUE),
todo: tile('check-circle', GREEN),
apply: tile('edit', ORANGE),
report: tile('note', VIOLET),
salary: tile('creditcard', GREEN),
perf: tile('chart-bar', BLUE),
archive: tile('user', CYAN),
notice: tile('notification', ROSE),
coop: tile('usergroup', TEAL),
contacts: tile('call', BLUE),
bidding: tile('flag', ORANGE),
project: tile('folder', BLUE),
finance: tile('chart-pie', GREEN),
hr: tile('usergroup', CYAN),
contracts: tile('file', VIOLET),
seals: tile('secured', VIOLET),
crm: tile('shop', TEAL),
system: tile('setting', BLUE)
}
const LABEL_TILES = [
['报销', 'expense'], ['借支', 'loan'], ['请假', 'leave'], ['出差', 'trip'], ['采购', 'procurement'],
['加班', 'overtime'], ['外出', 'outing'], ['补卡', 'card'], ['转岗', 'transfer'], ['转正', 'regularize'],
['离职', 'resign'], ['裁员', 'layoff'], ['用章', 'seal'], ['领用', 'receive'], ['打卡', 'clock'],
['考勤', 'clock'], ['待办', 'todo'], ['审批', 'todo'], ['申请', 'apply'], ['汇报', 'report'],
['工资', 'salary'], ['绩效', 'perf'], ['资料', 'archive'], ['公告', 'notice'], ['协同', 'coop'],
['通讯', 'contacts'], ['投标', 'bidding'], ['项目', 'project'], ['财务', 'finance'], ['人事', 'hr'],
['合同', 'contracts'], ['证照', 'seals'], ['印章', 'seals'], ['客户', 'crm'], ['系统', 'system']
]
const FALLBACK = tile('app', BLUE)
function applyKind(to) {
const q = to.indexOf('kind=')
if (q >= 0) {
const rest = to.slice(q + 5)
const end = rest.indexOf('&')
return decodeURIComponent(end >= 0 ? rest.slice(0, end) : rest)
}
const mark = '/apply/'
const p = to.indexOf(mark)
if (p < 0) return ''
const rest = to.slice(p + mark.length)
const cut = rest.search(/[?#]/)
return decodeURIComponent(cut >= 0 ? rest.slice(0, cut) : rest)
}
export function tileVisual(item) {
const to = String((item && (item.to || item.url || item.path)) || '')
const kind = applyKind(to)
if (kind && TILES[kind]) return TILES[kind]
const id = String((item && (item.id || item.kind || item.key)) || '')
if (TILES[id]) return TILES[id]
const label = String((item && (item.label || item.title)) || '')
const hit = LABEL_TILES.find(([k]) => label.includes(k))
return hit && TILES[hit[1]] ? TILES[hit[1]] : FALLBACK
}
export function tileEmoji(item) {
if (item && item.emoji) return item.emoji
const to = String((item && (item.to || item.url || item.path)) || '')
const m = to.match(/\/apply\/([^/?]+)/)
if (m && EMOJI[m[1]]) return EMOJI[m[1]]
const id = String((item && (item.id || item.kind || item.key)) || '')
if (EMOJI[id]) return EMOJI[id]
const label = String((item && (item.label || item.title)) || '')
return label ? label.slice(0, 1) : '·'
return tileVisual(item).name
}