perf(router): refresh (#142)

* feat: set add multiTagsCache

* perf(router): refresh

* fix(multiTags): clear storage when close other tag

Co-authored-by: lrl <742798240@qq.com>
This commit is contained in:
啝裳
2021-12-07 15:40:10 +08:00
committed by GitHub
parent d6a358e851
commit 12879f9553
5 changed files with 102 additions and 12 deletions

View File

@@ -1,6 +1,5 @@
import { defineStore } from "pinia";
import { store } from "/@/store";
import { getConfig } from "/@/config";
import { storageLocal } from "/@/utils/storage";
import { multiType, positionType } from "./types";
@@ -8,7 +7,7 @@ export const useMultiTagsStore = defineStore({
id: "pure-multiTags",
state: () => ({
// 存储标签页信息(路由信息)
multiTags: getConfig().MultiTagsCache
multiTags: storageLocal.getItem("responsive-sets").multiTagsCache
? storageLocal.getItem("responsive-tags")
: [
{
@@ -22,7 +21,7 @@ export const useMultiTagsStore = defineStore({
}
}
],
multiTagsCache: getConfig().MultiTagsCache
multiTagsCache: storageLocal.getItem("responsive-sets").multiTagsCache
}),
getters: {
getMultiTagsCache() {
@@ -30,6 +29,14 @@ export const useMultiTagsStore = defineStore({
}
},
actions: {
multiTagsCacheChange(multiTagsCache: boolean) {
this.multiTagsCache = multiTagsCache;
if (multiTagsCache) {
storageLocal.setItem("responsive-tags", this.multiTags);
} else {
storageLocal.removeItem("responsive-tags");
}
},
tagsCache(multiTags) {
this.getMultiTagsCache &&
storageLocal.setItem("responsive-tags", multiTags);
@@ -42,6 +49,7 @@ export const useMultiTagsStore = defineStore({
switch (mode) {
case "equal":
this.multiTags = value;
this.tagsCache(this.multiTags);
break;
case "push":
{