🐛 用户登录后 404.

This commit is contained in:
lijiahang
2024-03-22 16:32:37 +08:00
parent e43843d087
commit 27c1e16e57
3 changed files with 30 additions and 6 deletions

View File

@@ -10,8 +10,10 @@
<tbody>
<a-checkbox-group v-model="checkedKeys" style="display: contents;">
<template v-for="parentMenu in menuData" :key="parentMenu.id">
<template v-for="(childrenMenu, i) in parentMenu.children" :key="childrenMenu.id">
<tr>
<!-- 有子菜单 -->
<template v-if="parentMenu.children?.length">
<tr v-for="(childrenMenu, i) in parentMenu.children"
:key="childrenMenu.id">
<!-- 父菜单 -->
<td v-if="i === 0" :rowspan="parentMenu.children.length">
<a-checkbox :value="parentMenu.id">
@@ -38,6 +40,23 @@
</td>
</tr>
</template>
<!-- 无子菜单 -->
<template v-else>
<tr>
<!-- 父菜单 -->
<td>
<a-checkbox :value="parentMenu.id">
{{ parentMenu.name }}
</a-checkbox>
</td>
<!-- 子菜单 -->
<td>
</td>
<!-- 功能 -->
<td>
</td>
</tr>
</template>
</template>
</a-checkbox-group>
</tbody>

View File

@@ -1,6 +1,6 @@
import type { RouteLocationNormalized, RouteRecordNormalized, RouteRecordRaw } from 'vue-router';
import { useMenuStore, useUserStore } from '@/store';
import { STATUS_ROUTER_LIST, WHITE_ROUTER_LIST } from '@/router/constants';
import { DEFAULT_ROUTER, STATUS_ROUTER_LIST, WHITE_ROUTER_LIST } from '@/router/constants';
import { AdminRoleCode } from '@/types/const';
export default function usePermission() {
@@ -16,7 +16,7 @@ export default function usePermission() {
return false;
}
// 检查路由是否存在于授权路由中
const menuConfig = [...menuStore.appMenus, ...WHITE_ROUTER_LIST, ...STATUS_ROUTER_LIST];
const menuConfig = [...menuStore.appMenus, ...WHITE_ROUTER_LIST, ...STATUS_ROUTER_LIST, DEFAULT_ROUTER];
let exist = false;
while (menuConfig.length && !exist) {
const element = menuConfig.shift();
@@ -44,7 +44,7 @@ export default function usePermission() {
hasAnyPermission(permission: string[]) {
return userStore.permission?.includes('*') ||
permission.map(s => userStore.permission?.includes(s))
.filter(Boolean).length > 0;
.filter(Boolean).length > 0;
},
/**
@@ -61,7 +61,7 @@ export default function usePermission() {
hasAnyRole(role: string[]) {
return userStore.roles?.includes(AdminRoleCode) ||
role.map(s => userStore.roles?.includes(s))
.filter(Boolean).length > 0;
.filter(Boolean).length > 0;
}
};
}

View File

@@ -13,6 +13,11 @@ export const DEFAULT_ROUTE_NAME = 'workplace';
export const DEFAULT_ROUTE_FULL_PATH = '/workplace';
/**
* 默认路由
*/
export const DEFAULT_ROUTER = { name: DEFAULT_ROUTE_NAME, children: [] };
/**
* 路由白名单
*/