mirror of
https://github.com/fofolee/uTools-quickcommand.git
synced 2025-06-09 23:16:18 +08:00
修复json格式运行结果复制错误的bug,运行结果支持保存
This commit is contained in:
parent
5691a8e48e
commit
099ee21d8d
@ -34,7 +34,7 @@
|
|||||||
<ResultMenu
|
<ResultMenu
|
||||||
class="no-shadow q-pa-sm"
|
class="no-shadow q-pa-sm"
|
||||||
:stretch="true"
|
:stretch="true"
|
||||||
:content="runResult.join('')"
|
:runResult="runResult"
|
||||||
:closebtn="!fromUtools"
|
:closebtn="!fromUtools"
|
||||||
:textbtn="!enableHtml"
|
:textbtn="!enableHtml"
|
||||||
:imagebtn="!enableHtml && isDataUrl"
|
:imagebtn="!enableHtml && isDataUrl"
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
<q-btn icon="send" size="sm" @click="sendResult" v-show="textbtn" dense
|
<q-btn icon="send" size="sm" @click="sendResult" v-show="textbtn" dense
|
||||||
><q-tooltip v-if="!dense">发送到活动窗口</q-tooltip></q-btn
|
><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 icon="close" v-close-popup v-show="closebtn" dense size="sm" />
|
||||||
</q-btn-group>
|
</q-btn-group>
|
||||||
</template>
|
</template>
|
||||||
@ -31,7 +34,12 @@ export default {
|
|||||||
textbtn: Boolean,
|
textbtn: Boolean,
|
||||||
imagebtn: Boolean,
|
imagebtn: Boolean,
|
||||||
closebtn: Boolean,
|
closebtn: Boolean,
|
||||||
content: String,
|
runResult: Array,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
content() {
|
||||||
|
return this.getContent();
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyResult() {
|
copyResult() {
|
||||||
@ -48,6 +56,25 @@ export default {
|
|||||||
if (!imgs) return quickcommand.showMessageBox("dataUrl 格式不正确!");
|
if (!imgs) return quickcommand.showMessageBox("dataUrl 格式不正确!");
|
||||||
this.$emit("showImg", imgs);
|
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>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user