fix: update

This commit is contained in:
xiaoxian521
2021-11-27 10:05:36 +08:00
parent 8c31ca1bad
commit b65b972353
7 changed files with 95 additions and 64 deletions

View File

@@ -1,11 +1,24 @@
import { defineStore } from "pinia";
import { store } from "/@/store";
import { getConfig } from "/@/config";
// import { multiTagsType } from "/@/layout/types";
import { positionType } from "./types";
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
}
}
],
multiTagsCache: getConfig().MultiTagsCache
}),
getters: {
@@ -13,7 +26,24 @@ export const useMultiTagsStore = defineStore({
return this.multiTagsCache;
}
},
actions: {}
actions: {
handleTags<T>(mode: string, value?: T, position?: positionType): any {
switch (mode) {
case "equal":
this.multiTags = value;
break;
case "push":
this.multiTags.push(value);
break;
case "splice":
this.multiTags.splice(position?.startIndex, position?.length);
break;
case "slice":
this.multiTags.slice(-1);
break;
}
}
}
});
export function useMultiTagsStoreHook() {

View File

@@ -4,3 +4,8 @@ export type cacheType = {
mode: string;
name?: RouteRecordName;
};
export type positionType = {
startIndex?: number;
length?: number;
};