refactor(projects): 路由声明重构,添加composables,BaseLayout进行中,文件夹规范
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import type { Router, RouteLocationNormalized, NavigationGuardNext } from 'vue-router';
|
||||
import { useTitle } from '@vueuse/core';
|
||||
import { getToken, getLoginRedirectUrl, ROUTE_NAME_MAP } from '@/utils';
|
||||
import { routeName } from '@/router';
|
||||
import { getToken, getLoginRedirectUrl } from '@/utils';
|
||||
|
||||
/**
|
||||
* 路由守卫函数
|
||||
@ -29,9 +30,9 @@ function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNorm
|
||||
const routerAction: [boolean, () => void][] = [
|
||||
// 已登录状态跳转登录页,跳转至首页
|
||||
[
|
||||
isLogin && to.name === ROUTE_NAME_MAP.get('login'),
|
||||
isLogin && to.name === routeName('login'),
|
||||
() => {
|
||||
next({ name: ROUTE_NAME_MAP.get('root') });
|
||||
next({ name: routeName('root') });
|
||||
}
|
||||
],
|
||||
// 不需要登录权限的页面直接通行
|
||||
@ -46,7 +47,7 @@ function handleRouterAction(to: RouteLocationNormalized, from: RouteLocationNorm
|
||||
!isLogin && needLogin,
|
||||
() => {
|
||||
const redirectUrl = getLoginRedirectUrl();
|
||||
next({ name: ROUTE_NAME_MAP.get('login'), query: { redirectUrl } });
|
||||
next({ name: routeName('login'), query: { redirectUrl } });
|
||||
}
|
||||
],
|
||||
// 登录状态进入需要登录权限的页面,直接通行
|
||||
|
||||
Reference in New Issue
Block a user