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