|
@@ -182,12 +182,13 @@ const sendTextMessage = async (text) => {
|
|
|
}
|
|
|
}
|
|
|
const isLink = !!findHyperlinks(text)
|
|
|
- if (isLink) msg.messageType = 0
|
|
|
+ if (isLink) msg.messageType = 0;
|
|
|
+ console.log(currConversationChatList.value, '1122')
|
|
|
currConversationChatList.value.push(msg)
|
|
|
await scrollToBottom()
|
|
|
await chatsStore.sendSocketMessage(msg)
|
|
|
} catch (e) {
|
|
|
- // console.log(e, '2')
|
|
|
+ console.log(e, '2')
|
|
|
} finally {
|
|
|
}
|
|
|
}
|
|
@@ -251,17 +252,31 @@ const handleSendMessage = async ({ type, messageContent }) => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-const scrollToBottom = async () => {
|
|
|
+// async
|
|
|
+const scrollToBottom = () => {
|
|
|
// 操作向上加载不滚动 TODO 判断用户是否有向上滑的操作更准确
|
|
|
if (moreLoading.value) return
|
|
|
- setTimeout(async () => {
|
|
|
- await nextTick() // 确保DOM已经更新
|
|
|
+ // setTimeout(async () => {
|
|
|
+ // await nextTick() // 确保DOM已经更新
|
|
|
+ // const listElement = chatListRef.value?.$el
|
|
|
+ // if (listElement) {
|
|
|
+ // const scrollContainer = listElement
|
|
|
+ // scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
|
+ // }
|
|
|
+ // }, 200)
|
|
|
+
|
|
|
+ // await nextTick() // 确保DOM已经更新
|
|
|
+ // const listElement = chatListRef.value?.$el
|
|
|
+ // if (listElement) {
|
|
|
+ // const scrollContainer = listElement
|
|
|
+ // scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
|
+ // }
|
|
|
+ nextTick(() => {
|
|
|
const listElement = chatListRef.value?.$el
|
|
|
- if (listElement) {
|
|
|
- const scrollContainer = listElement
|
|
|
- scrollContainer.scrollTop = scrollContainer.scrollHeight
|
|
|
- }
|
|
|
- }, 200)
|
|
|
+ setTimeout(() => {
|
|
|
+ listElement && (listElement.scrollTop = listElement.scrollHeight + 100)
|
|
|
+ }, 200)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
// 获取我与对方的关注情况
|
|
@@ -318,7 +333,7 @@ function getLocalId() {
|
|
|
onMounted(() => {
|
|
|
initGroupId()
|
|
|
XYWebSocket.SocketEventsBus.on('chat-event', async (chat) => {
|
|
|
- // console.log('单聊页面消息订阅', chat)
|
|
|
+ console.log('单聊页面消息订阅', chat)
|
|
|
const isCurrGroupId = chat.groupId && chat.groupId === groupId.value
|
|
|
const isOtherUserMessage = chat.sendUserId && chatsStore.isRealMessage(chat.sendUserId)
|
|
|
if (isCurrGroupId) {
|
|
@@ -336,7 +351,7 @@ onMounted(() => {
|
|
|
watchEffect(() => {})
|
|
|
|
|
|
// 会话好友的信息
|
|
|
-const getAnnouncement = async () => {
|
|
|
+const getAnnouncement = () => {
|
|
|
return new Promise((resolve) => {
|
|
|
request('/website/tourMember/getOneWayMember', {
|
|
|
query: { groupId: groupId.value }
|