diff --git a/backend-fastapi/core/menu/service.py b/backend-fastapi/core/menu/service.py index ba9d9ef..4510fcb 100644 --- a/backend-fastapi/core/menu/service.py +++ b/backend-fastapi/core/menu/service.py @@ -17,7 +17,7 @@ from core.menu.schema import MenuCreate, MenuUpdate menu_cache = CacheManager(prefix="menu:") # 缓存key -AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v4" +AI_AGENT_ADMIN_MENU_CACHE_VERSION = "v5" MENU_TREE_CACHE_KEY = f"tree:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}" USER_ROUTE_CACHE_PREFIX = f"user_route:ai_agent_admin:{AI_AGENT_ADMIN_MENU_CACHE_VERSION}:" diff --git a/backend-fastapi/db_init.json b/backend-fastapi/db_init.json index 2215b28..1310d10 100644 --- a/backend-fastapi/db_init.json +++ b/backend-fastapi/db_init.json @@ -11744,7 +11744,7 @@ "fields": { "application_id": "23CFVEUHdZcOQyku1mbIO", "config_key": "frontend_preferences", - "config_value": "{\"app\": {\"defaultHomePath\": \"/app/workflow_center/page-render/flow_index\"}}", + "config_value": "{\"app\": {\"defaultHomePath\": \"/control-center\"}}", "config_type": "preferences", "description": "子应用UI偏好配置", "status": true, @@ -11764,7 +11764,7 @@ "fields": { "application_id": "uRFPsrZ0BSJodp-qesFq6", "config_key": "frontend_preferences", - "config_value": "{\"app\": {\"defaultHomePath\": \"/app/cheliangguanli/form-render/cheliangguanli\"}}", + "config_value": "{\"app\": {\"defaultHomePath\": \"/control-center\"}}", "config_type": "preferences", "description": "子应用UI偏好配置", "status": true, diff --git a/web/apps/web-ele/src/router/guard.ts b/web/apps/web-ele/src/router/guard.ts index 520c979..98561b4 100644 --- a/web/apps/web-ele/src/router/guard.ts +++ b/web/apps/web-ele/src/router/guard.ts @@ -8,16 +8,10 @@ import { startProgress, stopProgress } from '@vben/utils'; import { accessRoutes, coreRouteNames } from '#/router/routes'; import { useAuthStore } from '#/store'; import { useAppContextStore } from '#/store/app-context'; +import { normalizeHomePath } from '#/utils/legacy-home'; import { generateAccess } from './access'; -function normalizeHomePath(path?: null | string) { - if (!path || path === '/page-render/main_home') { - return preferences.app.defaultHomePath; - } - return path; -} - /** * 通用守卫配置 * @param router @@ -118,9 +112,8 @@ function setupAccessGuard(router: Router) { // 基本路由,这些路由不需要进入权限拦截 if (coreRouteNames.includes(to.name as string)) { if (to.path === LOGIN_PATH && accessStore.accessToken) { - return decodeURIComponent( - (to.query?.redirect as string) || - normalizeHomePath(userStore.userInfo?.homePath), + return normalizeHomePath( + (to.query?.redirect as string) || userStore.userInfo?.homePath, ); } return true; @@ -211,13 +204,15 @@ function setupAccessGuard(router: Router) { } // 重定向逻辑 - const redirectPath = (from.query.redirect ?? - (to.path === preferences.app.defaultHomePath - ? normalizeHomePath(userInfo.homePath) - : to.fullPath)) as string; + const redirectPath = normalizeHomePath( + (from.query.redirect ?? + (to.path === preferences.app.defaultHomePath + ? userInfo.homePath + : to.fullPath)) as string, + ); return { - ...router.resolve(decodeURIComponent(redirectPath)), + ...router.resolve(redirectPath), replace: true, }; }); diff --git a/web/apps/web-ele/src/store/auth.ts b/web/apps/web-ele/src/store/auth.ts index 546d3bf..2f6d654 100644 --- a/web/apps/web-ele/src/store/auth.ts +++ b/web/apps/web-ele/src/store/auth.ts @@ -4,7 +4,6 @@ import { ref } from 'vue'; import { useRouter } from 'vue-router'; import { LOGIN_PATH } from '@vben/constants'; -import { preferences } from '@vben/preferences'; import { resetAllStores, useAccessStore, useUserStore } from '@vben/stores'; import { defineStore } from 'pinia'; @@ -12,13 +11,7 @@ import { defineStore } from 'pinia'; import { getAccessCodesApi, loginApi, logoutApi } from '#/api/core/auth'; import { getUserInfoApi } from '#/api/core/user'; import { $t } from '#/locales'; - -function normalizeHomePath(path?: null | string) { - if (!path || path === '/page-render/main_home') { - return preferences.app.defaultHomePath; - } - return path; -} +import { normalizeHomePath } from '#/utils/legacy-home'; export const useAuthStore = defineStore('auth', () => { const accessStore = useAccessStore(); diff --git a/web/apps/web-ele/src/utils/legacy-home.ts b/web/apps/web-ele/src/utils/legacy-home.ts new file mode 100644 index 0000000..9ea51bf --- /dev/null +++ b/web/apps/web-ele/src/utils/legacy-home.ts @@ -0,0 +1,33 @@ +import { preferences } from '@vben/preferences'; + +const LEGACY_HOME_PATTERNS = [ + /^\/app\/[^/]+\/(?:form-render|page-render)\//, + /^\/(?:form-render|page-render)\//, + /^\/online-dev(?:\/|$)/, + /^\/online-development(?:\/|$)/, +]; + +function decodePath(path: string) { + try { + return decodeURIComponent(path); + } catch { + return path; + } +} + +function isLegacyHomePath(path: string) { + return LEGACY_HOME_PATTERNS.some((pattern) => pattern.test(path)); +} + +function normalizeHomePath(path?: null | string) { + if (!path) { + return preferences.app.defaultHomePath; + } + + const decodedPath = decodePath(path); + return isLegacyHomePath(decodedPath) + ? preferences.app.defaultHomePath + : decodedPath; +} + +export { normalizeHomePath }; diff --git a/web/apps/web-ele/src/views/_core/authentication/login.vue b/web/apps/web-ele/src/views/_core/authentication/login.vue index ef685b4..324ccb3 100644 --- a/web/apps/web-ele/src/views/_core/authentication/login.vue +++ b/web/apps/web-ele/src/views/_core/authentication/login.vue @@ -10,8 +10,7 @@ import { $t } from '@vben/locales'; import { getPreferencesConfigApi } from '#/api/core/ui-config'; import { useAuthStore } from '#/store'; - -const LEGACY_HOME_PATH = '/page-render/main_home'; +import { normalizeHomePath } from '#/utils/legacy-home'; defineOptions({ name: 'Login' }); @@ -61,10 +60,6 @@ const getRedirectState = () => { return redirect ? JSON.stringify({ redirect }) : undefined; }; -function normalizeRedirectPath(path: string) { - return path === LEGACY_HOME_PATH ? '/' : path; -} - type OAuthProvider = | 'dingtalk' | 'feishu' @@ -115,7 +110,7 @@ async function handleLogin(params: Record) { if (redirect) { // 有 redirect 参数时,登录成功后跳转到指定页面 await authStore.authLogin(params, async () => { - const targetPath = normalizeRedirectPath(decodeURIComponent(redirect)); + const targetPath = normalizeHomePath(redirect); await router.push(targetPath); }); } else {