1
This commit is contained in:
@@ -21,10 +21,23 @@
|
||||
<el-col :span="12">
|
||||
<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>
|
||||
<template v-if="resultList.length > 0">
|
||||
<div v-for="(msg, idx) in resultList" :key="idx" style="margin-bottom: 12px;">
|
||||
<el-input :value="msg" type="textarea" :rows="8" readonly />
|
||||
<div style="margin-top: 6px;">
|
||||
<el-button size="mini" type="success" @click="copyOne(msg)">复制第{{ idx + 1 }}段</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<el-button size="mini" type="primary" @click="copyAll">复制全部</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
<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>
|
||||
</template>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-col>
|
||||
@@ -42,13 +55,26 @@ export default {
|
||||
return {
|
||||
form: { command: '' },
|
||||
loading: false,
|
||||
result: ''
|
||||
result: '',
|
||||
resultList: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
copyOne(text) {
|
||||
if (!text) return
|
||||
this.doCopy(text)
|
||||
},
|
||||
copyAll() {
|
||||
if (!this.resultList || this.resultList.length === 0) return
|
||||
const text = this.resultList.join('\n\n')
|
||||
this.doCopy(text)
|
||||
},
|
||||
copyResult() {
|
||||
if (!this.result) return
|
||||
const text = this.result
|
||||
this.doCopy(text)
|
||||
},
|
||||
doCopy(text) {
|
||||
if (navigator.clipboard) {
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
this.$modal.msgSuccess('复制成功')
|
||||
@@ -74,7 +100,14 @@ export default {
|
||||
executeInstruction({ command: cmd }).then(res => {
|
||||
this.loading = false
|
||||
if (res && (res.code === 200 || res.msg === '操作成功')) {
|
||||
this.result = res.data || res.msg || ''
|
||||
const data = res.data
|
||||
if (Array.isArray(data)) {
|
||||
this.resultList = data
|
||||
this.result = ''
|
||||
} else {
|
||||
this.result = data || res.msg || ''
|
||||
this.resultList = []
|
||||
}
|
||||
} else {
|
||||
this.$modal.msgError(res && res.msg ? res.msg : '执行失败')
|
||||
}
|
||||
@@ -89,6 +122,7 @@ export default {
|
||||
clearAll() {
|
||||
this.form.command = ''
|
||||
this.result = ''
|
||||
this.resultList = []
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user