feat(pages): call-log-page
This commit is contained in:
@@ -31,12 +31,15 @@ const router = createRouter({
|
||||
},
|
||||
{
|
||||
path: 'log',
|
||||
redirect: '/log/vimp-log',
|
||||
children: [
|
||||
{
|
||||
path: 'vimp-log',
|
||||
component: () => import('@/pages/vimp-log-page.vue'),
|
||||
},
|
||||
{
|
||||
path: 'call-log',
|
||||
component: () => import('@/pages/call-log-page.vue'),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -62,32 +65,30 @@ const router = createRouter({
|
||||
|
||||
const whiteList = ['/debug'];
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
router.beforeEach((to) => {
|
||||
const userStore = useUserStore();
|
||||
const isAuthed = !!userStore.userLoginResult?.token;
|
||||
|
||||
// 放行白名单
|
||||
const inWhiteList = whiteList.some((path) => to.path.startsWith(path));
|
||||
if (inWhiteList) {
|
||||
next();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// 已登录用户不允许进入登录页(手动访问 /login 会重定向到首页)
|
||||
if (to.path === '/login') {
|
||||
if (isAuthed) {
|
||||
next({ path: '/' });
|
||||
return { path: '/' };
|
||||
} else {
|
||||
next();
|
||||
return true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 其它路由按登录态控制
|
||||
if (!isAuthed) {
|
||||
next('/login');
|
||||
} else {
|
||||
next();
|
||||
// 其它路由按登录态控制
|
||||
if (!isAuthed) {
|
||||
return { path: '/login' };
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user