feat: 🚀 订阅功能

This commit is contained in:
2025-09-16 16:38:30 +08:00
parent eb1b66a066
commit d3a3ef2911
456 changed files with 40544 additions and 124 deletions

View File

@@ -0,0 +1,50 @@
import router from "@/routers";
import { defineStore } from "pinia";
import { TabsState } from "@/stores/interface";
import piniaPersistConfig from "@/config/piniaPersist";
export const useTabsStore = defineStore({
id: "wms-tabs",
state: (): TabsState => ({
tabsMenuList: []
}),
actions: {
// Add Tabs
async addTabs(tabItem: any) {
if (this.tabsMenuList.every(item => item.path !== tabItem.path)) {
this.tabsMenuList.push(tabItem);
}
},
// Remove Tabs
async removeTabs(tabPath: string, isCurrent: boolean = true) {
const tabsMenuList = this.tabsMenuList;
if (isCurrent) {
tabsMenuList.forEach((item, index) => {
if (item.path !== tabPath) return;
const nextTab = tabsMenuList[index + 1] || tabsMenuList[index - 1];
if (!nextTab) return;
router.push(nextTab.path);
});
}
this.tabsMenuList = tabsMenuList.filter(item => item.path !== tabPath);
},
// Close MultipleTab
async closeMultipleTab(tabsMenuValue?: string) {
this.tabsMenuList = this.tabsMenuList.filter(item => {
return item.path === tabsMenuValue || !item.close;
});
},
// Set Tabs
async setTabs(tabsMenuList: any[]) {
this.tabsMenuList = tabsMenuList;
},
// Set Tabs Title
async setTabsTitle(title: string) {
const nowFullPath = location.hash.substring(1);
this.tabsMenuList.forEach(item => {
if (item.path == nowFullPath) item.title = title;
});
}
},
persist: piniaPersistConfig("wms-tabs")
});