From 9ea88e92865371ec4bd9fb610ae722c795213721 Mon Sep 17 00:00:00 2001 From: fofolee Date: Thu, 7 Apr 2022 15:51:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5lodash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandEditor.vue | 15 ++++++++------- src/components/CommandMenu.vue | 11 +++++++++-- src/pages/ConfigurationPage.vue | 25 +++++++++---------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/components/CommandEditor.vue b/src/components/CommandEditor.vue index 29c8ccd..53d1871 100644 --- a/src/components/CommandEditor.vue +++ b/src/components/CommandEditor.vue @@ -105,7 +105,7 @@ flat v-if="!isRunCodePage" :disable="!canCommandSave" - color="primary" + :color="canCommandSave ? 'primary' : 'grey'" icon="save" @click="saveCurrentCommand()" >保存 {{ commandString }}+s diff --git a/src/components/CommandMenu.vue b/src/components/CommandMenu.vue index 92fa2e4..b1715c3 100644 --- a/src/components/CommandMenu.vue +++ b/src/components/CommandMenu.vue @@ -278,9 +278,9 @@ export default { let currentQuickCommandCmds = this.getCommandType(); this.cmdType = this.commandTypes[currentQuickCommandCmds.type]; this.cmdMatch = currentQuickCommandCmds.match; - Object.assign( + _.merge( this.currentCommand, - JSON.parse(JSON.stringify(this.quickcommandInfo)) + _.pick(this.quickcommandInfo, "tags", "output", "features") ); this.setIcon(this.currentCommand.program); this.platformVerify(); @@ -362,6 +362,13 @@ export default { "error" ); } + + // 子输入框 + if (updateData.cmd.includes("{{subinput")) { + updateData.hasSubInput = true; + } else { + updateData.hasSubInput = false; + } return updateData; }, }, diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index d98d2bb..efaabf3 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -238,9 +238,7 @@ export default { computed: { // 当前标签下的所有快捷命令 currentTagQuickCommands() { - let commands = Object.values( - JSON.parse(JSON.stringify(this.allQuickCommands)) - ); + let commands = Object.values(_.cloneDeep(this.allQuickCommands)); switch (this.currentTag) { case "未分类": return commands.filter((cmd) => !cmd.tags || cmd.tags.length === 0); @@ -273,17 +271,12 @@ export default { }, // 所有命令对应的标签 allQuickCommandTags() { - return [ - ...new Set( - // 去重并确保默认在第一位 - Array.prototype.concat - .apply( - ["默认"], - Object.values(this.allQuickCommands).map((x) => x.tags) - ) - .concat(["未分类", "搜索结果"]) - ), - ].filter((x) => x); + return _.union( + ..._.concat( + "默认", + Object.values(this.allQuickCommands).map((x) => x.tags) + ) + ).concat(["未分类", "搜索结果"]); }, // 标签栏宽度 tabBarWidth() { @@ -352,7 +345,7 @@ export default { // 启用命令 enableCommand(code) { this.$utools.whole.setFeature( - JSON.parse(JSON.stringify(this.allQuickCommands[code].features)) + _.cloneDeep(this.allQuickCommands[code].features) ); this.activatedQuickCommandFeatureCodes.push(code); }, @@ -449,7 +442,7 @@ export default { }, ], }; - let commandsToExport = JSON.parse(JSON.stringify(this.allQuickCommands)); + let commandsToExport = _.cloneDeep(this.allQuickCommands); // 不导出默认命令 if (!utools.isDev()) Object.keys(commandsToExport).forEach((code) => {