From 099ee21d8d528b5b8ba7f8f0bb64f89f8b02fd4b Mon Sep 17 00:00:00 2001 From: fofolee Date: Sat, 11 Jan 2025 17:08:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Djson=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E7=BB=93=E6=9E=9C=E5=A4=8D=E5=88=B6=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84bug=EF=BC=8C=E8=BF=90=E8=A1=8C=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E6=94=AF=E6=8C=81=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/CommandRunResult.vue | 2 +- src/components/popup/ResultMenu.vue | 29 ++++++++++++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/components/CommandRunResult.vue b/src/components/CommandRunResult.vue index 699244a..1d16c83 100644 --- a/src/components/CommandRunResult.vue +++ b/src/components/CommandRunResult.vue @@ -34,7 +34,7 @@ 发送到活动窗口 + 保存到文件 @@ -31,7 +34,12 @@ export default { textbtn: Boolean, imagebtn: Boolean, closebtn: Boolean, - content: String, + runResult: Array, + }, + computed: { + content() { + return this.getContent(); + }, }, methods: { copyResult() { @@ -48,6 +56,25 @@ export default { if (!imgs) return quickcommand.showMessageBox("dataUrl 格式不正确!"); this.$emit("showImg", imgs); }, + saveResult() { + window.saveFile(this.content, { + defaultPath: "quickcommand-result.txt", + filters: [{ name: "txt", extensions: ["txt"] }], + }); + }, + getContent() { + let content = this.runResult.map((item) => { + if (typeof item === "object") { + try { + return JSON.stringify(item, null, 2); + } catch (e) { + return item.toString(); + } + } + return item; + }); + return content.join("\n"); + }, }, };