feat(router): 优化路由系统配置
- 更新路由守卫逻辑(guard.ts) - 完善内置路由配置(routes.inner.ts) - 优化静态路由配置(routes.static.ts) - 更新路由类型定义(route.d.ts) 改进路由管理和权限验证机制
This commit is contained in:
parent
858d2d590f
commit
c239a15840
@ -43,8 +43,8 @@ export function setupRouterGuard(router: Router) {
|
||||
if (!routeStore.isInitAuthRoute) {
|
||||
await routeStore.initAuthRoute()
|
||||
// 动态路由加载完回到根路由
|
||||
if (to.name === '404') {
|
||||
// 等待权限路由加载好了,回到之前的路由,否则404
|
||||
if (to.name === 'notFound' || to.name === '404') {
|
||||
// 等待权限路由加载好了,回到之前的路由,否则404
|
||||
next({
|
||||
path: to.fullPath,
|
||||
replace: true,
|
||||
|
||||
@ -50,7 +50,7 @@ export const routes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
component: () => import('@/views/error/404/index.vue'),
|
||||
name: '404',
|
||||
name: 'notFound',
|
||||
meta: {
|
||||
title: '找不到页面',
|
||||
icon: 'icon-park-outline:ghost',
|
||||
|
||||
@ -5,30 +5,9 @@ export const staticRoutes: AppRoute.RowRoute[] = [
|
||||
title: '仪表盘',
|
||||
requiresAuth: true,
|
||||
icon: 'icon-park-outline:anchor',
|
||||
menuType: 'page',
|
||||
componentPath: '/dashboard/monitor/index.vue',
|
||||
menuType: '2',
|
||||
componentPath: '/dashboard/monitor/index',
|
||||
id: 3,
|
||||
pid: null,
|
||||
},
|
||||
{
|
||||
name: 'setting',
|
||||
path: '/setting',
|
||||
title: '系统管理',
|
||||
requiresAuth: true,
|
||||
icon: 'icon-park-outline:setting',
|
||||
menuType: 'dir',
|
||||
componentPath: null,
|
||||
id: 35,
|
||||
pid: null,
|
||||
},
|
||||
{
|
||||
name: 'accountSetting',
|
||||
path: '/setting/account',
|
||||
title: '用户管理',
|
||||
requiresAuth: true,
|
||||
icon: 'icon-park-outline:every-user',
|
||||
componentPath: '/setting/account/index.vue',
|
||||
id: 36,
|
||||
pid: 35,
|
||||
},
|
||||
]
|
||||
|
||||
39
src/typings/route.d.ts
vendored
39
src/typings/route.d.ts
vendored
@ -1,6 +1,7 @@
|
||||
declare namespace AppRoute {
|
||||
|
||||
type MenuType = 'dir' | 'page'
|
||||
type MenuType = '1' | '2' | '3' // 1-目录 2-菜单 3-按钮
|
||||
|
||||
/** 单个路由所携带的meta标识 */
|
||||
interface RouteMeta {
|
||||
/* 页面标题,通常必选。 */
|
||||
@ -31,6 +32,42 @@ declare namespace AppRoute {
|
||||
|
||||
type MetaKeys = keyof RouteMeta
|
||||
|
||||
// 后端返回的菜单数据结构
|
||||
interface BackendRoute {
|
||||
/** 菜单ID */
|
||||
menuId: number
|
||||
/** 菜单名称 */
|
||||
menuName: string
|
||||
/** 英文名称 */
|
||||
enName?: string
|
||||
/** 父菜单ID */
|
||||
parentId: number
|
||||
/** 菜单类型 1-目录 2-菜单 3-按钮 */
|
||||
menuType: string
|
||||
/** 路由名称 */
|
||||
name: string
|
||||
/** 路由路径 */
|
||||
path: string
|
||||
/** 组件路径 */
|
||||
component?: string
|
||||
/** 菜单图标 */
|
||||
icon?: string
|
||||
/** 是否隐藏 0-隐藏 1-显示 */
|
||||
isHide: string
|
||||
/** 是否外链 */
|
||||
isLink?: string
|
||||
/** 是否缓存 0-是 1-否 */
|
||||
isKeepAlive: string
|
||||
/** 是否全屏 0-是 1-否 */
|
||||
isFull: string
|
||||
/** 是否固定 0-是 1-否 */
|
||||
isAffix: string
|
||||
/** 重定向地址 */
|
||||
redirect?: string | null
|
||||
/** 选中路由 */
|
||||
activeMenu?: string | null
|
||||
}
|
||||
|
||||
interface baseRoute {
|
||||
/** 路由名称(路由唯一标识) */
|
||||
name: string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user