diff --git a/src/views/system/jd-instruction/index.vue b/src/views/system/jd-instruction/index.vue index 63da940..98ddfcd 100644 --- a/src/views/system/jd-instruction/index.vue +++ b/src/views/system/jd-instruction/index.vue @@ -22,6 +22,9 @@ +
+ 复制响应 +
@@ -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 }