Files
shanxia2.0/bak/mobile-h5/src/api/menuApi.ts
T
wuzilongandCursor 72d372674a chore: archive mobile-h5 under bak for reference only.
Keep WeChat miniprogram as the primary mobile path; H5 remains available for lookup.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-12 08:09:41 +08:00

56 lines
1.4 KiB
TypeScript
Executable File

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)
})
}
}