|
@@ -1,6 +1,6 @@
|
|
|
import type { Router } from 'vue-router';
|
|
|
|
|
|
-import { LOGIN_PATH } from '@vben/constants';
|
|
|
+import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants';
|
|
|
import { preferences } from '@vben/preferences';
|
|
|
import { useAccessStore, useUserStore } from '@vben/stores';
|
|
|
import { startProgress, stopProgress } from '@vben/utils';
|
|
@@ -62,14 +62,20 @@ function setupAccessGuard(router: Router) {
|
|
|
const userStore = useUserStore();
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
if (!accessStore.accessToken) {
|
|
|
- if (
|
|
|
-
|
|
|
- coreRouteNames.includes(to.name as string) ||
|
|
|
-
|
|
|
- to.meta.ignoreAccess
|
|
|
- ) {
|
|
|
+
|
|
|
+ if (to.meta.ignoreAccess) {
|
|
|
return true;
|
|
|
}
|
|
|
|