Route legacy home to control center
This commit is contained in:
@@ -7139,14 +7139,12 @@
|
|||||||
"name": "ControlCenter",
|
"name": "ControlCenter",
|
||||||
"title": "menu-title.controlCenter",
|
"title": "menu-title.controlCenter",
|
||||||
"authCode": null,
|
"authCode": null,
|
||||||
"path": "/page-render/main_home",
|
"path": "/control-center",
|
||||||
"type": "online_page",
|
"type": "menu",
|
||||||
"component": "online-dev/page-render/index",
|
"component": "_core/control-center/index",
|
||||||
"redirect": null,
|
"redirect": null,
|
||||||
"activePath": null,
|
"activePath": null,
|
||||||
"query": {
|
"query": null,
|
||||||
"pageCode": "main_home"
|
|
||||||
},
|
|
||||||
"noBasicLayout": false,
|
"noBasicLayout": false,
|
||||||
"icon": "lucide:layout-dashboard",
|
"icon": "lucide:layout-dashboard",
|
||||||
"activeIcon": null,
|
"activeIcon": null,
|
||||||
|
|||||||
@@ -11,6 +11,13 @@ import { useAppContextStore } from '#/store/app-context';
|
|||||||
|
|
||||||
import { generateAccess } from './access';
|
import { generateAccess } from './access';
|
||||||
|
|
||||||
|
function normalizeHomePath(path?: null | string) {
|
||||||
|
if (!path || path === '/page-render/main_home') {
|
||||||
|
return preferences.app.defaultHomePath;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用守卫配置
|
* 通用守卫配置
|
||||||
* @param router
|
* @param router
|
||||||
@@ -113,8 +120,7 @@ function setupAccessGuard(router: Router) {
|
|||||||
if (to.path === LOGIN_PATH && accessStore.accessToken) {
|
if (to.path === LOGIN_PATH && accessStore.accessToken) {
|
||||||
return decodeURIComponent(
|
return decodeURIComponent(
|
||||||
(to.query?.redirect as string) ||
|
(to.query?.redirect as string) ||
|
||||||
userStore.userInfo?.homePath ||
|
normalizeHomePath(userStore.userInfo?.homePath),
|
||||||
preferences.app.defaultHomePath,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -207,7 +213,7 @@ function setupAccessGuard(router: Router) {
|
|||||||
// 重定向逻辑
|
// 重定向逻辑
|
||||||
const redirectPath = (from.query.redirect ??
|
const redirectPath = (from.query.redirect ??
|
||||||
(to.path === preferences.app.defaultHomePath
|
(to.path === preferences.app.defaultHomePath
|
||||||
? userInfo.homePath || preferences.app.defaultHomePath
|
? normalizeHomePath(userInfo.homePath)
|
||||||
: to.fullPath)) as string;
|
: to.fullPath)) as string;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ import { getAccessCodesApi, loginApi, logoutApi } from '#/api/core/auth';
|
|||||||
import { getUserInfoApi } from '#/api/core/user';
|
import { getUserInfoApi } from '#/api/core/user';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
|
function normalizeHomePath(path?: null | string) {
|
||||||
|
if (!path || path === '/page-render/main_home') {
|
||||||
|
return preferences.app.defaultHomePath;
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
export const useAuthStore = defineStore('auth', () => {
|
export const useAuthStore = defineStore('auth', () => {
|
||||||
const accessStore = useAccessStore();
|
const accessStore = useAccessStore();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -64,9 +71,7 @@ export const useAuthStore = defineStore('auth', () => {
|
|||||||
} else {
|
} else {
|
||||||
onSuccess
|
onSuccess
|
||||||
? await onSuccess?.()
|
? await onSuccess?.()
|
||||||
: await router.push(
|
: await router.push(normalizeHomePath(userInfo.homePath));
|
||||||
userInfo.homePath || preferences.app.defaultHomePath,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInfo?.realName) {
|
if (userInfo?.realName) {
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ import { $t } from '@vben/locales';
|
|||||||
import { getPreferencesConfigApi } from '#/api/core/ui-config';
|
import { getPreferencesConfigApi } from '#/api/core/ui-config';
|
||||||
import { useAuthStore } from '#/store';
|
import { useAuthStore } from '#/store';
|
||||||
|
|
||||||
|
const LEGACY_HOME_PATH = '/page-render/main_home';
|
||||||
|
|
||||||
defineOptions({ name: 'Login' });
|
defineOptions({ name: 'Login' });
|
||||||
|
|
||||||
const authStore = useAuthStore();
|
const authStore = useAuthStore();
|
||||||
@@ -59,6 +61,10 @@ const getRedirectState = () => {
|
|||||||
return redirect ? JSON.stringify({ redirect }) : undefined;
|
return redirect ? JSON.stringify({ redirect }) : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function normalizeRedirectPath(path: string) {
|
||||||
|
return path === LEGACY_HOME_PATH ? '/' : path;
|
||||||
|
}
|
||||||
|
|
||||||
type OAuthProvider =
|
type OAuthProvider =
|
||||||
| 'dingtalk'
|
| 'dingtalk'
|
||||||
| 'feishu'
|
| 'feishu'
|
||||||
@@ -109,7 +115,7 @@ async function handleLogin(params: Record<string, any>) {
|
|||||||
if (redirect) {
|
if (redirect) {
|
||||||
// 有 redirect 参数时,登录成功后跳转到指定页面
|
// 有 redirect 参数时,登录成功后跳转到指定页面
|
||||||
await authStore.authLogin(params, async () => {
|
await authStore.authLogin(params, async () => {
|
||||||
const targetPath = decodeURIComponent(redirect);
|
const targetPath = normalizeRedirectPath(decodeURIComponent(redirect));
|
||||||
await router.push(targetPath);
|
await router.push(targetPath);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user