Compare commits

..

2 Commits

Author SHA1 Message Date
2676e70c0c Merge branch 'wyfMain-dev'
Some checks are pending
Check / lint (push) Waiting to run
Check / typecheck (push) Waiting to run
Check / build (build, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build, 18.x, windows-latest) (push) Waiting to run
Check / build (build:app, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:app, 18.x, windows-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, ubuntu-latest) (push) Waiting to run
Check / build (build:mp-weixin, 18.x, windows-latest) (push) Waiting to run
2025-03-26 19:52:46 +08:00
f9f7e6e45d 处理上传进度条;处理多选记录的取消;处理发送图片对方没有更新;处理解散群、踢人在对方会话列表中没有该会话情况 2025-03-26 19:51:07 +08:00
7 changed files with 121 additions and 20 deletions

View File

@ -109,7 +109,7 @@ class Talk extends Base {
// useSettingsStore().isPromptTone && palyMusic() // useSettingsStore().isPromptTone && palyMusic()
} }
handle() { async handle() {
// 不是自己发送的消息则需要播放提示音 // 不是自己发送的消息则需要播放提示音
if (!this.isCurrSender()) { if (!this.isCurrSender()) {
this.play() this.play()
@ -117,7 +117,18 @@ class Talk extends Base {
// 判断会话列表是否存在,不存在则创建 // 判断会话列表是否存在,不存在则创建
if (useTalkStore().findTalkIndex(this.getIndexName()) == -1) { if (useTalkStore().findTalkIndex(this.getIndexName()) == -1) {
return this.addTalkItem() 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()
}
} }
// 判断当前是否正在和好友对话 // 判断当前是否正在和好友对话

View File

@ -206,6 +206,12 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
uploadImg(form, (e) => onProgressFn(e, randomId)).then( uploadImg(form, (e) => onProgressFn(e, randomId)).then(
({ status, data, msg }) => { ({ status, data, msg }) => {
if (status == 0) { 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({ resolve({
type: 'image', type: 'image',
url: data.ori_url, url: data.ori_url,
@ -215,6 +221,11 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
file_num: randomId, file_num: randomId,
}) })
} else { } else {
//
const index = virtualList.value.findIndex(item => item.file_num === randomId)
if (index !== -1) {
virtualList.value[index].uploadStatus = 3
}
resolve('') resolve('')
message.error(msg) message.error(msg)
} }
@ -261,6 +272,12 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
uploadImg(form, (e) => onProgressFn(e, randomId)).then( uploadImg(form, (e) => onProgressFn(e, randomId)).then(
({ status, data, msg }) => { ({ status, data, msg }) => {
if (status == 0) { 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) console.log(data)
resolve({ resolve({
type: 'video', type: 'video',
@ -271,8 +288,13 @@ const onUploadImageVideo = async (file, type = 'image', fileUrl) => {
file_num: randomId, file_num: randomId,
}) })
} else { } 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 uploadStatus: 1, // 1 2 3
} }
virtualList.value.unshift(newItem) 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)
}
})
}, },
}) })
} }

View File

