diff --git a/src/components/CommandCard.vue b/src/components/CommandCard.vue index 63a765e..32ab991 100644 --- a/src/components/CommandCard.vue +++ b/src/components/CommandCard.vue @@ -30,7 +30,7 @@ 运行 - + 导出 @@ -51,7 +51,13 @@ - 删除 - +
@@ -222,6 +232,12 @@ export default { if (cmd.type && cmd.type === "window") return false; return true; }, + // 默认命令不可删除 + canCommandEdit() { + if (utools.isDev()) return true; + let tags = this.commandInfo.tags; + return tags && tags.includes("默认") ? false : true; + }, // 匹配类型的颜色 cmdBadgeColor() { return (cmdType = "keyword") => { @@ -251,6 +267,18 @@ export default { } return shortStr === str ? shortStr : shortStr + "..."; }, + // 命令卡片点击事件 + handleCardClick() { + // 视图模式下直接运行命令 + if (this.cardStyle.code === 1) return this.runCommand(); + if (!this.canCommandEdit) + return quickcommand.showMessageBox("默认命令不可编辑", "warning"); + this.editCommand(); + }, + // 编辑命令 + editCommand() { + console.log(this.commandInfo); + }, // 运行命令 runCommand() { utools.redirect( diff --git a/src/pages/ConfigurationPage.vue b/src/pages/ConfigurationPage.vue index 8770e12..4c1a3ba 100644 --- a/src/pages/ConfigurationPage.vue +++ b/src/pages/ConfigurationPage.vue @@ -508,7 +508,13 @@ export default { }, ], }; - let stringifyCommands = JSON.stringify(this.allQuickCommands); + let commandsToExport = JSON.parse(JSON.stringify(this.allQuickCommands)); + // 不导出默认命令 + if (!utools.isDev()) + Object.keys(commandsToExport).forEach((code) => { + if (code.includes("default_")) delete commandsToExport[code]; + }); + let stringifyCommands = JSON.stringify(commandsToExport); if (saveAsFile) { window.saveFile(stringifyCommands, options); quickcommand.showMessageBox("导出成功!");