Merge pull request #9449 from liaozhiyang/master

修复因@jeecg/online库按需加载,导致高级查询组件不好使
This commit is contained in:
JEECG 2026-03-18 16:03:26 +08:00 committed by GitHub
commit 5472ba2f3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);
} }
/** 已加载的包缓存 */ /** 已加载的包缓存 */