File tree 4 files changed +40
-22
lines changed
4 files changed +40
-22
lines changed Original file line number Diff line number Diff line change 1
1
import type { Router } from 'vue-router' ;
2
2
3
- import { LOGIN_PATH } from '@vben/constants' ;
3
+ import { DEFAULT_HOME_PATH , LOGIN_PATH } from '@vben/constants' ;
4
4
import { preferences } from '@vben/preferences' ;
5
5
import { useAccessStore , useUserStore } from '@vben/stores' ;
6
6
import { startProgress , stopProgress } from '@vben/utils' ;
@@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
62
62
const userStore = useUserStore ( ) ;
63
63
const authStore = useAuthStore ( ) ;
64
64
65
+ // 基本路由,这些路由不需要进入权限拦截
66
+ if ( coreRouteNames . includes ( to . name as string ) ) {
67
+ if ( to . path === LOGIN_PATH && accessStore . accessToken ) {
68
+ return decodeURIComponent (
69
+ ( to . query ?. redirect as string ) || DEFAULT_HOME_PATH ,
70
+ ) ;
71
+ }
72
+ return true ;
73
+ }
74
+
65
75
// accessToken 检查
66
76
if ( ! accessStore . accessToken ) {
67
- if (
68
- // 基本路由,这些路由不需要进入权限拦截
69
- coreRouteNames . includes ( to . name as string ) ||
70
- // 明确声明忽略权限访问权限,则可以访问
71
- to . meta . ignoreAccess
72
- ) {
77
+ // 明确声明忽略权限访问权限,则可以访问
78
+ if ( to . meta . ignoreAccess ) {
73
79
return true ;
74
80
}
75
81
Original file line number Diff line number Diff line change 1
1
import type { Router } from 'vue-router' ;
2
2
3
- import { LOGIN_PATH } from '@vben/constants' ;
3
+ import { DEFAULT_HOME_PATH , LOGIN_PATH } from '@vben/constants' ;
4
4
import { preferences } from '@vben/preferences' ;
5
5
import { useAccessStore , useUserStore } from '@vben/stores' ;
6
6
import { startProgress , stopProgress } from '@vben/utils' ;
@@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
62
62
const userStore = useUserStore ( ) ;
63
63
const authStore = useAuthStore ( ) ;
64
64
65
+ // 基本路由,这些路由不需要进入权限拦截
66
+ if ( coreRouteNames . includes ( to . name as string ) ) {
67
+ if ( to . path === LOGIN_PATH && accessStore . accessToken ) {
68
+ return decodeURIComponent (
69
+ ( to . query ?. redirect as string ) || DEFAULT_HOME_PATH ,
70
+ ) ;
71
+ }
72
+ return true ;
73
+ }
74
+
65
75
// accessToken 检查
66
76
if ( ! accessStore . accessToken ) {
67
- if (
68
- // 基本路由,这些路由不需要进入权限拦截
69
- coreRouteNames . includes ( to . name as string ) ||
70
- // 明确声明忽略权限访问权限,则可以访问
71
- to . meta . ignoreAccess
72
- ) {
77
+ // 明确声明忽略权限访问权限,则可以访问
78
+ if ( to . meta . ignoreAccess ) {
73
79
return true ;
74
80
}
75
81
Original file line number Diff line number Diff line change 1
1
import type { Router } from 'vue-router' ;
2
2
3
- import { LOGIN_PATH } from '@vben/constants' ;
3
+ import { DEFAULT_HOME_PATH , LOGIN_PATH } from '@vben/constants' ;
4
4
import { preferences } from '@vben/preferences' ;
5
5
import { useAccessStore , useUserStore } from '@vben/stores' ;
6
6
import { startProgress , stopProgress } from '@vben/utils' ;
@@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
62
62
const userStore = useUserStore ( ) ;
63
63
const authStore = useAuthStore ( ) ;
64
64
65
+ // 基本路由,这些路由不需要进入权限拦截
66
+ if ( coreRouteNames . includes ( to . name as string ) ) {
67
+ if ( to . path === LOGIN_PATH && accessStore . accessToken ) {
68
+ return decodeURIComponent (
69
+ ( to . query ?. redirect as string ) || DEFAULT_HOME_PATH ,
70
+ ) ;
71
+ }
72
+ return true ;
73
+ }
74
+
65
75
// accessToken 检查
66
76
if ( ! accessStore . accessToken ) {
67
- if (
68
- // 基本路由,这些路由不需要进入权限拦截
69
- coreRouteNames . includes ( to . name as string ) ||
70
- // 明确声明忽略权限访问权限,则可以访问
71
- to . meta . ignoreAccess
72
- ) {
77
+ // 明确声明忽略权限访问权限,则可以访问
78
+ if ( to . meta . ignoreAccess ) {
73
79
return true ;
74
80
}
75
81
Original file line number Diff line number Diff line change 51
51
"publint" : " vsh publint" ,
52
52
"reinstall" : " pnpm clean --del-lock && pnpm bootstrap" ,
53
53
"test:unit" : " vitest" ,
54
- "update:deps" : " pnpm update --latest --recursive" ,
54
+ "update:deps" : " pnpm update --latest --recursive" ,
55
55
"version" : " pnpm exec changeset version && pnpm install --no-frozen-lockfile"
56
56
},
57
57
"devDependencies" : {
You can’t perform that action at this time.
0 commit comments