This commit is contained in:
2025-08-27 21:15:24 +08:00
parent 4a7d948061
commit 483a7c019c

View File

@@ -22,6 +22,9 @@
<el-form label-position="top">
<el-form-item label="响应">
<el-input :value="result" type="textarea" :rows="18" readonly />
<div style="margin-top: 8px;">
<el-button size="mini" type="success" @click="copyResult" :disabled="!result">复制响应</el-button>
</div>
</el-form-item>
</el-form>
</el-col>
@@ -43,6 +46,27 @@ export default {
}
},
methods: {
copyResult() {
if (!this.result) return
const text = this.result
if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => {
this.$modal.msgSuccess('复制成功')
}).catch(() => {
this.fallbackCopyText(text)
})
} else {
this.fallbackCopyText(text)
}
},
fallbackCopyText(text) {
const ta = document.createElement('textarea')
ta.value = text
document.body.appendChild(ta)
ta.focus(); ta.select()
try { document.execCommand('copy'); this.$modal.msgSuccess('复制成功') } catch (e) { this.$modal.msgError('复制失败') }
document.body.removeChild(ta)
},
run() {
const cmd = (this.form.command || '').trim()
if (!cmd) { this.$modal.msgError('请输入指令'); return }