清空数据时停用所有实用功能

This commit is contained in:
fofolee 2022-05-02 10:17:57 +08:00
parent dc7086fb9f
commit 46aa645792
4 changed files with 23 additions and 3 deletions

View File

@ -633,6 +633,7 @@ window.quickcommandHttpServer = () => {
}) })
} }
let stop = () => { let stop = () => {
if (!httpServer) return
httpServer.close() httpServer.close()
} }
return { return {

View File

@ -64,7 +64,10 @@ export default defineComponent({
let userProfile = this.utools.getDB( let userProfile = this.utools.getDB(
this.utools.DBPRE.CFG + "preferences" this.utools.DBPRE.CFG + "preferences"
); );
_.merge(defaultProfile, _.cloneDeep(userProfile)); this.profile = _.merge(
_.cloneDeep(defaultProfile),
_.cloneDeep(userProfile)
);
// //
_.forIn(this.profile.crontabs, (cronExp, featureCode) => { _.forIn(this.profile.crontabs, (cronExp, featureCode) => {
this.runCronTask(featureCode, cronExp); this.runCronTask(featureCode, cronExp);

View File

@ -212,7 +212,7 @@
<q-item-section side> <q-item-section side>
<q-icon name="delete" /> <q-icon name="delete" />
</q-item-section> </q-item-section>
<q-item-section>删除所有命令</q-item-section> <q-item-section>清空数据</q-item-section>
</q-item> </q-item>
</q-list> </q-list>
</q-menu> </q-menu>
@ -455,6 +455,13 @@ export default {
toggleFeature(type) { toggleFeature(type) {
this.$root.utools.whole.removeFeature(this.features[type].code) || this.$root.utools.whole.removeFeature(this.features[type].code) ||
this.$root.utools.whole.setFeature(_.cloneDeep(this.features[type])); 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;
}
}, },
}, },
}; };

View File

@ -207,6 +207,7 @@ import ConfigurationMenu from "components/ConfigurationMenu.vue";
import CommandRunResult from "components/CommandRunResult.vue"; import CommandRunResult from "components/CommandRunResult.vue";
import importAll from "../js/common/importAll.js"; import importAll from "../js/common/importAll.js";
import pinyinMatch from "pinyin-match"; import pinyinMatch from "pinyin-match";
import defaultProfile from "../js/options/defaultProfile.js";
const CommandEditor = defineAsyncComponent(() => const CommandEditor = defineAsyncComponent(() =>
import("components/CommandEditor.vue") import("components/CommandEditor.vue")
@ -517,7 +518,7 @@ export default {
// //
clearAllCommands() { clearAllCommands() {
quickcommand quickcommand
.showConfirmBox("将会清空所有自定义命令,请确认!") .showConfirmBox("将会清空所有自定义命令,停用所有实用功能,请确认!")
.then((isConfirmed) => { .then((isConfirmed) => {
if (!isConfirmed) if (!isConfirmed)
return quickcommand.showMessageBox("取消操作", "info"); return quickcommand.showMessageBox("取消操作", "info");
@ -527,6 +528,7 @@ export default {
.map((x) => x._id) .map((x) => x._id)
.forEach((y) => this.$root.utools.delDB(y)); .forEach((y) => this.$root.utools.delDB(y));
this.importDefaultCommands(); this.importDefaultCommands();
this.resetQuickFeatures();
this.clearAllFeatures(); this.clearAllFeatures();
Object.keys(this.allQuickCommands).forEach((featureCode) => { Object.keys(this.allQuickCommands).forEach((featureCode) => {
if (!featureCode.includes("default_")) if (!featureCode.includes("default_"))
@ -544,6 +546,13 @@ export default {
this.$root.utools.whole.removeFeature(feature.code); this.$root.utools.whole.removeFeature(feature.code);
} }
}, },
resetQuickFeatures() {
Object.assign(
this.$root.profile.quickFeatures,
_.cloneDeep(defaultProfile.quickFeatures)
);
window.quickcommandHttpServer().stop();
},
// //
updateSearch() { updateSearch() {
// //