Files
SaaS-lib/lib/paas/store/modules/config-service.ts
xuziqiang d0155dbe3c push
2024-05-15 17:29:42 +08:00

84 lines
2.2 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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<string>; //侧边栏显示文字
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[];
}