|
|
|
@ -287,7 +287,7 @@ |
|
|
|
:key="sIdx" |
|
|
|
class="history-section" |
|
|
|
> |
|
|
|
<text class="section-title">{{ section.title }}</text> |
|
|
|
<text class="section-title">{{ section.stockName }}</text> |
|
|
|
<view |
|
|
|
v-for="(item, idx) in section.items" |
|
|
|
:key="idx" |
|
|
|
@ -455,8 +455,8 @@ const goBlank = () => { |
|
|
|
}; |
|
|
|
|
|
|
|
// 历史抽屉控制 |
|
|
|
const openHistoryDrawer = () => { |
|
|
|
const res = postHistory({ |
|
|
|
const openHistoryDrawer = async() => { |
|
|
|
const res = await postHistory({ |
|
|
|
model: 5, |
|
|
|
}); |
|
|
|
|
|
|
|
@ -604,18 +604,67 @@ const simulateBotResponse = async (userMessage) => { |
|
|
|
// 首先进行意图识别 |
|
|
|
const res = await postIntent({ |
|
|
|
content: userMessage, |
|
|
|
language: 'cn', |
|
|
|
marketList: 'hk,cn,usa,my,sg,vi,in,gb', |
|
|
|
token: "pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", |
|
|
|
language: "cn", |
|
|
|
marketList: "hk,cn,usa,my,sg,vi,in,gb", |
|
|
|
token: |
|
|
|
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", |
|
|
|
}); |
|
|
|
|
|
|
|
console.log("res" + res); |
|
|
|
|
|
|
|
// 意图识别不通过 |
|
|
|
if (res.code !== 200) { |
|
|
|
console.log("未通过意图识别"); |
|
|
|
|
|
|
|
// 更新机器人的消息内容 |
|
|
|
const errorMessage = res.message || "请求失败,请稍后重试"; |
|
|
|
let responseText = `我已经收到您的消息: "${userMessage}"。错误信息: "${errorMessage}"`; |
|
|
|
|
|
|
|
// 开始打字机效果显示错误信息 |
|
|
|
let index = 0; |
|
|
|
const botIndex = messages.value.length - 1; |
|
|
|
|
|
|
|
const typeWriter = () => { |
|
|
|
if (index < responseText.length) { |
|
|
|
const ch = responseText.charAt(index); |
|
|
|
const current = messages.value[botIndex]; |
|
|
|
// 通过数组替换触发渲染,避免部分平台对子项属性变更不响应 |
|
|
|
messages.value.splice(botIndex, 1, { |
|
|
|
...current, |
|
|
|
content: current.content + ch, |
|
|
|
isTyping: true, |
|
|
|
}); |
|
|
|
index++; |
|
|
|
scrollToBottom(); |
|
|
|
|
|
|
|
// 字符间延迟,模拟打字效果 |
|
|
|
const baseDelay = 5; // 普通字符基础延迟(毫秒) |
|
|
|
const slowPunct = /[。!?!?;;]/; // 句号、感叹号、分号等较长停顿 |
|
|
|
const midPunct = /[,、,::]/; // 逗号、顿号、冒号等中等停顿 |
|
|
|
const delay = slowPunct.test(ch) |
|
|
|
? 220 |
|
|
|
: midPunct.test(ch) |
|
|
|
? 120 |
|
|
|
: baseDelay; |
|
|
|
setTimeout(typeWriter, delay); |
|
|
|
} else { |
|
|
|
// 打字完成,更新状态 |
|
|
|
const current = messages.value[botIndex]; |
|
|
|
messages.value.splice(botIndex, 1, { ...current, isTyping: false }); |
|
|
|
isSending.value = false; |
|
|
|
nextTick(() => { |
|
|
|
scrollToBottom(); |
|
|
|
}); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 启动打字机效果 |
|
|
|
setTimeout(typeWriter, 300); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
console.log("通过意图识别"); |
|
|
|
|
|
|
|
// 获取意图识别结果 |
|
|
|
const recordId = res.data.recordId; |
|
|
|
const parentId = res.data.parentId; |
|
|
|
@ -623,10 +672,11 @@ const simulateBotResponse = async (userMessage) => { |
|
|
|
|
|
|
|
// 获取股票信息 |
|
|
|
const StockInfo = await postStock({ |
|
|
|
recordId: "42", |
|
|
|
parentId: "0", |
|
|
|
stockId:"42", |
|
|
|
token: memberStore.userInfo?.token || '', |
|
|
|
recordId: recordId, |
|
|
|
parentId: parentId, |
|
|
|
stockId: stockId, |
|
|
|
token: |
|
|
|
"pCtw6AYK0EHAaIexoFHsbZjtsfEAIhcmwkCFm6uKko8VPfMvyDiODL9v9c0veic9fIpQbvT8zN4sH/Si6Q", |
|
|
|
language: "cn", |
|
|
|
}); |
|
|
|
console.log("StockInfo", StockInfo); |
|
|
|
@ -635,7 +685,7 @@ const simulateBotResponse = async (userMessage) => { |
|
|
|
// return ; |
|
|
|
// } |
|
|
|
|
|
|
|
const markdown = StockInfo.markdown; |
|
|
|
const markdown = StockInfo.data.markdown; |
|
|
|
console.log("StockInfo", StockInfo); |
|
|
|
|
|
|
|
// 添加请求延迟 |
|
|
|
|