From 596afcfed31aa11464f4577701daea622ddb9cd4 Mon Sep 17 00:00:00 2001 From: fofolee Date: Mon, 11 Apr 2022 22:07:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E4=BF=9D=E5=AD=98=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E6=97=B6=E7=9A=84=20dom=20=E6=93=8D=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandCard.vue | 8 ++++---- src/components/CommandEditor.vue | 16 +++------------- src/pages/ConfigurationPage.vue | 16 +++++++++++++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/CommandCard.vue b/src/components/CommandCard.vue index 0a1d951..8b83754 100644 --- a/src/components/CommandCard.vue +++ b/src/components/CommandCard.vue @@ -11,7 +11,7 @@
{ - // 先点一次,如果是停用状态则被启用 - // 如果是启用状态则停用 - let dom = document.getElementById(this.quickcommandInfo.features.code); - dom.querySelector(".q-toggle")?.click(); - // 如果之前一次点击是启用则不点 - // 如果之前一次点击是停用则再点一次启用,达到刷新目的 - this.$nextTick(() => { - dom.querySelector(".q-toggle[aria-checked='false']")?.click(); - }); - }); }, // 运行 runCurrentCommand() { diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index 6dd75a8..bcb39bb 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -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; }