From 46aa645792ea7814ae7eaab89e6b37ed7f0f7fbf Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 2 May 2022 10:17:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E5=81=9C=E7=94=A8=E6=89=80=E6=9C=89=E5=AE=9E=E7=94=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin/preload.js | 1 + src/App.vue | 5 ++++- src/components/ConfigurationMenu.vue | 9 ++++++++- src/pages/ConfigurationPage.vue | 11 ++++++++++- 4 files changed, 23 insertions(+), 3 deletions(-) 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() { // 记录当前标签页