比对检测计划
This commit is contained in:
@@ -8,6 +8,9 @@ import {
|
||||
} from "@/utils";
|
||||
import { useRouter } from "vue-router";
|
||||
import { AUTH_STORE_KEY } from "@/stores/constant";
|
||||
import {useModeStore} from '@/stores/modules/mode'
|
||||
|
||||
|
||||
export const useAuthStore = defineStore({
|
||||
id: AUTH_STORE_KEY,
|
||||
state: (): AuthState => ({
|
||||
@@ -43,9 +46,15 @@ export const useAuthStore = defineStore({
|
||||
},
|
||||
// Get AuthMenuList
|
||||
async getAuthMenuList() {
|
||||
const { data } = await getAuthMenuListApi();
|
||||
this.authMenuList = data;
|
||||
const modeStore = useModeStore()
|
||||
|
||||
const { data: menuData } = await getAuthMenuListApi();
|
||||
let data = menuData; // 新增变量接收并操作
|
||||
if(modeStore.currentMode === '比对式'){
|
||||
data = filterMenuTree(data);
|
||||
}
|
||||
this.authMenuList = data;
|
||||
|
||||
},
|
||||
// Set RouteName
|
||||
async setRouteName(name: string) {
|
||||
@@ -73,3 +82,16 @@ export const useAuthStore = defineStore({
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
// 工具函数:递归过滤掉 name == 'test' 的菜单项
|
||||
function filterMenuTree(menuList: any[]) {
|
||||
return menuList.filter(menu => {
|
||||
// 如果当前项有 children,递归处理子项
|
||||
if (menu.children && menu.children.length > 0) {
|
||||
menu.children = filterMenuTree(menu.children);
|
||||
}
|
||||
// 过滤掉 name 是 testSource、testScript 或 controlSource 的菜单项
|
||||
return !['testSource', 'testScript', 'controlSource'].includes(menu.name);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user