import { MenuListType } from '@/types/menu' import { processRoute } from '@/utils/menu' import { showLoadingToast, closeToast } from 'vant' // 简单的路由数据(移动端不需要复杂的路由配置) const simpleRoutes: any[] = [ { path: '/dashboard', name: 'Dashboard', meta: { title: '工作台', icon: '', isHide: false } }, { path: '/plans', name: 'Plans', meta: { title: '计划管理', icon: '', isHide: false } }, { path: '/inventory', name: 'Inventory', meta: { title: '出入库管理', icon: '', isHide: false } }, { path: '/weighing', name: 'Weighing', meta: { title: '地磅单管理', icon: '', isHide: false } } ] // 菜单接口 export const menuService = { // 获取菜单列表,模拟网络请求 getMenuList( delay: number = 300 ): Promise<{ menuList: MenuListType[]; closeLoading: () => void }> { // 获取到的菜单数据 const menuList = simpleRoutes // 处理后的菜单数据 const processedMenuList: MenuListType[] = menuList.map((route: any) => processRoute(route)) showLoadingToast({ message: '加载中...', forbidClick: true, duration: 0 }) return new Promise((resolve) => { setTimeout(() => { resolve({ menuList: processedMenuList, closeLoading: () => closeToast() }) }, delay) }) } }