mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-09 13:53:38 +08:00
fix: update
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user