()
| 56 | private static initialized = false; |
| 57 | |
| 58 | private static init(): void { |
| 59 | if (this.initialized) return; |
| 60 | try { |
| 61 | this.db = new Database(CONFIG_DB_PATH); |
| 62 | this.db.exec(` |
| 63 | CREATE TABLE IF NOT EXISTS config ( |
| 64 | key TEXT PRIMARY KEY, |
| 65 | value TEXT NOT NULL, |
| 66 | updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP |
| 67 | ) |
| 68 | `); |
| 69 | this.initialized = true; |
| 70 | } catch (error) { |
| 71 | console.error("初始化配置数据库失败:", error); |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | static get(key: string, defaultValue?: string): string { |
| 76 | this.init(); |