* 通用模块加载器 - 减少重复代码,提高可维护性
(
locale: string,
prefix: string,
overrideList: string[] = []
)
| 139 | * 通用模块加载器 - 减少重复代码,提高可维护性 |
| 140 | */ |
| 141 | private async loadModules( |
| 142 | locale: string, |
| 143 | prefix: string, |
| 144 | overrideList: string[] = [] |
| 145 | ): Promise<any> { |
| 146 | // 使用覆盖列表或从注册表中筛选符合前缀的模块名 |
| 147 | const moduleNames = overrideList.length > 0 |
| 148 | ? overrideList |
| 149 | : Array.from(this.moduleRegistry.keys()).filter(key => key.startsWith(prefix)); |
| 150 | |
| 151 | const results = await Promise.all( |
| 152 | moduleNames.map(module => this.loadModule(locale, module)) |
| 153 | ); |
| 154 | |
| 155 | return this.mergeModules(results, moduleNames); |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * 加载核心模块(最高优先级) |
no test coverage detected