| 123456789101112131415161718192021222324252627282930313233 |
- import { get } from './request.js'
- import { getToken } from './auth.js'
- import { resolveMenuIconColors } from './menu-icon-colors.js'
- function authHeader() {
- const token = getToken()
- return token ? { Authorization: 'Bearer ' + token } : {}
- }
- /** 当前用户移动端菜单(扁平列表) */
- export async function fetchMyMobileMenus() {
- const data = await get('/mini/menus', authHeader())
- const list = data?.list || data || []
- return list
- .map((m) => {
- const icon = m.icon || 'approve'
- const colors = resolveMenuIconColors({
- icon,
- iconBg: m.iconBg || m.icon_bg,
- iconFg: m.iconFg || m.icon_fg
- })
- return {
- id: m.id,
- title: m.title || m.menuName || m.menu_name,
- icon,
- path: m.path,
- iconBg: colors.iconBg,
- iconFg: colors.iconFg,
- tone: m.tone || ''
- }
- })
- .filter((m) => m.path)
- }
|