| 81 | |
| 82 | // 获取所有配置 |
| 83 | static getAll(): { [key: string]: string } { |
| 84 | this.init(); |
| 85 | if (!this.db) return {}; |
| 86 | |
| 87 | try { |
| 88 | const stmt = this.db.prepare("SELECT key, value FROM config"); |
| 89 | const rows = stmt.all() as { key: string; value: string }[]; |
| 90 | |
| 91 | const config: { [key: string]: string } = {}; |
| 92 | rows.forEach((row) => { |
| 93 | config[row.key] = row.value; |
| 94 | }); |
| 95 | |
| 96 | return config; |
| 97 | } catch (error) { |
| 98 | console.error("读取所有Komari配置失败:", error); |
| 99 | return {}; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | // 删除配置 |
| 104 | static delete(key: string): void { |