mirror of
https://github.com/yangjian102621/geekai.git
synced 2025-11-14 05:03:45 +08:00
feat(ui): 管理后台新增权限及部分组合式函数优化
This commit is contained in:
@@ -1,14 +1,27 @@
|
||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||
import { useAuthStore } from "@/stores/auth";
|
||||
import CustomLayout from '@/components/CustomLayout.vue'
|
||||
import { hasPermission } from "@/directives/permission";
|
||||
import menu from './menu'
|
||||
|
||||
declare module 'vue-router' {
|
||||
interface RouteMeta {
|
||||
title?: string
|
||||
permission?: string
|
||||
}
|
||||
}
|
||||
|
||||
const whiteListRoutes = [
|
||||
{
|
||||
path: "/login",
|
||||
name: "Login",
|
||||
component: () => import("@/views/LoginView.vue"),
|
||||
},
|
||||
{
|
||||
path: "/403",
|
||||
name: "403",
|
||||
component: () => import("@/views/NoPermission.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:pathMatch(.*)*",
|
||||
name: "404",
|
||||
@@ -44,9 +57,13 @@ router.beforeEach((to, _, next) => {
|
||||
return;
|
||||
}
|
||||
if (!authStore.token) {
|
||||
authStore.$reset();
|
||||
next({ name: "Login" });
|
||||
return;
|
||||
}
|
||||
if (to.meta.permission) {
|
||||
next(!hasPermission(to.meta.permission) ? { name: "403" } : undefined);
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
IconCodepen,
|
||||
IconWechatpay,
|
||||
IconRobot,
|
||||
IconSafe,
|
||||
} from "@arco-design/web-vue/es/icon";
|
||||
|
||||
const menu = [
|
||||
@@ -133,6 +134,15 @@ const menu = [
|
||||
},
|
||||
component: () => import("@/views/SysAdmin/SysAdminContainer.vue"),
|
||||
},
|
||||
{
|
||||
path: "/sysPermission",
|
||||
name: "SysPermission",
|
||||
meta: {
|
||||
title: "权限配置",
|
||||
icon: IconSafe,
|
||||
},
|
||||
component: () => import("@/views/SysPermission/SysPermissionContainer.vue"),
|
||||
},
|
||||
];
|
||||
|
||||
export default menu;
|
||||
|
||||
Reference in New Issue
Block a user