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