@ -16,7 +16,14 @@
@scrolltoupper="onScrollToUpper" @scrolltoupper="onScrollToUpper"
> >
<template #top> <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 <template
#subTitle #subTitle
v-if="talkStore?.findItem(talkParams.index_name)?.group_type === 4" v-if="talkStore?.findItem(talkParams.index_name)?.group_type === 4"
@ -310,13 +317,13 @@
<tm-image :width="68" :height="68" :src="zu6051"></tm-image> <tm-image :width="68" :height="68" :src="zu6051"></tm-image>
<div class="mt-[6rpx]">逐条转发</div> <div class="mt-[6rpx]">逐条转发</div>
</div> </div>
<div <!-- <div
@click="handleWechatForward" @click="handleWechatForward"
class="flex flex-col items-center justify-center" class="flex flex-col items-center justify-center"
> >
<tm-image :width="68" :height="68" :src="zu6052"></tm-image> <tm-image :width="68" :height="68" :src="zu6052"></tm-image>
<div class="mt-[6rpx]">微信</div> <div class="mt-[6rpx]">微信</div>
</div> </div> -->
<div <div
@click="handleDelete" @click="handleDelete"
class="flex flex-col items-center justify-center" class="flex flex-col items-center justify-center"
@ -1346,9 +1353,12 @@ const getMentionSelectLists = (mentionSelectList) => {
// mention // mention
mentionSelectList.forEach((mentionSelectItem) => { mentionSelectList.forEach((mentionSelectItem) => {
// @ id 0
const id =
mentionSelectItem?.nickname === '所有人' ? 0 : mentionSelectItem?.id
mention.insertItem( mention.insertItem(
{ {
id: mentionSelectItem?.id, id: id,
denotationChar: '@', denotationChar: '@',
value: mentionSelectItem?.nickname + ' ', value: mentionSelectItem?.nickname + ' ',
}, },
@ -1382,11 +1392,19 @@ const updateMentionUserIds = () => {
// @IDnumber // @IDnumber
ops.forEach((op) => { ops.forEach((op) => {
if (op.insert && op.insert.mention) { 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)
}
} }
}) })
// 使mentionsmentionUserIds // 使mentionsmentionUserIds
// @@0
if (currentMentions.has(0) || currentMentions.size === 0) {
currentMentions.add(0)
}
state.value.mentionUserIds = Array.from(currentMentions) state.value.mentionUserIds = Array.from(currentMentions)
} }

View File

@ -128,7 +128,7 @@ export const useDialogueStore = defineStore('dialogue', {
this.unreadNum = data?.unread_num || 0 this.unreadNum = data?.unread_num || 0
this.members = [] this.members = []
if (data.talk_type == 2 && !data.is_dismiss && !data.is_quit) { if (data.talk_type == 2 && !this.isDismiss && !this.isQuit) {
this.updateGroupMembers() this.updateGroupMembers()
} }
}, },

View File

@ -141,6 +141,8 @@ export const useDialogueListStore = createGlobalState(() => {
...virtualList.value[index], // 保留原有不需要修改的字段 ...virtualList.value[index], // 保留原有不需要修改的字段
...item, // 覆盖需要更新的字段 ...item, // 覆盖需要更新的字段
}) })
} else {
zpagingRef.value?.addChatRecordData(item, false, false)
} }
} else { } else {
zpagingRef.value?.addChatRecordData(item, false, false) zpagingRef.value?.addChatRecordData(item, false, false)

View File

@ -74,7 +74,7 @@ export const useUploadsStore = defineStore('uploads', {
this.triggerUpload(upload_id,msgId) this.triggerUpload(upload_id,msgId)
this.isShow = true this.isShow = true
} }
}) })
}, },
@ -91,7 +91,19 @@ export const useUploadsStore = defineStore('uploads', {
item.status = 1 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) => { .then((res) => {
if (res.code == 200) { if (res.code == 200) {
item.uploadIndex++ item.uploadIndex++
@ -103,21 +115,36 @@ export const useUploadsStore = defineStore('uploads', {
updateUploadProgress(msgId,100) updateUploadProgress(msgId,100)
this.sendUploadMessage(item, msgId) 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 { } else {
item.status = 3 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(() => { .catch(() => {
item.status = 3 item.status = 3
// 更新虚拟列表中的状态为失败
const { virtualList } = useDialogueListStore()
const index = virtualList.value.findIndex(item => item.file_num === msgId)
if (index !== -1) {
virtualList.value[index].uploadStatus = 3
}
}) })
}, },

View File

@ -104,6 +104,11 @@ export const upload = (url, data = {}, options = {}) => {
url, url,
method: 'post', method: 'post',
data: data, data: data,
onUploadProgress: (progressEvent) => {
if (options.onProgress) {
options.onProgress(progressEvent)
}
},
...options ...options
}) })
} }