52 lines
1.8 KiB
JavaScript
52 lines
1.8 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-mentions',
|
|
'oa-wechat-notify',
|
|
'market-presign',
|
|
'market-protocol',
|
|
'market-payment-chase',
|
|
'market-payment',
|
|
'market-freight'
|
|
])
|
|
|
|
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-mentions': { iconBg: 'transparent', iconFg: '' },
|
|
'oa-wechat-notify': { iconBg: 'transparent', iconFg: '' },
|
|
'market-presign': { iconBg: 'transparent', iconFg: '' },
|
|
'market-protocol': { iconBg: 'transparent', iconFg: '' },
|
|
'market-payment-chase': { iconBg: 'transparent', iconFg: '' },
|
|
'market-payment': { iconBg: 'transparent', iconFg: '' },
|
|
'market-freight': { 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 }
|
|
}
|
|
|