mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-03-26 15:23:11 +00:00
Merge pull request #9449 from liaozhiyang/master
修复因@jeecg/online库按需加载,导致高级查询组件不好使
This commit is contained in:
commit
5472ba2f3d
@ -1,7 +1,7 @@
|
|||||||
import type { App } from 'vue';
|
import type { App } from 'vue';
|
||||||
import { warn } from '/@/utils/log';
|
import { warn } from '/@/utils/log';
|
||||||
import { registerDynamicRouter } from '/@/utils/monorepo/dynamicRouter';
|
import { registerDynamicRouter } from '/@/utils/monorepo/dynamicRouter';
|
||||||
import { add } from '/@/components/Form/src/componentMap';
|
import { createAsyncComponent } from "@/utils/factory/createAsyncComponent";
|
||||||
|
|
||||||
// 懒加载模块配置(按需加载,访问相关路由时才加载对应包)
|
// 懒加载模块配置(按需加载,访问相关路由时才加载对应包)
|
||||||
const lazyPackages = [
|
const lazyPackages = [
|
||||||
@ -19,6 +19,33 @@ const installOptions = {
|
|||||||
export function registerPackages(app: App) {
|
export function registerPackages(app: App) {
|
||||||
// 仅保存 app 实例,不立即加载模块
|
// 仅保存 app 实例,不立即加载模块
|
||||||
appInstance = app;
|
appInstance = app;
|
||||||
|
app.component(
|
||||||
|
'superQuery',
|
||||||
|
createAsyncComponent(() => {
|
||||||
|
return import('@jeecg/online').then(mod => {
|
||||||
|
const str = mod.default.install.toString();
|
||||||
|
const importPaths = extractDynamicImportPaths(str);
|
||||||
|
return import(importPaths.find(path => path.includes('SuperQuery')) ?? importPaths[1])
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
app.component(
|
||||||
|
'JOnlineSearchSelect',
|
||||||
|
createAsyncComponent(() => {
|
||||||
|
return import('@jeecg/online').then(mod => {
|
||||||
|
const str = mod.default.install.toString();
|
||||||
|
const importPaths = extractDynamicImportPaths(str);
|
||||||
|
debugger
|
||||||
|
return import(importPaths.find(path => path.includes('JOnlineSearchSelect')) ?? importPaths[0])
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function extractDynamicImportPaths(code: string): string[] {
|
||||||
|
// 匹配 import("...") / import('...'),保留括号内路径(包含 query 参数)
|
||||||
|
const matches = code.matchAll(/import\(\s*(['"])(.*?)\1\s*\)/g);
|
||||||
|
return Array.from(matches, (m) => m[2]).filter(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 已加载的包缓存 */
|
/** 已加载的包缓存 */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user