diff --git a/src/store/config.ts b/src/store/config.ts index 9ebaed81..8be2acc1 100644 --- a/src/store/config.ts +++ b/src/store/config.ts @@ -11,15 +11,28 @@ export const useConfigStore = defineStore('config', () => { config.value = res; }); - const { execute: set } = useApi(apiConfig.updateConfig, { - failRule: (res) => !res, - message: { - success: 'Apply Success!', - fail: 'Apply Failed!', - }, + const { execute: set, onResult: onSetRusult } = useApi( + apiConfig.updateConfig, + { + failRule: (res) => !res, + message: { + success: 'Apply Success!', + fail: 'Apply Failed!', + }, + } + ); + + /** + * 保持 config 后重启,以应用最新配置 + */ + onSetRusult(() => { + const { restart } = useProgramStore(); + restart(); }); - const setConfig = () => set(config.value); + const setConfig = () => { + set(config.value); + }; function getSettingGroup(key: Tkey) { return computed(() => config.value[key]);