diff --git a/pages/WYXD/WYXD.vue b/pages/WYXD/WYXD.vue index 55c214b..402eb4f 100644 --- a/pages/WYXD/WYXD.vue +++ b/pages/WYXD/WYXD.vue @@ -244,7 +244,7 @@ onLoad((options) => { .wyxd-slide-area { flex: 1; min-height: 0; - padding: 20rpx; + /* padding: 20rpx; */ } .wyxd-slide-scroll { @@ -254,10 +254,18 @@ onLoad((options) => { box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.04); } -.wyxd-slide-card { +/* .wyxd-slide-card { padding: 32rpx; min-height: 100%; box-sizing: border-box; +} */ +.wyxd-slide-card { + min-height: 100%; + box-sizing: border-box; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; /* 子元素垂直排列 */ } /* ===== 底部翻页 ===== */ diff --git a/unpackage/dist/dev/app-plus/app-service.js b/unpackage/dist/dev/app-plus/app-service.js index 412614c..2756b50 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:346", "Token或UserId未准备好"); + formatAppLog("warn", "at pages/Chat/Chat.vue:345", "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:472", "解析失败", e2); + formatAppLog("error", "at pages/Chat/Chat.vue:471", "解析失败", e2); return content; } }; @@ -5784,7 +5784,7 @@ This will fail in production.`); files }; } catch (e2) { - formatAppLog("error", "at pages/Chat/Chat.vue:549", "解析文件信息失败:", e2); + formatAppLog("error", "at pages/Chat/Chat.vue:548", "解析文件信息失败:", e2); return { textContent: content, files: [] @@ -5821,7 +5821,7 @@ This will fail in production.`); } takeUserConversations(); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:594", "新建普通会话失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:593", "新建普通会话失败:", error); uni.showToast({ title: "创建会话失败,请重试", icon: "none" @@ -5859,7 +5859,7 @@ This will fail in production.`); }; const previewFileArray = vue.ref([]); const uploadPhoto = () => { - formatAppLog("log", "at pages/Chat/Chat.vue:643", "点击了拍照上传"); + formatAppLog("log", "at pages/Chat/Chat.vue:642", "点击了拍照上传"); uni.chooseImage({ count: 1, sourceType: ["camera", "album"], @@ -5882,7 +5882,7 @@ This will fail in production.`); }); }, fail: (err) => { - formatAppLog("error", "at pages/Chat/Chat.vue:661", "选择图片失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:660", "选择图片失败", err); } }); }; @@ -5891,12 +5891,12 @@ This will fail in production.`); }; const fileList = vue.ref([]); const uploadFile = () => { - formatAppLog("log", "at pages/Chat/Chat.vue:672", "点击了上传文件"); + formatAppLog("log", "at pages/Chat/Chat.vue:671", "点击了上传文件"); chooseFile({ count: 5, type: "all", success: (res) => { - formatAppLog("log", "at pages/Chat/Chat.vue:677", "成功了"); + formatAppLog("log", "at pages/Chat/Chat.vue:676", "成功了"); fileList.value = res.tempFiles; previewFileArray.value.push(...res.tempFiles); uni.showToast({ @@ -5905,7 +5905,7 @@ This will fail in production.`); }); }, fail: (err) => { - formatAppLog("error", "at pages/Chat/Chat.vue:688", "选择失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:687", "选择失败:", err); uni.showToast({ title: "选择失败", icon: "error" @@ -6107,7 +6107,7 @@ This will fail in production.`); previewFileArray.value = []; } catch (err) { uni.hideLoading(); - formatAppLog("error", "at pages/Chat/Chat.vue:923", "文件上传失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:922", "文件上传失败:", err); uni.showToast({ title: "文件上传失败,请重试", icon: "error" @@ -6130,6 +6130,17 @@ This will fail in production.`); await handleFriendConnect(); const receiverId = getReceiverId(); const hasFiles = uploadedFiles.value.length > 0; + const newMessageData = { + "sender": UserId.value, + "receiver": receiverId, + "content": textMessage.value, + "taskId": null, + "avatar": null, + "createTime": "", + "messageType": "null", + "contentJson": hasFiles ? JSON.stringify(uploadedFiles.value) : "null" + }; + allmessages.value = [...allmessages.value, newMessageData]; const body = { "command": 1, "sender": UserId.value, @@ -6148,17 +6159,6 @@ This will fail in production.`); "body": body }; friendSocketStore.send(data); - const newMessageData = { - "sender": UserId.value, - "receiver": receiverId, - "content": textMessage.value, - "taskId": null, - "avatar": null, - "createTime": "", - "messageType": "null", - "contentJson": hasFiles ? JSON.stringify(uploadedFiles.value) : "null" - }; - allmessages.value = [...allmessages.value, newMessageData]; textMessage.value = ""; uploadedFiles.value = []; setTimeout(() => { @@ -6180,11 +6180,6 @@ This will fail in production.`); if (hasFiles) { body.uploadVos = uploadedFiles.value; } - const data = { - "version": "1.1", - "body": body - }; - friendSocketStore.send(data); const newMessageData = { "id": allmessages.value.length + 1, "message": textMessage.value, @@ -6195,6 +6190,11 @@ This will fail in production.`); "sender": UserId.value }; allmessages.value = [...allmessages.value, newMessageData]; + const data = { + "version": "1.1", + "body": body + }; + friendSocketStore.send(data); textMessage.value = ""; uploadedFiles.value = []; setTimeout(() => { @@ -6210,6 +6210,10 @@ This will fail in production.`); messageContent = messageContent ? `${messageContent} [文件信息:${fileJson}]` : `[文件信息:${fileJson}]`; } + allmessages.value = [...allmessages.value, { + role: "user", + content: messageContent + }]; const data = { "type": "chat", "conversation_id": currentSessionId.value, @@ -6218,10 +6222,6 @@ This will fail in production.`); socketStore.send(data); isThinking.value = true; isSelfSent.value = true; - allmessages.value = [...allmessages.value, { - role: "user", - content: messageContent - }]; streamingMessageId.value = "streaming-" + Date.now(); allmessages.value = [...allmessages.value, { role: "assistant", @@ -6241,15 +6241,15 @@ This will fail in production.`); } }; const stopConversation = async () => { - formatAppLog("log", "at pages/Chat/Chat.vue:1092", "中断对话 - 当前会话ID:", currentSessionId.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1082", "中断对话 - 当前会话ID:", currentSessionId.value); try { await socketStore.send({ type: "stop", conversation_id: currentSessionId.value }); - formatAppLog("log", "at pages/Chat/Chat.vue:1098", "中断指令已发送成功"); + formatAppLog("log", "at pages/Chat/Chat.vue:1088", "中断指令已发送成功"); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1100", "中断指令发送失败:", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1090", "中断指令发送失败:", err); } if (streamingMessageId.value) { allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); @@ -6267,9 +6267,9 @@ This will fail in production.`); }); }; vue.watch(() => socketStore.isThinking, (newVal, oldVal) => { - formatAppLog("log", "at pages/Chat/Chat.vue:1124", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); + formatAppLog("log", "at pages/Chat/Chat.vue:1114", "isThinking 变化:", oldVal, "→", newVal, "messageString:", socketStore.messageString); if (!oldVal && newVal) { - formatAppLog("log", "at pages/Chat/Chat.vue:1127", "AI开始回复(跨设备同步),锁定输入框"); + formatAppLog("log", "at pages/Chat/Chat.vue:1117", "AI开始回复(跨设备同步),锁定输入框"); isThinking.value = true; if (!streamingMessageId.value) { streamingMessageId.value = "streaming-" + Date.now(); @@ -6283,7 +6283,7 @@ This will fail in production.`); return; } if (oldVal && !newVal) { - formatAppLog("log", "at pages/Chat/Chat.vue:1143", "AI回复结束(正常/中断),解锁并刷新消息列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1133", "AI回复结束(正常/中断),解锁并刷新消息列表"); if (streamingMessageId.value) { allmessages.value = allmessages.value.filter((m) => m._id !== streamingMessageId.value); streamingMessageId.value = null; @@ -6335,15 +6335,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:1207", "用户信息已加载:", UserId.value, UserAvatar.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1197", "用户信息已加载:", UserId.value, UserAvatar.value); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1209", "获取用户信息失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1199", "获取用户信息失败:", error); } }; const takeUserConversations = async () => { try { userToken.value = getToken(); - formatAppLog("log", "at pages/Chat/Chat.vue:1217", "token:", userToken.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1207", "token:", userToken.value); UserConversations.value = await getUserConversations(userToken.value) || []; const savedSessionId = getCurrentSessionId(); if (savedSessionId && UserConversations.value.some((c) => c._id === savedSessionId)) { @@ -6353,7 +6353,7 @@ This will fail in production.`); } else { currentSessionId.value = ""; } - formatAppLog("log", "at pages/Chat/Chat.vue:1229", "保存会话id:", currentSessionId.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1219", "保存会话id:", currentSessionId.value); uni.setStorageSync("currentSessionId", currentSessionId.value); } catch (error) { uni.showToast({ @@ -6365,17 +6365,17 @@ This will fail in production.`); const FriendInfoList = vue.ref([]); const takeFriendList = async () => { try { - formatAppLog("log", "at pages/Chat/Chat.vue:1244", "开始获取好友列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1234", "开始获取好友列表"); const friendList = await getChatFriend(UserId.value); - formatAppLog("log", "at pages/Chat/Chat.vue:1247", "friendList:", friendList); + formatAppLog("log", "at pages/Chat/Chat.vue:1237", "friendList:", friendList); if (friendList && friendList.length) { FriendInfoList.value = await takeUserAvatar(friendList); } else { FriendInfoList.value = []; - formatAppLog("log", "at pages/Chat/Chat.vue:1252", "好友列表为空"); + formatAppLog("log", "at pages/Chat/Chat.vue:1242", "好友列表为空"); } } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1255", "获取好友列表失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1245", "获取好友列表失败:", error); FriendInfoList.value = []; } finally { UserConversations.value = FriendInfoList.value; @@ -6402,17 +6402,17 @@ This will fail in production.`); }; }); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1285", "获取好友头像失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1275", "获取好友头像失败", err); return friendList; } }; const GroupList = vue.ref([]); const takeGroupList = async () => { try { - formatAppLog("log", "at pages/Chat/Chat.vue:1295", "开始获取群聊列表"); + formatAppLog("log", "at pages/Chat/Chat.vue:1285", "开始获取群聊列表"); GroupList.value = await getGroup(UserId.value); } catch (error) { - formatAppLog("error", "at pages/Chat/Chat.vue:1300", "获取群聊列表失败:", error); + formatAppLog("error", "at pages/Chat/Chat.vue:1290", "获取群聊列表失败:", error); GroupList.value = []; } finally { UserConversations.value = GroupList.value; @@ -6424,22 +6424,22 @@ This will fail in production.`); return []; try { const memberIds = memberList.map((item) => item.groupContactId); - formatAppLog("log", "at pages/Chat/Chat.vue:1314", "请求头像的ID列表:", memberIds); + formatAppLog("log", "at pages/Chat/Chat.vue:1304", "请求头像的ID列表:", memberIds); const memberAvatarList = await getUserAvatar(userToken.value, memberIds); - formatAppLog("log", "at pages/Chat/Chat.vue:1316", "头像接口返回数据:", memberAvatarList); + formatAppLog("log", "at pages/Chat/Chat.vue:1306", "头像接口返回数据:", memberAvatarList); const userMap = new Map(memberAvatarList.map((user) => [user.user_id, user]) || []); - formatAppLog("log", "at pages/Chat/Chat.vue:1319", "userMap的keys:", Array.from(userMap.keys())); + formatAppLog("log", "at pages/Chat/Chat.vue:1309", "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:1324", `查找 ${memberId} 的头像:`, userInfo); + formatAppLog("log", "at pages/Chat/Chat.vue:1314", `查找 ${memberId} 的头像:`, userInfo); return { ...member, avatar: (userInfo == null ? void 0 : userInfo.avatar) || null }; }); } catch (err) { - formatAppLog("error", "at pages/Chat/Chat.vue:1331", "获取群成员头像失败", err); + formatAppLog("error", "at pages/Chat/Chat.vue:1321", "获取群成员头像失败", err); return memberList; } }; @@ -6486,12 +6486,12 @@ This will fail in production.`); const takeGroupMessages = async () => { try { allmessages.value = await getGroupMessages(currentSessionId.value) || []; - formatAppLog("log", "at pages/Chat/Chat.vue:1395", "群聊消息:", allmessages.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1385", "群聊消息:", allmessages.value); const memberList = await getGroupMemberList(currentSessionId.value); - formatAppLog("log", "at pages/Chat/Chat.vue:1398", "获取到的群成员列表:", memberList); + formatAppLog("log", "at pages/Chat/Chat.vue:1388", "获取到的群成员列表:", memberList); if (memberList && memberList.length) { groupMemberList.value = await takeGroupMemberAvatar(memberList); - formatAppLog("log", "at pages/Chat/Chat.vue:1401", "群成员列表(带头像):", groupMemberList.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1391", "群成员列表(带头像):", groupMemberList.value); } else { groupMemberList.value = []; } @@ -6515,9 +6515,9 @@ This will fail in production.`); } }; vue.watch(() => friendSocketStore.MessageReceived, (newId) => { - formatAppLog("log", "at pages/Chat/Chat.vue:1448", "收到了好友消息"); + formatAppLog("log", "at pages/Chat/Chat.vue:1438", "收到了好友消息"); if (newId) { - formatAppLog("log", "at pages/Chat/Chat.vue:1450", "ChatType:", ChatType.value); + formatAppLog("log", "at pages/Chat/Chat.vue:1440", "ChatType:", ChatType.value); switch (ChatType.value) { case 0: takeConversationMessages(); @@ -6532,7 +6532,7 @@ This will fail in production.`); friendSocketStore.MessageReceived = false; break; default: - formatAppLog("log", "at pages/Chat/Chat.vue:1466", "default 分支"); + formatAppLog("log", "at pages/Chat/Chat.vue:1456", "default 分支"); friendSocketStore.MessageReceived = false; break; } diff --git a/unpackage/dist/dev/app-plus/pages/WYXD/WYXD.css b/unpackage/dist/dev/app-plus/pages/WYXD/WYXD.css index 5e81963..8404fd2 100644 --- a/unpackage/dist/dev/app-plus/pages/WYXD/WYXD.css +++ b/unpackage/dist/dev/app-plus/pages/WYXD/WYXD.css @@ -378,7 +378,7 @@ .wyxd-slide-area[data-v-507487c4] { flex: 1; min-height: 0; - padding: 0.625rem; + /* padding: 20rpx; */ } .wyxd-slide-scroll[data-v-507487c4] { height: 100%; @@ -386,10 +386,18 @@ border-radius: 0.375rem; box-shadow: 0 0.0625rem 0.375rem rgba(0, 0, 0, 0.04); } -.wyxd-slide-card[data-v-507487c4] { - padding: 1rem; +/* .wyxd-slide-card { + padding: 32rpx; min-height: 100%; box-sizing: border-box; +} */ +.wyxd-slide-card[data-v-507487c4] { + min-height: 100%; + box-sizing: border-box; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; /* 子元素垂直排列 */ } /* ===== 底部翻页 ===== */ .wyxd-pager[data-v-507487c4] {