update:下载智能体的聊天记录

This commit is contained in:
hrz
2025-10-01 01:24:13 +08:00
parent ed07793c47
commit 5b4d79902f
15 changed files with 362 additions and 21 deletions
+27 -11
View File
@@ -1,5 +1,5 @@
import RequestService from '../httpRequest';
import { getServiceUrl } from '../api';
import RequestService from '../httpRequest';
export default {
@@ -97,7 +97,7 @@ export default {
});
}).send();
},
// 新增:获取智能体模板分页列表
getAgentTemplatesPage(params, callback) {
RequestService.sendRequest()
@@ -208,7 +208,7 @@ export default {
}).send();
},
// 获取指定智能体声纹列表
getAgentVoicePrintList(id,callback) {
getAgentVoicePrintList(id, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/voice-print/list/${id}`)
.method('GET')
@@ -218,7 +218,7 @@ export default {
})
.networkFail(() => {
RequestService.reAjaxFun(() => {
this.getAgentVoicePrintList(id,callback);
this.getAgentVoicePrintList(id, callback);
});
}).send();
},
@@ -254,7 +254,7 @@ export default {
}).send();
},
// 获取指定智能体用户类型聊天记录
getRecentlyFiftyByAgentId(id,callback) {
getRecentlyFiftyByAgentId(id, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${id}/chat-history/user`)
.method('GET')
@@ -264,12 +264,12 @@ export default {
})
.networkFail(() => {
RequestService.reAjaxFun(() => {
this.getRecentlyFiftyByAgentId(id,callback);
this.getRecentlyFiftyByAgentId(id, callback);
});
}).send();
},
// 获取指定智能体用户类型聊天记录
getContentByAudioId(id,callback) {
getContentByAudioId(id, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/${id}/chat-history/audio`)
.method('GET')
@@ -279,7 +279,7 @@ export default {
})
.networkFail(() => {
RequestService.reAjaxFun(() => {
this.getContentByAudioId(id,callback);
this.getContentByAudioId(id, callback);
});
}).send();
},
@@ -300,7 +300,7 @@ export default {
});
}).send();
},
// 更新智能体模板
updateAgentTemplate(templateData, callback) {
RequestService.sendRequest()
@@ -317,7 +317,7 @@ export default {
});
}).send();
},
// 删除智能体模板
deleteAgentTemplate(id, callback) {
RequestService.sendRequest()
@@ -333,7 +333,7 @@ export default {
});
}).send();
},
// 批量删除智能体模板
batchDeleteAgentTemplate(ids, callback) {
RequestService.sendRequest()
@@ -366,4 +366,20 @@ export default {
});
}).send();
},
// 获取聊天记录下载链接UUID
getDownloadUrl(agentId, sessionId, callback) {
RequestService.sendRequest()
.url(`${getServiceUrl()}/agent/chat-history/getDownloadUrl/${agentId}/${sessionId}`)
.method('POST')
.success((res) => {
RequestService.clearRequestTime();
callback(res);
})
.networkFail(() => {
RequestService.reAjaxFun(() => {
this.getDownloadUrl(agentId, sessionId, callback);
});
}).send();
},
}
@@ -1,5 +1,6 @@
<template>
<el-dialog :title="$t('chatHistory.with') + agentName + $t('chatHistory.dialogTitle') + (currentMacAddress ? '[' + currentMacAddress + ']' : '')"
<el-dialog
:title="$t('chatHistory.with') + agentName + $t('chatHistory.dialogTitle') + (currentMacAddress ? '[' + currentMacAddress + ']' : '')"
:visible.sync="dialogVisible" width="80%" :before-close="handleClose" custom-class="chat-history-dialog">
<div class="chat-container">
<div class="session-list" @scroll="handleScroll">
@@ -36,6 +37,14 @@
</div>
</div>
</div>
<div v-if="currentSessionId" class="download-buttons">
<el-button type="primary" plain size="small" @click="downloadCurrentSessionWithPrevious">
{{ $t('chatHistory.downloadCurrentWithPreviousSessions') }}
</el-button>
<el-button type="primary" plain size="small" @click="downloadCurrentSession">
{{ $t('chatHistory.downloadCurrentSession') }}
</el-button>
</div>
</el-dialog>
</template>
@@ -292,6 +301,30 @@ export default {
// 返回对应的头像图片
return require(`@/assets/user-avatar${avatarIndex}.png`);
},
// 下载本会话聊天记录
downloadCurrentSession() {
Api.agent.getDownloadUrl(this.agentId, this.currentSessionId, (res) => {
if (res && res.data && res.data.code === 0 && res.data.data) {
const uuid = res.data.data;
window.open(`${Api.getServiceUrl()}/agent/chat-history/download/${uuid}/current`, '_blank');
} else {
this.$message.error(this.$t('chatHistory.downloadLinkFailed'));
}
});
},
// 下载本会话及前20条会话聊天记录
downloadCurrentSessionWithPrevious() {
Api.agent.getDownloadUrl(this.agentId, this.currentSessionId, (res) => {
if (res && res.data && res.data.code === 0 && res.data.data) {
const uuid = res.data.data;
window.open(`${Api.getServiceUrl()}/agent/chat-history/download/${uuid}/previous`, '_blank');
} else {
this.$message.error(this.$t('chatHistory.downloadLinkFailed'));
}
});
}
}
};
@@ -441,6 +474,22 @@ export default {
vertical-align: middle;
margin: 0 10px;
}
.download-buttons {
padding: 20px;
display: flex;
gap: 10px;
border-top: 1px solid #eee;
position: absolute;
bottom: 0;
left: 0;
right: 0;
background-color: white;
}
.download-buttons .el-button {
flex: 1;
}
</style>
<style>
@@ -453,7 +502,7 @@ export default {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
height: 90vh;
height: 98vh;
max-width: 85vw;
border-radius: 12px;
overflow: hidden;
+3
View File
@@ -500,6 +500,9 @@ export default {
'chatHistory.selectSession': 'Please select a session to view chat history',
'chatHistory.today': 'Today',
'chatHistory.yesterday': 'Yesterday',
'chatHistory.downloadCurrentSession': 'Download current session chat history',
'chatHistory.downloadCurrentWithPreviousSessions': 'Download current and previous 20 sessions chat history',
'chatHistory.downloadLinkFailed': 'Failed to get download link',
'cache.status': 'Cache Status',
'cache.cdnEnabled': 'CDN Mode Enabled',
'cache.cdnDisabled': 'CDN Mode Disabled',
+3
View File
@@ -500,6 +500,9 @@ export default {
'chatHistory.selectSession': '请选择会话查看聊天记录',
'chatHistory.today': '今天',
'chatHistory.yesterday': '昨天',
'chatHistory.downloadCurrentSession': '下载本会话聊天记录',
'chatHistory.downloadCurrentWithPreviousSessions': '下载本会话及前20条会话聊天记录',
'chatHistory.downloadLinkFailed': '获取下载链接失败',
'cache.status': '缓存状态',
'cache.cdnEnabled': 'CDN模式已启用',
'cache.cdnDisabled': 'CDN模式已禁用',
+3
View File
@@ -500,6 +500,9 @@ export default {
'chatHistory.selectSession': '請選擇會話查看聊天記錄',
'chatHistory.today': '今天',
'chatHistory.yesterday': '昨天',
'chatHistory.downloadCurrentSession': '下載本會話聊天記錄',
'chatHistory.downloadCurrentWithPreviousSessions': '下載本會話及前20條會話聊天記錄',
'chatHistory.downloadLinkFailed': '獲取下載鏈接失敗',
'cache.status': '緩存狀態',
'cache.cdnEnabled': 'CDN模式已啟用',
'cache.cdnDisabled': 'CDN模式已禁用',
@@ -30,8 +30,9 @@
show-overflow-tooltip>
<template slot-scope="scope">
<div v-if="isSensitiveParam(scope.row.paramCode)">
<span v-if="!scope.row.showValue">{{ maskSensitiveValue(scope.row.paramValue)
}}</span>
<span v-if="!scope.row.showValue">
{{ maskSensitiveValue(scope.row.paramValue) }}
</span>
<span v-else>{{ scope.row.paramValue }}</span>
<el-button size="mini" type="text" @click="toggleSensitiveValue(scope.row)">
{{ scope.row.showValue ? $t('paramManagement.hide') :
@@ -120,7 +121,7 @@ export default {
dialogVisible: false,
dialogTitle: "新增参数",
isAllSelected: false,
sensitive_keys: ["api_key", "personal_access_token", "access_token", "token", "secret", "access_key_secret", "secret_key"],
sensitive_keys: ["api_key", "personal_access_token", "access_token", "token", "secret", "access_key_secret", "secret_key", "password", "mqtt_signature_key", "private_key"],
paramForm: {
id: null,
paramCode: "",