u
This commit is contained in:
1 parent
32d423b759
commit
78eb811ff7
102 files changed
+12067
-209
No files matched your search
@@ -3,6 +3,7 @@ import 'nprogress/nprogress.css'
|
||||
import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'
|
||||
|
||||
import airRoutes from './modules/air'
|
||||
import authRoutes from './modules/auth'
|
||||
import containerRoutes from './modules/container'
|
||||
import crmRoutes from './modules/crm'
|
||||
import financeRoutes from './modules/finance'
|
||||
@@ -19,6 +20,8 @@ NProgress.configure({ showSpinner: false })
|
||||
const firstMenuPath = menuItems[0]?.path ?? '/ocean'
|
||||
|
||||
const routes: RouteRecordRaw[] = [
|
||||
// 认证域(登录等):顶层路由,与主框架平级、不套 DefaultLayout
|
||||
...authRoutes,
|
||||
{
|
||||
path: '/',
|
||||
component: () => import('@/layouts/DefaultLayout.vue'),
|
||||
@@ -30,12 +33,31 @@ const routes: RouteRecordRaw[] = [
|
||||
...financeRoutes,
|
||||
...crmRoutes,
|
||||
...systemRoutes,
|
||||
// 403 / 500:作为主框架的子路由(保留侧栏/顶栏/页签,用户可直接切走),
|
||||
// 与 fms-vue 一致(routes.js 里 /403 /500 挂在布局下)。
|
||||
// 渲染崩溃的兜底不经过这里 —— 那由 App 层的 ErrorBoundary 全屏渲染。
|
||||
//
|
||||
// 页签 / 面包屑 / 文档标题统一用「403 / 500」状态码(与 URL 一一对应),
|
||||
// 页面内的标题仍由 G3Result 按 locale 显示「无权访问 / 页面出错了」。
|
||||
{
|
||||
path: '/403',
|
||||
name: 'forbidden',
|
||||
component: () => import('@/views/fallback/Forbidden.vue'),
|
||||
meta: { title: '403' },
|
||||
},
|
||||
{
|
||||
path: '/500',
|
||||
name: 'server-error',
|
||||
component: () => import('@/views/fallback/ServerError.vue'),
|
||||
meta: { title: '500' },
|
||||
},
|
||||
],
|
||||
},
|
||||
// 通配 404:独立布局(无外壳),放最后
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
name: 'not-found',
|
||||
component: () => import('@/views/error/NotFound.vue'),
|
||||
component: () => import('@/views/fallback/NotFound.vue'),
|
||||
meta: { title: '页面不存在' },
|
||||
},
|
||||
]
|
||||
@@ -80,6 +102,26 @@ export function findMenuItemByPath(path: string): MenuItem | undefined {
|
||||
return walk(menuItems)
|
||||
}
|
||||
|
||||
/**
|
||||
* 在菜单树中按 key 查找菜单项(含子级)。
|
||||
* 面包屑用它把祖先 key 链还原成「分组名称」。
|
||||
*/
|
||||
export function findMenuItemByKey(key: string): MenuItem | undefined {
|
||||
const walk = (items: MenuItem[]): MenuItem | undefined => {
|
||||
for (const item of items) {
|
||||
if (item.key === key) return item
|
||||
|
||||
if (item.children?.length) {
|
||||
const found = walk(item.children)
|
||||
if (found) return found
|
||||
}
|
||||
}
|
||||
return undefined
|
||||
}
|
||||
|
||||
return walk(menuItems)
|
||||
}
|
||||
|
||||
/**
|
||||
* 由当前路径反查它的所有祖先分组 key(从顶级到最近一级)。
|
||||
* 支持多级嵌套与详情页:/ocean/booking/123 会命中「海运」「订舱业务」。
|
||||
|
||||
Reference in new issue
Block a user