| 26 | private static db: any = null; |
| 27 | private static initialized = false; |
| 28 | private static configPath: string; |
| 29 | |
| 30 | private static async init(): Promise<void> { |
| 31 | if (this.initialized) return; |
| 32 | |
| 33 | try { |
| 34 | // 使用插件专用目录 |
| 35 | this.configPath = resolvePluginAssetFile({ |
| 36 | plugin: "sticker", |
| 37 | fileName: "config.json", |
| 38 | legacyDirs: ["sticker"], |
| 39 | legacyFiles: [{ dir: "sticker", fileName: "config.json" }], |
| 40 | }); |
| 41 | |
| 42 | // 以扁平结构初始化 |
| 43 | this.db = await JSONFilePreset<Record<string, any>>( |
| 44 | this.configPath, |
| 45 | { ...DEFAULT_CONFIG } |
| 46 | ); |
| 47 | this.initialized = true; |
| 48 | } catch (error) { |
| 49 | console.error("[sticker] 初始化配置失败:", error); |
| 50 | } |