(routerPrefix: string, pluginName: any, exposedModule: string, pluginPath: any)
| 380 | } |
| 381 | |
| 382 | const loadModule = async (routerPrefix: string, pluginName: any, exposedModule: string, pluginPath: any) => { |
| 383 | if (!modules.get(routerPrefix)) { |
| 384 | try { |
| 385 | const loadedModule = await loadRemoteModule(generateRemoteModuleTemplate(pluginName, exposedModule, pluginPath)) |
| 386 | const Module = loadedModule.default ?? loadedModule |
| 387 | let ModuleBootstrap |
| 388 | try { |
| 389 | ModuleBootstrap = await loadRemoteModule(generateRemoteModuleTemplate(pluginName, 'Bootstrap', pluginPath)) |
| 390 | } catch (error) { |
| 391 | console.warn('Bootstrap module not found:', error) |
| 392 | } |
| 393 | setModules((prevModules) => new Map(prevModules).set(routerPrefix, Module[exposedModule])) |
| 394 | if (!validateExportLifecycle(Module)) { |
| 395 | console.error('需要导出插件生命周期函数') |
| 396 | return |
| 397 | } |
| 398 | await Module.bootstrap?.({ |
| 399 | pluginProvider, |
| 400 | pluginEventHub, |
| 401 | pluginSlotHub |
| 402 | }) |
| 403 | return Module |
| 404 | } catch (error) { |
| 405 | console.error('导入插件失败:', error) |
| 406 | } |
| 407 | } |
| 408 | return getModule(routerPrefix, true) |
| 409 | } |
| 410 | |
| 411 | const loadExecutedPlugin = async () => { |
| 412 | setStartLoadExecutePlugin(true) |
nothing calls this directly
no test coverage detected