| 347 | cmdHandlers = { |
| 348 | subinfo: this.handleSubinfo.bind(this), |
| 349 | cha: this.handleCha.bind(this), |
| 350 | }; |
| 351 | |
| 352 | // 加载远程配置映射 |
| 353 | private async loadRemoteMappings(): Promise<number> { |
| 354 | try { |
| 355 | const response = await axios.get(REMOTE_MAPPINGS_URL, { timeout: 10000 }); |
| 356 | const content = response.data as string; |
| 357 | const mappings: Record<string, string> = {}; |
| 358 | content.split('\n').forEach(line => { |
| 359 | const trimmed = line.trim(); |
| 360 | if (trimmed && !trimmed.startsWith('#')) { |
| 361 | const equalsIndex = trimmed.indexOf('='); |
| 362 | if (equalsIndex > 0) { |
| 363 | mappings[trimmed.substring(0, equalsIndex).trim()] = trimmed.substring(equalsIndex + 1).trim(); |
| 364 | } |
| 365 | } |
| 366 | }); |
| 367 | REMOTE_CONFIG_MAPPINGS = mappings; |
| 368 | return Object.keys(REMOTE_CONFIG_MAPPINGS).length; |
| 369 | } catch (error) { |
| 370 | // 忽略加载失败 |
| 371 | return 0; |