MCPcopy
hub / github.com/AstrBotDevs/AstrBot / loadModules

Method loadModules

dashboard/src/i18n/loader.ts:141–156  ·  view source on GitHub ↗

* 通用模块加载器 - 减少重复代码,提高可维护性

(
    locale: string,
    prefix: string,
    overrideList: string[] = []
  )

Source from the content-addressed store, hash-verified

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 * 加载核心模块(最高优先级)

Callers 3

loadCoreModulesMethod · 0.95
loadFeatureModulesMethod · 0.95
loadMessageModulesMethod · 0.95

Calls 6

loadModuleMethod · 0.95
mergeModulesMethod · 0.95
fromMethod · 0.80
allMethod · 0.80
filterMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected