1
This commit is contained in:
@@ -22,6 +22,9 @@
|
|||||||
<el-form label-position="top">
|
<el-form label-position="top">
|
||||||
<el-form-item label="响应">
|
<el-form-item label="响应">
|
||||||
<el-input :value="result" type="textarea" :rows="18" readonly />
|
<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-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-col>
|
</el-col>
|
||||||
@@ -43,6 +46,27 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
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() {
|
run() {
|
||||||
const cmd = (this.form.command || '').trim()
|
const cmd = (this.form.command || '').trim()
|
||||||
if (!cmd) { this.$modal.msgError('请输入指令'); return }
|
if (!cmd) { this.$modal.msgError('请输入指令'); return }
|
||||||
|
|||||||
Reference in New Issue
Block a user