diff --git a/pages/Chat/Chat.vue b/pages/Chat/Chat.vue index edf42d4..b8f91d5 100644 --- a/pages/Chat/Chat.vue +++ b/pages/Chat/Chat.vue @@ -41,8 +41,7 @@ + @refresh-conversations="takeUserConversations" @select-chat="isChatSidebar = false"> @@ -67,7 +66,7 @@ + :upper-threshold="0" :scroll-with-animation="!isThinking" @scroll="onScroll"> @@ -211,6 +210,10 @@ + @@ -587,6 +590,7 @@ }) return } + closeNewChatModal(); takeUserConversations(); } catch (error) { @@ -1035,8 +1039,8 @@ }, 1000) } -//修改优先把消息加入列表 - + //修改优先把消息加入列表 + // 发送AI消息 const sendAIMessage = async () => { @@ -1048,7 +1052,7 @@ content: messageContent }] await handleConnect(); - + if (uploadedFiles.value.length) { const fileJson = JSON.stringify(uploadedFiles.value) messageContent = messageContent ? diff --git a/pages/WorkSpace/WorkSpace.vue b/pages/WorkSpace/WorkSpace.vue index 03bc32a..13b431b 100644 --- a/pages/WorkSpace/WorkSpace.vue +++ b/pages/WorkSpace/WorkSpace.vue @@ -605,7 +605,10 @@ // 处理文件夹点击(非选择模式下进入文件夹,仅目录可点击进入) const handleFolderClick = (folder) => { - if (folder.type !== 'directory') return; + if (folder.type !== 'directory') { + handleLongPress(folder) + return + } folderStack.value.push({ path: folder.path, name: folder.name diff --git a/unpackage/dist/dev/app-plus/app-service.js b/unpackage/dist/dev/app-plus/app-service.js index 2756b50..f26bb30 100644 --- a/unpackage/dist/dev/app-plus/app-service.js +++ b/unpackage/dist/dev/app-plus/app-service.js @@ -5639,7 +5639,7 @@ This will fail in production.`); if (friendSocketStore.isConnected) return; if (!userToken.value || !UserId.value) { - formatAppLog("warn", "at pages/Chat/Chat.vue:345", "Token或UserId未准备好"); + formatAppLog("warn", "at pages/Chat/Chat.vue:349", "Token或UserId未准备好"); return; } friendSocketStore.connect({ @@ -5725,7 +5725,7 @@ This will fail in production.`); ); return html; } catch (e2) { - formatAppLog("error", "at pages/Chat/Chat.vue:471", "解析失败", e2); + formatAppLog("error", "at pages/Chat/Chat.vue:475", "解析失败", e2); return content; } }; @@ -5784,7 +5784,7 @@ This will fail in production.`); files }; } catch (e2) { - formatAppLog("error", "at pages/Chat/Chat.vue:548", "解析文件信息失败:", e2); + formatAppLog("error", "at pages/Chat/Chat.vue:552", "解析文件信息失败:", e2); return { textContent: content, files: [] @@ -5819,9 +5819,10 @@ This will fail in production.`); }); return; } + closeNewChatModal(); takeUserConversations(); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:593", "新建普通会话失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:598", "新建普通会话失败:", error); uni.showToast({ title: "创建会话失败,请重试", icon: "none" @@ -5859,7 +5860,7 @@ This will fail in production.`); }; const previewFileArray = vue.ref([]); const uploadPhoto = () => { - formatAppLog("log", "at pages/Chat/Chat.vue:642", "点击了拍照上传"); + formatAppLog("log", "at pages/Chat/Chat.vue:647", "点击了拍照上传"); uni.chooseImage({ count: 1, sourceType: ["camera", "album"], @@ -5882,7 +5883,7 @@ This will fail in production.`); }); }, fail: (err) => { - formatAppLog("error", "at pages/Chat/Chat.vue:660", "选择图片失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:665", "选择图片失败", err); } }); }; @@ -5891,12 +5892,12 @@ This will fail in production.`); }; const fileList = vue.ref([]); const uploadFile = () => { - formatAppLog("log", "at pages/Chat/Chat.vue:671", "点击了上传文件"); + formatAppLog("log", "at pages/Chat/Chat.vue:676", "点击了上传文件"); chooseFile({ count: 5, type: "all", success: (res) => { - formatAppLog("log", "at pages/Chat/Chat.vue:676", "成功了"); + formatAppLog("log", "at pages/Chat/Chat.vue:681", "成功了"); fileList.value = res.tempFiles; previewFileArray.value.push(...res.tempFiles); uni.showToast({ @@ -5905,7 +5906,7 @@ This will fail in production.`); }); }, fail: (err) => { - formatAppLog("error", "at pages/Chat/Chat.vue:687", "选择失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:692", "选择失败:", err); uni.showToast({ title: "选择失败", icon: "error" @@ -6107,7 +6108,7 @@ This will fail in production.`); previewFileArray.value = []; } catch (err) { uni.hideLoading(); - formatAppLog("error", "at pages/Chat/Chat.vue:922", "文件上传失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:927", "文件上传失败:", err); uni.showToast({ title: "文件上传失败,请重试", icon: "error" @@ -6126,10 +6127,6 @@ This will fail in production.`); sendGroupMessage(); }; const sendFriendMessage = async () => { - if (!friendSocketStore.isConnecting) - await handleFriendConnect(); - const receiverId = getReceiverId(); - const hasFiles = uploadedFiles.value.length > 0; const newMessageData = { "sender": UserId.value, "receiver": receiverId, @@ -6141,6 +6138,10 @@ This will fail in production.`); "contentJson": hasFiles ? JSON.stringify(uploadedFiles.value) : "null" }; allmessages.value = [...allmessages.value, newMessageData]; + if (!friendSocketStore.isConnecting) + await handleFriendConnect(); + const receiverId = getReceiverId(); + const hasFiles = uploadedFiles.value.length > 0; const body = { "command": 1, "sender": UserId.value, @@ -6166,6 +6167,16 @@ This will fail in production.`); }, 1e3); }; const sendGroupMessage = async () => { + const newMessageData = { + "id": allmessages.value.length + 1, + "message": textMessage.value, + "messageType": hasFiles ? 1 : 0, + "groupId": null, + "createTime": "", + "contentJson": hasFiles ? JSON.stringify(uploadedFiles.value) : "", + "sender": UserId.value + }; + allmessages.value = [...allmessages.value, newMessageData]; if (!friendSocketStore.isConnecting) await handleFriendConnect(); const hasFiles = uploadedFiles.value.length > 0; @@ -6180,16 +6191,6 @@ This will fail in production.`); if (hasFiles) { body.uploadVos = uploadedFiles.value; } - const newMessageData = { - "id": allmessages.value.length + 1, - "message": textMessage.value, - "messageType": hasFiles ? 1 : 0, - "groupId": null, - "createTime": "", - "contentJson": hasFiles ? JSON.stringify(uploadedFiles.value) : "", - "sender": UserId.value - }; - allmessages.value = [...allmessages.value, newMessageData]; const data = { "version": "1.1", "body": body @@ -6203,17 +6204,17 @@ This will fail in production.`); }; const sendAIMessage = async () => { try { - await handleConnect(); let messageContent = textMessage.value; + allmessages.value = [...allmessages.value, { + role: "user", + content: messageContent + }]; + await handleConnect(); if (uploadedFiles.value.length) { const fileJson = JSON.stringify(uploadedFiles.value); messageContent = messageContent ? `${messageContent} [文件信息:${fileJson}]` : `[文件信息:${fileJson}]`; } - allmessages.value = [...allmessages.value, { - role: "user", - content: messageContent - }]; const data = { "type": "chat", "conversation_id": currentSessionId.value, @@ -6241,15 +6242,15 @@ This will fail in production.`); } }; const stopConversation = async () => { - formatAppLog("log", "at pages/Chat/Chat.vue:1082", "中断对话 - 当前会话ID:", currentSessionId.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1097", "中断对话 - 当前会话ID:", currentSessionId.value); try { await socketStore.send({ type: "stop", conversation_id: currentSessionId.value }); - formatAppLog("log", "at pages/Chat/Chat.vue:1088", "中断指令已发送成功"); + formatAppLog("log", "at pages/Chat/Chat.vue:1103", "中断指令已发送成功"); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1090", "中断指令发送失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1105", "中断指令发送失败:", err); } if (streamingMessageId.value) { allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); @@ -6267,9 +6268,9 @@ This will fail in production.`); }); }; vue.watch(() => socketStore.isThinking, (newVal, oldVal) => { - formatAppLog("log", "at pages/Chat/Chat.vue:1114", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); + formatAppLog("log", "at pages/Chat/Chat.vue:1129", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); if (!oldVal && newVal) { - formatAppLog("log", "at pages/Chat/Chat.vue:1117", "AI开始回复(跨设备同步),锁定输入框"); + formatAppLog("log", "at pages/Chat/Chat.vue:1132", "AI开始回复(跨设备同步),锁定输入框"); isThinking.value = true; if (!streamingMessageId.value) { streamingMessageId.value = "streaming-" + Date.now(); @@ -6283,7 +6284,7 @@ This will fail in production.`); return; } if (oldVal && !newVal) { - formatAppLog("log", "at pages/Chat/Chat.vue:1133", "AI回复结束(正常/中断),解锁并刷新消息列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1148", "AI回复结束(正常/中断),解锁并刷新消息列表"); if (streamingMessageId.value) { allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); streamingMessageId.value = null; @@ -6335,15 +6336,15 @@ This will fail in production.`); UserData.value = await getUserInfo(userToken.value); UserId.value = UserData.value._id; UserAvatar.value = UserData.value.avatar || ""; - formatAppLog("log", "at pages/Chat/Chat.vue:1197", "用户信息已加载:", UserId.value, UserAvatar.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1212", "用户信息已加载:", UserId.value, UserAvatar.value); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1199", "获取用户信息失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1214", "获取用户信息失败:", error); } }; const takeUserConversations = async () => { try { userToken.value = getToken(); - formatAppLog("log", "at pages/Chat/Chat.vue:1207", "token:", userToken.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1222", "token:", userToken.value); UserConversations.value = await getUserConversations(userToken.value) || []; const savedSessionId = getCurrentSessionId(); if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) { @@ -6353,7 +6354,7 @@ This will fail in production.`); } else { currentSessionId.value = ""; } - formatAppLog("log", "at pages/Chat/Chat.vue:1219", "保存会话id:", currentSessionId.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1234", "保存会话id:", currentSessionId.value); uni.setStorageSync("currentSessionId", currentSessionId.value); } catch (error) { uni.showToast({ @@ -6365,17 +6366,17 @@ This will fail in production.`); const FriendInfoList = vue.ref([]); const takeFriendList = async () => { try { - formatAppLog("log", "at pages/Chat/Chat.vue:1234", "开始获取好友列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1249", "开始获取好友列表"); const friendList = await getChatFriend(UserId.value); - formatAppLog("log", "at pages/Chat/Chat.vue:1237", "friendList:", friendList); + formatAppLog("log", "at pages/Chat/Chat.vue:1252", "friendList:", friendList); if (friendList && friendList.length) { FriendInfoList.value = await takeUserAvatar(friendList); } else { FriendInfoList.value = []; - formatAppLog("log", "at pages/Chat/Chat.vue:1242", "好友列表为空"); + formatAppLog("log", "at pages/Chat/Chat.vue:1257", "好友列表为空"); } } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1245", "获取好友列表失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1260", "获取好友列表失败:", error); FriendInfoList.value = []; } finally { UserConversations.value = FriendInfoList.value; @@ -6402,17 +6403,17 @@ This will fail in production.`); }; }); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1275", "获取好友头像失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1290", "获取好友头像失败", err); return friendList; } }; const GroupList = vue.ref([]); const takeGroupList = async () => { try { - formatAppLog("log", "at pages/Chat/Chat.vue:1285", "开始获取群聊列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1300", "开始获取群聊列表"); GroupList.value = await getGroup(UserId.value); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1290", "获取群聊列表失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1305", "获取群聊列表失败:", error); GroupList.value = []; } finally { UserConversations.value = GroupList.value; @@ -6424,22 +6425,22 @@ This will fail in production.`); return []; try { const memberIds = memberList.map((item) => item.groupContactId); - formatAppLog("log", "at pages/Chat/Chat.vue:1304", "请求头像的ID列表:", memberIds); + formatAppLog("log", "at pages/Chat/Chat.vue:1319", "请求头像的ID列表:", memberIds); const memberAvatarList = await getUserAvatar(userToken.value, memberIds); - formatAppLog("log", "at pages/Chat/Chat.vue:1306", "头像接口返回数据:", memberAvatarList); + formatAppLog("log", "at pages/Chat/Chat.vue:1321", "头像接口返回数据:", memberAvatarList); const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []); - formatAppLog("log", "at pages/Chat/Chat.vue:1309", "userMap的keys:", Array.from(userMap.keys())); + formatAppLog("log", "at pages/Chat/Chat.vue:1324", "userMap的keys:", Array.from(userMap.keys())); return memberList.map((member) => { const memberId = member.groupContactId; const userInfo = userMap.get(memberId); - formatAppLog("log", "at pages/Chat/Chat.vue:1314", `查找 ${memberId} 的头像:`, userInfo); + formatAppLog("log", "at pages/Chat/Chat.vue:1329", `查找 ${memberId} 的头像:`, userInfo); return { ...member, avatar: (userInfo == null ? void 0 : userInfo.avatar) || null }; }); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1321", "获取群成员头像失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1336", "获取群成员头像失败", err); return memberList; } }; @@ -6486,12 +6487,12 @@ This will fail in production.`); const takeGroupMessages = async () => { try { allmessages.value = await getGroupMessages(currentSessionId.value) || []; - formatAppLog("log", "at pages/Chat/Chat.vue:1385", "群聊消息:", allmessages.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1400", "群聊消息:", allmessages.value); const memberList = await getGroupMemberList(currentSessionId.value); - formatAppLog("log", "at pages/Chat/Chat.vue:1388", "获取到的群成员列表:", memberList); + formatAppLog("log", "at pages/Chat/Chat.vue:1403", "获取到的群成员列表:", memberList); if (memberList && memberList.length) { groupMemberList.value = await takeGroupMemberAvatar(memberList); - formatAppLog("log", "at pages/Chat/Chat.vue:1391", "群成员列表(带头像):", groupMemberList.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1406", "群成员列表(带头像):", groupMemberList.value); } else { groupMemberList.value = []; } @@ -6515,9 +6516,9 @@ This will fail in production.`); } }; vue.watch(() => friendSocketStore.MessageReceived, (newId) => { - formatAppLog("log", "at pages/Chat/Chat.vue:1438", "收到了好友消息"); + formatAppLog("log", "at pages/Chat/Chat.vue:1453", "收到了好友消息"); if (newId) { - formatAppLog("log", "at pages/Chat/Chat.vue:1440", "ChatType:", ChatType.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1455", "ChatType:", ChatType.value); switch (ChatType.value) { case 0: takeConversationMessages(); @@ -6532,7 +6533,7 @@ This will fail in production.`); friendSocketStore.MessageReceived = false; break; default: - formatAppLog("log", "at pages/Chat/Chat.vue:1456", "default 分支"); + formatAppLog("log", "at pages/Chat/Chat.vue:1471", "default 分支"); friendSocketStore.MessageReceived = false; break; } @@ -6796,7 +6797,7 @@ This will fail in production.`); "scroll-y": "", "scroll-into-view": $setup.scrollToView, "upper-threshold": 0, - "scroll-with-animation": true, + "scroll-with-animation": !$setup.isThinking, onScroll: $setup.onScroll }, [ $setup.isLoadingMessages ? (vue.openBlock(), vue.createElementBlock("view", { @@ -7112,7 +7113,7 @@ This will fail in production.`); id: "chat-bottom-b", style: { "height": "1rpx" } }) - ], 40, ["scroll-into-view"]), + ], 40, ["scroll-into-view", "scroll-with-animation"]), vue.createElementVNode( "view", { @@ -7738,8 +7739,10 @@ This will fail in production.`); currentFolderList.value = getCurrentFolderList(); }; const handleFolderClick = (folder) => { - if (folder.type !== "directory") + if (folder.type !== "directory") { + handleLongPress(folder); return; + } folderStack.value.push({ path: folder.path, name: folder.name @@ -7778,7 +7781,7 @@ This will fail in production.`); uni.navigateBack({ delta: 1, fail() { - formatAppLog("log", "at pages/WorkSpace/WorkSpace.vue:658", "返回失败,进入兜底跳转"); + formatAppLog("log", "at pages/WorkSpace/WorkSpace.vue:661", "返回失败,进入兜底跳转"); uni.reLaunch({ url: "/pages/Chat/Chat" });