()
| 29 | |
| 30 | // 初始化数据库 |
| 31 | private static init(): void { |
| 32 | if (this.initialized) return; |
| 33 | |
| 34 | try { |
| 35 | this.db = new Database(CONFIG_DB_PATH); |
| 36 | this.db.exec(` |
| 37 | CREATE TABLE IF NOT EXISTS config ( |
| 38 | key TEXT PRIMARY KEY, |
| 39 | value TEXT NOT NULL, |
| 40 | updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
| 41 | ) |
| 42 | `); |
| 43 | this.initialized = true; |
| 44 | } catch (error) { |
| 45 | console.error("初始化Komari配置数据库失败:", error); |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | static get(key: string, defaultValue?: string): string { |
| 50 | this.init(); |