feat:群聊问题修复+相关项目文档更新
This commit is contained in:
@@ -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}` })
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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'
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user