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