This commit is contained in:
雷欧(林平凡)
2025-08-28 13:50:35 +08:00
parent ef1a0430d4
commit acb59b64bd

View File

@@ -5,43 +5,34 @@
<span>京东指令台</span> <span>京东指令台</span>
</div> </div>
<el-row :gutter="20"> <el-form :model="form" label-width="80px" label-position="top">
<el-col :span="12"> <el-form-item label="输入指令">
<el-form :model="form" label-width="80px" label-position="top"> <el-input v-model="form.command" type="textarea" :rows="8" placeholder="例如:京今日统计 / 京昨日订单 / 慢搜关键词 / 录单20250101-20250107" />
<el-form-item label="输入指令"> </el-form-item>
<el-input v-model="form.command" type="textarea" :rows="10" placeholder="例如:京今日统计 / 京昨日订单 / 慢搜关键词 / 录单20250101-20250107" /> <el-form-item>
</el-form-item> <el-button type="primary" @click="run" :loading="loading">执行</el-button>
<el-form-item> <el-button @click="fillMenu">菜单</el-button>
<el-button type="primary" @click="run" :loading="loading">执行</el-button> <el-button @click="clearAll">清空</el-button>
<el-button @click="fillMenu">菜单</el-button> </el-form-item>
<el-button @click="clearAll">清空</el-button> </el-form>
</el-form-item>
</el-form> <el-divider>响应</el-divider>
</el-col>
<el-col :span="12"> <div v-if="resultList.length === 0" style="padding: 12px 0;">
<el-form label-position="top"> <el-empty description="无响应" />
<el-form-item label="响应"> </div>
<template v-if="resultList.length > 0"> <div v-else>
<div v-for="(msg, idx) in resultList" :key="idx" style="margin-bottom: 12px;"> <div v-for="(msg, idx) in resultList" :key="idx" class="msg-block">
<el-input :value="msg" type="textarea" :rows="8" readonly /> <div class="msg-header">
<div style="margin-top: 6px;"> <span> {{ idx + 1 }} </span>
<el-button size="mini" type="success" @click="copyOne(msg)">复制{{ idx + 1 }}</el-button> <el-button size="mini" type="success" @click="copyOne(msg)">复制</el-button>
</div> </div>
</div> <el-input :value="msg" type="textarea" :rows="8" readonly />
<div> </div>
<el-button size="mini" type="primary" @click="copyAll">复制全部</el-button> <div style="margin-top: 8px;">
</div> <el-button size="mini" type="primary" @click="copyAll">复制全部</el-button>
</template> </div>
<template v-else> </div>
<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>
</el-row>
</el-card> </el-card>
</div> </div>
</template> </template>
@@ -55,7 +46,6 @@ export default {
return { return {
form: { command: '' }, form: { command: '' },
loading: false, loading: false,
result: '',
resultList: [] resultList: []
} }
}, },
@@ -69,11 +59,6 @@ export default {
const text = this.resultList.join('\n\n') const text = this.resultList.join('\n\n')
this.doCopy(text) this.doCopy(text)
}, },
copyResult() {
if (!this.result) return
const text = this.result
this.doCopy(text)
},
doCopy(text) { doCopy(text) {
if (navigator.clipboard) { if (navigator.clipboard) {
navigator.clipboard.writeText(text).then(() => { navigator.clipboard.writeText(text).then(() => {
@@ -101,13 +86,9 @@ export default {
this.loading = false this.loading = false
if (res && (res.code === 200 || res.msg === '操作成功')) { if (res && (res.code === 200 || res.msg === '操作成功')) {
const data = res.data const data = res.data
if (Array.isArray(data)) { if (Array.isArray(data)) this.resultList = data
this.resultList = data else if (typeof data === 'string') this.resultList = data ? [data] : []
this.result = '' else this.resultList = []
} else {
this.result = data || res.msg || ''
this.resultList = []
}
} else { } else {
this.$modal.msgError(res && res.msg ? res.msg : '执行失败') this.$modal.msgError(res && res.msg ? res.msg : '执行失败')
} }
@@ -121,7 +102,6 @@ export default {
}, },
clearAll() { clearAll() {
this.form.command = '' this.form.command = ''
this.result = ''
this.resultList = [] this.resultList = []
} }
} }
@@ -130,6 +110,8 @@ export default {
<style scoped> <style scoped>
.box-card { margin: 20px; } .box-card { margin: 20px; }
.msg-block { margin-bottom: 12px; }
.msg-header { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
</style> </style>