44
55import { Component } from 'vue' ;
66import { RouteRecordRaw } from 'vue-router' ;
7+ import { moduleRegistry } from '@/utils/module-registry'
78
89// 基础类型定义
910export type ModuleResourceKey = string ;
@@ -84,6 +85,8 @@ export interface ModuleResource {
8485 locales ?: LocaleModule ;
8586 /** 状态管理 */
8687 stores ?: Record < string , StoreModule > ;
88+ /** 各种类型的事件 */
89+ events ?: Record < string , UtilFunction > ;
8790 /** 其他自定义资源 */
8891 [ key : string ] : any ;
8992}
@@ -195,10 +198,20 @@ export interface IModuleRegistry {
195198 * 搜索包含特定资源的模块
196199 */
197200 searchModules ( resourceType : keyof ModuleResource , resourceName ?: string ) : string [ ] ;
201+
202+ /**
203+ * 注册远程模块
204+ */
205+ loadRemoteModule ( moduleId : string , path : string ) : Promise < void >
206+
207+ /**
208+ * 注册单个远程组件
209+ */
210+ loadRemoteComponent ( moduleId : string , path : string , componentName : string ) : Promise < void >
198211}
199212
200213// 泛型助手类型
201- export type GetResourceType < T extends keyof ModuleResource > =
214+ export type GetResourceType < T extends keyof ModuleResource > =
202215 T extends 'apis' ? Record < string , ApiFunction | ApiModule > :
203216 T extends 'components' ? ComponentResource :
204217 T extends 'utils' ? Record < string , UtilFunction | UtilModule > :
@@ -207,6 +220,7 @@ export type GetResourceType<T extends keyof ModuleResource> =
207220 T extends 'routes' ? RouteModule :
208221 T extends 'locales' ? LocaleModule :
209222 T extends 'stores' ? Record < string , StoreModule > :
223+ T extends 'events' ? Record < string , UtilFunction > :
210224 any ;
211225
212226// 辅助工具类型
@@ -247,4 +261,4 @@ declare global {
247261 interface Window {
248262 __MODULE_REGISTRY__ ?: IModuleRegistry ;
249263 }
250- }
264+ }
0 commit comments