feat: 消息聊天最近列表支持删除会话
This commit is contained in:
@@ -10,6 +10,8 @@ export const getUnreadList = () => request.get('/messages/unreadList')
|
||||
|
||||
export const markAsRead = (id) => request.post(`/messages/${id}/read`)
|
||||
|
||||
export const deleteConversation = (withUserId) => request.delete(`/messages/conversation/${withUserId}`)
|
||||
|
||||
export const getUsers = () => request.get('/messages/users')
|
||||
|
||||
// 聊天文件上传(图片和文件统一接口)
|
||||
|
||||
@@ -217,7 +217,7 @@ import { ref, computed, onMounted, onUnmounted, nextTick } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import { ChatLineRound, User, Search, Close, Loading, Picture, Paperclip, Download, ChatDotRound, Promotion } from '@element-plus/icons-vue'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { getUsers, getMessages, sendMessage as sendMessageApi, uploadChatFile, getUnreadList } from '@/api/message'
|
||||
import { getUsers, getMessages, sendMessage as sendMessageApi, uploadChatFile, getUnreadList, deleteConversation } from '@/api/message'
|
||||
import { chatService } from '@/services/chat'
|
||||
|
||||
const props = defineProps({ modelValue: Boolean })
|
||||
@@ -571,7 +571,12 @@ const downloadFile = async (msg) => {
|
||||
|
||||
// ======== 其他操作 ========
|
||||
|
||||
const deleteRecentChat = (chat) => {
|
||||
const deleteRecentChat = async (chat) => {
|
||||
try {
|
||||
await deleteConversation(chat.id)
|
||||
} catch (e) {
|
||||
// 即使 API 失败也删本地
|
||||
}
|
||||
const idx = recentChats.value.findIndex(c => c.id === chat.id)
|
||||
if (idx > -1) recentChats.value.splice(idx, 1)
|
||||
if (currentContact.value?.id === chat.id) currentContact.value = null
|
||||
|
||||
Reference in New Issue
Block a user