Merge pull request #149 from xiaoxian521/fix/menuModel

fix: tag
This commit is contained in:
啝裳 2021-12-15 11:08:44 +08:00 committed by GitHub
commit cbffe31c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 46 deletions

View File

@ -123,7 +123,13 @@ pnpm build
## 微信交流群
本人微信18237613535拉你进群
本人微信18237613535拉你进群有什么问题你可以和群友交流
## 付费咨询、需求定制
作者精力有限,需要提供服务的可扫下面的二维码加微信
<img src="http://yiming_chang.gitee.io/manages/cost.jpg" width="150px" height="150px" />
## 许可证

View File

@ -17,8 +17,8 @@ import closeLeft from "/@/assets/svg/close_left.svg";
import closeOther from "/@/assets/svg/close_other.svg";
import closeRight from "/@/assets/svg/close_right.svg";
import { isEqual } from "lodash-es";
import { emitter } from "/@/utils/mitt";
import { isEqual, isEmpty } from "lodash-es";
import { transformI18n } from "/@/plugins/i18n";
import { storageLocal } from "/@/utils/storage";
import { useRoute, useRouter } from "vue-router";
@ -272,9 +272,10 @@ function dynamicRouteTag(value: string, parentPath: string): void {
//
function onFresh() {
toggleClass(true, refreshButton, document.querySelector(".rotate"));
const { fullPath } = unref(route);
const { fullPath, query } = unref(route);
router.replace({
path: "/redirect" + fullPath
path: "/redirect" + fullPath,
query: query
});
setTimeout(() => {
removeClass(document.querySelector(".rotate"), refreshButton);
@ -367,6 +368,19 @@ function deleteMenu(item, tag?: string) {
function onClickDrop(key, item, selectRoute?: RouteConfigs) {
if (item && item.disabled) return;
let selectTagRoute;
if (selectRoute) {
selectTagRoute = {
path: selectRoute.path,
meta: selectRoute.meta,
name: selectRoute.name,
query: selectRoute.query
};
} else {
selectTagRoute = { path: route.path, meta: route.meta };
}
//
switch (key) {
case 0:
@ -375,49 +389,19 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
break;
case 1:
//
selectRoute
? deleteMenu({
path: selectRoute.path,
meta: selectRoute.meta,
name: selectRoute.name
})
: deleteMenu({ path: route.path, meta: route.meta });
deleteMenu(selectTagRoute);
break;
case 2:
//
selectRoute
? deleteMenu(
{
path: selectRoute.path,
meta: selectRoute.meta
},
"left"
)
: deleteMenu({ path: route.path, meta: route.meta }, "left");
deleteMenu(selectTagRoute, "left");
break;
case 3:
//
selectRoute
? deleteMenu(
{
path: selectRoute.path,
meta: selectRoute.meta
},
"right"
)
: deleteMenu({ path: route.path, meta: route.meta }, "right");
deleteMenu(selectTagRoute, "right");
break;
case 4:
//
selectRoute
? deleteMenu(
{
path: selectRoute.path,
meta: selectRoute.meta
},
"other"
)
: deleteMenu({ path: route.path, meta: route.meta }, "other");
deleteMenu(selectTagRoute, "other");
break;
case 5:
//
@ -430,7 +414,7 @@ function onClickDrop(key, item, selectRoute?: RouteConfigs) {
break;
}
setTimeout(() => {
showMenuModel(route.fullPath);
showMenuModel(route.fullPath, route.query);
});
}
@ -456,18 +440,31 @@ function disabledMenus(value: boolean) {
}
//
function showMenuModel(currentPath: string, refresh = false) {
function showMenuModel(
currentPath: string,
query: object = {},
refresh = false
) {
let allRoute = multiTags.value;
let routeLength = multiTags.value.length;
// currentIndex1
let currentIndex = allRoute.findIndex(v => v.path === currentPath);
// currentIndexrouteLength-1
let currentIndex = -1;
if (isEmpty(query)) {
currentIndex = allRoute.findIndex(v => v.path === currentPath);
} else {
currentIndex = allRoute.findIndex(v => isEqual(v.query, query));
}
showMenus(true);
if (refresh) {
tagsViews.value[0].show = true;
}
/**
* currentIndex为1时左侧的菜单是首页则不显示关闭左侧标签页
* 如果currentIndex等于routeLength-1右侧没有菜单则不显示关闭右侧标签页
*/
if (currentIndex === 1 && routeLength !== 2) {
//
tagsViews.value[2].show = false;
@ -506,7 +503,7 @@ function openMenu(tag, e) {
} else if (route.path !== tag.path) {
//
tagsViews.value[0].show = false;
showMenuModel(tag.path);
showMenuModel(tag.path, tag.query);
} else if (
// eslint-disable-next-line no-dupe-else-if
multiTags.value.length === 2 &&
@ -517,7 +514,7 @@ function openMenu(tag, e) {
tagsViews.value[4].show = false;
} else if (route.path === tag.path) {
//
showMenuModel(tag.path, true);
showMenuModel(tag.path, tag.query, true);
}
currentSelect.value = tag;
@ -545,7 +542,7 @@ function tagOnClick(item) {
path: item?.path,
query: item?.query
});
showMenuModel(item?.path);
showMenuModel(item?.path, item?.query);
}
//