mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-02-02 18:28:40 +08:00
fix: successful login should not take you to the login page (#4056)
* fix: successful login should not take you to the login page * chore: use DEFAULT_HOME_PATH constants * chore: remove invalid spaces in script * fix: lint error
This commit is contained in:
parent
9dce5b44ec
commit
e27be2d47a
@ -1,6 +1,6 @@
|
|||||||
import type { Router } from 'vue-router';
|
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 { 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';
|
||||||
@ -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 (
|
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
|
||||||
coreRouteNames.includes(to.name as string) ||
|
|
||||||
// 明确声明忽略权限访问权限,则可以访问
|
// 明确声明忽略权限访问权限,则可以访问
|
||||||
to.meta.ignoreAccess
|
if (to.meta.ignoreAccess) {
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { Router } from 'vue-router';
|
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 { 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';
|
||||||
@ -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 (
|
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
|
||||||
coreRouteNames.includes(to.name as string) ||
|
|
||||||
// 明确声明忽略权限访问权限,则可以访问
|
// 明确声明忽略权限访问权限,则可以访问
|
||||||
to.meta.ignoreAccess
|
if (to.meta.ignoreAccess) {
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import type { Router } from 'vue-router';
|
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 { 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';
|
||||||
@ -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 (
|
|
||||||
// 基本路由,这些路由不需要进入权限拦截
|
|
||||||
coreRouteNames.includes(to.name as string) ||
|
|
||||||
// 明确声明忽略权限访问权限,则可以访问
|
// 明确声明忽略权限访问权限,则可以访问
|
||||||
to.meta.ignoreAccess
|
if (to.meta.ignoreAccess) {
|
||||||
) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
"publint": "vsh publint",
|
"publint": "vsh publint",
|
||||||
"reinstall": "pnpm clean --del-lock && pnpm bootstrap",
|
"reinstall": "pnpm clean --del-lock && pnpm bootstrap",
|
||||||
"test:unit": "vitest",
|
"test:unit": "vitest",
|
||||||
"update:deps": " pnpm update --latest --recursive",
|
"update:deps": "pnpm update --latest --recursive",
|
||||||
"version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
|
"version": "pnpm exec changeset version && pnpm install --no-frozen-lockfile"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
Loading…
Reference in New Issue
Block a user