|
@@ -5,16 +5,18 @@ import { getParentLayout, LAYOUT, EXCEPTION_COMPONENT } from '/@/router/constant
|
|
|
import { cloneDeep, omit } from 'lodash-es';
|
|
|
import { warn } from '/@/utils/log';
|
|
|
import { createRouter, createWebHashHistory } from 'vue-router';
|
|
|
-import { getTenantId, getToken } from "/@/utils/auth";
|
|
|
+import { getTenantId, getToken } from '/@/utils/auth';
|
|
|
import { URL_HASH_TAB, _eval } from '/@/utils';
|
|
|
//引入online lib路由
|
|
|
import { packageViews } from '/@/utils/monorepo/dynamicRouter';
|
|
|
-import {useI18n} from "/@/hooks/web/useI18n";
|
|
|
+import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
|
|
|
export type LayoutMapKey = 'LAYOUT';
|
|
|
const IFRAME = () => import('/@/views/sys/iframe/FrameBlank.vue');
|
|
|
// const IFRAME = () => import('/@/views/sys/iframe/index.vue');
|
|
|
const LayoutContent = () => import('/@/layouts/default/content/index.vue');
|
|
|
+const QIANKUN_NEED_AIR = () => import('/@/components/vent/micro/needAir.vue');
|
|
|
+const QIANKUN_VENT_MODAL = () => import('/@/components/vent/micro/ventModal.vue');
|
|
|
|
|
|
const LayoutMap = new Map<string, () => Promise<typeof import('*.vue')>>();
|
|
|
|
|
@@ -22,25 +24,27 @@ LayoutMap.set('LAYOUT', LAYOUT);
|
|
|
LayoutMap.set('IFRAME', IFRAME);
|
|
|
//微前端qiankun
|
|
|
LayoutMap.set('LayoutsContent', LayoutContent);
|
|
|
-
|
|
|
+LayoutMap.set('VENTMODAL', QIANKUN_VENT_MODAL);
|
|
|
+LayoutMap.set('NEEDAIR', QIANKUN_NEED_AIR);
|
|
|
|
|
|
let dynamicViewsModules: Record<string, () => Promise<Recordable>>;
|
|
|
+let microViews: Record<string, () => Promise<Recordable>>;
|
|
|
|
|
|
// Dynamic introduction
|
|
|
function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
|
|
|
if (!dynamicViewsModules) {
|
|
|
+ microViews = import.meta.glob('../../components/vent/micro/**/*.{vue,tsx}');
|
|
|
dynamicViewsModules = import.meta.glob('../../views/**/*.{vue,tsx}');
|
|
|
//合并online lib路由
|
|
|
- dynamicViewsModules = Object.assign({}, dynamicViewsModules, packageViews);
|
|
|
+ dynamicViewsModules = Object.assign({}, dynamicViewsModules, packageViews, microViews);
|
|
|
}
|
|
|
if (!routes) return;
|
|
|
routes.forEach((item) => {
|
|
|
-
|
|
|
//【jeecg-boot/issues/I5N2PN】左侧动态菜单怎么做国际化处理 2022-10-09
|
|
|
//菜单支持国际化翻译
|
|
|
if (item?.meta?.title) {
|
|
|
const { t } = useI18n();
|
|
|
- if(item.meta.title.includes('t(\'') && t){
|
|
|
+ if (item.meta.title.includes("t('") && t) {
|
|
|
// update-begin--author:liaozhiyang---date:20230906---for:【QQYUN-6390】eval替换成new Function,解决build警告
|
|
|
item.meta.title = new Function('t', `return ${item.meta.title}`)(t);
|
|
|
// update-end--author:liaozhiyang---date:20230906---for:【QQYUN-6390】eval替换成new Function,解决build警告
|
|
@@ -63,7 +67,10 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
|
|
|
let tenantId = getTenantId();
|
|
|
// URL支持{{ window.xxx }}占位符变量
|
|
|
//update-begin---author:wangshuai ---date:20220711 for:[VUEN-1638]菜单tenantId需要动态生成------------
|
|
|
- item.component = (item.component || '').replace(/{{([^}}]+)?}}/g, (s1, s2) => _eval(s2)).replace('${token}', token).replace('${tenantId}', tenantId);
|
|
|
+ item.component = (item.component || '')
|
|
|
+ .replace(/{{([^}}]+)?}}/g, (s1, s2) => _eval(s2))
|
|
|
+ .replace('${token}', token)
|
|
|
+ .replace('${tenantId}', tenantId);
|
|
|
//update-end---author:wangshuai ---date:20220711 for:[VUEN-1638]菜单tenantId需要动态生成------------
|
|
|
// 适配 iframe
|
|
|
if (/^\/?http(s)?/.test(item.component as string)) {
|
|
@@ -91,6 +98,7 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
|
|
|
if (component) {
|
|
|
const layoutFound = LayoutMap.get(component.toUpperCase());
|
|
|
if (layoutFound) {
|
|
|
+ console.log('6666666666666666', layoutFound, component);
|
|
|
item.component = layoutFound;
|
|
|
} else {
|
|
|
// update-end--author:zyf---date:20220307--for:VUEN-219兼容后台返回动态首页,目的适配跟v2版本配置一致 --------
|
|
@@ -108,12 +116,18 @@ function asyncImportRoute(routes: AppRouteRecordRaw[] | undefined) {
|
|
|
}
|
|
|
children && asyncImportRoute(children);
|
|
|
});
|
|
|
+ console.log('------------------------>', routes);
|
|
|
}
|
|
|
|
|
|
function dynamicImport(dynamicViewsModules: Record<string, () => Promise<Recordable>>, component: string) {
|
|
|
const keys = Object.keys(dynamicViewsModules);
|
|
|
const matchKeys = keys.filter((key) => {
|
|
|
- const k = key.replace('../../views', '');
|
|
|
+ let k = '';
|
|
|
+ if (key.startsWith('../../components')) {
|
|
|
+ k = key.replace('../../components', '');
|
|
|
+ } else {
|
|
|
+ k = key.replace('../../views', '');
|
|
|
+ }
|
|
|
const startFlag = component.startsWith('/');
|
|
|
const endFlag = component.endsWith('.vue') || component.endsWith('.tsx');
|
|
|
const startIndex = startFlag ? 0 : 1;
|
|
@@ -231,8 +245,9 @@ export function addSlashToRouteComponent(routeList: AppRouteRecordRaw[]) {
|
|
|
routeList.forEach((route) => {
|
|
|
if (route.path.startsWith('/subSysmodal')) {
|
|
|
route.path = '/micro-vent-3dModal' + route.path;
|
|
|
- route.component = 'layouts/default/index';
|
|
|
+ route.component = 'VENTMODAL';
|
|
|
}
|
|
|
+
|
|
|
let component = route.component as string;
|
|
|
if (component) {
|
|
|
const layoutFound = LayoutMap.get(component);
|
|
@@ -242,5 +257,6 @@ export function addSlashToRouteComponent(routeList: AppRouteRecordRaw[]) {
|
|
|
}
|
|
|
route.children && addSlashToRouteComponent(route.children);
|
|
|
});
|
|
|
+ console.log('9999999999999999999999999999>', routeList);
|
|
|
return routeList as unknown as T[];
|
|
|
}
|