ai对话分页

This commit is contained in:
2026-08-05 11:42:57 +08:00
parent fbda01a624
commit e0d7f93c80
5 changed files with 799 additions and 105 deletions

View File

@@ -122,7 +122,11 @@
<view class="main-chat"> <view class="main-chat">
<scroll-view class="chat-messages" direction="vertical" scroll-y :scroll-into-view="scrollToView" <scroll-view class="chat-messages" direction="vertical" scroll-y :scroll-into-view="scrollToView"
:upper-threshold="0" :scroll-with-animation="!isThinking" @scroll="onScroll"> :upper-threshold="50" :scroll-with-animation="!isThinking" @scroll="onScroll" @scrolltoupper="onScrollToUpper">
<!-- 加载更多提示AI 会话 -->
<view v-if="ChatType === 0 && isAILoadingMore" class="load-more-tip">
<text>加载更多消息...</text>
</view>
<!-- 消息加载中弹窗仅会话变化时显示 --> <!-- 消息加载中弹窗仅会话变化时显示 -->
<view v-if="isLoadingMessages" class="messages-loading-overlay"> <view v-if="isLoadingMessages" class="messages-loading-overlay">
<view class="messages-loading-card"> <view class="messages-loading-card">
@@ -1685,7 +1689,11 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
const bottomToggle = ref(false) const bottomToggle = ref(false)
// 加载状态和分页相关变量 // 加载状态和分页相关变量
const isLoadingMore = ref(false) // 是否正在加载更多 const isLoadingMore = ref(false) // 是否正在加载更多
const isAILoadingMore = ref(false) // AI 会话是否正在加载更多(滚动到顶部触发)
const aiPageNumber = ref(0) // AI 会话当前服务端页码0-based
const hasMoreAIMessages = ref(true) // AI 会话是否还有更多消息可加载
const currentPage = ref(1) // 当前页码(如果后端支持分页) const currentPage = ref(1) // 当前页码(如果后端支持分页)
const pageSize = 200;
// 计算属性:自动根据 allmessages 和 currentPage 计算显示消息 // 计算属性:自动根据 allmessages 和 currentPage 计算显示消息
const currentMessages = computed(() => { const currentMessages = computed(() => {
// return allmessages.value.slice(-pageInfoNumber); // return allmessages.value.slice(-pageInfoNumber);
@@ -1696,8 +1704,12 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
// 获取对话消息 // 获取对话消息
const takeConversationMessages = async () => { const takeConversationMessages = async () => {
try { try {
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || []; aiPageNumber.value = 0
// console.log("获取到的所有消息:", JSON.stringify(allmessages.value) ); hasMoreAIMessages.value = true
const rawMessages = await getConversationMessages(userToken.value, currentSessionId.value, pageSize, 0) || [];
// API 返回的数据已被过滤,无法通过数量判断是否有更多,始终尝试加载更多
allmessages.value = rawMessages
console.log("获取到的所有消息:", JSON.stringify(allmessages.value) );
// console.log("获取到的所有消息:", allmessages.value); // console.log("获取到的所有消息:", allmessages.value);
// currentMessages.value = allmessages.value.slice(-pageInfoNumber); // currentMessages.value = allmessages.value.slice(-pageInfoNumber);
// 数据获取后执行滚动 // 数据获取后执行滚动
@@ -1766,7 +1778,39 @@ import { openFile as openFileNative, downloadAndOpen } from '@/utils/fileOpener.
// // currentMessages.value = allmessages.value.slice(-pageInfoNumber); // // currentMessages.value = allmessages.value.slice(-pageInfoNumber);
// } // }
// 滚动到顶部时加载更多 AI 消息
const onScrollToUpper = async () => {
if (ChatType.value === 0) {
await loadMoreAIMessages()
}
}
// 加载更多 AI 历史消息(上一页),并定位到原第一条消息
const loadMoreAIMessages = async () => {
if (isAILoadingMore.value || !hasMoreAIMessages.value || !currentSessionId.value) return
isAILoadingMore.value = true
try {
const nextPage = aiPageNumber.value + 1
const olderMessages = await getConversationMessages(userToken.value, currentSessionId.value, pageSize, nextPage)
if (olderMessages && olderMessages.length > 0) {
aiPageNumber.value = nextPage
allmessages.value = [...olderMessages, ...allmessages.value]
// 定位滚动原本第一条消息old index 0现在在 index = olderMessages.length 处
await nextTick()
scrollToView.value = 'msg-' + olderMessages.length
} else {
// 只有 API 返回空时才确认没有更多
hasMoreAIMessages.value = false
}
} catch (e) {
console.error('加载更多消息失败:', e)
uni.showToast({ title: '加载更多失败', icon: 'none' })
} finally {
isAILoadingMore.value = false
}
}
// 监听滚动 // 监听滚动
const onScroll = (e) => {} const onScroll = (e) => {}

View File

@@ -88,7 +88,11 @@ if (uni.restoreGlobal) {
} }
} else { } else {
if (String(res.statusCode).startsWith("5")) { if (String(res.statusCode).startsWith("5")) {
reject({ serverError: true, code: res.statusCode, message: "服务器升级中,请稍后再试" }); reject({
serverError: true,
code: res.statusCode,
message: "服务器升级中,请稍后再试"
});
} else { } else {
reject(`请求失败:${res.statusCode}`); reject(`请求失败:${res.statusCode}`);
} }
@@ -127,15 +131,16 @@ if (uni.restoreGlobal) {
}); });
}); });
}; };
const getConversationMessages = async (token, conversatio_id) => { const getConversationMessages = async (token, conversation_id, size, page_number) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
url: `${BASE_URL$1}/get_conversation_messages`, url: `${BASE_URL$1}/get_conversation_messages`,
method: "POST", method: "POST",
data: { data: {
"access_token": token, "access_token": token,
"login_type": "phone", "conversation_id": conversation_id,
"conversation_id": conversatio_id "size": 20,
"current": page_number
}, },
header: { header: {
"Content-Type": "application/json" "Content-Type": "application/json"
@@ -144,7 +149,8 @@ if (uni.restoreGlobal) {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const messagesInfo = res.data; const messagesInfo = res.data;
if (messagesInfo) { if (messagesInfo) {
formatAppLog("log", "at utils/cloud-api.js:93", "工作区id为", messagesInfo.workspace_id || "(无)"); formatAppLog("log", "at utils/cloud-api.js:98", "返回数据为", messagesInfo);
formatAppLog("log", "at utils/cloud-api.js:99", "工作区id为", messagesInfo.workspace_id || "(无)");
if (messagesInfo.workspace_id) { if (messagesInfo.workspace_id) {
uni.setStorageSync("workspace_id", messagesInfo.workspace_id); uni.setStorageSync("workspace_id", messagesInfo.workspace_id);
} }
@@ -564,7 +570,11 @@ if (uni.restoreGlobal) {
uri: fileUri uri: fileUri
}; };
}); });
formatAppLog("log", "at utils/cloud-api.js:595", "uploadFileToShortStorage 参数:", { workspacesId, fileCount: uploadFiles.length, filePath }); formatAppLog("log", "at utils/cloud-api.js:602", "uploadFileToShortStorage 参数:", {
workspacesId,
fileCount: uploadFiles.length,
filePath
});
uni.uploadFile({ uni.uploadFile({
url: `${BASE_URL$1}/cloud_api/file/temp/upload`, url: `${BASE_URL$1}/cloud_api/file/temp/upload`,
method: "POST", method: "POST",
@@ -575,14 +585,17 @@ if (uni.restoreGlobal) {
}, },
files: uploadFiles, files: uploadFiles,
success: (res) => { success: (res) => {
formatAppLog("log", "at utils/cloud-api.js:607", "uploadFileToShortStorage 响应状态:", res.statusCode, "数据:", res.data); formatAppLog("log", "at utils/cloud-api.js:618", "uploadFileToShortStorage 响应状态:", res.statusCode, "数据:", res.data);
if (res.statusCode === 200) { if (res.statusCode === 200) {
try { try {
const respond = JSON.parse(res.data); const respond = JSON.parse(res.data);
if (Array.isArray(respond) && respond.length > 0) { if (Array.isArray(respond) && respond.length > 0) {
resolve(respond); resolve(respond);
} else if (respond.success) { } else if (respond.success) {
resolve([{ url: respond.url || respond.message, success: true }]); resolve([{
url: respond.url || respond.message,
success: true
}]);
} else { } else {
const msg = (respond == null ? void 0 : respond.error) || (respond == null ? void 0 : respond.message) || "上传文件到短存云端获取URL出错啦"; const msg = (respond == null ? void 0 : respond.error) || (respond == null ? void 0 : respond.message) || "上传文件到短存云端获取URL出错啦";
reject(msg); reject(msg);
@@ -1532,7 +1545,7 @@ if (uni.restoreGlobal) {
success: (res) => { success: (res) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const respond = res.data; const respond = res.data;
formatAppLog("log", "at utils/cloud-api.js:1703", respond); formatAppLog("log", "at utils/cloud-api.js:1718", respond);
if (respond.local_success) { if (respond.local_success) {
resolve(respond.url || respond.download_url || respond.data || respond); resolve(respond.url || respond.download_url || respond.data || respond);
} else { } else {
@@ -1550,6 +1563,33 @@ if (uni.restoreGlobal) {
}); });
}); });
}; };
const getAgentList = (token) => {
return new Promise((resolve, reject) => {
uni.request({
url: `${BASE_URL$1}/cloud_api/agent/list`,
method: "POST",
header: {
"Content-Type": "application/json"
},
data: {
"access_token": token
},
success: (res) => {
if (res.statusCode === 200) {
const respond = res.data;
if (respond.success) {
resolve(respond.data);
} else {
const msg = "获取智能体列表出错啦";
reject(msg);
}
} else {
reject(`获取智能体列表失败:${res.statusCode}`);
}
}
});
});
};
const _export_sfc = (sfc, props) => { const _export_sfc = (sfc, props) => {
const target = sfc.__vccOpts || sfc; const target = sfc.__vccOpts || sfc;
for (const [key, val] of props) { for (const [key, val] of props) {
@@ -4680,6 +4720,7 @@ This will fail in production.`);
const logs = vue.ref([]); const logs = vue.ref([]);
const maxLogCount = vue.ref(20); const maxLogCount = vue.ref(20);
const authFailReason = vue.ref(""); const authFailReason = vue.ref("");
const pcOffline = vue.ref(false);
const isConnected = vue.computed(() => connectionStatus.value === "connected"); const isConnected = vue.computed(() => connectionStatus.value === "connected");
const isConnecting = vue.computed(() => connectionStatus.value === "connecting"); const isConnecting = vue.computed(() => connectionStatus.value === "connecting");
const isDisconnected = vue.computed(() => connectionStatus.value === "disconnected"); const isDisconnected = vue.computed(() => connectionStatus.value === "disconnected");
@@ -4696,7 +4737,7 @@ This will fail in production.`);
if (logs.value.length > maxLogCount.value) { if (logs.value.length > maxLogCount.value) {
logs.value = logs.value.slice(-maxLogCount.value); logs.value = logs.value.slice(-maxLogCount.value);
} }
formatAppLog("log", "at stores/socket.js:54", `[${type.toUpperCase()}] ${connect2}`); formatAppLog("log", "at stores/socket.js:55", `[${type.toUpperCase()}] ${connect2}`);
} }
function clearLogs() { function clearLogs() {
logs.value = []; logs.value = [];
@@ -4708,6 +4749,7 @@ This will fail in production.`);
...config.value, ...config.value,
...options ...options
}; };
pcOffline.value = false;
addLog( addLog(
"info", "info",
`准备连接WebSocket。Token:${config.value.token || "未设置"}。ConversationId: ${config.value.conversationId || "未设置"}` `准备连接WebSocket。Token:${config.value.token || "未设置"}。ConversationId: ${config.value.conversationId || "未设置"}`
@@ -4734,7 +4776,7 @@ This will fail in production.`);
addLog("warn", "已主动断开连接"); addLog("warn", "已主动断开连接");
} }
async function send(message) { async function send(message) {
formatAppLog("log", "at stores/socket.js:98", "检查到要发生消息为:", message); formatAppLog("log", "at stores/socket.js:100", "检查到要发生消息为:", message);
if (!isConnected.value) { if (!isConnected.value) {
addLog("error", "发送失败: 连接未建立"); addLog("error", "发送失败: 连接未建立");
throw new Error("连接未建立"); throw new Error("连接未建立");
@@ -4751,7 +4793,7 @@ This will fail in production.`);
function handleOpen() { function handleOpen() {
connectionStatus.value = "connected"; connectionStatus.value = "connected";
addLog("success", "连接成功!发送auth"); addLog("success", "连接成功!发送auth");
formatAppLog("log", "at stores/socket.js:117", "连接成功!发送auth"); formatAppLog("log", "at stores/socket.js:119", "连接成功!发送auth");
sendAuth(); sendAuth();
} }
function handleClose() { function handleClose() {
@@ -4785,7 +4827,7 @@ This will fail in production.`);
message_id, message_id,
data data
} = messageData || {}; } = messageData || {};
formatAppLog("log", "at stores/socket.js:162", `[handleMessage] type = ${type}, data = ${JSON.stringify(data)}`); formatAppLog("log", "at stores/socket.js:164", `[handleMessage] type = ${type}, data = ${JSON.stringify(data)}`);
switch (type) { switch (type) {
case "auth_ok": case "auth_ok":
addLog("success", "连接成功"); addLog("success", "连接成功");
@@ -4803,6 +4845,7 @@ This will fail in production.`);
handleBusinessMessage(data); handleBusinessMessage(data);
break; break;
case "pc_offline": case "pc_offline":
pcOffline.value = true;
addLog("warn", "PC 端已离线"); addLog("warn", "PC 端已离线");
break; break;
default: default:
@@ -4818,14 +4861,14 @@ This will fail in production.`);
} }
function handleBusinessMessage(data) { function handleBusinessMessage(data) {
if (data === "exit") { if (data === "exit") {
formatAppLog("log", "at stores/socket.js:224", "ai结束思考"); formatAppLog("log", "at stores/socket.js:227", "ai结束思考");
isThinking.value = false; isThinking.value = false;
return; return;
} }
if (!data || typeof data !== "object") if (!data || typeof data !== "object")
return; return;
if (data.cmd === "event_callback" && data.info === "中断成功") { if (data.cmd === "event_callback" && data.info === "中断成功") {
formatAppLog("log", "at stores/socket.js:234", "后端确认中断成功"); formatAppLog("log", "at stores/socket.js:237", "后端确认中断成功");
addLog("warn", `中断确认: ${data.info}`); addLog("warn", `中断确认: ${data.info}`);
isThinking.value = false; isThinking.value = false;
return; return;
@@ -4839,14 +4882,14 @@ This will fail in production.`);
task_call_id task_call_id
} = data; } = data;
if (!isThinking.value && (chunk || message_role === "assistant")) { if (!isThinking.value && (chunk || message_role === "assistant")) {
formatAppLog("log", "at stores/socket.js:251", "ai开始思考"); formatAppLog("log", "at stores/socket.js:254", "ai开始思考");
messageString.value = ""; messageString.value = "";
isThinking.value = true; isThinking.value = true;
} }
if (chunk) { if (chunk) {
messageString.value += chunk; messageString.value += chunk;
if (!isThinking.value) { if (!isThinking.value) {
formatAppLog("log", "at stores/socket.js:260", "修改状态为开始思考"); formatAppLog("log", "at stores/socket.js:263", "修改状态为开始思考");
isThinking.value = true; isThinking.value = true;
} }
} }
@@ -4868,6 +4911,7 @@ This will fail in production.`);
logs, logs,
config, config,
authFailReason, authFailReason,
pcOffline,
// 计算属性 // 计算属性
isConnected, isConnected,
isConnecting, isConnecting,
@@ -5714,6 +5758,7 @@ This will fail in production.`);
} }
}); });
} }
const pageSize = 200;
const _sfc_main$a = { const _sfc_main$a = {
__name: "Chat", __name: "Chat",
setup(__props, { expose: __expose }) { setup(__props, { expose: __expose }) {
@@ -5723,7 +5768,7 @@ This will fail in production.`);
if (friendSocketStore.isConnected) if (friendSocketStore.isConnected)
return; return;
if (!userToken.value || !UserId.value) { if (!userToken.value || !UserId.value) {
formatAppLog("warn", "at pages/Chat/Chat.vue:356", "Token或UserId未准备好"); formatAppLog("warn", "at pages/Chat/Chat.vue:408", "Token或UserId未准备好");
return; return;
} }
friendSocketStore.connect({ friendSocketStore.connect({
@@ -5920,7 +5965,7 @@ This will fail in production.`);
}); });
return html; return html;
} catch (e2) { } catch (e2) {
formatAppLog("error", "at pages/Chat/Chat.vue:564", "解析失败", e2); formatAppLog("error", "at pages/Chat/Chat.vue:616", "解析失败", e2);
return content; return content;
} }
}; };
@@ -5971,7 +6016,7 @@ This will fail in production.`);
files files
}; };
} catch (e2) { } catch (e2) {
formatAppLog("error", "at pages/Chat/Chat.vue:633", "解析文件信息失败:", e2); formatAppLog("error", "at pages/Chat/Chat.vue:685", "解析文件信息失败:", e2);
return { return {
textContent: content, textContent: content,
files: [] files: []
@@ -6009,7 +6054,7 @@ This will fail in production.`);
closeNewChatModal(); closeNewChatModal();
takeUserConversations(); takeUserConversations();
} catch (error) { } catch (error) {
formatAppLog("error", "at pages/Chat/Chat.vue:679", "新建普通会话失败:", error); formatAppLog("error", "at pages/Chat/Chat.vue:731", "新建普通会话失败:", error);
uni.showToast({ uni.showToast({
title: "创建会话失败,请重试", title: "创建会话失败,请重试",
icon: "none" icon: "none"
@@ -6020,6 +6065,35 @@ This will fail in production.`);
const closeNewChatModal = () => { const closeNewChatModal = () => {
showNewChatModal.value = false; showNewChatModal.value = false;
}; };
const showAgentModal = vue.ref(false);
const agentList = vue.ref([]);
const agentLoading = vue.ref(false);
const selectAgentChat = async () => {
try {
showNewChatModal.value = false;
showAgentModal.value = true;
agentLoading.value = true;
agentList.value = [];
const agents = await getAgentList(userToken.value);
if (agents && Array.isArray(agents)) {
agentList.value = agents;
} else {
uni.showToast({ title: "获取智能体列表失败", icon: "none" });
}
} catch (error) {
formatAppLog("error", "at pages/Chat/Chat.vue:763", "获取智能体列表失败:", error);
uni.showToast({ title: "获取智能体列表失败,请重试", icon: "none" });
} finally {
agentLoading.value = false;
}
};
const closeAgentModal = () => {
showAgentModal.value = false;
agentList.value = [];
};
const handleAgentSelect = async (agent) => {
formatAppLog("log", "at pages/Chat/Chat.vue:776", "点击了", agent.title);
};
const isChatSidebar = vue.ref(false); const isChatSidebar = vue.ref(false);
const handleChatSidebar = () => { const handleChatSidebar = () => {
isChatSidebar.value = !isChatSidebar.value; isChatSidebar.value = !isChatSidebar.value;
@@ -6050,9 +6124,62 @@ This will fail in production.`);
url: "/pages/Login/Login" url: "/pages/Login/Login"
}); });
}; };
const handleRefresh = async () => {
isThinking.value = false;
isSelfSent.value = false;
socketStore.isThinking = false;
textMessage.value = "";
uploadedFiles.value = [];
previewFileArray.value = [];
if (streamingMessageId.value) {
allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value);
streamingMessageId.value = null;
}
const titleMap = { 0: "AI消息", 1: "好友消息", 2: "群聊消息" };
const title = titleMap[ChatType.value] || "消息";
uni.showLoading({ title: `刷新${title}中...`, mask: true });
try {
const token = getToken();
if (!token) {
uni.hideLoading();
uni.showToast({ title: "登录已失效,请重新登录", icon: "none", duration: 1500 });
setTimeout(() => uni.reLaunch({ url: "/pages/Login/Login" }), 1500);
return;
}
await getUserInfo(token);
if (ChatType.value === 0 && !socketStore.isConnected) {
await handleConnect();
}
switch (ChatType.value) {
case 0:
await takeConversationMessages();
break;
case 1:
await takeFriendMessages();
break;
case 2:
await takeGroupMessages();
break;
default:
await takeConversationMessages();
break;
}
uni.hideLoading();
uni.showToast({ title: "已刷新", icon: "success", duration: 1200 });
} catch (e2) {
uni.hideLoading();
const errMsg2 = typeof e2 === "string" ? e2 : (e2 == null ? void 0 : e2.message) || "";
if (errMsg2.includes("token") || errMsg2.includes("Token") || errMsg2.includes("登录") || errMsg2.includes("过期")) {
uni.showToast({ title: "登录已失效,请重新登录", icon: "none", duration: 1500 });
setTimeout(() => uni.reLaunch({ url: "/pages/Login/Login" }), 1500);
} else {
uni.showToast({ title: "刷新失败", icon: "error", duration: 1500 });
}
}
};
const previewFileArray = vue.ref([]); const previewFileArray = vue.ref([]);
const uploadPhoto = () => { const uploadPhoto = () => {
formatAppLog("log", "at pages/Chat/Chat.vue:739", "点击了拍照上传"); formatAppLog("log", "at pages/Chat/Chat.vue:916", "点击了拍照上传");
uni.chooseImage({ uni.chooseImage({
count: 1, count: 1,
sourceType: ["camera", "album"], sourceType: ["camera", "album"],
@@ -6075,7 +6202,7 @@ This will fail in production.`);
}); });
}, },
fail: (err) => { fail: (err) => {
formatAppLog("error", "at pages/Chat/Chat.vue:757", "选择图片失败", err); formatAppLog("error", "at pages/Chat/Chat.vue:934", "选择图片失败", err);
} }
}); });
}; };
@@ -6084,12 +6211,12 @@ This will fail in production.`);
}; };
const fileList = vue.ref([]); const fileList = vue.ref([]);
const uploadFile = () => { const uploadFile = () => {
formatAppLog("log", "at pages/Chat/Chat.vue:768", "点击了上传文件"); formatAppLog("log", "at pages/Chat/Chat.vue:945", "点击了上传文件");
chooseFile({ chooseFile({
count: 5, count: 5,
type: "all", type: "all",
success: (res) => { success: (res) => {
formatAppLog("log", "at pages/Chat/Chat.vue:773", "成功了"); formatAppLog("log", "at pages/Chat/Chat.vue:950", "成功了");
fileList.value = res.tempFiles; fileList.value = res.tempFiles;
previewFileArray.value.push(...res.tempFiles); previewFileArray.value.push(...res.tempFiles);
uni.showToast({ uni.showToast({
@@ -6098,7 +6225,7 @@ This will fail in production.`);
}); });
}, },
fail: (err) => { fail: (err) => {
formatAppLog("error", "at pages/Chat/Chat.vue:784", "选择失败:", err); formatAppLog("error", "at pages/Chat/Chat.vue:961", "选择失败:", err);
uni.showToast({ uni.showToast({
title: "选择失败", title: "选择失败",
icon: "error" icon: "error"
@@ -6337,7 +6464,7 @@ This will fail in production.`);
previewFileArray.value = []; previewFileArray.value = [];
} catch (err) { } catch (err) {
uni.hideLoading(); uni.hideLoading();
formatAppLog("error", "at pages/Chat/Chat.vue:1059", "文件上传失败:", err); formatAppLog("error", "at pages/Chat/Chat.vue:1236", "文件上传失败:", err);
uni.showToast({ uni.showToast({
title: "文件上传失败,请重试", title: "文件上传失败,请重试",
icon: "error" icon: "error"
@@ -6471,15 +6598,15 @@ This will fail in production.`);
} }
}; };
const stopConversation = async () => { const stopConversation = async () => {
formatAppLog("log", "at pages/Chat/Chat.vue:1229", "中断对话 - 当前会话ID:", currentSessionId.value); formatAppLog("log", "at pages/Chat/Chat.vue:1406", "中断对话 - 当前会话ID:", currentSessionId.value);
try { try {
await socketStore.send({ await socketStore.send({
type: "stop", type: "stop",
conversation_id: currentSessionId.value conversation_id: currentSessionId.value
}); });
formatAppLog("log", "at pages/Chat/Chat.vue:1235", "中断指令已发送成功"); formatAppLog("log", "at pages/Chat/Chat.vue:1412", "中断指令已发送成功");
} catch (err) { } catch (err) {
formatAppLog("error", "at pages/Chat/Chat.vue:1237", "中断指令发送失败:", err); formatAppLog("error", "at pages/Chat/Chat.vue:1414", "中断指令发送失败:", err);
} }
if (streamingMessageId.value) { if (streamingMessageId.value) {
allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value);
@@ -6496,11 +6623,14 @@ This will fail in production.`);
duration: 1500 duration: 1500
}); });
}; };
vue.watch(() => socketStore.isThinking, (newVal, oldVal) => { vue.watch(() => socketStore.isThinking, async (newVal, oldVal) => {
formatAppLog("log", "at pages/Chat/Chat.vue:1261", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); formatAppLog("log", "at pages/Chat/Chat.vue:1438", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString);
if (!oldVal && newVal) { if (!oldVal && newVal) {
formatAppLog("log", "at pages/Chat/Chat.vue:1264", "AI开始回复跨设备同步锁定输入框"); formatAppLog("log", "at pages/Chat/Chat.vue:1441", "AI开始回复跨设备同步锁定输入框");
isThinking.value = true; isThinking.value = true;
if (!isSelfSent.value) {
await takeConversationMessages();
}
if (!streamingMessageId.value) { if (!streamingMessageId.value) {
streamingMessageId.value = "streaming-" + Date.now(); streamingMessageId.value = "streaming-" + Date.now();
allmessages.value = [...allmessages.value, { allmessages.value = [...allmessages.value, {
@@ -6513,12 +6643,12 @@ This will fail in production.`);
return; return;
} }
if (oldVal && !newVal) { if (oldVal && !newVal) {
formatAppLog("log", "at pages/Chat/Chat.vue:1280", "AI回复结束正常/中断),解锁并刷新消息列表"); formatAppLog("log", "at pages/Chat/Chat.vue:1460", "AI回复结束正常/中断),解锁并刷新消息列表");
await takeConversationMessages();
if (streamingMessageId.value) { if (streamingMessageId.value) {
allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value);
streamingMessageId.value = null; streamingMessageId.value = null;
} }
takeConversationMessages();
isThinking.value = false; isThinking.value = false;
isSelfSent.value = false; isSelfSent.value = false;
textMessage.value = ""; textMessage.value = "";
@@ -6541,6 +6671,23 @@ This will fail in production.`);
}, 500); }, 500);
} }
}); });
vue.watch(() => socketStore.pcOffline, (offline) => {
if (offline) {
isThinking.value = false;
socketStore.isThinking = false;
socketStore.pcOffline = false;
uni.showToast({
title: "PC端不在线请先登录",
icon: "none",
duration: 1500
});
setTimeout(() => {
uni.reLaunch({
url: "/pages/Login/Login"
});
}, 1500);
}
});
vue.watch(() => socketStore.messageString, (newContent) => { vue.watch(() => socketStore.messageString, (newContent) => {
if (!streamingMessageId.value || !socketStore.isThinking) if (!streamingMessageId.value || !socketStore.isThinking)
return; return;
@@ -6567,15 +6714,15 @@ This will fail in production.`);
UserData.value = await getUserInfo(userToken.value); UserData.value = await getUserInfo(userToken.value);
UserId.value = UserData.value._id; UserId.value = UserData.value._id;
UserAvatar.value = UserData.value.avatar || ""; UserAvatar.value = UserData.value.avatar || "";
formatAppLog("log", "at pages/Chat/Chat.vue:1346", "用户信息已加载:", UserId.value, UserAvatar.value); formatAppLog("log", "at pages/Chat/Chat.vue:1547", "用户信息已加载:", UserId.value, UserAvatar.value);
} catch (error) { } catch (error) {
formatAppLog("error", "at pages/Chat/Chat.vue:1348", "获取用户信息失败:", error); formatAppLog("error", "at pages/Chat/Chat.vue:1549", "获取用户信息失败:", error);
} }
}; };
const takeUserConversations = async () => { const takeUserConversations = async () => {
try { try {
userToken.value = getToken(); userToken.value = getToken();
formatAppLog("log", "at pages/Chat/Chat.vue:1356", "token:", userToken.value); formatAppLog("log", "at pages/Chat/Chat.vue:1557", "token:", userToken.value);
UserConversations.value = await getUserConversations(userToken.value) || []; UserConversations.value = await getUserConversations(userToken.value) || [];
const savedSessionId = getCurrentSessionId(); const savedSessionId = getCurrentSessionId();
if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) { if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) {
@@ -6585,7 +6732,7 @@ This will fail in production.`);
} else { } else {
currentSessionId.value = ""; currentSessionId.value = "";
} }
formatAppLog("log", "at pages/Chat/Chat.vue:1368", "保存会话id", currentSessionId.value); formatAppLog("log", "at pages/Chat/Chat.vue:1569", "保存会话id", currentSessionId.value);
uni.setStorageSync("currentSessionId", currentSessionId.value); uni.setStorageSync("currentSessionId", currentSessionId.value);
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
@@ -6597,17 +6744,17 @@ This will fail in production.`);
const FriendInfoList = vue.ref([]); const FriendInfoList = vue.ref([]);
const takeFriendList = async () => { const takeFriendList = async () => {
try { try {
formatAppLog("log", "at pages/Chat/Chat.vue:1383", "开始获取好友列表"); formatAppLog("log", "at pages/Chat/Chat.vue:1584", "开始获取好友列表");
const friendList = await getChatFriend(UserId.value); const friendList = await getChatFriend(UserId.value);
formatAppLog("log", "at pages/Chat/Chat.vue:1386", "friendList:", friendList); formatAppLog("log", "at pages/Chat/Chat.vue:1587", "friendList:", friendList);
if (friendList && friendList.length) { if (friendList && friendList.length) {
FriendInfoList.value = await takeUserAvatar(friendList); FriendInfoList.value = await takeUserAvatar(friendList);
} else { } else {
FriendInfoList.value = []; FriendInfoList.value = [];
formatAppLog("log", "at pages/Chat/Chat.vue:1391", "好友列表为空"); formatAppLog("log", "at pages/Chat/Chat.vue:1592", "好友列表为空");
} }
} catch (error) { } catch (error) {
formatAppLog("error", "at pages/Chat/Chat.vue:1394", "获取好友列表失败:", error); formatAppLog("error", "at pages/Chat/Chat.vue:1595", "获取好友列表失败:", error);
FriendInfoList.value = []; FriendInfoList.value = [];
} finally { } finally {
UserConversations.value = FriendInfoList.value; UserConversations.value = FriendInfoList.value;
@@ -6634,17 +6781,17 @@ This will fail in production.`);
}; };
}); });
} catch (err) { } catch (err) {
formatAppLog("error", "at pages/Chat/Chat.vue:1424", "获取好友头像失败", err); formatAppLog("error", "at pages/Chat/Chat.vue:1625", "获取好友头像失败", err);
return friendList; return friendList;
} }
}; };
const GroupList = vue.ref([]); const GroupList = vue.ref([]);
const takeGroupList = async () => { const takeGroupList = async () => {
try { try {
formatAppLog("log", "at pages/Chat/Chat.vue:1434", "开始获取群聊列表"); formatAppLog("log", "at pages/Chat/Chat.vue:1635", "开始获取群聊列表");
GroupList.value = await getGroup(UserId.value); GroupList.value = await getGroup(UserId.value);
} catch (error) { } catch (error) {
formatAppLog("error", "at pages/Chat/Chat.vue:1439", "获取群聊列表失败:", error); formatAppLog("error", "at pages/Chat/Chat.vue:1640", "获取群聊列表失败:", error);
GroupList.value = []; GroupList.value = [];
} finally { } finally {
UserConversations.value = GroupList.value; UserConversations.value = GroupList.value;
@@ -6656,22 +6803,22 @@ This will fail in production.`);
return []; return [];
try { try {
const memberIds = memberList.map((item) => item.groupContactId); const memberIds = memberList.map((item) => item.groupContactId);
formatAppLog("log", "at pages/Chat/Chat.vue:1453", "请求头像的ID列表:", memberIds); formatAppLog("log", "at pages/Chat/Chat.vue:1654", "请求头像的ID列表:", memberIds);
const memberAvatarList = await getUserAvatar(userToken.value, memberIds); const memberAvatarList = await getUserAvatar(userToken.value, memberIds);
formatAppLog("log", "at pages/Chat/Chat.vue:1455", "头像接口返回数据:", memberAvatarList); formatAppLog("log", "at pages/Chat/Chat.vue:1656", "头像接口返回数据:", memberAvatarList);
const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []); const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []);
formatAppLog("log", "at pages/Chat/Chat.vue:1458", "userMap的keys:", Array.from(userMap.keys())); formatAppLog("log", "at pages/Chat/Chat.vue:1659", "userMap的keys:", Array.from(userMap.keys()));
return memberList.map((member) => { return memberList.map((member) => {
const memberId = member.groupContactId; const memberId = member.groupContactId;
const userInfo = userMap.get(memberId); const userInfo = userMap.get(memberId);
formatAppLog("log", "at pages/Chat/Chat.vue:1463", `查找 ${memberId} 的头像:`, userInfo); formatAppLog("log", "at pages/Chat/Chat.vue:1664", `查找 ${memberId} 的头像:`, userInfo);
return { return {
...member, ...member,
avatar: (userInfo == null ? void 0 : userInfo.avatar) || null avatar: (userInfo == null ? void 0 : userInfo.avatar) || null
}; };
}); });
} catch (err) { } catch (err) {
formatAppLog("error", "at pages/Chat/Chat.vue:1470", "获取群成员头像失败", err); formatAppLog("error", "at pages/Chat/Chat.vue:1671", "获取群成员头像失败", err);
return memberList; return memberList;
} }
}; };
@@ -6685,13 +6832,20 @@ This will fail in production.`);
const scrollToView = vue.ref(""); const scrollToView = vue.ref("");
const bottomToggle = vue.ref(false); const bottomToggle = vue.ref(false);
const isLoadingMore = vue.ref(false); const isLoadingMore = vue.ref(false);
const isAILoadingMore = vue.ref(false);
const aiPageNumber = vue.ref(0);
const hasMoreAIMessages = vue.ref(true);
const currentPage = vue.ref(1); const currentPage = vue.ref(1);
const currentMessages = vue.computed(() => { const currentMessages = vue.computed(() => {
return allmessages.value; return allmessages.value;
}); });
const takeConversationMessages = async () => { const takeConversationMessages = async () => {
try { try {
allmessages.value = await getConversationMessages(userToken.value, currentSessionId.value) || []; aiPageNumber.value = 0;
hasMoreAIMessages.value = true;
const rawMessages = await getConversationMessages(userToken.value, currentSessionId.value, pageSize, 0) || [];
allmessages.value = rawMessages;
formatAppLog("log", "at pages/Chat/Chat.vue:1712", "获取到的所有消息:", JSON.stringify(allmessages.value));
scrollToBottom(); scrollToBottom();
} catch (error) { } catch (error) {
uni.showToast({ uni.showToast({
@@ -6718,12 +6872,12 @@ This will fail in production.`);
const takeGroupMessages = async () => { const takeGroupMessages = async () => {
try { try {
allmessages.value = await getGroupMessages(currentSessionId.value) || []; allmessages.value = await getGroupMessages(currentSessionId.value) || [];
formatAppLog("log", "at pages/Chat/Chat.vue:1535", "群聊消息:", allmessages.value); formatAppLog("log", "at pages/Chat/Chat.vue:1744", "群聊消息:", allmessages.value);
const memberList = await getGroupMemberList(currentSessionId.value); const memberList = await getGroupMemberList(currentSessionId.value);
formatAppLog("log", "at pages/Chat/Chat.vue:1538", "获取到的群成员列表:", memberList); formatAppLog("log", "at pages/Chat/Chat.vue:1747", "获取到的群成员列表:", memberList);
if (memberList && memberList.length) { if (memberList && memberList.length) {
groupMemberList.value = await takeGroupMemberAvatar(memberList); groupMemberList.value = await takeGroupMemberAvatar(memberList);
formatAppLog("log", "at pages/Chat/Chat.vue:1541", "群成员列表(带头像):", groupMemberList.value); formatAppLog("log", "at pages/Chat/Chat.vue:1750", "群成员列表(带头像):", groupMemberList.value);
} else { } else {
groupMemberList.value = []; groupMemberList.value = [];
} }
@@ -6737,6 +6891,33 @@ This will fail in production.`);
isLoadingMessages.value = false; isLoadingMessages.value = false;
} }
}; };
const onScrollToUpper = async () => {
if (ChatType.value === 0) {
await loadMoreAIMessages();
}
};
const loadMoreAIMessages = async () => {
if (isAILoadingMore.value || !hasMoreAIMessages.value || !currentSessionId.value)
return;
isAILoadingMore.value = true;
try {
const nextPage = aiPageNumber.value + 1;
const olderMessages = await getConversationMessages(userToken.value, currentSessionId.value, pageSize, nextPage);
if (olderMessages && olderMessages.length > 0) {
aiPageNumber.value = nextPage;
allmessages.value = [...olderMessages, ...allmessages.value];
await vue.nextTick();
scrollToView.value = "msg-" + olderMessages.length;
} else {
hasMoreAIMessages.value = false;
}
} catch (e2) {
formatAppLog("error", "at pages/Chat/Chat.vue:1808", "加载更多消息失败:", e2);
uni.showToast({ title: "加载更多失败", icon: "none" });
} finally {
isAILoadingMore.value = false;
}
};
const onScroll = (e2) => { const onScroll = (e2) => {
}; };
const scrollToBottom = async () => { const scrollToBottom = async () => {
@@ -6747,9 +6928,9 @@ This will fail in production.`);
} }
}; };
vue.watch(() => friendSocketStore.MessageReceived, (newId) => { vue.watch(() => friendSocketStore.MessageReceived, (newId) => {
formatAppLog("log", "at pages/Chat/Chat.vue:1588", "收到了好友消息"); formatAppLog("log", "at pages/Chat/Chat.vue:1829", "收到了好友消息");
if (newId) { if (newId) {
formatAppLog("log", "at pages/Chat/Chat.vue:1590", "ChatType:", ChatType.value); formatAppLog("log", "at pages/Chat/Chat.vue:1831", "ChatType:", ChatType.value);
switch (ChatType.value) { switch (ChatType.value) {
case 0: case 0:
takeConversationMessages(); takeConversationMessages();
@@ -6764,7 +6945,7 @@ This will fail in production.`);
friendSocketStore.MessageReceived = false; friendSocketStore.MessageReceived = false;
break; break;
default: default:
formatAppLog("log", "at pages/Chat/Chat.vue:1606", "default 分支"); formatAppLog("log", "at pages/Chat/Chat.vue:1847", "default 分支");
friendSocketStore.MessageReceived = false; friendSocketStore.MessageReceived = false;
break; break;
} }
@@ -6843,11 +7024,11 @@ This will fail in production.`);
onUnload(() => { onUnload(() => {
socketStore.disconnect(); socketStore.disconnect();
}); });
const __returned__ = { friendSocketStore, handleFriendConnect, socketStore, ChatType, wyxdWorkspaceId, wyxdFilePath, wyxdFileName, wyxdUserToken, hasWyxdFile, convertMarkdownTable, renderTable, escapeLoneUnderscores, isDownloadLink, renderDownloadBtn, supportedExtensions, extPattern, pareseMarkdown, sanitizeContent, previewImage, openFile: openFile$1, formatFileSize: formatFileSize2, parseFileInfo, selectNormalChat, showNewChatModal, closeNewChatModal, isChatSidebar, handleChatSidebar, goWorkSpace, goWyxdViewer, goCloudDatabase, logOut, previewFileArray, uploadPhoto, deleteImage, fileList, uploadFile, handleConnect, isThinking, isSelfSent, isUploading, isLoadingMessages, uploadedFiles, streamingMessageId, showMessageModal, detailLinks, handleChatContentClick, extractLinks, extractFileNameFromUrl, getFileTypeInfo, showMessageDetail, closeMessageDetail, downloadToast, get downloadToastTimer() { const __returned__ = { friendSocketStore, handleFriendConnect, socketStore, ChatType, wyxdWorkspaceId, wyxdFilePath, wyxdFileName, wyxdUserToken, hasWyxdFile, convertMarkdownTable, renderTable, escapeLoneUnderscores, isDownloadLink, renderDownloadBtn, supportedExtensions, extPattern, pareseMarkdown, sanitizeContent, previewImage, openFile: openFile$1, formatFileSize: formatFileSize2, parseFileInfo, selectNormalChat, showNewChatModal, closeNewChatModal, showAgentModal, agentList, agentLoading, selectAgentChat, closeAgentModal, handleAgentSelect, isChatSidebar, handleChatSidebar, goWorkSpace, goWyxdViewer, goCloudDatabase, logOut, handleRefresh, previewFileArray, uploadPhoto, deleteImage, fileList, uploadFile, handleConnect, isThinking, isSelfSent, isUploading, isLoadingMessages, uploadedFiles, streamingMessageId, showMessageModal, detailLinks, handleChatContentClick, extractLinks, extractFileNameFromUrl, getFileTypeInfo, showMessageDetail, closeMessageDetail, downloadToast, get downloadToastTimer() {
return downloadToastTimer; return downloadToastTimer;
}, set downloadToastTimer(v) { }, set downloadToastTimer(v) {
downloadToastTimer = v; downloadToastTimer = v;
}, showDownloadToast, hideDownloadToast, openLink, downloadAndHandle, sendMessage, sendFriendMessage, sendGroupMessage, sendAIMessage, stopConversation, textMessage, UserConversations, currentSessionId, userToken, UserId, UserAvatar, UserData, takeUserInfo, takeUserConversations, FriendInfoList, takeFriendList, takeTalkUserAvatar, takeUserAvatar, GroupList, takeGroupList, groupMemberList, takeGroupMemberAvatar, getGroupMemberAvatarById, allmessages, scrollToView, bottomToggle, isLoadingMore, currentPage, currentMessages, takeConversationMessages, takeFriendMessages, takeGroupMessages, onScroll, scrollToBottom, computed: vue.computed, getCurrentInstance: vue.getCurrentInstance, nextTick: vue.nextTick, onMounted: vue.onMounted, ref: vue.ref, watch: vue.watch, get onLoad() { }, showDownloadToast, hideDownloadToast, openLink, downloadAndHandle, sendMessage, sendFriendMessage, sendGroupMessage, sendAIMessage, stopConversation, textMessage, UserConversations, currentSessionId, userToken, UserId, UserAvatar, UserData, takeUserInfo, takeUserConversations, FriendInfoList, takeFriendList, takeTalkUserAvatar, takeUserAvatar, GroupList, takeGroupList, groupMemberList, takeGroupMemberAvatar, getGroupMemberAvatarById, allmessages, scrollToView, bottomToggle, isLoadingMore, isAILoadingMore, aiPageNumber, hasMoreAIMessages, currentPage, pageSize, currentMessages, takeConversationMessages, takeFriendMessages, takeGroupMessages, onScrollToUpper, loadMoreAIMessages, onScroll, scrollToBottom, computed: vue.computed, getCurrentInstance: vue.getCurrentInstance, nextTick: vue.nextTick, onMounted: vue.onMounted, ref: vue.ref, watch: vue.watch, get onLoad() {
return onLoad; return onLoad;
}, get onShow() { }, get onShow() {
return onShow; return onShow;
@@ -6869,6 +7050,8 @@ This will fail in production.`);
return getUserAvatar; return getUserAvatar;
}, get conversationMessageDownload() { }, get conversationMessageDownload() {
return conversationMessageDownload; return conversationMessageDownload;
}, get getAgentList() {
return getAgentList;
}, get getToken() { }, get getToken() {
return getToken; return getToken;
}, get getCurrentSessionId() { }, get getCurrentSessionId() {
@@ -6961,7 +7144,10 @@ This will fail in production.`);
class: "arrow-right-style" class: "arrow-right-style"
}) })
]), ]),
vue.createElementVNode("view", { class: "ncd-option ncd-intelligence" }, [ vue.createElementVNode("view", {
class: "ncd-option ncd-intelligence",
onClick: $setup.selectAgentChat
}, [
vue.createElementVNode("view", { class: "ncd-opt-icon" }, [ vue.createElementVNode("view", { class: "ncd-opt-icon" }, [
vue.createVNode(_component_uni_icons, { vue.createVNode(_component_uni_icons, {
type: "star", type: "star",
@@ -6981,6 +7167,98 @@ This will fail in production.`);
]) ])
]) ])
])) : vue.createCommentVNode("v-if", true), ])) : vue.createCommentVNode("v-if", true),
$setup.showAgentModal ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "agent-modal-mask",
onClick: $setup.closeAgentModal
}, [
vue.createElementVNode("view", {
class: "agent-modal",
onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
}, ["stop"]))
}, [
vue.createElementVNode("view", { class: "agent-modal-header" }, [
vue.createElementVNode("text", { class: "agent-modal-title" }, "选择智能体"),
vue.createElementVNode("view", {
class: "agent-modal-close",
onClick: $setup.closeAgentModal
}, [
vue.createVNode(_component_uni_icons, {
type: "closeempty",
size: "20",
color: "#999"
})
])
]),
vue.createElementVNode("scroll-view", {
class: "agent-list",
"scroll-y": "true"
}, [
$setup.agentLoading ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0,
class: "agent-loading"
}, [
vue.createVNode(_component_uni_icons, {
type: "spinner-cycle",
size: "24",
color: "#1677ff"
}),
vue.createElementVNode("text", { class: "agent-loading-text" }, "加载智能体列表...")
])) : $setup.agentList.length === 0 ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "agent-empty"
}, [
vue.createElementVNode("text", { class: "agent-empty-text" }, "暂无可用智能体")
])) : (vue.openBlock(true), vue.createElementBlock(
vue.Fragment,
{ key: 2 },
vue.renderList($setup.agentList, (agent) => {
return vue.openBlock(), vue.createElementBlock("view", {
key: agent._id,
class: "agent-card",
onClick: ($event) => $setup.handleAgentSelect(agent)
}, [
vue.createElementVNode("view", { class: "agent-card-header" }, [
vue.createElementVNode("view", { class: "agent-avatar" }, [
vue.createVNode(_component_uni_icons, {
type: "vip",
size: "22",
color: "#fff"
})
]),
vue.createElementVNode("view", { class: "agent-card-info" }, [
vue.createElementVNode(
"text",
{ class: "agent-card-title" },
vue.toDisplayString(agent.title),
1
/* TEXT */
)
])
]),
vue.createElementVNode(
"text",
{ class: "agent-card-desc" },
vue.toDisplayString(agent.description),
1
/* TEXT */
)
], 8, ["onClick"]);
}),
128
/* KEYED_FRAGMENT */
))
]),
vue.createElementVNode("view", { class: "agent-modal-footer" }, [
vue.createElementVNode("view", {
class: "agent-modal-btn agent-modal-btn-cancel",
onClick: $setup.closeAgentModal
}, [
vue.createElementVNode("text", null, "取消")
])
])
])
])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "chat-page page-container" }, [ vue.createElementVNode("view", { class: "chat-page page-container" }, [
$setup.isChatSidebar ? (vue.openBlock(), vue.createElementBlock("view", { $setup.isChatSidebar ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0, key: 0,
@@ -6996,13 +7274,13 @@ This will fail in production.`);
vue.createVNode($setup["ChatSidebar"], { vue.createVNode($setup["ChatSidebar"], {
chatList: $setup.UserConversations, chatList: $setup.UserConversations,
showNewChatModal: $setup.showNewChatModal, showNewChatModal: $setup.showNewChatModal,
"onUpdate:showNewChatModal": _cache[1] || (_cache[1] = ($event) => $setup.showNewChatModal = $event), "onUpdate:showNewChatModal": _cache[2] || (_cache[2] = ($event) => $setup.showNewChatModal = $event),
currentSessionId: $setup.currentSessionId, currentSessionId: $setup.currentSessionId,
"onUpdate:currentSessionId": _cache[2] || (_cache[2] = ($event) => $setup.currentSessionId = $event), "onUpdate:currentSessionId": _cache[3] || (_cache[3] = ($event) => $setup.currentSessionId = $event),
chatType: $setup.ChatType, chatType: $setup.ChatType,
"onUpdate:chatType": _cache[3] || (_cache[3] = ($event) => $setup.ChatType = $event), "onUpdate:chatType": _cache[4] || (_cache[4] = ($event) => $setup.ChatType = $event),
onRefreshConversations: $setup.takeUserConversations, onRefreshConversations: $setup.takeUserConversations,
onSelectChat: _cache[4] || (_cache[4] = ($event) => $setup.isChatSidebar = false) onSelectChat: _cache[5] || (_cache[5] = ($event) => $setup.isChatSidebar = false)
}, null, 8, ["chatList", "showNewChatModal", "currentSessionId", "chatType"]) }, null, 8, ["chatList", "showNewChatModal", "currentSessionId", "chatType"])
], ],
2 2
@@ -7029,6 +7307,16 @@ This will fail in production.`);
}, [ }, [
vue.createElementVNode("view", { class: "iconfont icon-cloud" }) vue.createElementVNode("view", { class: "iconfont icon-cloud" })
]), ]),
vue.createElementVNode("view", {
class: "head-btn",
onClick: $setup.handleRefresh
}, [
vue.createVNode(_component_uni_icons, {
type: "refreshempty",
size: "24",
color: "#52c41a"
})
]),
vue.createElementVNode("view", { vue.createElementVNode("view", {
class: "head-btn log-out", class: "head-btn log-out",
onClick: $setup.logOut onClick: $setup.logOut
@@ -7058,7 +7346,7 @@ This will fail in production.`);
}, ""), }, ""),
vue.createElementVNode("view", { vue.createElementVNode("view", {
class: "wyxd-banner-close", class: "wyxd-banner-close",
onClick: _cache[5] || (_cache[5] = vue.withModifiers(($event) => $setup.hasWyxdFile = false, ["stop"])) onClick: _cache[6] || (_cache[6] = vue.withModifiers(($event) => $setup.hasWyxdFile = false, ["stop"]))
}, "×") }, "×")
])) : vue.createCommentVNode("v-if", true), ])) : vue.createCommentVNode("v-if", true),
vue.createElementVNode("view", { class: "main-chat" }, [ vue.createElementVNode("view", { class: "main-chat" }, [
@@ -7067,12 +7355,19 @@ This will fail in production.`);
direction: "vertical", direction: "vertical",
"scroll-y": "", "scroll-y": "",
"scroll-into-view": $setup.scrollToView, "scroll-into-view": $setup.scrollToView,
"upper-threshold": 0, "upper-threshold": 50,
"scroll-with-animation": !$setup.isThinking, "scroll-with-animation": !$setup.isThinking,
onScroll: $setup.onScroll onScroll: $setup.onScroll,
onScrolltoupper: $setup.onScrollToUpper
}, [ }, [
$setup.isLoadingMessages ? (vue.openBlock(), vue.createElementBlock("view", { $setup.ChatType === 0 && $setup.isAILoadingMore ? (vue.openBlock(), vue.createElementBlock("view", {
key: 0, key: 0,
class: "load-more-tip"
}, [
vue.createElementVNode("text", null, "加载更多消息...")
])) : vue.createCommentVNode("v-if", true),
$setup.isLoadingMessages ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1,
class: "messages-loading-overlay" class: "messages-loading-overlay"
}, [ }, [
vue.createElementVNode("view", { class: "messages-loading-card" }, [ vue.createElementVNode("view", { class: "messages-loading-card" }, [
@@ -7192,7 +7487,7 @@ This will fail in production.`);
)), )),
$setup.ChatType === 1 ? (vue.openBlock(true), vue.createElementBlock( $setup.ChatType === 1 ? (vue.openBlock(true), vue.createElementBlock(
vue.Fragment, vue.Fragment,
{ key: 1 }, { key: 2 },
vue.renderList($setup.currentMessages, (message, index) => { vue.renderList($setup.currentMessages, (message, index) => {
var _a; var _a;
return vue.openBlock(), vue.createElementBlock("view", { return vue.openBlock(), vue.createElementBlock("view", {
@@ -7285,7 +7580,7 @@ This will fail in production.`);
)) : vue.createCommentVNode("v-if", true), )) : vue.createCommentVNode("v-if", true),
$setup.ChatType === 2 ? (vue.openBlock(true), vue.createElementBlock( $setup.ChatType === 2 ? (vue.openBlock(true), vue.createElementBlock(
vue.Fragment, vue.Fragment,
{ key: 2 }, { key: 3 },
vue.renderList($setup.currentMessages, (message, index) => { vue.renderList($setup.currentMessages, (message, index) => {
var _a; var _a;
return vue.openBlock(), vue.createElementBlock("view", { return vue.openBlock(), vue.createElementBlock("view", {
@@ -7396,7 +7691,7 @@ This will fail in production.`);
"view", "view",
{ {
class: vue.normalizeClass(["chat-interactive-btn", { disabled: $setup.isThinking }]), class: vue.normalizeClass(["chat-interactive-btn", { disabled: $setup.isThinking }]),
onClick: _cache[6] || (_cache[6] = ($event) => !$setup.isThinking && $setup.uploadPhoto()) onClick: _cache[7] || (_cache[7] = ($event) => !$setup.isThinking && $setup.uploadPhoto())
}, },
"拍照上传", "拍照上传",
2 2
@@ -7406,7 +7701,7 @@ This will fail in production.`);
"view", "view",
{ {
class: vue.normalizeClass(["chat-interactive-btn", { disabled: $setup.isThinking }]), class: vue.normalizeClass(["chat-interactive-btn", { disabled: $setup.isThinking }]),
onClick: _cache[7] || (_cache[7] = ($event) => !$setup.isThinking && $setup.uploadFile()) onClick: _cache[8] || (_cache[8] = ($event) => !$setup.isThinking && $setup.uploadFile())
}, },
"上传文件", "上传文件",
2 2
@@ -7454,7 +7749,7 @@ This will fail in production.`);
class: "message-input", class: "message-input",
placeholder: $setup.isThinking ? $setup.isSelfSent ? "AI 正在回复中..." : "电脑正在运行,请稍后" : "输入消息...", placeholder: $setup.isThinking ? $setup.isSelfSent ? "AI 正在回复中..." : "电脑正在运行,请稍后" : "输入消息...",
disabled: $setup.isThinking, disabled: $setup.isThinking,
"onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => $setup.textMessage = $event), "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => $setup.textMessage = $event),
"auto-height": "" "auto-height": ""
}, null, 8, ["placeholder", "disabled"]), [ }, null, 8, ["placeholder", "disabled"]), [
[vue.vModelText, $setup.textMessage] [vue.vModelText, $setup.textMessage]
@@ -7468,7 +7763,7 @@ This will fail in production.`);
])) : (vue.openBlock(), vue.createElementBlock("view", { ])) : (vue.openBlock(), vue.createElementBlock("view", {
key: 1, key: 1,
class: "input-btn-group send-message-btn", class: "input-btn-group send-message-btn",
onClick: _cache[9] || (_cache[9] = ($event) => $setup.sendMessage()) onClick: _cache[10] || (_cache[10] = ($event) => $setup.sendMessage())
}, [ }, [
vue.createElementVNode("view", { class: "iconfont icon-fasong" }) vue.createElementVNode("view", { class: "iconfont icon-fasong" })
])) ]))
@@ -7484,13 +7779,13 @@ This will fail in production.`);
]) ])
]), ]),
$setup.showMessageModal ? (vue.openBlock(), vue.createElementBlock("view", { $setup.showMessageModal ? (vue.openBlock(), vue.createElementBlock("view", {
key: 1, key: 2,
class: "ncd-overlay", class: "ncd-overlay",
onClick: $setup.closeMessageDetail onClick: $setup.closeMessageDetail
}, [ }, [
vue.createElementVNode("view", { vue.createElementVNode("view", {
class: "ncd-card message-detail-card", class: "ncd-card message-detail-card",
onClick: _cache[10] || (_cache[10] = vue.withModifiers(() => { onClick: _cache[11] || (_cache[11] = vue.withModifiers(() => {
}, ["stop"])) }, ["stop"]))
}, [ }, [
vue.createElementVNode("view", { class: "ncd-header" }, [ vue.createElementVNode("view", { class: "ncd-header" }, [
@@ -7550,7 +7845,7 @@ This will fail in production.`);
$setup.downloadToast.show ? (vue.openBlock(), vue.createElementBlock( $setup.downloadToast.show ? (vue.openBlock(), vue.createElementBlock(
"view", "view",
{ {
key: 2, key: 3,
class: vue.normalizeClass(["download-toast-overlay", $setup.downloadToast.show ? "" : ""]) class: vue.normalizeClass(["download-toast-overlay", $setup.downloadToast.show ? "" : ""])
}, },
[ [

View File

@@ -1096,6 +1096,171 @@ to { opacity: 1; transform: translateY(0) scale(1);
.ncd-intelligence .ncd-opt-icon[data-v-5eb7b895] { .ncd-intelligence .ncd-opt-icon[data-v-5eb7b895] {
background: linear-gradient(135deg, #8b5cf6, #7c3aed); background: linear-gradient(135deg, #8b5cf6, #7c3aed);
} }
/* ========== 智能体选择弹窗 ========== */
.agent-modal-mask[data-v-5eb7b895] {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.45);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}
.agent-modal[data-v-5eb7b895] {
width: 85%;
max-height: 70%;
background-color: #ffffff;
border-radius: 0.75rem;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12);
}
.agent-modal-header[data-v-5eb7b895] {
display: flex;
justify-content: center;
align-items: center;
padding: 0.9375rem 0.9375rem 0.625rem;
position: relative;
border-bottom: 0.0625rem solid #f0f0f0;
}
.agent-modal-title[data-v-5eb7b895] {
font-size: 1.0625rem;
font-weight: 700;
color: #1a1a2e;
}
.agent-modal-close[data-v-5eb7b895] {
position: absolute;
right: 0.75rem;
top: 50%;
transform: translateY(-50%);
padding: 0.3125rem;
}
.agent-list[data-v-5eb7b895] {
box-sizing: border-box;
flex: 1;
padding: 0.625rem 0.75rem;
max-height: 18.75rem;
}
.agent-loading[data-v-5eb7b895] {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 1.875rem 0;
}
.agent-loading-text[data-v-5eb7b895] {
margin-top: 0.5rem;
font-size: 0.8125rem;
color: #999;
}
.agent-empty[data-v-5eb7b895] {
display: flex;
align-items: center;
justify-content: center;
padding: 2.5rem 0;
}
.agent-empty-text[data-v-5eb7b895] {
font-size: 0.875rem;
color: #999;
}
.agent-card[data-v-5eb7b895] {
box-sizing: border-box;
width: 100%;
background: linear-gradient(135deg, #f8f5ff, #efe8ff);
border: 0.0625rem solid #c4b5fd;
border-radius: 0.625rem;
padding: 0.875rem 0.75rem;
margin-bottom: 0.625rem;
transition: all 0.2s ease;
overflow: hidden;
}
.agent-card[data-v-5eb7b895]:active {
transform: scale(0.98);
border-color: #a78bfa;
background: linear-gradient(135deg, #f3efff, #e8dcff);
}
.agent-card-header[data-v-5eb7b895] {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
}
.agent-avatar[data-v-5eb7b895] {
width: 2.1875rem;
height: 2.1875rem;
border-radius: 0.625rem;
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.agent-card-info[data-v-5eb7b895] {
margin-left: 0.5rem;
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.agent-card-title[data-v-5eb7b895] {
font-size: 0.9375rem;
font-weight: 600;
color: #1a1a2e;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-card-category[data-v-5eb7b895] {
font-size: 0.6875rem;
color: #8b5cf6;
margin-top: 0.125rem;
}
.agent-card-desc[data-v-5eb7b895] {
font-size: 0.8125rem;
color: #555;
line-height: 1.5;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-card-welcome[data-v-5eb7b895] {
font-size: 0.75rem;
color: #7c3aed;
margin-top: 0.375rem;
padding-top: 0.375rem;
border-top: 0.0625rem dashed #ddd6fe;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-modal-footer[data-v-5eb7b895] {
padding: 0.625rem 0.9375rem 0.9375rem;
border-top: 0.0625rem solid #f0f0f0;
display: flex;
justify-content: flex-end;
}
.agent-modal-btn[data-v-5eb7b895] {
padding: 0.5625rem 1.5rem;
border-radius: 0.5rem;
font-size: 0.875rem;
font-weight: 500;
}
.agent-modal-btn-cancel[data-v-5eb7b895] {
background: #f0f0f0;
color: #666;
}
.agent-modal-btn-cancel[data-v-5eb7b895]:active {
background: #e0e0e0;
}
/* ==========新建聊天列表相关====== */ /* ==========新建聊天列表相关====== */
.close-option-card[data-v-5eb7b895] { .close-option-card[data-v-5eb7b895] {
width: 100%; width: 100%;
@@ -1188,6 +1353,9 @@ to { opacity: 1; transform: translateY(0) scale(1);
.head-btn .iconfont[data-v-5eb7b895] { .head-btn .iconfont[data-v-5eb7b895] {
font-size: 1.5rem; font-size: 1.5rem;
} }
.chat-btn-group .head-btn[data-v-5eb7b895]:nth-child(4) {
/* 刷新按钮 */
}
.log-out[data-v-5eb7b895] { .log-out[data-v-5eb7b895] {
/* background: #ffd4d4; */ /* background: #ffd4d4; */
} }

View File

@@ -1096,6 +1096,171 @@ to { opacity: 1; transform: translateY(0) scale(1);
.ncd-intelligence .ncd-opt-icon[data-v-fdf84df1] { .ncd-intelligence .ncd-opt-icon[data-v-fdf84df1] {
background: linear-gradient(135deg, #8b5cf6, #7c3aed); background: linear-gradient(135deg, #8b5cf6, #7c3aed);
} }
/* ========== 智能体选择弹窗 ========== */
.agent-modal-mask[data-v-fdf84df1] {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.45);
backdrop-filter: blur(4px);
-webkit-backdrop-filter: blur(4px);
z-index: 1000;
display: flex;
align-items: center;
justify-content: center;
}
.agent-modal[data-v-fdf84df1] {
width: 85%;
max-height: 70%;
background-color: #ffffff;
border-radius: 0.75rem;
overflow: hidden;
display: flex;
flex-direction: column;
box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12);
}
.agent-modal-header[data-v-fdf84df1] {
display: flex;
justify-content: center;
align-items: center;
padding: 0.9375rem 0.9375rem 0.625rem;
position: relative;
border-bottom: 0.0625rem solid #f0f0f0;
}
.agent-modal-title[data-v-fdf84df1] {
font-size: 1.0625rem;
font-weight: 700;
color: #1a1a2e;
}
.agent-modal-close[data-v-fdf84df1] {
position: absolute;
right: 0.75rem;
top: 50%;
transform: translateY(-50%);
padding: 0.3125rem;
}
.agent-list[data-v-fdf84df1] {
box-sizing: border-box;
flex: 1;
padding: 0.625rem 0.75rem;
max-height: 18.75rem;
}
.agent-loading[data-v-fdf84df1] {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 1.875rem 0;
}
.agent-loading-text[data-v-fdf84df1] {
margin-top: 0.5rem;
font-size: 0.8125rem;
color: #999;
}
.agent-empty[data-v-fdf84df1] {
display: flex;
align-items: center;
justify-content: center;
padding: 2.5rem 0;
}
.agent-empty-text[data-v-fdf84df1] {
font-size: 0.875rem;
color: #999;
}
.agent-card[data-v-fdf84df1] {
box-sizing: border-box;
width: 100%;
background: linear-gradient(135deg, #f8f5ff, #efe8ff);
border: 0.0625rem solid #c4b5fd;
border-radius: 0.625rem;
padding: 0.875rem 0.75rem;
margin-bottom: 0.625rem;
transition: all 0.2s ease;
overflow: hidden;
}
.agent-card[data-v-fdf84df1]:active {
transform: scale(0.98);
border-color: #a78bfa;
background: linear-gradient(135deg, #f3efff, #e8dcff);
}
.agent-card-header[data-v-fdf84df1] {
display: flex;
align-items: center;
margin-bottom: 0.5rem;
}
.agent-avatar[data-v-fdf84df1] {
width: 2.1875rem;
height: 2.1875rem;
border-radius: 0.625rem;
background: linear-gradient(135deg, #8b5cf6, #7c3aed);
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
}
.agent-card-info[data-v-fdf84df1] {
margin-left: 0.5rem;
display: flex;
flex-direction: column;
flex: 1;
min-width: 0;
}
.agent-card-title[data-v-fdf84df1] {
font-size: 0.9375rem;
font-weight: 600;
color: #1a1a2e;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.agent-card-category[data-v-fdf84df1] {
font-size: 0.6875rem;
color: #8b5cf6;
margin-top: 0.125rem;
}
.agent-card-desc[data-v-fdf84df1] {
font-size: 0.8125rem;
color: #555;
line-height: 1.5;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 5;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-card-welcome[data-v-fdf84df1] {
font-size: 0.75rem;
color: #7c3aed;
margin-top: 0.375rem;
padding-top: 0.375rem;
border-top: 0.0625rem dashed #ddd6fe;
word-break: break-all;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.agent-modal-footer[data-v-fdf84df1] {
padding: 0.625rem 0.9375rem 0.9375rem;
border-top: 0.0625rem solid #f0f0f0;
display: flex;
justify-content: flex-end;
}
.agent-modal-btn[data-v-fdf84df1] {
padding: 0.5625rem 1.5rem;
border-radius: 0.5rem;
font-size: 0.875rem;
font-weight: 500;
}
.agent-modal-btn-cancel[data-v-fdf84df1] {
background: #f0f0f0;
color: #666;
}
.agent-modal-btn-cancel[data-v-fdf84df1]:active {
background: #e0e0e0;
}
/* ==========新建聊天列表相关====== */ /* ==========新建聊天列表相关====== */
.close-option-card[data-v-fdf84df1] { .close-option-card[data-v-fdf84df1] {
width: 100%; width: 100%;
@@ -1188,6 +1353,9 @@ to { opacity: 1; transform: translateY(0) scale(1);
.head-btn .iconfont[data-v-fdf84df1] { .head-btn .iconfont[data-v-fdf84df1] {
font-size: 1.5rem; font-size: 1.5rem;
} }
.chat-btn-group .head-btn[data-v-fdf84df1]:nth-child(4) {
/* 刷新按钮 */
}
.log-out[data-v-fdf84df1] { .log-out[data-v-fdf84df1] {
/* background: #ffd4d4; */ /* background: #ffd4d4; */
} }

View File

@@ -29,7 +29,11 @@ export const login = async (username, password) => {
} }
} else { } else {
if (String(res.statusCode).startsWith('5')) { if (String(res.statusCode).startsWith('5')) {
reject({ serverError: true, code: res.statusCode, message: '服务器升级中,请稍后再试' }) reject({
serverError: true,
code: res.statusCode,
message: '服务器升级中,请稍后再试'
})
} else { } else {
reject(`请求失败:${res.statusCode}`) reject(`请求失败:${res.statusCode}`)
} }
@@ -73,15 +77,16 @@ export const getUserConversations = async (token) => {
} }
// 获取与AI的对话内容 // 获取与AI的对话内容
export const getConversationMessages = async (token, conversatio_id) => { export const getConversationMessages = async (token, conversation_id, size, page_number) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
url: `${BASE_URL}/get_conversation_messages`, url: `${BASE_URL}/get_conversation_messages`,
method: 'POST', method: 'POST',
data: { data: {
"access_token": token, "access_token": token,
"login_type": "phone", "conversation_id": conversation_id,
"conversation_id": conversatio_id "size": 20,
"current": page_number
}, },
header: { header: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@@ -90,14 +95,15 @@ export const getConversationMessages = async (token, conversatio_id) => {
if (res.statusCode === 200) { if (res.statusCode === 200) {
const messagesInfo = res.data const messagesInfo = res.data
if (messagesInfo) { if (messagesInfo) {
console.log("返回数据为",messagesInfo);
console.log("工作区id为", messagesInfo.workspace_id || '(无)'); console.log("工作区id为", messagesInfo.workspace_id || '(无)');
if (messagesInfo.workspace_id) { if (messagesInfo.workspace_id) {
uni.setStorageSync('workspace_id', messagesInfo.workspace_id) uni.setStorageSync('workspace_id', messagesInfo.workspace_id)
} }
const filtered = (messagesInfo.messages || []).filter( const filtered = (messagesInfo.messages || []).filter(
m => m.role !== 'tool' m => m.role !== 'tool'
) )
resolve(filtered) resolve(filtered)
} else { } else {
const msg = res.data.error || '获取消息出错啦' const msg = res.data.error || '获取消息出错啦'
reject(msg) reject(msg)
@@ -556,9 +562,9 @@ export const workspaceUploadFileByURL = (token, workspacesId, urls, dirPath) =>
const failedItems = (respond.results || []) const failedItems = (respond.results || [])
.filter(r => !r.success) .filter(r => !r.success)
.map(r => r.error || '未知错误'); .map(r => r.error || '未知错误');
const msg = failedItems.length > 0 const msg = failedItems.length > 0 ?
? `上传失败 ${respond.failed_count}/${respond.total_files}${failedItems[0]}` `上传失败 ${respond.failed_count}/${respond.total_files}${failedItems[0]}` :
: (respond.summary || respond?.error || '上传文件到工作区出错啦'); (respond.summary || respond?.error || '上传文件到工作区出错啦');
reject(msg); reject(msg);
} }
} else { } else {
@@ -585,14 +591,19 @@ export const uploadFileToShortStorage = (workspacesId, files, filePath) => {
// 构建 files 数组供 uni.uploadFile 使用 // 构建 files 数组供 uni.uploadFile 使用
const uploadFiles = fileList.map((file) => { const uploadFiles = fileList.map((file) => {
const fileUri = typeof file === 'string' ? file : (file.tempFilePath || file.path || file); const fileUri = typeof file === 'string' ? file : (file.tempFilePath || file.path ||
file);
return { return {
name: 'files', name: 'files',
uri: fileUri uri: fileUri
}; };
}); });
console.log('uploadFileToShortStorage 参数:', { workspacesId, fileCount: uploadFiles.length, filePath }); console.log('uploadFileToShortStorage 参数:', {
workspacesId,
fileCount: uploadFiles.length,
filePath
});
uni.uploadFile({ uni.uploadFile({
url: `${BASE_URL}/cloud_api/file/temp/upload`, url: `${BASE_URL}/cloud_api/file/temp/upload`,
@@ -614,9 +625,13 @@ export const uploadFileToShortStorage = (workspacesId, files, filePath) => {
resolve(respond); resolve(respond);
} else if (respond.success) { } else if (respond.success) {
// 兼容 { success: true, url: "..." } 格式 // 兼容 { success: true, url: "..." } 格式
resolve([{ url: respond.url || respond.message, success: true }]); resolve([{
url: respond.url || respond.message,
success: true
}]);
} else { } else {
const msg = respond?.error || respond?.message || '上传文件到短存云端获取URL出错啦'; const msg = respond?.error || respond?.message ||
'上传文件到短存云端获取URL出错啦';
reject(msg); reject(msg);
} }
} catch (e) { } catch (e) {
@@ -1721,23 +1736,27 @@ export const conversationMessageDownload = (token, workspacesId, localUrl) => {
// 智能体 // 智能体
// 获取智能体列表 // 获取智能体列表
export const getAgentList = (token) =>{ export const getAgentList = (token) => {
return new Promise((resolve,reject)=>{ return new Promise((resolve, reject) => {
uni.request({ uni.request({
url:`${BASE_URL}/cloud_api/agent/list`, url: `${BASE_URL}/cloud_api/agent/list`,
method:"POST", method: "POST",
header:{'Content-Type':'application/json'}, header: {
data:{"access_token":token}, 'Content-Type': 'application/json'
},
data: {
"access_token": token
},
success: (res) => { success: (res) => {
if(res.statusCode === 200){ if (res.statusCode === 200) {
const respond = res.data; const respond = res.data;
if(respond.success){ if (respond.success) {
resolve(respond.data) resolve(respond.data)
} else { } else {
const msg = '获取智能体列表出错啦'; const msg = '获取智能体列表出错啦';
reject(msg); reject(msg);
} }
}else{ } else {
reject(`获取智能体列表失败:${res.statusCode}`) reject(`获取智能体列表失败:${res.statusCode}`)
} }
} }