Compare commits
3 Commits
65653525a0
...
af9c3c7c28
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
af9c3c7c28 | ||
|
|
fe0a36e446 | ||
|
|
6f9f129883 |
@ -78,8 +78,6 @@ const sendMessage = () => {
|
|||||||
// 否则发送新消息
|
// 否则发送新消息
|
||||||
if (!inputMessage.value.trim()) return;
|
if (!inputMessage.value.trim()) return;
|
||||||
emit('send', inputMessage.value)
|
emit('send', inputMessage.value)
|
||||||
inputMessage.value = ''
|
|
||||||
emit('update:inputMessage', inputMessage.value)
|
|
||||||
|
|
||||||
// 发送后保持焦点(可选)
|
// 发送后保持焦点(可选)
|
||||||
if (props.holdKeyboard && textareaRef.value) {
|
if (props.holdKeyboard && textareaRef.value) {
|
||||||
|
|||||||
@ -235,9 +235,6 @@
|
|||||||
if (!inputText.trim()) return;
|
if (!inputText.trim()) return;
|
||||||
handleNoHideKeyboard()
|
handleNoHideKeyboard()
|
||||||
sendMessage(inputText)
|
sendMessage(inputText)
|
||||||
if(!isSessionActive.value) {
|
|
||||||
inputMessage.value = ''
|
|
||||||
}
|
|
||||||
// 发送消息后保持键盘状态
|
// 发送消息后保持键盘状态
|
||||||
if (holdKeyboard.value && inputAreaRef.value) {
|
if (holdKeyboard.value && inputAreaRef.value) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -343,6 +340,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
chatMsgList.value.push(newMsg)
|
chatMsgList.value.push(newMsg)
|
||||||
|
inputMessage.value = '';
|
||||||
sendChat(message, isInstruct)
|
sendChat(message, isInstruct)
|
||||||
console.log("发送的新消息:",JSON.stringify(newMsg))
|
console.log("发送的新消息:",JSON.stringify(newMsg))
|
||||||
}
|
}
|
||||||
@ -466,7 +464,7 @@
|
|||||||
console.log('请求完成');
|
console.log('请求完成');
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
isSessionActive.value = false; // 出错也允许再次发送
|
isSessionActive.value = false; // 出错也允许再次发送
|
||||||
console.log('error:', err)
|
console.log('error:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 打字机函数
|
// 打字机函数
|
||||||
@ -490,6 +488,9 @@
|
|||||||
// 停止请求函数
|
// 停止请求函数
|
||||||
const stopRequest = () => {
|
const stopRequest = () => {
|
||||||
if (requestTaskRef.value && requestTaskRef.value.abort) {
|
if (requestTaskRef.value && requestTaskRef.value.abort) {
|
||||||
|
// 标记请求已中止,用于过滤后续可能到达的数据
|
||||||
|
requestTaskRef.value.isAborted = true;
|
||||||
|
// 中止请求
|
||||||
requestTaskRef.value.abort();
|
requestTaskRef.value.abort();
|
||||||
// 重置状态
|
// 重置状态
|
||||||
isSessionActive.value = false;
|
isSessionActive.value = false;
|
||||||
@ -507,6 +508,8 @@
|
|||||||
typeWriterTimer = null;
|
typeWriterTimer = null;
|
||||||
}
|
}
|
||||||
setTimeoutScrollToBottom()
|
setTimeoutScrollToBottom()
|
||||||
|
// 清空请求引用
|
||||||
|
requestTaskRef.value = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -59,7 +59,8 @@ function agentChatStream(params, onChunk) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
requestTask.onChunkReceived(res => {
|
requestTask.onChunkReceived(res => {
|
||||||
if (hasError) return;
|
// 检查请求是否已被中止
|
||||||
|
if (hasError || requestTask.isAborted) return;
|
||||||
const base64 = uni.arrayBufferToBase64(res.data);
|
const base64 = uni.arrayBufferToBase64(res.data);
|
||||||
let data = '';
|
let data = '';
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
import { BASE_URL } from "../../constant/base";
|
import { BASE_URL } from "../../constant/base";
|
||||||
|
import { goLogin } from "@/hooks/useGoLogin";
|
||||||
|
|
||||||
const defaultConfig = {
|
const defaultConfig = {
|
||||||
header: {
|
header: {
|
||||||
@ -49,6 +50,10 @@ function request(url, args = {}, method = 'POST', customConfig = {}) {
|
|||||||
success: (res) => {
|
success: (res) => {
|
||||||
console.log("请求响应:" + JSON.stringify(res))
|
console.log("请求响应:" + JSON.stringify(res))
|
||||||
resolve(res.data)
|
resolve(res.data)
|
||||||
|
if(res.statusCode && res.statusCode === 424) {
|
||||||
|
uni.setStorageSync('token', '')
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
console.error("请求失败:", err);
|
console.error("请求失败:", err);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user