()
| 34 | } |
| 35 | |
| 36 | public async loadConfig(): Promise<HttpServerConfig> { |
| 37 | try { |
| 38 | const saved = databaseAPI.dbGet(DB_KEY) |
| 39 | if (saved) { |
| 40 | this.config = { |
| 41 | enabled: saved.enabled ?? false, |
| 42 | port: saved.port ?? DEFAULT_PORT, |
| 43 | apiKey: saved.apiKey || this.generateApiKey() |
| 44 | } |
| 45 | } |
| 46 | } catch (error) { |
| 47 | console.error('[HttpServer] 加载配置失败:', error) |
| 48 | } |
| 49 | return this.config |
| 50 | } |
| 51 | |
| 52 | public async saveConfig(config: Partial<HttpServerConfig>): Promise<HttpServerConfig> { |
| 53 | this.config = { ...this.config, ...config } |
no test coverage detected