From 9694570dea1ae42c635ecfc08214e23a816f32f3 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 7 Apr 2022 17:30:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E4=BF=9D=E5=AD=98=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandEditor.vue | 23 +++++++++++++++++++---- src/components/CommandMenu.vue | 9 +++++++-- src/js/options/commandTypes.js | 1 + src/pages/ConfigurationPage.vue | 7 +++++-- 4 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index 53d1871..1b8095f 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -161,7 +161,7 @@ export default { programLanguages: Object.keys(this.$programmings), sideBarWidth: "290px", languageBarHeight: "40px", - canCommandSave: this.action.type === "edit" ? true : false, + canCommandSave: this.action.type === "code" ? false : true, quickcommandInfo: { features: { explain: "", @@ -202,7 +202,7 @@ export default { }, computed: { allQuickCommandTags() { - return this.parentPage.allQuickCommandTags.filter( + return this.parent.allQuickCommandTags.filter( (x) => x !== "默认" && x !== "未分类" && x !== "搜索结果" ); }, @@ -407,9 +407,24 @@ export default { }, // 保存 saveCurrentCommand() { - let updatedData = this.$refs.editor.SaveMenuData(); + let updatedData = this.$refs.menu.SaveMenuData(); if (!updatedData) return; - _.merge(this.quickcommandInfo, updatedData); + Object.assign(this.quickcommandInfo, _.cloneDeep(updatedData)); + this.$utools.putDB( + _.cloneDeep(this.quickcommandInfo), + this.$utools.DBPRE.QC + this.quickcommandInfo.features.code + ); + this.$emit("editorEvent", { + type: "save", + data: _.cloneDeep(this.quickcommandInfo), + }); + this.closeEditor(); + this.$nextTick(() => { + document + .getElementById(this.quickcommandInfo.features.code) + .querySelector(".q-toggle[aria-checked='false']") + ?.click(); + }); }, }, }; diff --git a/src/components/CommandMenu.vue b/src/components/CommandMenu.vue index b1715c3..83473cb 100644 --- a/src/components/CommandMenu.vue +++ b/src/components/CommandMenu.vue @@ -256,7 +256,12 @@ export default { outputTypes: outputTypes, outputTypesOptions: Object.keys(outputTypes), specialVar: "{{}}", - allQuickCommandTags: this.$parent.parent.allQuickCommandTags, + allQuickCommandTags: _.without( + this.$parent.parent.allQuickCommandTags, + "默认", + "未分类", + "搜索结果" + ), }; }, props: { @@ -282,7 +287,7 @@ export default { this.currentCommand, _.pick(this.quickcommandInfo, "tags", "output", "features") ); - this.setIcon(this.currentCommand.program); + this.setIcon(this.quickcommandInfo.program); this.platformVerify(); }, // 没有图标,或者使用了语言图标 diff --git a/src/js/options/commandTypes.js b/src/js/options/commandTypes.js index fdfb52d..9e2488b 100644 --- a/src/js/options/commandTypes.js +++ b/src/js/options/commandTypes.js @@ -96,6 +96,7 @@ const commandTypes = { icon: "construction", desc: "通过json格式的配置实现同时匹配关键字、窗口、文件甚至图片,或者指定文件数量、窗口类等", valueType: "json", + disabledSpecialVars: null, matchToCmds: (rules, desc) => JSON.parse(rules), verify: rules => { try { diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index efaabf3..ad8fae3 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -422,12 +422,12 @@ export default { let el = document.getElementById(code); el.scrollIntoViewIfNeeded(); // 闪一下 - el.style.filter = "invert(1) drop-shadow(1px 1px 5px #0000008e)"; + el.style.filter = "drop-shadow(2px 4px 6px black)"; el.style.transform = "translateY(-5px)"; setTimeout(() => { el.style.filter = ""; el.style.transform = ""; - }, 500); + }, 800); }); }, // 全部导出 @@ -513,6 +513,9 @@ export default { 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); default: return; }