40 lines
1.3 KiB
JavaScript
40 lines
1.3 KiB
JavaScript
/**
|
|
* 主页宫格图标配色:每项可自定义 iconBg / iconFg。
|
|
* 未配置时按 icon 名回退到此处默认色对。
|
|
*/
|
|
/** OA 宫格 PNG 自带颜色,不套色底 */
|
|
const OA_PNG_ICONS = new Set([
|
|
'approve',
|
|
'oa-drafts',
|
|
'oa-pending',
|
|
'oa-done',
|
|
'oa-mine',
|
|
'oa-cc',
|
|
'oa-wechat-notify'
|
|
])
|
|
|
|
export const MENU_ICON_COLOR_DEFAULTS = {
|
|
approve: { iconBg: 'transparent', iconFg: '' },
|
|
'oa-drafts': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-pending': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-done': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-mine': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-cc': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-wechat-notify': { iconBg: 'transparent', iconFg: '' },
|
|
'orders-o': { iconBg: '#eef2f1', iconFg: '#3d524a' },
|
|
'apps-o': { iconBg: '#eef2f1', iconFg: '#3d524a' }
|
|
}
|
|
|
|
export function resolveMenuIconColors(menu) {
|
|
const icon = String(menu?.icon || '').trim()
|
|
// OA PNG 自带色:忽略接口下发的色底,避免灰底盖住图标
|
|
if (OA_PNG_ICONS.has(icon)) {
|
|
return { iconBg: 'transparent', iconFg: '' }
|
|
}
|
|
const fallback = MENU_ICON_COLOR_DEFAULTS[icon] || {}
|
|
const iconBg = String(menu?.iconBg || menu?.icon_bg || fallback.iconBg || '').trim()
|
|
const iconFg = String(menu?.iconFg || menu?.icon_fg || fallback.iconFg || '').trim()
|
|
return { iconBg, iconFg }
|
|
}
|
|
|