mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-03-27 07:41:08 +00:00
@jeecg/online库导出了SuperQuery和JOnlineSearchSelect组件,正常注册相关组件
This commit is contained in:
parent
3d579372d8
commit
38a3ce7b9b
@ -20,34 +20,15 @@ export function registerPackages(app: App) {
|
|||||||
// 仅保存 app 实例,不立即加载模块
|
// 仅保存 app 实例,不立即加载模块
|
||||||
appInstance = app;
|
appInstance = app;
|
||||||
app.component(
|
app.component(
|
||||||
'superQuery',
|
'SuperQuery',
|
||||||
createAsyncComponent(() => {
|
createAsyncComponent(() => import('@jeecg/online').then(mod => mod.SuperQuery))
|
||||||
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(
|
app.component(
|
||||||
'JOnlineSearchSelect',
|
'JOnlineSearchSelect',
|
||||||
createAsyncComponent(() => {
|
createAsyncComponent(() => import('@jeecg/online').then(mod => mod.JOnlineSearchSelect))
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 已加载的包缓存 */
|
/** 已加载的包缓存 */
|
||||||
const loadedPackages = new Map<string, any>();
|
const loadedPackages = new Map<string, any>();
|
||||||
/** 正在加载的包 Promise 缓存(防止重复加载) */
|
/** 正在加载的包 Promise 缓存(防止重复加载) */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user