fix: update

This commit is contained in:
lrl
2021-11-27 15:16:50 +08:00
parent b65b972353
commit 6d3a8c5a88
4 changed files with 40 additions and 26 deletions

View File

@@ -2,23 +2,26 @@ import { defineStore } from "pinia";
import { store } from "/@/store";
import { getConfig } from "/@/config";
import { positionType } from "./types";
import { storageLocal } from "/@/utils/storage";
export const useMultiTagsStore = defineStore({
id: "pure-multiTags",
state: () => ({
// 存储标签页信息(路由信息)
multiTags: [
{
path: "/welcome",
parentPath: "/",
meta: {
title: "message.hshome",
icon: "el-icon-s-home",
i18n: true,
showLink: true
}
}
],
multiTags: getConfig().MultiTagsCache
? storageLocal.getItem("responsive-tags")
: [
{
path: "/welcome",
parentPath: "/",
meta: {
title: "message.hshome",
icon: "el-icon-s-home",
i18n: true,
showLink: true
}
}
],
multiTagsCache: getConfig().MultiTagsCache
}),
getters: {
@@ -27,6 +30,10 @@ export const useMultiTagsStore = defineStore({
}
},
actions: {
tagsCache(multiTags) {
this.getMultiTagsCache &&
storageLocal.setItem("responsive-tags", multiTags);
},
handleTags<T>(mode: string, value?: T, position?: positionType): any {
switch (mode) {
case "equal":
@@ -34,12 +41,15 @@ export const useMultiTagsStore = defineStore({
break;
case "push":
this.multiTags.push(value);
this.tagsCache(this.multiTags);
break;
case "splice":
this.multiTags.splice(position?.startIndex, position?.length);
this.tagsCache(this.multiTags);
return this.multiTags;
break;
case "slice":
this.multiTags.slice(-1);
return this.multiTags.slice(-1);
break;
}
}