mirror of
https://gitee.com/log4j/pig-ui.git
synced 2024-12-23 05:40:20 +08:00
'admin-22.11.19:修复v2.3.0版本动态路由事件调用关闭当前tagsview、普通路由刷新界面参数丢失问题'
This commit is contained in:
parent
f9ce14431d
commit
161748a549
@ -101,6 +101,7 @@ interface CurrentContextmenu {
|
|||||||
query: any;
|
query: any;
|
||||||
path: string;
|
path: string;
|
||||||
contextMenuClickId: string | number;
|
contextMenuClickId: string | number;
|
||||||
|
commonUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
@ -357,29 +358,34 @@ export default defineComponent({
|
|||||||
else await router.push({ name: item.name, query: item.query });
|
else await router.push({ name: item.name, query: item.query });
|
||||||
stores.setCurrenFullscreen(true);
|
stores.setCurrenFullscreen(true);
|
||||||
};
|
};
|
||||||
// 当前项右键菜单点击,拿当前点击的路由路径对比 浏览器缓存中的 tagsView 路由数组,取当前点击项的详细路由信息
|
// 当前项右键菜单点击,拿 `当前点击的路由路径` 对比 `tagsView 路由数组`,取当前点击项的详细路由信息
|
||||||
// 防止 tagsView 非当前页演示时,操作异常
|
// 防止 tagsView 非当前页演示时,操作异常
|
||||||
const getCurrentRouteItem = (path: string, cParams: any) => {
|
// https://gitee.com/lyt-top/vue-next-admin/issues/I61VS9
|
||||||
const itemRoute = Session.get('tagsViewList') ? Session.get('tagsViewList') : state.tagsViewList;
|
const getCurrentRouteItem = (item: any) => {
|
||||||
return itemRoute.find((v: any) => {
|
let resItem: any = {};
|
||||||
if (
|
state.tagsViewList.forEach((v: any) => {
|
||||||
v.path === path &&
|
v.transUrl = transUrlParams(v);
|
||||||
isObjectValueEqual(
|
if (v.transUrl) {
|
||||||
v.meta.isDynamic ? (v.params ? v.params : null) : v.query ? v.query : null,
|
if (v.meta.isDynamic) {
|
||||||
cParams && Object.keys(cParams ? cParams : {}).length > 0 ? cParams : null
|
// 路由带参数:动态路由(xxx/:id/:name")isDynamic
|
||||||
)
|
if (v.transUrl === transUrlParams(v) && v.transUrl === decodeURI(item.path)) resItem = v;
|
||||||
) {
|
} else {
|
||||||
return v;
|
// 路由带参数:普通路由,因为有 tagsView 共用/不共用
|
||||||
} else if (v.path === path && Object.keys(cParams ? cParams : {}).length <= 0) {
|
if (v.transUrl === transUrlParams(v) && v.transUrl === item.commonUrl) resItem = v;
|
||||||
return v;
|
}
|
||||||
|
} else {
|
||||||
|
// 路由不带参数
|
||||||
|
if (v.path === decodeURI(item.path)) resItem = v;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
if (!resItem) return null;
|
||||||
|
else return resItem;
|
||||||
};
|
};
|
||||||
// 当前项右键菜单点击
|
// 当前项右键菜单点击
|
||||||
const onCurrentContextmenuClick = async (item: CurrentContextmenu) => {
|
const onCurrentContextmenuClick = async (item: CurrentContextmenu) => {
|
||||||
const cParams = item.meta.isDynamic ? item.params : item.query;
|
item.commonUrl = transUrlParams(item);
|
||||||
if (!getCurrentRouteItem(item.path, cParams)) return ElMessage({ type: 'warning', message: '请正确输入路径及完整参数(query、params)' });
|
if (!getCurrentRouteItem(item)) return ElMessage({ type: 'warning', message: '请正确输入路径及完整参数(query、params)' });
|
||||||
const { path, name, params, query, meta, url } = getCurrentRouteItem(item.path, cParams);
|
const { path, name, params, query, meta, url } = getCurrentRouteItem(item);
|
||||||
switch (item.contextMenuClickId) {
|
switch (item.contextMenuClickId) {
|
||||||
case 0:
|
case 0:
|
||||||
// 刷新当前
|
// 刷新当前
|
||||||
|
@ -114,11 +114,12 @@ router.beforeEach(async (to, from, next) => {
|
|||||||
// 后端控制路由:路由数据初始化,防止刷新时丢失
|
// 后端控制路由:路由数据初始化,防止刷新时丢失
|
||||||
await initBackEndControlRoutes();
|
await initBackEndControlRoutes();
|
||||||
// 解决刷新时,一直跳 404 页面问题,关联问题 No match found for location with path 'xxx'
|
// 解决刷新时,一直跳 404 页面问题,关联问题 No match found for location with path 'xxx'
|
||||||
next({ path: to.path });
|
// to.query 防止页面刷新时,普通路由带参数时,参数丢失。动态路由(xxx/:id/:name")isDynamic 无需处理
|
||||||
|
next({ path: to.path, query: to.query });
|
||||||
} else {
|
} else {
|
||||||
// https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP
|
// https://gitee.com/lyt-top/vue-next-admin/issues/I5F1HP
|
||||||
await initFrontEndControlRoutes();
|
await initFrontEndControlRoutes();
|
||||||
next({ path: to.path });
|
next({ path: to.path, query: to.query });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
next();
|
next();
|
||||||
|
Loading…
Reference in New Issue
Block a user