mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-03 13:44:47 +08:00
fix: update
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -4,3 +4,8 @@ export type cacheType = {
|
||||
mode: string;
|
||||
name?: RouteRecordName;
|
||||
};
|
||||
|
||||
export type positionType = {
|
||||
startIndex?: number;
|
||||
length?: number;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user