提交 ccf20a6e 编写于 作者: 郝先瑞

refactor: 无权页面跳转401页面

上级 30c09d35
......@@ -6,7 +6,7 @@ import 'nprogress/nprogress.css';
NProgress.configure({ showSpinner: false }); // 进度环显示/隐藏
// 白名单路由
const whiteList = ['/login', '/auth-redirect'];
const whiteList = ['/login'];
router.beforeEach(async (to, from, next) => {
NProgress.start();
......@@ -21,7 +21,7 @@ router.beforeEach(async (to, from, next) => {
const hasGetUserInfo = user.roles.length > 0;
if (hasGetUserInfo) {
if (to.matched.length === 0) {
from.name ? next({ name: from.name }) : next('/');
from.name ? next({ name: from.name }) : next('/401');
} else {
next();
}
......
......@@ -27,11 +27,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('@/views/error-page/404.vue'),
meta: { hidden: true }
},
{
path: '/401',
component: () => import('@/views/error-page/401.vue'),
meta: { hidden: true }
},
{
path: '/',
component: Layout,
......@@ -42,7 +38,12 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('@/views/dashboard/index.vue'),
name: 'Dashboard',
meta: { title: 'dashboard', icon: 'homepage', affix: true }
}
},
{
path: '401',
component: () => import('@/views/error-page/401.vue'),
meta: { hidden: true }
},
]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册