fix: 登录后访问/auth/login应该跳转到首页
This commit is contained in:
parent
14a5201bc7
commit
eeb5c55c5f
@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
|
|||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
|
// 基本路由,这些路由不需要进入权限拦截
|
||||||
|
if (coreRouteNames.includes(to.name as string)) {
|
||||||
|
if (to.path === LOGIN_PATH && accessStore.accessToken) {
|
||||||
|
return decodeURIComponent(
|
||||||
|
(to.query?.redirect as string) || DEFAULT_HOME_PATH,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// accessToken 检查
|
// accessToken 检查
|
||||||
if (!accessStore.accessToken) {
|
if (!accessStore.accessToken) {
|
||||||
if (
|
// 明确声明忽略权限访问权限,则可以访问
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
if (to.meta.ignoreAccess) {
|
||||||
coreRouteNames.includes(to.name as string) ||
|
|
||||||
// 明确声明忽略权限访问权限,则可以访问
|
|
||||||
to.meta.ignoreAccess
|
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,15 +93,6 @@ function setupAccessGuard(router: Router) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const accessRoutes = accessStore.accessRoutes;
|
const accessRoutes = accessStore.accessRoutes;
|
||||||
/**
|
|
||||||
* 已经登录 前往登录页 跳转到首页
|
|
||||||
*/
|
|
||||||
if (to.path === LOGIN_PATH) {
|
|
||||||
return {
|
|
||||||
path: DEFAULT_HOME_PATH,
|
|
||||||
replace: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// 是否已经生成过动态路由
|
// 是否已经生成过动态路由
|
||||||
if (accessRoutes && accessRoutes.length > 0) {
|
if (accessRoutes && accessRoutes.length > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user