From 9d6fd9cc26697a4917b2e0abee0fc9e26d068ed6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E6=99=8B=E9=A3=9E?= <378266566@qq.com> Date: Tue, 2 Dec 2025 17:13:06 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9A=82=E6=97=B6=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E9=A6=96=E9=A1=B5,=E9=BB=98=E8=AE=A4=E8=B7=B3=E8=BD=AC?= =?UTF-8?q?=E5=88=B0=E6=A8=A1=E5=9E=8B=E8=AE=AD=E7=BB=83,=E4=B9=8B?= =?UTF-8?q?=E5=90=8E=E6=9C=89=E9=A6=96=E9=A1=B5=E4=BC=9A=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/enums/pageEnum.ts | 3 +++ src/router/guard/permissionGuard.ts | 3 ++- src/router/routes/index.ts | 5 +++-- src/store/modules/permission.ts | 16 +++++++++++----- src/store/modules/user.ts | 15 ++++++++++++++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/enums/pageEnum.ts b/src/enums/pageEnum.ts index da262f3..05eb888 100644 --- a/src/enums/pageEnum.ts +++ b/src/enums/pageEnum.ts @@ -8,6 +8,9 @@ export enum PageEnum { // error log page path ERROR_LOG_PAGE = '/error-log/list', MESSAGE_PAGE = '/profile/notify-message', + + // model train path + MODEL_TRAIN = '/model/list', } export const PageWrapperFixedHeightKey = 'PageWrapperFixedHeight' diff --git a/src/router/guard/permissionGuard.ts b/src/router/guard/permissionGuard.ts index 97016b3..67c1617 100644 --- a/src/router/guard/permissionGuard.ts +++ b/src/router/guard/permissionGuard.ts @@ -63,12 +63,14 @@ export function createPermissionGuard(router: Router) { path: LOGIN_PATH, replace: true, } + if (to.path) { redirectData.query = { ...redirectData.query, redirect: to.path, } } + next(redirectData) return } @@ -92,7 +94,6 @@ export function createPermissionGuard(router: Router) { return } } - if (permissionStore.getIsDynamicAddedRoute) { next() return diff --git a/src/router/routes/index.ts b/src/router/routes/index.ts index 44163a4..976093a 100644 --- a/src/router/routes/index.ts +++ b/src/router/routes/index.ts @@ -15,15 +15,16 @@ Object.keys(modules).forEach((key) => { const mod = (modules as Recordable)[key].default || {} const modList = Array.isArray(mod) ? [...mod] : [mod] routeModuleList.push(...modList) + }) export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList] -// 根路由 +// 根路由--之前跳转首页,现在先跳转模型训练页,如果后面有首页要求,再改回来 export const RootRoute: AppRouteRecordRaw = { path: '/', name: 'Root', - redirect: PageEnum.BASE_HOME, + redirect: PageEnum.MODEL_TRAIN, meta: { title: 'Root', }, diff --git a/src/store/modules/permission.ts b/src/store/modules/permission.ts index d81f0f6..f543e7b 100644 --- a/src/store/modules/permission.ts +++ b/src/store/modules/permission.ts @@ -226,11 +226,14 @@ export const usePermissionStore = defineStore('app-permission', { // 动态引入组件 routeList = transformObjToRoute(routeList) // Background routing to menu structure - // 后台路由到菜单结构 - const backMenuList = transformRouteToMenu([dashboard, ...routeList]) +// 后台路由到菜单结构 // 为了去掉页面--关于-- // const backMenuList = transformRouteToMenu([dashboard, ...routeList, about]) + // 后台路由到菜单结构 + // const backMenuList = transformRouteToMenu([dashboard, ...routeList]) + //去掉首页 + const backMenuList = transformRouteToMenu([...routeList]) this.setBackMenuList(backMenuList) // remove meta.ignoreRoute item @@ -239,10 +242,13 @@ export const usePermissionStore = defineStore('app-permission', { routeList = routeList.filter(routeRemoveIgnoreFilter) routeList = flatMultiLevelRoutes(routeList) - - routes = [PAGE_NOT_FOUND_ROUTE, dashboard, ...routeList] - // 为了去掉页面--关于-- + // 为了去掉页面--关于-- // routes = [PAGE_NOT_FOUND_ROUTE, dashboard, ...routeList, about] + // 为了去掉页面 + // routes = [PAGE_NOT_FOUND_ROUTE, dashboard, ...routeList] + + routes = [PAGE_NOT_FOUND_ROUTE, ...routeList] + break } diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index bd8ceda..668c4d8 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -153,7 +153,20 @@ export const useUserStore = defineStore('app-user', { router.addRoute(PAGE_NOT_FOUND_ROUTE as unknown as RouteRecordRaw) permissionStore.setDynamicAddedRoute(true) } - goHome && (await router.replace(PageEnum.BASE_HOME)) + + + //原来的版本--就只跳转首页 + // goHome && (await router.replace(PageEnum.BASE_HOME)) + + // 获取重定向地址(从路由查询参数中) + const currentRoute = router.currentRoute.value + const redirectPath = currentRoute.query.redirect as string + const redirect = redirectPath ? decodeURIComponent(redirectPath) : null + // 如果有重定向地址,优先跳转到重定向地址 + // 如果没有重定向地址,默认跳转到模型训练页 + goHome && (await router.replace(redirect || PageEnum.MODEL_TRAIN)) + + } return userInfo },