feat: 产品菜单路由权限
This commit is contained in:
@ -1,15 +1,25 @@
|
||||
/*
|
||||
* @Author: rd 1344903914@qq.com
|
||||
* @Date: 2025-07-08 11:22:05
|
||||
* @LastEditors: rd 1344903914@qq.com
|
||||
* @LastEditTime: 2025-07-08 14:06:41
|
||||
* @FilePath: /lingji-work-fe/src/stores/modules/side-bar/constants.ts
|
||||
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
||||
*/
|
||||
import { MENU_GROUP_IDS } from '@/router/constants';
|
||||
export const MENU_LIST = [
|
||||
{
|
||||
id: MENU_GROUP_IDS.WORK_BENCH_ID,
|
||||
name: '工作台',
|
||||
pathName: 'Home',
|
||||
requiresAuth: false,
|
||||
permissionKey: '', // 权限key,如果为空,则表示该菜单不需要权限,与后端约定
|
||||
},
|
||||
{
|
||||
id: MENU_GROUP_IDS.DATA_ENGINE_ID,
|
||||
name: '全域数据分析',
|
||||
permissionKey: 'data_analysis',
|
||||
requiresAuth: true,
|
||||
children: [
|
||||
{
|
||||
name: '行业热门话题洞察',
|
||||
@ -41,6 +51,7 @@ export const MENU_LIST = [
|
||||
id: MENU_GROUP_IDS.PROPERTY_ID,
|
||||
name: '营销资产中台',
|
||||
permissionKey: 'marketing_asset',
|
||||
requiresAuth: true,
|
||||
children: [
|
||||
{
|
||||
name: '品牌资产管理',
|
||||
|
||||
@ -11,12 +11,15 @@ import { useEnterpriseStore } from '@/stores/modules/enterprise';
|
||||
interface sidebarState {
|
||||
activeMenuId: number | null;
|
||||
menuList: any[];
|
||||
allowAccessRoutes: any[];
|
||||
}
|
||||
|
||||
export const useSidebarStore = defineStore('sidebar', {
|
||||
state: (): sidebarState => ({
|
||||
activeMenuId: null,
|
||||
menuList: [],
|
||||
|
||||
allowAccessRoutes: [], // 允许访问的路由列表
|
||||
}),
|
||||
actions: {
|
||||
clearActiveMenuId() {
|
||||
@ -25,12 +28,14 @@ export const useSidebarStore = defineStore('sidebar', {
|
||||
setActiveMenuId(id: number) {
|
||||
this.activeMenuId = id;
|
||||
},
|
||||
clearUserNavbarMenuList() {
|
||||
this.menuList = [];
|
||||
},
|
||||
// navbar菜单列表由企业对应权限决定
|
||||
getNavbarMenuList() {
|
||||
getUserNavbarMenuList() {
|
||||
const enterpriseStore = useEnterpriseStore();
|
||||
const enterpriseInfo = enterpriseStore.getEnterpriseInfo();
|
||||
this.menuList = MENU_LIST.filter(
|
||||
(item) => !item.permissionKey || enterpriseInfo?.permissions?.includes(item.permissionKey),
|
||||
(item) => !item.permissionKey || enterpriseStore.enterpriseInfo?.permissions?.includes(item.permissionKey),
|
||||
);
|
||||
},
|
||||
// 根据当前路由自动设置 activeMenuId
|
||||
@ -61,7 +66,7 @@ export const useSidebarStore = defineStore('sidebar', {
|
||||
return null;
|
||||
};
|
||||
|
||||
const menuId = findMenuGroup(appRoutes);
|
||||
const menuId = findMenuGroup(appRoutes as any);
|
||||
if (menuId !== null) {
|
||||
this.activeMenuId = menuId;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user