Files
mengxiang-vpp-portal-web/src/store/modules/system.js
T

60 lines
1.2 KiB
JavaScript
Raw Normal View History

import { defineStore } from "pinia";
/**
* 多系统链接管理 Store
* 预留:后续用于管理子系统列表、快捷跳转、权限关联等
*/
export const useSystemStore = defineStore("system", {
state: () => ({
/** 系统列表 */
systemList: [],
/** 当前选中的系统 */
currentSystem: null,
/** 系统分类 */
categories: [],
/** 加载状态 */
loading: false,
}),
getters: {
/**
* 按分类获取系统列表
*/
getSystemsByCategory: (state) => (categoryId) => {
return state.systemList.filter((s) => s.categoryId === categoryId);
},
/**
* 获取收藏的系统
*/
favoriteSystems: (state) => {
return state.systemList.filter((s) => s.isFavorite);
},
},
actions: {
/**
* 设置系统列表
*/
setSystemList(list) {
this.systemList = list;
},
/**
* 设置当前系统
*/
setCurrentSystem(system) {
this.currentSystem = system;
},
/**
* 重置状态
*/
reset() {
this.systemList = [];
this.currentSystem = null;
this.categories = [];
this.loading = false;
},
},
});