diff --git a/apps/web-antd/src/router/guard.ts b/apps/web-antd/src/router/guard.ts index 0ee23fe..60f82d3 100644 --- a/apps/web-antd/src/router/guard.ts +++ b/apps/web-antd/src/router/guard.ts @@ -74,7 +74,6 @@ function setupAccessGuard(router: Router) { // 没有访问权限,跳转登录页面 if (to.fullPath !== LOGIN_PATH) { - console.log('没有访问权限,请登录'); return { path: LOGIN_PATH, // 如不需要,直接删除 query @@ -96,11 +95,13 @@ function setupAccessGuard(router: Router) { // 生成路由表 // 当前登录用户拥有的角色标识列表 const userInfo = userStore.userInfo || (await authStore.fetchUserInfo()); - const userRoles = userInfo.roles ?? []; + // const userRoles = userInfo.roles ?? []; + // permissions Keven自定义 + const permissions = userInfo.permissions ?? []; // 生成菜单和路由 const { accessibleMenus, accessibleRoutes } = await generateAccess({ - roles: userRoles, + roles: permissions, router, // 则会在菜单中显示,但是访问会被重定向到403 routes: accessRoutes, diff --git a/apps/web-antd/src/router/routes/modules/home.ts b/apps/web-antd/src/router/routes/modules/home.ts index c15057a..e54ba3f 100644 --- a/apps/web-antd/src/router/routes/modules/home.ts +++ b/apps/web-antd/src/router/routes/modules/home.ts @@ -9,6 +9,7 @@ const routes: RouteRecordRaw[] = [ icon: 'mdi:home', title: '首页', order: -1, + authority: ['dashboard'], }, }, ]; diff --git a/apps/web-antd/src/router/routes/modules/ppt.ts b/apps/web-antd/src/router/routes/modules/ppt.ts index 17121ce..9a16113 100644 --- a/apps/web-antd/src/router/routes/modules/ppt.ts +++ b/apps/web-antd/src/router/routes/modules/ppt.ts @@ -11,6 +11,7 @@ const routes: RouteRecordRaw[] = [ icon: SvgPPT, title: 'PPT自动生成', order: 3, + authority: ['dify:workflow:run'], }, }, ]; diff --git a/apps/web-antd/src/router/routes/modules/spider.ts b/apps/web-antd/src/router/routes/modules/spider.ts index 202e035..7ac8bd6 100644 --- a/apps/web-antd/src/router/routes/modules/spider.ts +++ b/apps/web-antd/src/router/routes/modules/spider.ts @@ -11,6 +11,7 @@ const routes: RouteRecordRaw[] = [ icon: SvgSpider, title: '数据爬取', order: 1, + authority: ['dify:server:init'], }, }, ]; diff --git a/apps/web-antd/src/router/routes/modules/system.ts b/apps/web-antd/src/router/routes/modules/system.ts index f880611..642770a 100644 --- a/apps/web-antd/src/router/routes/modules/system.ts +++ b/apps/web-antd/src/router/routes/modules/system.ts @@ -10,6 +10,7 @@ const routes: RouteRecordRaw[] = [ icon: IconSystem, title: '系统管理', order: 4, + authority: ['system'], }, children: [ { @@ -19,6 +20,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: EosRole, title: '角色管理', + authority: ['system:role'], }, }, { @@ -28,6 +30,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: RiDept, title: '部门管理', + authority: ['system:dept'], }, }, { @@ -37,6 +40,7 @@ const routes: RouteRecordRaw[] = [ meta: { icon: MdiUser, title: '用户管理', + authority: ['system:user'], }, }, ], diff --git a/apps/web-antd/src/router/routes/modules/word.ts b/apps/web-antd/src/router/routes/modules/word.ts index 9a35697..9254152 100644 --- a/apps/web-antd/src/router/routes/modules/word.ts +++ b/apps/web-antd/src/router/routes/modules/word.ts @@ -11,6 +11,7 @@ const routes: RouteRecordRaw[] = [ icon: SvgWord, title: 'Word自动生成', order: 2, + authority: ['dify:chat:send'], }, }, ]; diff --git a/apps/web-antd/src/store/auth.ts b/apps/web-antd/src/store/auth.ts index 116d6b1..17417e7 100644 --- a/apps/web-antd/src/store/auth.ts +++ b/apps/web-antd/src/store/auth.ts @@ -51,6 +51,8 @@ export const useAuthStore = defineStore('auth', () => { realName: user.username, username: user.username, roles: [user.role.name], + // permissions Keven自定义 + permissions: user.permissions, homePath: '/home', token: csrf.token, };