(key: string, defaultValue?: string)
| 68 | } |
| 69 | |
| 70 | static get(key: string, defaultValue?: string): string { |
| 71 | this.init(); |
| 72 | |
| 73 | try { |
| 74 | const stmt = this.db.prepare("SELECT value FROM config WHERE key = ?"); |
| 75 | const row = stmt.get(key) as { value: string } | undefined; |
| 76 | |
| 77 | if (row) { |
| 78 | return row.value; |
| 79 | } |
| 80 | } catch (error) { |
| 81 | console.error("读取配置失败:", error); |
| 82 | } |
| 83 | |
| 84 | return defaultValue || DEFAULT_CONFIG[key] || ""; |
| 85 | } |
| 86 | |
| 87 | static set(key: string, value: string): void { |
| 88 | this.init(); |
no test coverage detected