// import { message } from 'ant-design-vue'; import { defineStore } from 'pinia'; // import { router } from '/nerv-lib/paas/router'; // import { http } from '/nerv-lib/util/http'; export const configRegist = defineStore({ id: 'configRegist', /** * sideMenu 侧边栏菜单 * @returns */ state(): { sideMenu: { [k: string]: SideMenu }; activateUrls: { [k: string]: number } } { return { sideMenu: {}, activateUrls: {} }; }, getters: {}, actions: { setSideMenu(menu: SideMenu) { if (menu.name) { this.sideMenu[menu.name] = menu; } }, getSidMenu(name: any) { return this.sideMenu[name]; }, setUrl(url: string, index: number) { this.activateUrls[url] = index; }, removeUrl(url: string) { delete this.activateUrls[url]; }, hasUrl(url: string) { let isExist = false; Object.keys(this.activateUrls).some((el) => { el === url ? (isExist = true) : ''; }); return isExist; }, isLaster(url: string) { let isCurr = true; const ind = this.activateUrls[url]; const indexMap = Object.values(this.activateUrls).sort(); isCurr = ind >= indexMap[indexMap.length - 1]; return isCurr; }, }, }); export interface SideMenuItem { authMap?: Array; //侧边栏显示文字 isOpen?: boolean; //侧边栏权限标记 ifShow?: Boolean | Function; //dom隐藏 label: string; //侧边栏路由 module: string; //菜单所属模块 name: string; //是否属于项目权限 projectName?: boolean; //是否根据多个模块授权,默认是&&连接符 url: string; //是否是全局开放的模块 app?: string; // bindView?: string; openPermission?: boolean; submenus?: SideMenuItem[]; } export interface SideMenu { backTo?: string; //通过匹配路由的name,获取菜单信息 ifShow?: Boolean | Function; //dom隐藏 menus: SideMenuItem[]; //显示标题名称 name: string; //返回的路径 root?: boolean; //是否是根目录 title?: string; backToHandle?: Function } export interface ModuleResItem { label: string; name: string; operations: []; url: string; } export interface ModuleRes { app: string; catalog: string; icon: string; label: string; menus: ModuleResItem[]; }