mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-04 21:19:52 +08:00
fix: 修复页面刷新顶部菜单不展示
This commit is contained in:
parent
4994f78dfe
commit
625d832310
@ -22,11 +22,12 @@ function getInsertCommonScript() {
|
||||
}
|
||||
|
||||
export const SCRIPT_MENU: CommonScriptMenu[] = [
|
||||
{
|
||||
title: t('project.code_segment.importApiTest'),
|
||||
value: 'api_definition',
|
||||
command: 'api_definition',
|
||||
},
|
||||
// TODO 这个版本不上
|
||||
// {
|
||||
// title: t('project.code_segment.importApiTest'),
|
||||
// value: 'api_definition',
|
||||
// command: 'api_definition',
|
||||
// },
|
||||
{
|
||||
title: t('project.code_segment.newApiTest'),
|
||||
value: 'new_api_request',
|
||||
|
@ -95,15 +95,7 @@
|
||||
}
|
||||
|
||||
const filterMenuTopRouter =
|
||||
currentParent?.children?.filter((item: any) => {
|
||||
if (permission.accessRouter(item) && item.meta?.isTopMenu) {
|
||||
// if (item.name === RouteEnum.SETTING_SYSTEM_AUTHORIZED_MANAGEMENT) {
|
||||
// return appStore.packageType === 'enterprise';
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}) || [];
|
||||
currentParent?.children?.filter((item: any) => permission.accessRouter(item) && item.meta?.isTopMenu) || [];
|
||||
|
||||
appStore.setTopMenus(filterMenuTopRouter);
|
||||
setCurrentTopMenu(name as string);
|
||||
|
@ -16,7 +16,7 @@ export default function usePermission() {
|
||||
* @returns 是否
|
||||
*/
|
||||
accessRouter(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||
if (includes(firstLevelMenu, route.name)) {
|
||||
if (firstLevelMenu.includes(route.name as string)) {
|
||||
// 一级菜单: 创建项目时 被勾选的模块
|
||||
return topLevelMenuHasPermission(route);
|
||||
}
|
||||
|
@ -272,6 +272,22 @@ const useAppStore = defineStore('app', {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
async getProjectInfos() {
|
||||
try {
|
||||
const res = await getProjectInfo(this.currentProjectId);
|
||||
if (!res || res.deleted) {
|
||||
const router = useRouter();
|
||||
router.push({
|
||||
name: NO_PROJECT_ROUTE_NAME,
|
||||
});
|
||||
}
|
||||
if (res) {
|
||||
this.setCurrentMenuConfig(res?.moduleIds || []);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 初始化页面配置
|
||||
*/
|
||||
|
@ -82,11 +82,15 @@ export function composePermissions(userRoleRelations: UserRoleRelation[], type:
|
||||
}
|
||||
|
||||
// 判断当前一级菜单是否有权限
|
||||
export function topLevelMenuHasPermission(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||
export async function topLevelMenuHasPermission(route: RouteLocationNormalized | RouteRecordRaw) {
|
||||
const userStore = useUserStore();
|
||||
const appStore = useAppStore();
|
||||
const { currentMenuConfig } = appStore;
|
||||
if (!currentMenuConfig.includes(route.name as string)) {
|
||||
if (!currentMenuConfig.length) {
|
||||
await appStore.getProjectInfos();
|
||||
}
|
||||
|
||||
if (currentMenuConfig.length && !currentMenuConfig.includes(route.name as string)) {
|
||||
// 没有配置的菜单不显示
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user