File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed
jeecgboot-vue3/src/utils/monorepo Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change 11import type { App } from 'vue' ;
22import { warn } from '/@/utils/log' ;
33import { registerDynamicRouter } from '/@/utils/monorepo/dynamicRouter' ;
4- import { add } from '/@/components/Form/src/componentMap' ;
4+ import { createAsyncComponent } from "@/utils/factory/createAsyncComponent" ;
55
66// 懒加载模块配置(按需加载,访问相关路由时才加载对应包)
77const lazyPackages = [
@@ -19,6 +19,33 @@ const installOptions = {
1919export function registerPackages ( app : App ) {
2020 // 仅保存 app 实例,不立即加载模块
2121 appInstance = app ;
22+ app . component (
23+ 'superQuery' ,
24+ createAsyncComponent ( ( ) => {
25+ return import ( '@jeecg/online' ) . then ( mod => {
26+ const str = mod . default . install . toString ( ) ;
27+ const importPaths = extractDynamicImportPaths ( str ) ;
28+ return import ( importPaths . find ( path => path . includes ( 'SuperQuery' ) ) ?? importPaths [ 1 ] )
29+ } ) ;
30+ } )
31+ ) ;
32+ app . component (
33+ 'JOnlineSearchSelect' ,
34+ createAsyncComponent ( ( ) => {
35+ return import ( '@jeecg/online' ) . then ( mod => {
36+ const str = mod . default . install . toString ( ) ;
37+ const importPaths = extractDynamicImportPaths ( str ) ;
38+ debugger
39+ return import ( importPaths . find ( path => path . includes ( 'JOnlineSearchSelect' ) ) ?? importPaths [ 0 ] )
40+ } ) ;
41+ } )
42+ ) ;
43+ }
44+
45+ function extractDynamicImportPaths ( code : string ) : string [ ] {
46+ // 匹配 import("...") / import('...'),保留括号内路径(包含 query 参数)
47+ const matches = code . matchAll ( / i m p o r t \( \s * ( [ ' " ] ) ( .* ?) \1\s * \) / g) ;
48+ return Array . from ( matches , ( m ) => m [ 2 ] ) . filter ( Boolean ) ;
2249}
2350
2451/** 已加载的包缓存 */
You can’t perform that action at this time.
0 commit comments