diff --git a/plugin/preload.js b/plugin/preload.js index 8f078b9..6128f35 100644 --- a/plugin/preload.js +++ b/plugin/preload.js @@ -633,6 +633,7 @@ window.quickcommandHttpServer = () => { }) } let stop = () => { + if (!httpServer) return httpServer.close() } return { diff --git a/src/App.vue b/src/App.vue index efc6f9d..f9a0b31 100644 --- a/src/App.vue +++ b/src/App.vue @@ -64,7 +64,10 @@ export default defineComponent({ let userProfile = this.utools.getDB( this.utools.DBPRE.CFG + "preferences" ); - _.merge(defaultProfile, _.cloneDeep(userProfile)); + this.profile = _.merge( + _.cloneDeep(defaultProfile), + _.cloneDeep(userProfile) + ); // 计划任务 _.forIn(this.profile.crontabs, (cronExp, featureCode) => { this.runCronTask(featureCode, cronExp); diff --git a/src/components/ConfigurationMenu.vue b/src/components/ConfigurationMenu.vue index 296896f..ec3204b 100644 --- a/src/components/ConfigurationMenu.vue +++ b/src/components/ConfigurationMenu.vue @@ -212,7 +212,7 @@ - 删除所有命令 + 清空数据 @@ -455,6 +455,13 @@ export default { toggleFeature(type) { this.$root.utools.whole.removeFeature(this.features[type].code) || this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type])); + if ( + type === "apiServer" && + !this.$root.profile.quickFeatures.apiServer.enable + ) { + window.quickcommandHttpServer().stop(); + this.$root.profile.quickFeatures.apiServer.serverStatus = false; + } }, }, }; diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index 471e331..d8174db 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -207,6 +207,7 @@ import ConfigurationMenu from "components/ConfigurationMenu.vue"; import CommandRunResult from "components/CommandRunResult.vue"; import importAll from "../js/common/importAll.js"; import pinyinMatch from "pinyin-match"; +import defaultProfile from "../js/options/defaultProfile.js"; const CommandEditor = defineAsyncComponent(() => import("components/CommandEditor.vue") @@ -517,7 +518,7 @@ export default { // 清空 clearAllCommands() { quickcommand - .showConfirmBox("将会清空所有自定义命令,请确认!") + .showConfirmBox("将会清空所有自定义命令,停用所有实用功能,请确认!") .then((isConfirmed) => { if (!isConfirmed) return quickcommand.showMessageBox("取消操作", "info"); @@ -527,6 +528,7 @@ export default { .map((x) => x._id) .forEach((y) => this.$root.utools.delDB(y)); this.importDefaultCommands(); + this.resetQuickFeatures(); this.clearAllFeatures(); Object.keys(this.allQuickCommands).forEach((featureCode) => { if (!featureCode.includes("default_")) @@ -544,6 +546,13 @@ export default { this.$root.utools.whole.removeFeature(feature.code); } }, + resetQuickFeatures() { + Object.assign( + this.$root.profile.quickFeatures, + _.cloneDeep(defaultProfile.quickFeatures) + ); + window.quickcommandHttpServer().stop(); + }, // 搜索 updateSearch() { // 记录当前标签页