feat: 路由动态权限控制、图片广场优化
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import type { NavigationGuardNext, RouteLocationNormalized } from 'vue-router';
|
||||
import { ElMessage } from 'element-plus';
|
||||
import { useNProgress } from '@vueuse/integrations/useNProgress';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import { ROUTER_WHITE_LIST } from '@/config';
|
||||
import { checkPagePermission } from '@/config/permission';
|
||||
import { errorRouter, layoutRouter, staticRouter } from '@/routers/modules/staticRouter';
|
||||
import { useDesignStore, useUserStore } from '@/stores';
|
||||
|
||||
@@ -63,6 +65,16 @@ router.beforeEach(
|
||||
if (!userStore.token)
|
||||
userStore.logout();
|
||||
|
||||
// 7. 页面权限检查
|
||||
const userName = userStore.userInfo?.user?.userName;
|
||||
const hasPermission = checkPagePermission(to.path, userName);
|
||||
|
||||
if (!hasPermission) {
|
||||
// 用户无权访问该页面,跳转到403页面
|
||||
ElMessage.warning('您没有权限访问该页面');
|
||||
return next('/403');
|
||||
}
|
||||
|
||||
// 其余逻辑 预留...
|
||||
|
||||
// 8. 放行路由
|
||||
|
||||
Reference in New Issue
Block a user