|
@@ -7,7 +7,8 @@ export const useKeepAliveStore = defineStore({
|
|
|
id: "geeker-keepAlive",
|
|
|
state: (): KeepAliveState => ({
|
|
|
keepAliveName: [],
|
|
|
- keepAliveList: []
|
|
|
+ keepAliveList: [],
|
|
|
+ closeAliveList: []
|
|
|
}),
|
|
|
getters: {
|
|
|
getKeepAliveList(): any[] {
|
|
@@ -26,11 +27,19 @@ export const useKeepAliveStore = defineStore({
|
|
|
!this.keepAliveName.includes(route.name) && this.keepAliveName.push(route.name);
|
|
|
|
|
|
let routeItem = this.keepAliveList.find((item: any) => item.fullPath == route.fullPath);
|
|
|
+ console.log("getKeepAliveName routeItem addKeepAliveName :>> ", JSON.stringify(this.keepAliveList));
|
|
|
+
|
|
|
+ console.log("getKeepAliveName routeItem removeKeepAliveName closeAliveList:>> ", JSON.stringify(this.closeAliveList));
|
|
|
if (!routeItem) {
|
|
|
+ let closeItem = this.closeAliveList.find((item: any) => item.fullPath == route.fullPath);
|
|
|
routeItem = {
|
|
|
fullPath: route.fullPath,
|
|
|
times: 0
|
|
|
};
|
|
|
+ if (closeItem) {
|
|
|
+ routeItem.times = closeItem.times + 1;
|
|
|
+ this.closeAliveList = this.closeAliveList.filter((item: any) => item.fullPath != route.fullPath);
|
|
|
+ }
|
|
|
this.keepAliveList.push(routeItem);
|
|
|
}
|
|
|
},
|
|
@@ -40,11 +49,13 @@ export const useKeepAliveStore = defineStore({
|
|
|
|
|
|
let index = this.keepAliveList.findIndex(item => item.fullPath === route.path);
|
|
|
if (index > -1) {
|
|
|
- // this.keepAliveList.splice(index, 1);
|
|
|
- this.keepAliveList[index].times = this.keepAliveList[index].times + 1;
|
|
|
+ if (this.closeAliveList.every(item => item.fullPath !== route.path)) {
|
|
|
+ this.closeAliveList.push(this.keepAliveList[index]);
|
|
|
+ }
|
|
|
+ this.keepAliveList.splice(index, 1);
|
|
|
+ // this.keepAliveList[index].times = this.keepAliveList[index].times + 1;
|
|
|
}
|
|
|
-
|
|
|
- console.log("getKeepAliveName routeItem removeKeepAliveName :>> ", JSON.stringify(this.keepAliveList));
|
|
|
+ console.log("getKeepAliveName routeItem removeKeepAliveName :>> ", index, JSON.stringify(this.keepAliveList));
|
|
|
console.log("getKeepAliveName routeItem removeKeepAliveName :>> ", this.keepAliveList);
|
|
|
console.log("getKeepAliveName routeItem keepAliveName :>> ", this.keepAliveName);
|
|
|
},
|
|
@@ -65,11 +76,12 @@ export const useKeepAliveStore = defineStore({
|
|
|
getKeepAliveName(name: string) {
|
|
|
let routeItem = this.keepAliveList.find((item: any) => item.fullPath == name);
|
|
|
if (!routeItem) {
|
|
|
- routeItem = {
|
|
|
- fullPath: name,
|
|
|
- times: 0
|
|
|
- };
|
|
|
- this.keepAliveList.push(routeItem);
|
|
|
+ // routeItem = {
|
|
|
+ // fullPath: name,
|
|
|
+ // times: 0
|
|
|
+ // };
|
|
|
+ // this.keepAliveList.push(routeItem);
|
|
|
+ return undefined;
|
|
|
}
|
|
|
return routeItem;
|
|
|
},
|
|
@@ -102,6 +114,14 @@ export const useKeepAliveStore = defineStore({
|
|
|
from.fullPath.split("?")[0],
|
|
|
to.fullPath.split("?")[0] != from.fullPath.split("?")[0]
|
|
|
);
|
|
|
+ console.log(
|
|
|
+ 'tabsParams.path.indexOf("/edit?") > -1 || tabsParams.path.indexOf("/edit/") > -1 :>> ',
|
|
|
+ Boolean(tabsParams.path.indexOf("/edit?") > -1 || tabsParams.path.indexOf("/edit/") > -1)
|
|
|
+ );
|
|
|
+ console.log(
|
|
|
+ 'tabsParams.path.indexOf("/detail?") > -1 || tabsParams.path.indexOf("/detail/") > -1 :>> ',
|
|
|
+ Boolean(tabsParams.path.indexOf("/detail?") > -1 || tabsParams.path.indexOf("/detail/") > -1)
|
|
|
+ );
|
|
|
// if (from.meta?.activeMenu == to.meta?.activeMenu && to.fullPath.split("?")[0] != from.fullPath.split("?")[0]) {
|
|
|
if (tabsParams.path.indexOf("/edit?") > -1 || tabsParams.path.indexOf("/edit/") > -1) {
|
|
|
let key = "/edit?";
|
|
@@ -185,6 +205,7 @@ export const useKeepAliveStore = defineStore({
|
|
|
// }
|
|
|
!isReplace && tabStore.addTabs(tabsParams);
|
|
|
!isReplace && to.meta.isKeepAlive && this.addKeepAliveName(to);
|
|
|
+ console.log("!isReplace && to.meta.isKeepAlive => ", Boolean(!isReplace), Boolean(to.meta.isKeepAlive));
|
|
|
}
|
|
|
}
|
|
|
});
|