Browse Source

优化deepmate的思考过程,添加用户头像

lihuilin/feature-20251024095243-我的
wangyi 3 weeks ago
parent
commit
f213fdea1d
  1. 75
      pages/deepMate/deepMate.vue

75
pages/deepMate/deepMate.vue

@ -129,13 +129,24 @@
"
>
<!-- 会话图标 -->
<text
<!-- <text
:class="
message.isUser
? 'fa-solid fa-user message-icon'
: 'fa-solid fa-robot message-icon'
"
></text>
></text> -->
<image
v-if="message.isUser"
class="message-icon"
:src="userAvatar"
mode="scaleToFill"
/><image
v-else
class="message-icon"
src="/static/icons/robot.svg"
mode="scaleToFill"
/>
<!-- 会话内容 -->
<view class="message-content">
<!-- <text class="message-text">{{ message.content }}</text> -->
@ -299,6 +310,8 @@ import {
postHistoryDetail,
} from "../../api/deepMate/deepMate";
import { useUserStore } from "../../stores/modules/userInfo";
const renderer = new marked.Renderer();
renderer.heading = function (text, level) {
return `<p>${text}</p>`;
@ -335,41 +348,20 @@ const drawerOffsetY = ref(0);
const searchHistory = ref([]);
const historyList = ref([]);
const hotTopics = ref([
{
id: 1,
text: "英伟达(NVDA)股票情绪温度?",
icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
},
{
id: 2,
text: "博通(AVGO)明天还能涨吗?",
icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
},
{
id: 3,
text: "为什么Fluence Energy(FLNC)会暴涨?",
icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
},
{
id: 4,
text: "为什么Fluence Energy(FLNC)会暴涨?",
icon: "https://d31zlh4on95l9h.cloudfront.net/images/7ed58be0f4b81aeb398d9ba2534a624b.svg",
},
]);
//
onLoad((options) => {
console.log('deepMate页面接收到参数:', options);
console.log("deepMate页面接收到参数:", options);
// query
if (options.query) {
const decodedQuery = decodeURIComponent(options.query);
console.log('解码后的查询内容:', decodedQuery);
console.log("解码后的查询内容:", decodedQuery);
//
inputMessage.value = decodedQuery;
//
setTimeout(() => {
sendMessage();
@ -526,6 +518,12 @@ const formatTimeForHistory = (timeString) => {
return timeString;
};
const userStore = useUserStore();
//
const userAvatar = computed(() => {
return userStore.userInfo.avatar;
});
// ///
const groupedHistory = computed(() => {
const sections = [];
@ -656,9 +654,8 @@ const simulateBotResponse = async (userMessage) => {
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q",
});
} catch (error) {
} finally {
isSending.value = false;
} finally {
}
console.log("res" + res);
@ -768,7 +765,9 @@ const simulateBotResponse = async (userMessage) => {
messages.value[messages.value.length - 1].isSecond = true;
messages.value[messages.value.length - 1].isThinking = false;
setTimeout(() => {
messages.value[messages.value.length - 1].isThinking = false;
}, 500);
//
nextTick(() => {
@ -780,7 +779,7 @@ const simulateBotResponse = async (userMessage) => {
let index = 0;
const botIndex = messages.value.length - 1;
const baseDelay = 165; //
const baseDelay = 5; //
const slowPunct = /[。!?!?;;]/; //
const midPunct = /[,、,::]/; //
@ -1269,25 +1268,25 @@ async function itemClick(item) {
.message-icon {
font-size: 24rpx;
margin: 0 10rpx;
padding: 10rpx;
/* padding: 10rpx; */
border-radius: 50%;
background-color: #ddd;
width: 40rpx;
height: 40rpx;
width: 60rpx;
height: 60rpx;
display: flex;
align-items: center;
justify-content: center;
}
.user-message .message-icon {
background-color: #007aff;
/* background-color: #007aff; */
border-radius: 50%;
color: #fff;
/* box-shadow: 0 0 12rpx rgba(0, 122, 255, 0.4); */
}
.bot-message .message-icon {
background: url("/static/images/robot (1).svg");
/* background: url("/static/images/robot (1).svg"); */
color: white;
}

Loading…
Cancel
Save