|
@@ -17,6 +17,7 @@ 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 { transformI18n } from "/@/plugins/i18n";
|
|
|
import { storageLocal } from "/@/utils/storage";
|
|
@@ -46,6 +47,61 @@ let multiTags: ComputedRef<Array<RouteConfigs>> = computed(() => {
|
|
|
return useMultiTagsStoreHook()?.multiTags;
|
|
|
});
|
|
|
|
|
|
+const linkIsActive = computed(() => {
|
|
|
+ return item => {
|
|
|
+ if (Object.keys(route.query).length === 0) {
|
|
|
+ if (route.path === item.path) {
|
|
|
+ return "is-active";
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isEqual(route?.query, item?.query)) {
|
|
|
+ return "is-active";
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+});
|
|
|
+
|
|
|
+const scheduleIsActive = computed(() => {
|
|
|
+ return item => {
|
|
|
+ if (Object.keys(route.query).length === 0) {
|
|
|
+ if (route.path === item.path) {
|
|
|
+ return "schedule-active";
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isEqual(route?.query, item?.query)) {
|
|
|
+ return "schedule-active";
|
|
|
+ } else {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+});
|
|
|
+
|
|
|
+const iconIsActive = computed(() => {
|
|
|
+ return (item, index) => {
|
|
|
+ if (index === 0) return;
|
|
|
+ if (Object.keys(route.query).length === 0) {
|
|
|
+ if (route.path === item.path) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (isEqual(route?.query, item?.query)) {
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+});
|
|
|
+
|
|
|
const dynamicTagView = () => {
|
|
|
const index = multiTags.value.findIndex(item => {
|
|
|
return item.path === route.path;
|
|
@@ -229,7 +285,13 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|
|
// 存放被删除的缓存路由
|
|
|
let delAliveRouteList = [];
|
|
|
let valueIndex: number = multiTags.value.findIndex((item: any) => {
|
|
|
- return item.path === obj.path;
|
|
|
+ if (item.query) {
|
|
|
+ if (item.path === obj.path) {
|
|
|
+ return item.query === obj.query;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return item.path === obj.path;
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
const spliceRoute = (
|
|
@@ -280,7 +342,8 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|
|
if (tag === "left") return;
|
|
|
nextTick(() => {
|
|
|
router.push({
|
|
|
- path: newRoute[0].path
|
|
|
+ path: newRoute[0].path,
|
|
|
+ query: newRoute[0].query
|
|
|
});
|
|
|
});
|
|
|
} else {
|
|
@@ -292,7 +355,8 @@ function deleteDynamicTag(obj: any, current: any, tag?: string) {
|
|
|
});
|
|
|
!isHasActiveTag &&
|
|
|
router.push({
|
|
|
- path: newRoute[0].path
|
|
|
+ path: newRoute[0].path,
|
|
|
+ query: newRoute[0].query
|
|
|
});
|
|
|
}
|
|
|
}
|
|
@@ -478,7 +542,8 @@ function openMenu(tag, e) {
|
|
|
// 触发tags标签切换
|
|
|
function tagOnClick(item) {
|
|
|
router.push({
|
|
|
- path: item?.path
|
|
|
+ path: item?.path,
|
|
|
+ query: item?.query
|
|
|
});
|
|
|
showMenuModel(item?.path);
|
|
|
}
|
|
@@ -564,7 +629,7 @@ onBeforeMount(() => {
|
|
|
:key="index"
|
|
|
:class="[
|
|
|
'scroll-item is-closable',
|
|
|
- $route.path === item.path ? 'is-active' : '',
|
|
|
+ linkIsActive(item),
|
|
|
$route.path === item.path && showModel === 'card'
|
|
|
? 'card-active'
|
|
|
: ''
|
|
@@ -574,12 +639,12 @@ onBeforeMount(() => {
|
|
|
@mouseleave.prevent="onMouseleave(item, index)"
|
|
|
@click="tagOnClick(item)"
|
|
|
>
|
|
|
- <router-link :to="item.path">{{
|
|
|
- transformI18n(item.meta.title, item.meta.i18n)
|
|
|
- }}</router-link>
|
|
|
+ <router-link :to="item.path"
|
|
|
+ >{{ transformI18n(item.meta.title, item.meta.i18n) }}
|
|
|
+ </router-link>
|
|
|
<el-icon
|
|
|
v-if="
|
|
|
- ($route.path === item.path && index !== 0) ||
|
|
|
+ iconIsActive(item, index) ||
|
|
|
(index === activeIndex && index !== 0)
|
|
|
"
|
|
|
class="el-icon-close"
|
|
@@ -590,7 +655,7 @@ onBeforeMount(() => {
|
|
|
<div
|
|
|
:ref="'schedule' + index"
|
|
|
v-if="showModel !== 'card'"
|
|
|
- :class="[$route.path === item.path ? 'schedule-active' : '']"
|
|
|
+ :class="[scheduleIsActive(item)]"
|
|
|
></div>
|
|
|
</div>
|
|
|
</div>
|