wms_worker_station/src/router/menuRoutes.js
2026-05-21 14:51:37 +08:00

37 lines
964 B
JavaScript

import OrderView from '@/views/order/index.vue'
import CatchWeightView from '@/views/catch-weight/index.vue'
import ReturnsView from '@/views/returns/index.vue'
/** 将 user.info 中 menus[].path 规范为以 / 开头的路径 */
export function normalizeMenuPath(path) {
const raw = String(path || '').trim()
if (!raw) {
return ''
}
return raw.startsWith('/') ? raw : `/${raw}`
}
/**
* 后端动态菜单 path -> 本地页面组件
* 新增菜单时在此注册对应 views 组件
*/
const menuRouteMap = {
'/order': OrderView,
'/catchWeight': CatchWeightView,
'/returns': ReturnsView,
}
/** 根据菜单 path 解析要渲染的页面组件 */
export function resolveMenuView(path) {
const normalized = normalizeMenuPath(path)
if (!normalized) {
return null
}
return menuRouteMap[normalized] || null
}
/** 是否已在本地注册该动态路由页面 */
export function hasMenuView(path) {
return !!resolveMenuView(path)
}