feat:群聊问题修复+相关项目文档更新

This commit is contained in:
bujinyuan
2026-03-05 09:24:49 +08:00
parent 4f55ef6de0
commit 8ee870636c
29 changed files with 1155 additions and 225 deletions

View File

@@ -113,6 +113,7 @@
<script setup>
import { ref, onMounted, computed } from 'vue'
import { onShow } from '@dcloudio/uni-app'
import { useContactStore } from '@/store/contact'
import { useWebSocketStore } from '@/store/websocket'
import { useUserStore } from '@/store/user'
@@ -134,22 +135,33 @@ const filteredFriends = computed(() => {
)
})
const refreshData = async () => {
if (!userStore.isLoggedIn) return
try {
await Promise.all([
contactStore.fetchFriends(),
contactStore.fetchPendingRequests()
])
} catch (e) {
console.error('获取联系人数据失败', e)
}
}
onMounted(async () => {
if (userStore.isLoggedIn) {
wsStore.connect()
contactStore.initWsListeners()
try {
await Promise.all([
contactStore.fetchFriends(),
contactStore.fetchPendingRequests()
])
} catch (e) {
console.error('获取联系人数据失败', e)
}
await refreshData()
}
loading.value = false
})
onShow(() => {
if (!loading.value) {
refreshData()
}
})
const goToSearch = () => uni.navigateTo({ url: '/pages/contact/search' })
const goToRequests = () => uni.navigateTo({ url: '/pages/contact/request' })
const goToDetail = (friend) => uni.navigateTo({ url: `/pages/contact/detail?userId=${friend.user_id}` })

View File

@@ -97,7 +97,7 @@ const handleAccept = async (requestId) => {
uni.showToast({ title: '已接受', icon: 'success' })
} catch (e) {
console.error('接受好友申请失败', e)
uni.showToast({ title: e?.data?.message || '接受申请失败', icon: 'none' })
uni.showToast({ title: e?.message || '接受申请失败', icon: 'none' })
} finally {
processingMap[requestId] = false
}
@@ -111,7 +111,7 @@ const handleReject = async (requestId) => {
uni.showToast({ title: '已拒绝', icon: 'none' })
} catch (e) {
console.error('拒绝好友申请失败', e)
uni.showToast({ title: e?.data?.message || '拒绝申请失败', icon: 'none' })
uni.showToast({ title: e?.message || '拒绝申请失败', icon: 'none' })
} finally {
processingMap[requestId] = false
}

View File

@@ -157,7 +157,7 @@ const showAddDialog = (user) => {
console.error('发送好友申请失败', e)
addingMap[user.id] = false
uni.showToast({
title: e?.data?.message || '发送申请失败',
title: e?.message || '发送申请失败',
icon: 'none'
})
}