1
This commit is contained in:
@@ -8,4 +8,12 @@ export function executeInstruction(data) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getHistory(type, limit) {
|
||||||
|
return request({
|
||||||
|
url: '/jarvis/instruction/history',
|
||||||
|
method: 'get',
|
||||||
|
params: { type, limit }
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,12 +35,52 @@
|
|||||||
<el-button size="mini" type="primary" @click="copyAll">复制全部</el-button>
|
<el-button size="mini" type="primary" @click="copyAll">复制全部</el-button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<el-divider>历史消息记录</el-divider>
|
||||||
|
|
||||||
|
<div class="history-container">
|
||||||
|
<div class="history-column">
|
||||||
|
<div class="history-header">
|
||||||
|
<span>历史请求(最近 {{ historyLimit }} 条)</span>
|
||||||
|
<el-button size="mini" type="primary" icon="el-icon-refresh" @click="loadHistory" :loading="historyLoading">刷新</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="history-content">
|
||||||
|
<div v-if="requestHistory.length === 0" class="empty-history">
|
||||||
|
<el-empty description="暂无历史请求" :image-size="80" />
|
||||||
|
</div>
|
||||||
|
<div v-else class="history-list">
|
||||||
|
<div v-for="(item, idx) in requestHistory" :key="'req-' + idx" class="history-item">
|
||||||
|
<div class="history-time">{{ extractTime(item) }}</div>
|
||||||
|
<div class="history-text">{{ extractMessage(item) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="history-column">
|
||||||
|
<div class="history-header">
|
||||||
|
<span>历史响应(最近 {{ historyLimit }} 条)</span>
|
||||||
|
<el-button size="mini" type="success" @click="copyHistory('response')">复制全部</el-button>
|
||||||
|
</div>
|
||||||
|
<div class="history-content">
|
||||||
|
<div v-if="responseHistory.length === 0" class="empty-history">
|
||||||
|
<el-empty description="暂无历史响应" :image-size="80" />
|
||||||
|
</div>
|
||||||
|
<div v-else class="history-list">
|
||||||
|
<div v-for="(item, idx) in responseHistory" :key="'res-' + idx" class="history-item">
|
||||||
|
<div class="history-time">{{ extractTime(item) }}</div>
|
||||||
|
<div class="history-text">{{ extractMessage(item) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { executeInstruction } from '@/api/system/instruction'
|
import { executeInstruction, getHistory } from '@/api/system/instruction'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'JdInstruction',
|
name: 'JdInstruction',
|
||||||
@@ -48,9 +88,16 @@ export default {
|
|||||||
return {
|
return {
|
||||||
form: { command: '' },
|
form: { command: '' },
|
||||||
loading: false,
|
loading: false,
|
||||||
resultList: []
|
resultList: [],
|
||||||
|
requestHistory: [],
|
||||||
|
responseHistory: [],
|
||||||
|
historyLoading: false,
|
||||||
|
historyLimit: 50
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.loadHistory()
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
copyOne(text) {
|
copyOne(text) {
|
||||||
if (!text) return
|
if (!text) return
|
||||||
@@ -61,6 +108,15 @@ export default {
|
|||||||
const text = this.resultList.join('\n\n')
|
const text = this.resultList.join('\n\n')
|
||||||
this.doCopy(text)
|
this.doCopy(text)
|
||||||
},
|
},
|
||||||
|
copyHistory(type) {
|
||||||
|
const list = type === 'response' ? this.responseHistory : this.requestHistory
|
||||||
|
if (!list || list.length === 0) {
|
||||||
|
this.$modal.msgWarning('暂无历史记录')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const text = list.map(item => this.extractMessage(item)).join('\n\n')
|
||||||
|
this.doCopy(text)
|
||||||
|
},
|
||||||
doCopy(text) {
|
doCopy(text) {
|
||||||
if (navigator.clipboard) {
|
if (navigator.clipboard) {
|
||||||
navigator.clipboard.writeText(text).then(() => {
|
navigator.clipboard.writeText(text).then(() => {
|
||||||
@@ -91,6 +147,8 @@ export default {
|
|||||||
if (Array.isArray(data)) this.resultList = data
|
if (Array.isArray(data)) this.resultList = data
|
||||||
else if (typeof data === 'string') this.resultList = data ? [data] : []
|
else if (typeof data === 'string') this.resultList = data ? [data] : []
|
||||||
else this.resultList = []
|
else this.resultList = []
|
||||||
|
// 执行成功后刷新历史记录
|
||||||
|
this.loadHistory()
|
||||||
} else {
|
} else {
|
||||||
this.$modal.msgError(res && res.msg ? res.msg : '执行失败')
|
this.$modal.msgError(res && res.msg ? res.msg : '执行失败')
|
||||||
}
|
}
|
||||||
@@ -99,6 +157,34 @@ export default {
|
|||||||
this.$modal.msgError('执行失败,请稍后重试')
|
this.$modal.msgError('执行失败,请稍后重试')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
loadHistory() {
|
||||||
|
this.historyLoading = true
|
||||||
|
Promise.all([
|
||||||
|
getHistory('request', this.historyLimit),
|
||||||
|
getHistory('response', this.historyLimit)
|
||||||
|
]).then(([reqRes, respRes]) => {
|
||||||
|
this.historyLoading = false
|
||||||
|
if (reqRes && reqRes.code === 200) {
|
||||||
|
this.requestHistory = reqRes.data || []
|
||||||
|
}
|
||||||
|
if (respRes && respRes.code === 200) {
|
||||||
|
this.responseHistory = respRes.data || []
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
|
this.historyLoading = false
|
||||||
|
this.$modal.msgError('加载历史记录失败')
|
||||||
|
})
|
||||||
|
},
|
||||||
|
extractTime(item) {
|
||||||
|
if (!item) return ''
|
||||||
|
const idx = item.indexOf(' | ')
|
||||||
|
return idx > 0 ? item.substring(0, idx) : ''
|
||||||
|
},
|
||||||
|
extractMessage(item) {
|
||||||
|
if (!item) return ''
|
||||||
|
const idx = item.indexOf(' | ')
|
||||||
|
return idx > 0 ? item.substring(idx + 3) : item
|
||||||
|
},
|
||||||
fillTF() {
|
fillTF() {
|
||||||
this.form.command = 'TF'
|
this.form.command = 'TF'
|
||||||
},
|
},
|
||||||
@@ -108,7 +194,6 @@ export default {
|
|||||||
fillMan() {
|
fillMan() {
|
||||||
this.form.command = '慢单'
|
this.form.command = '慢单'
|
||||||
},
|
},
|
||||||
|
|
||||||
clearAll() {
|
clearAll() {
|
||||||
this.form.command = ''
|
this.form.command = ''
|
||||||
this.resultList = []
|
this.resultList = []
|
||||||
@@ -121,6 +206,94 @@ export default {
|
|||||||
.box-card { margin: 20px; }
|
.box-card { margin: 20px; }
|
||||||
.msg-block { margin-bottom: 12px; }
|
.msg-block { margin-bottom: 12px; }
|
||||||
.msg-header { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
|
.msg-header { display: flex; align-items: center; justify-content: space-between; margin: 6px 0; }
|
||||||
|
|
||||||
|
/* 历史消息容器 */
|
||||||
|
.history-container {
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-column {
|
||||||
|
flex: 1;
|
||||||
|
border: 1px solid #DCDFE6;
|
||||||
|
border-radius: 4px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 12px 16px;
|
||||||
|
background-color: #F5F7FA;
|
||||||
|
border-bottom: 1px solid #DCDFE6;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #303133;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-content {
|
||||||
|
height: 500px;
|
||||||
|
overflow-y: auto;
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty-history {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-list {
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-item {
|
||||||
|
padding: 10px 12px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
background-color: #F9FAFC;
|
||||||
|
border-left: 3px solid #409EFF;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-item:hover {
|
||||||
|
background-color: #ECF5FF;
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-time {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #909399;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-text {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #303133;
|
||||||
|
line-height: 1.5;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
word-break: break-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 滚动条美化 */
|
||||||
|
.history-content::-webkit-scrollbar {
|
||||||
|
width: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-content::-webkit-scrollbar-track {
|
||||||
|
background: #F5F7FA;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-content::-webkit-scrollbar-thumb {
|
||||||
|
background: #DCDFE6;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.history-content::-webkit-scrollbar-thumb:hover {
|
||||||
|
background: #C0C4CC;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user