去除保存命令时的 dom 操作

This commit is contained in:
fofolee 2022-04-11 22:07:03 +08:00
parent de8dad1698
commit 596afcfed3
3 changed files with 20 additions and 20 deletions

View File

@ -11,7 +11,7 @@
<!-- 开关 -->
<div class="absolute" style="z-index: 1; left: 20px; bottom: 16px">
<q-toggle
v-model="isCommandActivated"
:model-value="isCommandActivated"
checked-icon="flash_on"
color="orange-6"
@click="toggleCommandActivated"
@ -212,7 +212,6 @@ export default {
data() {
return {
allProgrammings: this.$programmings,
isCommandActivated: this.activated,
maxCmdStingLen: 8,
commandTypes: commandTypes,
cmdBadgeSheet: {
@ -267,7 +266,7 @@ export default {
},
props: {
commandInfo: Object,
activated: Boolean,
isCommandActivated: Boolean,
cardStyle: Object,
},
mounted() {
@ -311,8 +310,9 @@ export default {
toggleCommandActivated() {
let event = {
data: this.commandInfo.features.code,
type:"toggle"
};
event.type = this.isCommandActivated ? "enable" : "disable";
event.type = this.isCommandActivated ? "disable" : "enable";
this.$emit("commandChanged", event);
},
//

View File

@ -340,26 +340,16 @@ export default {
let updatedData = this.$refs.menu.SaveMenuData();
if (!updatedData) return;
Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData));
let newQuickcommandInfo = _.cloneDeep(this.quickcommandInfo);
this.$utools.putDB(
_.cloneDeep(this.quickcommandInfo),
newQuickcommandInfo,
this.$utools.DBPRE.QC + this.quickcommandInfo.features.code
);
this.$emit("editorEvent", {
type: "save",
data: _.cloneDeep(this.quickcommandInfo),
data: newQuickcommandInfo,
});
this.closeEditor();
this.$nextTick(() => {
//
//
let dom = document.getElementById(this.quickcommandInfo.features.code);
dom.querySelector(".q-toggle")?.click();
//
//
this.$nextTick(() => {
dom.querySelector(".q-toggle[aria-checked='false']")?.click();
});
});
},
//
runCurrentCommand() {

View File

@ -69,7 +69,7 @@
v-for="commandInfo in currentTagQuickCommands"
:key="commandInfo.features.code"
:commandInfo="commandInfo"
:activated="
:isCommandActivated="
activatedQuickCommandFeatureCodes.includes(
commandInfo.features.code
)
@ -537,14 +537,24 @@ export default {
};
this.isCommandEditorShow = true;
},
saveCommand(command) {
let code = command.features.code;
this.allQuickCommands[code] = command;
//
if (!this.activatedQuickCommandFeatureCodes.includes(code))
this.activatedQuickCommandFeatureCodes.push(code);
//
this.$utools.whole.removeFeature(code);
this.$utools.whole.setFeature(command.features);
this.locateToCommand(command.tags, code);
},
editorEvent(event) {
switch (event.type) {
case "close":
this.isCommandEditorShow = false;
return;
case "save":
this.allQuickCommands[event.data.features.code] = event.data;
this.locateToCommand(event.data.tags, event.data.features.code);
this.saveCommand(event.data);
default:
return;
}