fix(theme-editor): fix enable invalid (#2539)

* fix(theme-editor): fix enable invalid

* chore: fix typo
This commit is contained in:
被雨水过滤的空气-Rain 2023-08-27 17:26:14 +08:00 committed by GitHub
parent 8e42da2b01
commit 176d380331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ export class ThemeEditorPlugin extends Plugin {
beforeLoad() {} beforeLoad() {}
async load() { async load() {
this.theme = this.db.collection({ this.db.collection({
name: 'themeConfig', name: 'themeConfig',
fields: [ fields: [
// 主题配置内容,一个 JSON 字符串 // 主题配置内容,一个 JSON 字符串
@ -32,8 +32,14 @@ export class ThemeEditorPlugin extends Plugin {
} }
async install(options?: InstallOptions) { async install(options?: InstallOptions) {
if ((await this.theme.repository.count()) === 0) { const themeRepo = this.db.getRepository('themeConfig');
await this.theme.repository.create({
if (!themeRepo) {
throw new Error(`themeConfig repository does not exist`);
}
if ((await themeRepo.count()) === 0) {
await themeRepo.create({
values: [antd, dark, compact, compactDark], values: [antd, dark, compact, compactDark],
}); });
} }