处理上传进度条;处理多选记录的取消;处理发送图片对方没有更新;处理解散群、踢人在对方会话列表中没有该会话情况
This commit is contained in:
parent
1f4c5ba6df
commit
f9f7e6e45d
@ -109,7 +109,7 @@ class Talk extends Base {
|
||||
// useSettingsStore().isPromptTone && palyMusic()
|
||||
}
|
||||
|
||||
handle() {
|
||||
async handle() {
|
||||
// 不是自己发送的消息则需要播放提示音
|
||||
if (!this.isCurrSender()) {
|
||||
this.play()
|
||||
@ -117,8 +117,19 @@ class Talk extends Base {
|
||||
|
||||
// 判断会话列表是否存在,不存在则创建
|
||||
if (useTalkStore().findTalkIndex(this.getIndexName()) == -1) {
|
||||
if (this.resource.msg_type == 1106) {
|
||||
//群解散时,需要热更新会话列表
|
||||
await useTalkStore().loadTalkList()
|
||||
} else if (
|
||||
this.resource.msg_type == 1104 ||
|
||||
this.resource.msg_type == 1115
|
||||
) {
|
||||
//群成员被移出时,需要热更新会话列表
|
||||
await useTalkStore().loadTalkList()
|
||||
} else {
|
||||
return this.addTalkItem()
|
||||
}
|
||||
}
|
||||
|
||||
// 判断当前是否正在和好友对话
|
||||
if (this.isTalk(this.talk_type, this.receiver_id, this.sender_id)) {
|
||||
|
@ -206,6 +206,12 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
|
||||
uploadImg(form, (e) => onProgressFn(e, randomId)).then(
|
||||
({ status, data, msg }) => {
|
||||
if (status == 0) {
|
||||
// 更新上传状态为成功
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 2
|
||||
virtualList.value[index].uploadCurrent = 100
|
||||
}
|
||||
resolve({
|
||||
type: 'image',
|
||||
url: data.ori_url,
|
||||
@ -215,6 +221,11 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
|
||||
file_num: randomId,
|
||||
})
|
||||
} else {
|
||||
// 更新上传状态为失败
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 3
|
||||
}
|
||||
resolve('')
|
||||
message.error(msg)
|
||||
}
|
||||
@ -261,6 +272,12 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
|
||||
uploadImg(form, (e) => onProgressFn(e, randomId)).then(
|
||||
({ status, data, msg }) => {
|
||||
if (status == 0) {
|
||||
// 更新上传状态为成功
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 2
|
||||
virtualList.value[index].uploadCurrent = 100
|
||||
}
|
||||
console.log(data)
|
||||
resolve({
|
||||
type: 'video',
|
||||
@ -271,8 +288,13 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
|
||||
file_num: randomId,
|
||||
})
|
||||
} else {
|
||||
// resolve('')
|
||||
// message.error(msg)
|
||||
// 更新上传状态为失败
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 3
|
||||
}
|
||||
resolve('')
|
||||
message.error(msg)
|
||||
}
|
||||
},
|
||||
)
|
||||
@ -456,7 +478,23 @@ const chooseFile = () => {
|
||||
uploadStatus: 1, // 1 上传中 2 上传成功 3 上传失败
|
||||
}
|
||||
virtualList.value.unshift(newItem)
|
||||
uploadsStore.initUploadFile(res.tempFiles[0], props.talkParams, randomId)
|
||||
uploadsStore.initUploadFile(res.tempFiles[0], props.talkParams, randomId, (status, data, msg) => {
|
||||
if (status === 0) {
|
||||
// 更新上传状态为成功
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 2
|
||||
virtualList.value[index].uploadCurrent = 100
|
||||
}
|
||||
} else {
|
||||
// 更新上传状态为失败
|
||||
const index = virtualList.value.findIndex(item => item.file_num === randomId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 3
|
||||
}
|
||||
message.error(msg)
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -16,7 +16,14 @@
|
||||
@scrolltoupper="onScrollToUpper"
|
||||
>
|
||||
<template #top>
|
||||
<customNavbar :title="talkParams.username" id="navBarArea">
|
||||
<customNavbar
|
||||
:title="talkParams.username"
|
||||
id="navBarArea"
|
||||
:hideBack="dialogueStore.isOpenMultiSelect"
|
||||
>
|
||||
<template #left v-if="dialogueStore.isOpenMultiSelect">
|
||||
<text class="ml-[36rpx]" @click="dialogueStore.isOpenMultiSelect = false">取消</text>
|
||||
</template>
|
||||
<template
|
||||
#subTitle
|
||||
v-if="talkStore?.findItem(talkParams.index_name)?.group_type === 4"
|
||||
@ -310,13 +317,13 @@
|
||||
<tm-image :width="68" :height="68" :src="zu6051"></tm-image>
|
||||
<div class="mt-[6rpx]">逐条转发</div>
|
||||
</div>
|
||||
<div
|
||||
<!-- <div
|
||||
@click="handleWechatForward"
|
||||
class="flex flex-col items-center justify-center"
|
||||
>
|
||||
<tm-image :width="68" :height="68" :src="zu6052"></tm-image>
|
||||
<div class="mt-[6rpx]">微信</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<div
|
||||
@click="handleDelete"
|
||||
class="flex flex-col items-center justify-center"
|
||||
@ -1346,9 +1353,12 @@ const getMentionSelectLists = (mentionSelectList) => {
|
||||
|
||||
// 逐个插入mention
|
||||
mentionSelectList.forEach((mentionSelectItem) => {
|
||||
// 如果是@所有人,确保 id 为 0
|
||||
const id =
|
||||
mentionSelectItem?.nickname === '所有人' ? 0 : mentionSelectItem?.id
|
||||
mention.insertItem(
|
||||
{
|
||||
id: mentionSelectItem?.id,
|
||||
id: id,
|
||||
denotationChar: '@',
|
||||
value: mentionSelectItem?.nickname + ' ',
|
||||
},
|
||||
@ -1382,11 +1392,19 @@ const updateMentionUserIds = () => {
|
||||
// 收集当前所有@的用户ID,并转换为number类型
|
||||
ops.forEach((op) => {
|
||||
if (op.insert && op.insert.mention) {
|
||||
currentMentions.add(Number(op.insert.mention.id))
|
||||
const id = Number(op.insert.mention.id)
|
||||
// 过滤掉 null 值
|
||||
if (!isNaN(id)) {
|
||||
currentMentions.add(id)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// 直接使用当前编辑器中的mentions作为mentionUserIds
|
||||
// 如果当前有@所有人,或者没有任何@,则添加0
|
||||
if (currentMentions.has(0) || currentMentions.size === 0) {
|
||||
currentMentions.add(0)
|
||||
}
|
||||
state.value.mentionUserIds = Array.from(currentMentions)
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ export const useDialogueStore = defineStore('dialogue', {
|
||||
this.unreadNum = data?.unread_num || 0
|
||||
|
||||
this.members = []
|
||||
if (data.talk_type == 2 && !data.is_dismiss && !data.is_quit) {
|
||||
if (data.talk_type == 2 && !this.isDismiss && !this.isQuit) {
|
||||
this.updateGroupMembers()
|
||||
}
|
||||
},
|
||||
|
@ -141,6 +141,8 @@ export const useDialogueListStore = createGlobalState(() => {
|
||||
...virtualList.value[index], // 保留原有不需要修改的字段
|
||||
...item, // 覆盖需要更新的字段
|
||||
})
|
||||
} else {
|
||||
zpagingRef.value?.addChatRecordData(item, false, false)
|
||||
}
|
||||
} else {
|
||||
zpagingRef.value?.addChatRecordData(item, false, false)
|
||||
|
@ -91,7 +91,19 @@ export const useUploadsStore = defineStore('uploads', {
|
||||
|
||||
item.status = 1
|
||||
|
||||
ServeFileSubareaUpload(form)
|
||||
// 开始上传时就更新进度
|
||||
const currentPercentage = (item.uploadIndex / item.files.length) * 100
|
||||
item.percentage = currentPercentage.toFixed(1)
|
||||
updateUploadProgress(msgId, currentPercentage)
|
||||
|
||||
ServeFileSubareaUpload(form, (progressEvent) => {
|
||||
// 计算当前分片的进度
|
||||
const currentChunkProgress = (progressEvent.loaded / progressEvent.total) * 100
|
||||
// 计算总体进度:已完成分片 + 当前分片的进度
|
||||
const totalProgress = ((item.uploadIndex + currentChunkProgress / 100) / item.files.length) * 100
|
||||
item.percentage = totalProgress.toFixed(1)
|
||||
updateUploadProgress(msgId, totalProgress)
|
||||
})
|
||||
.then((res) => {
|
||||
if (res.code == 200) {
|
||||
item.uploadIndex++
|
||||
@ -103,21 +115,36 @@ export const useUploadsStore = defineStore('uploads', {
|
||||
|
||||
updateUploadProgress(msgId,100)
|
||||
this.sendUploadMessage(item, msgId)
|
||||
} else {
|
||||
const percentage = (item.uploadIndex / item.files.length) * 100
|
||||
item.percentage = percentage.toFixed(1)
|
||||
console.log(msgId,'msgId');
|
||||
console.log(percentage,'percentage');
|
||||
|
||||
updateUploadProgress(msgId,percentage)
|
||||
this.triggerUpload(uploadId,msgId)
|
||||
// 更新虚拟列表中的状态
|
||||
const { virtualList } = useDialogueListStore()
|
||||
const index = virtualList.value.findIndex(item => item.file_num === msgId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 2
|
||||
virtualList.value[index].uploadCurrent = 100
|
||||
}
|
||||
} else {
|
||||
// 继续上传下一个分片
|
||||
this.triggerUpload(uploadId, msgId)
|
||||
}
|
||||
} else {
|
||||
item.status = 3
|
||||
// 更新虚拟列表中的状态为失败
|
||||
const { virtualList } = useDialogueListStore()
|
||||
const index = virtualList.value.findIndex(item => item.file_num === msgId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 3
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
item.status = 3
|
||||
// 更新虚拟列表中的状态为失败
|
||||
const { virtualList } = useDialogueListStore()
|
||||
const index = virtualList.value.findIndex(item => item.file_num === msgId)
|
||||
if (index !== -1) {
|
||||
virtualList.value[index].uploadStatus = 3
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
|
@ -104,6 +104,11 @@ export const upload = (url, data = {}, options = {}) => {
|
||||
url,
|
||||
method: 'post',
|
||||
data: data,
|
||||
onUploadProgress: (progressEvent) => {
|
||||
if (options.onProgress) {
|
||||
options.onProgress(progressEvent)
|
||||
}
|
||||
},
|
||||
...options
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user