import { CoreConfig } from "../model/CoreConfig"; import Vue from "vue"; import { NAMESPACE } from "../constants/config/storage.config"; import store from "store"; class RouteTopologyStore { private static readonly INITED = NAMESPACE + "inited"; private static readonly TREE_ROUTES = NAMESPACE + "treeRoutes"; private static readonly HORIZONTAL_ROUTES = NAMESPACE + "horizontalRoutes"; /** * @description: 获取全局配置 * @author ChenRui * @date 2020/12/17 16:16 */ get coreConfig(): Partial { if (Vue.prototype.$dc != null) { return Vue.prototype.$dc; } return {}; } get suffix(): string { if (this.coreConfig.sysId) { return ":" + this.coreConfig.sysId; } return ""; } public set inited(inited: boolean) { const key = RouteTopologyStore.INITED + this.suffix; if (inited) { store.set(key, inited); } else { store.remove(key); } } public get inited(): boolean { const key = RouteTopologyStore.INITED + this.suffix; return store.get(key); } public set treeRoutes(treeRoutes: any) { const key = RouteTopologyStore.TREE_ROUTES + this.suffix; if (treeRoutes) { store.set(key, treeRoutes); } else { store.remove(key); } } public get treeRoutes(): any { const key = RouteTopologyStore.TREE_ROUTES + this.suffix; return store.get(key); } public set horizontalRoutes(horizontalRoutes: any) { const key = RouteTopologyStore.HORIZONTAL_ROUTES + this.suffix; if (horizontalRoutes) { store.set(key, horizontalRoutes); } else { store.remove(key); } } public get horizontalRoutes(): any { const key = RouteTopologyStore.HORIZONTAL_ROUTES + this.suffix; return store.get(key); } } const routeTopologyStore = new RouteTopologyStore(); export { routeTopologyStore };