mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2026-03-26 15:23:11 +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 实例,不立即加载模块
|
||||
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])
|
||||
});
|
||||
})
|
||||
'SuperQuery',
|
||||
createAsyncComponent(() => import('@jeecg/online').then(mod => mod.SuperQuery))
|
||||
);
|
||||
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])
|
||||
});
|
||||
})
|
||||
createAsyncComponent(() => import('@jeecg/online').then(mod => mod.JOnlineSearchSelect))
|
||||
);
|
||||
}
|
||||
|
||||
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>();
|
||||
/** 正在加载的包 Promise 缓存(防止重复加载) */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user