fix: plugin list not updated after upgrade (#2545)
This commit is contained in:
parent
176d380331
commit
c65507606a
@ -69,6 +69,9 @@ export class PresetNocoBase extends Plugin {
|
||||
plugin: this,
|
||||
},
|
||||
});
|
||||
this.app.on('beforeUpgrade', async () => {
|
||||
await this.createIfNotExist();
|
||||
});
|
||||
}
|
||||
|
||||
get allPlugins() {
|
||||
@ -79,6 +82,14 @@ export class PresetNocoBase extends Plugin {
|
||||
.concat(this.localPlugins.map((name) => ({ name })));
|
||||
}
|
||||
|
||||
async createIfNotExist() {
|
||||
const repository = this.app.db.getRepository<any>('applicationPlugins');
|
||||
const existPlugins = await repository.find();
|
||||
const existPluginNames = existPlugins.map((item) => item.name);
|
||||
const plugins = this.allPlugins.filter((item) => !existPluginNames.includes(item.name));
|
||||
await repository.create({ values: plugins });
|
||||
}
|
||||
|
||||
async install() {
|
||||
const repository = this.app.db.getRepository<any>('applicationPlugins');
|
||||
const existPlugins = await repository.find();
|
||||
|
Loading…
Reference in New Issue
Block a user