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"); + }, }, };