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 @@