(key: string, defaultValue?: string)
| 47 | } |
| 48 | |
| 49 | static get(key: string, defaultValue?: string): string { |
| 50 | this.init(); |
| 51 | if (!this.db) return defaultValue || ""; |
| 52 | |
| 53 | try { |
| 54 | const stmt = this.db.prepare("SELECT value FROM config WHERE key = ?"); |
| 55 | const row = stmt.get(key) as { value: string } | undefined; |
| 56 | |
| 57 | if (row) { |
| 58 | return row.value; |
| 59 | } |
| 60 | } catch (error) { |
| 61 | console.error("读取Komari配置失败:", error); |
| 62 | } |
| 63 | |
| 64 | return defaultValue || ""; |
| 65 | } |
| 66 | |
| 67 | static set(key: string, value: string): void { |
| 68 | this.init(); |
no test coverage detected