|
|
@@ -5,6 +5,23 @@ import { cloneDeep, omit } from 'lodash-es'
|
|
|
import qs from 'qs'
|
|
|
|
|
|
const modules = import.meta.glob('../views/**/*.{vue,tsx}')
|
|
|
+const getCurrentSource = () => sessionStorage.getItem('LOGIN_SOURCE') || ''
|
|
|
+
|
|
|
+const getRouteComponent = (route: AppCustomRouteRecordRaw, modulesRoutesKeys: string[]) => {
|
|
|
+ const index = route?.component
|
|
|
+ ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
|
|
|
+ : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
|
|
|
+
|
|
|
+ if (index >= 0) {
|
|
|
+ return modules[modulesRoutesKeys[index]]
|
|
|
+ }
|
|
|
+
|
|
|
+ if (getCurrentSource() === 'qhse_nav') {
|
|
|
+ return () => import('@/views/Error/ComingSoon.vue')
|
|
|
+ }
|
|
|
+
|
|
|
+ return undefined
|
|
|
+}
|
|
|
/**
|
|
|
* 注册一个异步组件
|
|
|
* @param componentPath 例:/bpm/oa/leave/detail
|
|
|
@@ -115,10 +132,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord
|
|
|
redirect: route.redirect,
|
|
|
meta: meta
|
|
|
}
|
|
|
- const index = route?.component
|
|
|
- ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
|
|
|
- : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
|
|
|
- childrenData.component = modules[modulesRoutesKeys[index]]
|
|
|
+ childrenData.component = getRouteComponent(route, modulesRoutesKeys)
|
|
|
data.children = [childrenData]
|
|
|
} else {
|
|
|
// 目录
|
|
|
@@ -138,10 +152,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord
|
|
|
// 菜单
|
|
|
} else {
|
|
|
// 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会根path保持一致)
|
|
|
- const index = route?.component
|
|
|
- ? modulesRoutesKeys.findIndex((ev) => ev.includes(route.component))
|
|
|
- : modulesRoutesKeys.findIndex((ev) => ev.includes(route.path))
|
|
|
- data.component = modules[modulesRoutesKeys[index]]
|
|
|
+ data.component = getRouteComponent(route, modulesRoutesKeys)
|
|
|
}
|
|
|
if (route.children) {
|
|
|
data.children = generateRoute(route.children)
|