From 3d579372d8c141bc215f669e97722f76d7616132 Mon Sep 17 00:00:00 2001 From: liaozhiyang Date: Wed, 18 Mar 2026 15:58:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9B=A0@jeecg/online?= =?UTF-8?q?=E5=BA=93=E6=8C=89=E9=9C=80=E5=8A=A0=E8=BD=BD=EF=BC=8C=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=AB=98=E7=BA=A7=E6=9F=A5=E8=AF=A2=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E5=A5=BD=E4=BD=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/utils/monorepo/registerPackages.ts | 29 ++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/jeecgboot-vue3/src/utils/monorepo/registerPackages.ts b/jeecgboot-vue3/src/utils/monorepo/registerPackages.ts index efeaa739c..8c38e1abc 100644 --- a/jeecgboot-vue3/src/utils/monorepo/registerPackages.ts +++ b/jeecgboot-vue3/src/utils/monorepo/registerPackages.ts @@ -1,7 +1,7 @@ import type { App } from 'vue'; import { warn } from '/@/utils/log'; import { registerDynamicRouter } from '/@/utils/monorepo/dynamicRouter'; -import { add } from '/@/components/Form/src/componentMap'; +import { createAsyncComponent } from "@/utils/factory/createAsyncComponent"; // 懒加载模块配置(按需加载,访问相关路由时才加载对应包) const lazyPackages = [ @@ -19,6 +19,33 @@ const installOptions = { 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]) + }); + }) + ); + 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); } /** 已加载的包缓存 */