mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-08 22:51:25 +08:00
修复json格式运行结果复制错误的bug,运行结果支持保存
This commit is contained in:
parent
5691a8e48e
commit
099ee21d8d
@ -34,7 +34,7 @@
|
||||
<ResultMenu
|
||||
class="no-shadow q-pa-sm"
|
||||
:stretch="true"
|
||||
:content="runResult.join('')"
|
||||
:runResult="runResult"
|
||||
:closebtn="!fromUtools"
|
||||
:textbtn="!enableHtml"
|
||||
:imagebtn="!enableHtml && isDataUrl"
|
||||
|
@ -19,6 +19,9 @@
|
||||
<q-btn icon="send" size="sm" @click="sendResult" v-show="textbtn" dense
|
||||
><q-tooltip v-if="!dense">发送到活动窗口</q-tooltip></q-btn
|
||||
>
|
||||
<q-btn icon="save" v-if="!dense" size="sm" @click="saveResult" dense
|
||||
><q-tooltip>保存到文件</q-tooltip></q-btn
|
||||
>
|
||||
<q-btn icon="close" v-close-popup v-show="closebtn" dense size="sm" />
|
||||
</q-btn-group>
|
||||
</template>
|
||||
@ -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");
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user