()
| 53 | aff: this.handleAffCommand.bind(this) |
| 54 | }; |
| 55 | |
| 56 | // 初始化数据库 |
| 57 | private async initDB(): Promise<void> { |
| 58 | if (this.db) return; |
| 59 | |
| 60 | const dbPath = path.join( |
| 61 | createDirectoryInAssets(this.PLUGIN_NAME), |
| 62 | "data.json" |
| 63 | ); |
| 64 | |
| 65 | this.db = await JSONFilePreset<DBData>(dbPath, { affs: [] }); |
| 66 | |
| 67 | // 迁移旧数据 |
| 68 | if (this.db.data.aff) { |
| 69 | this.db.data.affs.push(this.db.data.aff); |
| 70 | delete this.db.data.aff; |
| 71 | await this.db.write(); |
| 72 | } |
| 73 | } |
| 74 |