可信代码库-AI大模型对话刷新、复制、点赞、点踩功能开发

This commit is contained in:
付民康
2025-07-01 17:03:24 +08:00
parent f496b3a3be
commit df692cbda4
2 changed files with 15 additions and 10 deletions

View File

@@ -40,7 +40,7 @@ const $Decrypt = (text) => {
// 尝试解析为JSON对象
return JSON.parse(originalText);
} catch (e) {
console.error('解密失败:', e);
// console.error('解密失败:', e);
return text; // 解密失败返回原始数据
}
};
@@ -199,6 +199,7 @@ const proxyService = (params: any, customConfigs?: CustomConfigs) => {
// response 拦截器
service.interceptors.response.use(
(response) => {
debugger
response.data.data = $Decrypt(response.data.data)
return response;
},

View File

@@ -53,10 +53,10 @@
<Other v-else :content="msg.content"></Other>
<div class="bubble-bottom-operations">
<img onclick="handleRefresh()" src="@/assets/imgs/jyh/ai/icon_generate.png" />
<i class="icon-file" title="复制" onclick="handleFile()"></i>
<img style="cursor: pointer" @click="()=>handleRefresh(idx)" src="@/assets/imgs/jyh/ai/icon_generate.png" />
<i class="icon-copy-new" title="复制" @click="()=>handleFile(idx)"></i>
<i :class="msg.islike==='like'?'icon-like-solid':'icon-like'" title="点赞" @click="() => handleLike(idx, 'like')" ></i>
<i :class="msg.islike==='dislike'?'icon-dislike-solid':'icon-dislike'" class="icon-dislike" title="踩" @click="() => handleLike(idx, 'dislike')" ></i>
<i :class="msg.islike==='dislike'?'icon-like-solid icon-dislike-solid':'icon-dislike'" title="踩" @click="() => handleLike(idx, 'dislike')" ></i>
<!-- <i class="icon-clever-customer" title="智能客服" onclick="handleCustomerService()"></i>-->
<!-- <i class="icon-more-operate" title="更多操作" onclick="handleMore()"></i>-->
</div>
@@ -276,16 +276,16 @@ const onSubmit = async (e, answer = undefined) => {
// 刷新回答(重新发送上一个用户问题)
const handleRefresh = (index: number) => {
const currentMsg = messages.value[index];
if (currentMsg.role === 'ai-model' && currentMsg.question) { // 假设AI回答的question字段存储了用户原始问题
onSubmit(currentMsg.question); // 调用原有发送方法
const currentMsg = messages.value[index-1];
if (currentMsg.role === 'user' && currentMsg.content) { // 假设AI回答的question字段存储了用户原始问题
onSubmit(currentMsg.content); // 调用原有发送方法
}
};
// 复制回答内容
const handleFile = (index: number) => {
const currentMsg = messages.value[index];
if (currentMsg.role === 'ai-model') {
if (currentMsg.role === 'ai-model' || currentMsg.role === 'system') {
const content = currentMsg.content || '';
// 处理富文本或特殊格式(示例中直接提取文本)
const textContent = typeof content === 'string' ? content : JSON.stringify(content);
@@ -305,8 +305,8 @@ const handleFile = (index: number) => {
// 点赞/点踩处理
const handleLike = (index: number, type: 'like' | 'dislike') => {
const currentMsg = messages.value[index];
if (currentMsg.role === 'ai-model' && currentMsg.id) { // 假设消息有唯一ID
messages.value[currentMsg.id].islike = type;
if (currentMsg.role === 'ai-model' || currentMsg.role === 'system') {
messages.value[index].islike = type;
// // 调用接口示例中需替换为实际API
// axios.post('/api/rateConversation', {
@@ -1077,4 +1077,8 @@ onMounted(() => {
}
}
}
.icon-dislike-solid {
transform: scaleX(-1) rotate(180deg);
}
</style>