|
|
@ -1,6 +1,6 @@ |
|
|
import type { Router } from 'vue-router'; |
|
|
import type { Router } from 'vue-router'; |
|
|
|
|
|
|
|
|
import { DEFAULT_HOME_PATH, LOGIN_PATH } from '@vben/constants'; |
|
|
import { LOGIN_PATH } from '@vben/constants'; |
|
|
import { preferences } from '@vben/preferences'; |
|
|
import { preferences } from '@vben/preferences'; |
|
|
import { useAccessStore, useUserStore } from '@vben/stores'; |
|
|
import { useAccessStore, useUserStore } from '@vben/stores'; |
|
|
import { startProgress, stopProgress } from '@vben/utils'; |
|
|
import { startProgress, stopProgress } from '@vben/utils'; |
|
|
@ -56,7 +56,7 @@ function setupAccessGuard(router: Router) { |
|
|
return decodeURIComponent( |
|
|
return decodeURIComponent( |
|
|
(to.query?.redirect as string) || |
|
|
(to.query?.redirect as string) || |
|
|
userStore.userInfo?.homePath || |
|
|
userStore.userInfo?.homePath || |
|
|
DEFAULT_HOME_PATH, |
|
|
preferences.app.defaultHomePath, |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
return true; |
|
|
return true; |
|
|
@ -75,7 +75,7 @@ function setupAccessGuard(router: Router) { |
|
|
path: LOGIN_PATH, |
|
|
path: LOGIN_PATH, |
|
|
// 如不需要,直接删除 query
|
|
|
// 如不需要,直接删除 query
|
|
|
query: |
|
|
query: |
|
|
to.fullPath === DEFAULT_HOME_PATH |
|
|
to.fullPath === preferences.app.defaultHomePath |
|
|
? {} |
|
|
? {} |
|
|
: { redirect: encodeURIComponent(to.fullPath) }, |
|
|
: { redirect: encodeURIComponent(to.fullPath) }, |
|
|
// 携带当前跳转的页面,登录后重新跳转该页面
|
|
|
// 携带当前跳转的页面,登录后重新跳转该页面
|
|
|
@ -108,8 +108,8 @@ function setupAccessGuard(router: Router) { |
|
|
accessStore.setAccessRoutes(accessibleRoutes); |
|
|
accessStore.setAccessRoutes(accessibleRoutes); |
|
|
accessStore.setIsAccessChecked(true); |
|
|
accessStore.setIsAccessChecked(true); |
|
|
const redirectPath = (from.query.redirect ?? |
|
|
const redirectPath = (from.query.redirect ?? |
|
|
(to.path === DEFAULT_HOME_PATH |
|
|
(to.path === preferences.app.defaultHomePath |
|
|
? userInfo.homePath || DEFAULT_HOME_PATH |
|
|
? userInfo.homePath || preferences.app.defaultHomePath |
|
|
: to.fullPath)) as string; |
|
|
: to.fullPath)) as string; |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
|