diff --git a/packages/plugin/src/command.ts b/packages/plugin/src/command.ts index e880a57d..6815486e 100644 --- a/packages/plugin/src/command.ts +++ b/packages/plugin/src/command.ts @@ -35,8 +35,6 @@ export class PluginCommandManager { private unregistryCommand(pluginInstance: plugin.Plugin) { let cmds = getPluginCommandMetadata(pluginInstance) - cmds.forEach(cmd => { - this.CommandManager.off(pluginInstance, cmd.name) - }) + cmds.forEach(cmd => this.CommandManager.off(pluginInstance, cmd.name)) } } diff --git a/packages/plugin/src/config.ts b/packages/plugin/src/config.ts index cb8d6a29..22ca8d5c 100644 --- a/packages/plugin/src/config.ts +++ b/packages/plugin/src/config.ts @@ -69,7 +69,7 @@ export class PluginConfigManager { saveConfig(plugin: plugin.Plugin) { let configs = getPluginConfigMetadata(plugin) for (let [_, config] of configs) { - this.saveConfig0(plugin, config) + config.autosave && this.saveConfig0(plugin, config) } } @@ -102,7 +102,6 @@ export class PluginConfigManager { private saveConfig0(plugin: plugin.Plugin, metadata: interfaces.ConfigMetadata) { try { - if (metadata.readonly) { console.debug(`[${plugin.description.name}] Skip Save Config ${metadata.variable} Because it's readonly!`) } metadata.file = fs.concat(fs.file(plugin.description.loadMetadata.file).parent, plugin.description.name, metadata.filename) let result = this.getConfigLoader(metadata.format).dump(plugin[metadata.variable]) base.save(metadata.file, result) diff --git a/packages/plugin/src/decorators.ts b/packages/plugin/src/decorators.ts index 1fc3d6c4..ece6191f 100644 --- a/packages/plugin/src/decorators.ts +++ b/packages/plugin/src/decorators.ts @@ -77,6 +77,7 @@ export function config(metadata: interfaces.ConfigMetadata = {}) { metadata.variable = key metadata.version = metadata.version ?? 1 metadata.format = metadata.format ?? 'yml' + metadata.autosave = metadata.autosave ?? false metadata.filename = metadata.filename ?? metadata.name + '.' + metadata.format let previousMetadata = getPluginConfigMetadata(target) previousMetadata.set(metadata.name, metadata) diff --git a/packages/plugin/src/interfaces.ts b/packages/plugin/src/interfaces.ts index bdc87ea1..308894e0 100644 --- a/packages/plugin/src/interfaces.ts +++ b/packages/plugin/src/interfaces.ts @@ -72,9 +72,9 @@ export namespace interfaces { */ format?: string /** - * 是否为只读(关闭时将不会自动保存) + * 自动保存 默认为 false */ - readonly?: boolean + autosave?: boolean /** * 配置文件名称 */