From d0ff2225c705f3a3afc7bc23a57f8148395a72e6 Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Thu, 23 Nov 2023 23:01:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E6=80=81=E8=B7=AF=E7=94=B1=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E5=8F=B3=E9=94=AE=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= =?UTF-8?q?404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/web/usePage.ts | 44 ++++++++++++-------------------- src/store/modules/multipleTab.ts | 15 +++++++++++ src/views/sys/redirect/index.vue | 38 +++++++++++++-------------- 3 files changed, 50 insertions(+), 47 deletions(-) diff --git a/src/hooks/web/usePage.ts b/src/hooks/web/usePage.ts index 80fbaba..7583607 100644 --- a/src/hooks/web/usePage.ts +++ b/src/hooks/web/usePage.ts @@ -7,6 +7,7 @@ import { unref } from 'vue'; import { useRouter } from 'vue-router'; import { REDIRECT_NAME } from '/@/router/constant'; import { useUserStore } from '/@/store/modules/user'; +import { useMultipleTabStore } from '/@/store/modules/multipleTab'; export type RouteLocationRawEx = Omit & { path: PageEnum }; @@ -51,40 +52,27 @@ export const useRedo = (_router?: Router) => { resolve(false); return; } + // update-begin--author:liaozhiyang---date:20231123---for:【QQYUN-7099】动态路由匹配右键重新加载404 + const tabStore = useMultipleTabStore(); if (name && Object.keys(params).length > 0) { - //update-begin-author:taoyan date:2022-10-19 for: VUEN-2356 【vue3】online表单、表单设计器 功能测试 右键刷新时 404 - if(isDynamicRoute(params, name)){ - params['_redirect_type'] = 'path'; - params['path'] = fullPath; - }else{ - params['_redirect_type'] = 'name'; - params['path'] = String(name); - } - //update-end-author:taoyan date:2022-10-19 for: VUEN-2356 【vue3】online表单、表单设计器 功能测试 右键刷新时 404 + tabStore.setRedirectPageParam({ + redirect_type: 'name', + name: String(name), + params, + query, + }); + params['path'] = String(name); } else { - params['_redirect_type'] = 'path'; + tabStore.setRedirectPageParam({ + redirect_type: 'path', + path: fullPath, + query, + }); params['path'] = fullPath; } + // update-end--author:liaozhiyang---date:20231123---for:【QQYUN-7099】动态路由匹配右键重新加载404 push({ name: REDIRECT_NAME, params, query }).then(() => resolve(true)); }); } return redo; }; - -/** - * 判断是不是动态路由的跳转 - * @param params - * @param name - */ -function isDynamicRoute(params, name){ - let arr = Object.keys(params); - let flag = false; - for(let i=0;i0){ - flag = true; - break; - } - } - return flag; -} diff --git a/src/store/modules/multipleTab.ts b/src/store/modules/multipleTab.ts index a0f73c0..790e186 100644 --- a/src/store/modules/multipleTab.ts +++ b/src/store/modules/multipleTab.ts @@ -14,11 +14,21 @@ import { MULTIPLE_TABS_KEY } from '/@/enums/cacheEnum'; import projectSetting from '/@/settings/projectSetting'; import { useUserStore } from '/@/store/modules/user'; +import type { LocationQueryRaw, RouteParamsRaw } from 'vue-router'; export interface MultipleTabState { cacheTabList: Set; tabList: RouteLocationNormalized[]; lastDragEndIndex: number; + redirectPageParam: null | redirectPageParamType; +} + +interface redirectPageParamType { + redirect_type: string; + name?: string; + path?: string; + query: LocationQueryRaw; + params?: RouteParamsRaw; } function handleGotoPage(router: Router) { @@ -45,6 +55,8 @@ export const useMultipleTabStore = defineStore({ tabList: cacheTab ? Persistent.getLocal(MULTIPLE_TABS_KEY) || [] : [], // Index of the last moved tab lastDragEndIndex: 0, + // 重定向时存储的路由参数 + redirectPageParam: null, }), getters: { getTabList(): RouteLocationNormalized[] { @@ -348,6 +360,9 @@ export const useMultipleTabStore = defineStore({ await this.updateCacheTab(); } }, + setRedirectPageParam(data) { + this.redirectPageParam = data; + }, }, }); diff --git a/src/views/sys/redirect/index.vue b/src/views/sys/redirect/index.vue index 7aa5463..9adb0e3 100644 --- a/src/views/sys/redirect/index.vue +++ b/src/views/sys/redirect/index.vue @@ -4,27 +4,27 @@