提交
This commit is contained in:
1 parent
93c28759d0
commit
b23a2eb350
129 files changed
+28511
-17769
No files matched your search
@@ -11,7 +11,6 @@ import type { AppRouteRecord } from '@/types/router'
|
||||
import { useUserStore } from '@/store/modules/user'
|
||||
import { useAppMode } from '@/hooks/core/useAppMode'
|
||||
import { fetchGetMenuList } from '@/api/admin'
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
import { asyncRoutes } from '../routes/asyncRoutes'
|
||||
import { RoutesAlias } from '../routesAlias'
|
||||
import { formatMenuTitle } from '@/utils'
|
||||
@@ -72,15 +71,12 @@ export class MenuProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
// 静态菜单模式下,admin 按后端返回的 menuCodes 过滤菜单
|
||||
if (info?.role === 'admin') {
|
||||
const perm = await fetchGetMenuCodes()
|
||||
// 静态菜单模式下,admin 按 fetchUserInfo 已缓存的 menuCodes 过滤菜单(避免重复请求)
|
||||
if (info?.role === 'admin' && !userStore.menuPermAll && !userStore.isSuperAdmin) {
|
||||
const codeSet = new Set(
|
||||
(perm?.menuCodes || []).map((x) => this.normalizeMenuCode(x)).filter(Boolean)
|
||||
(userStore.menuCodes || []).map((x) => this.normalizeMenuCode(x)).filter(Boolean)
|
||||
)
|
||||
if (!perm?.all) {
|
||||
menuList = this.filterMenuByCodes(menuList, codeSet)
|
||||
}
|
||||
menuList = this.filterMenuByCodes(menuList, codeSet)
|
||||
}
|
||||
|
||||
return this.filterEmptyMenus(menuList)
|
||||
|
||||
@@ -49,6 +49,7 @@ import { loadingService } from '@/utils/ui'
|
||||
import { useCommon } from '@/hooks/core/useCommon'
|
||||
import { useWorktabStore } from '@/store/modules/worktab'
|
||||
import { fetchGetUserInfo, fetchGetMenuCodes } from '@/api/auth'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ApiStatus } from '@/utils/http/status'
|
||||
import { isHttpError } from '@/utils/http/error'
|
||||
import { RouteRegistry, MenuProcessor, IframeRouteManager, RoutePermissionValidator } from '../core'
|
||||
@@ -278,11 +279,15 @@ async function handleDynamicRoutes(
|
||||
// 2. 获取菜单数据
|
||||
const menuList = await menuProcessor.getMenuList()
|
||||
|
||||
// 3. 验证菜单数据:无可用菜单时跳转 403,而非当作系统错误
|
||||
// 3. 验证菜单数据:无可用菜单时清会话并退回登录页
|
||||
if (!menuProcessor.validateMenuList(menuList)) {
|
||||
routeInitInProgress = false
|
||||
closeLoading()
|
||||
next({ name: 'Exception403', replace: true })
|
||||
ElMessage.error('当前账号未分配菜单权限,请联系管理员')
|
||||
const userStore = useUserStore()
|
||||
await userStore.clearSession()
|
||||
resetRouterState(0)
|
||||
next({ name: 'Login', replace: true })
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -937,6 +937,17 @@ export const sqxpAdminRoutes: AppRouteRecord[] = [
|
||||
roles: ['admin']
|
||||
},
|
||||
children: [
|
||||
{
|
||||
id: '70000000000000000000000000000001',
|
||||
name: 'QualityInspectionPreTransitSample',
|
||||
path: 'pre-transit-sample',
|
||||
component: '/quality-inspection/pre-transit-sample/index',
|
||||
meta: {
|
||||
title: '预产及在途样本',
|
||||
keepAlive: true,
|
||||
menuCode: 'biz:preTransitSample:list'
|
||||
}
|
||||
},
|
||||
{
|
||||
id: '70000000000000000000000000000002',
|
||||
name: 'QualityInspectionSampleReception',
|
||||
|
||||
Reference in new issue
Block a user