From 7de53bcc6d3c3ab21b779859c4c5975f29ae9934 Mon Sep 17 00:00:00 2001 From: Leo <98382335+gaoziman@users.noreply.github.com> Date: Tue, 8 Jul 2025 10:54:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(router):=20=E4=BC=98=E5=8C=96=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=E7=B3=BB=E7=BB=9F=E5=B9=B6=E6=94=AF=E6=8C=81=E6=9D=83?= =?UTF-8?q?=E9=99=90=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 扩展路由元数据字段,新增auth权限标识支持 - 完善路由转换器,支持从后端菜单数据提取权限标识 - 优化静态路由配置,为仪表板添加固定标签页属性 - 增强路由类型定义,支持更灵活的权限验证机制 --- src/router/routes.static.ts | 1 + src/store/router/helper.ts | 3 ++- src/typings/route.d.ts | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/router/routes.static.ts b/src/router/routes.static.ts index b24e076..2e6b24a 100644 --- a/src/router/routes.static.ts +++ b/src/router/routes.static.ts @@ -9,6 +9,7 @@ export const staticRoutes: AppRoute.RowRoute[] = [ componentPath: '/dashboard/monitor/index', id: 3, pid: null, + pinTab: true, }, // { // name: 'personal-center', diff --git a/src/store/router/helper.ts b/src/store/router/helper.ts index a87b16a..3e340a3 100644 --- a/src/store/router/helper.ts +++ b/src/store/router/helper.ts @@ -9,7 +9,7 @@ import { clone, min, omit, pick } from 'radash' import { RouterLink } from 'vue-router' const metaFields: AppRoute.MetaKeys[] - = ['title', 'icon', 'requiresAuth', 'roles', 'keepAlive', 'hide', 'order', 'href', 'activeMenu', 'withoutTab', 'pinTab', 'menuType'] + = ['title', 'icon', 'requiresAuth', 'roles', 'auth', 'keepAlive', 'hide', 'order', 'href', 'activeMenu', 'withoutTab', 'pinTab', 'menuType'] // 将后端菜单数据转换为前端路由数据 function transformBackendToRoute(backendRoute: AppRoute.BackendRoute): AppRoute.RowRoute { @@ -22,6 +22,7 @@ function transformBackendToRoute(backendRoute: AppRoute.BackendRoute): AppRoute. redirect: backendRoute.redirect || undefined, title: backendRoute.menuName, icon: backendRoute.icon, + auth: backendRoute.auth, // 权限标识 requiresAuth: true, // 动态路由都需要认证 hide: backendRoute.isHide === '0', // 0-隐藏 1-显示 keepAlive: backendRoute.isKeepAlive === '0', // 0-是 1-否 diff --git a/src/typings/route.d.ts b/src/typings/route.d.ts index b0bdffe..f4a9ec5 100644 --- a/src/typings/route.d.ts +++ b/src/typings/route.d.ts @@ -12,6 +12,8 @@ declare namespace AppRoute { requiresAuth?: boolean /* 可以访问的角色 */ roles?: Entity.RoleType[] + /* 权限标识,用于按钮权限验证 */ + auth?: string /* 是否开启页面缓存 */ keepAlive?: boolean /* 有些路由我们并不想在菜单中显示,比如某些编辑页面。 */ @@ -52,6 +54,8 @@ declare namespace AppRoute { component?: string /** 菜单图标 */ icon?: string + /** 权限标识 */ + auth?: string /** 是否隐藏 0-隐藏 1-显示 */ isHide: string /** 是否外链 */