Selaa lähdekoodia

fix: 开启免打扰时已读状态异常的bug

xsx 8 kuukautta sitten
vanhempi
commit
68c042ad47

+ 5 - 3
im-uniapp/components/chat-item/chat-item.vue

@@ -17,8 +17,8 @@
 				<view class="chat-send-name" v-if="isShowSendName">{{ chat.sendNickName + ':&nbsp;' }}</view>
 				<rich-text class="chat-content-text"
 					:nodes="$emo.transform(chat.lastContent,'emoji-small')"></rich-text>
-				<uni-badge v-if="chat.unreadCount > 0" :max-num="99" :text="chat.unreadCount" />
 				<view v-if="chat.isDnd" class="icon iconfont icon-dnd"></view>
+				<uni-badge v-else-if="chat.unreadCount > 0" :max-num="99" :text="chat.unreadCount" />
 			</view>
 		</view>
 	</view>
@@ -170,9 +170,11 @@ export default {
 				white-space: nowrap;
 				overflow: hidden;
 				text-overflow: ellipsis;
-
 			}
-
+			
+			.icon {
+				font-size: $im-font-size;
+			}
 		}
 	}
 }

+ 12 - 14
im-uniapp/pages/chat/chat-box.vue

@@ -669,21 +669,19 @@ export default {
 			});
 		},
 		readedMessage() {
-			if (this.unreadCount == 0) {
-				return;
-			}
-			let url = ""
-			if (this.chat.type == "GROUP") {
-				url = `/message/group/readed?groupId=${this.chat.targetId}`
-			} else {
-				url = `/message/private/readed?friendId=${this.chat.targetId}`
+			if (this.unreadCount > 0) {
+				let url = ""
+				if (this.chat.type == "GROUP") {
+					url = `/message/group/readed?groupId=${this.chat.targetId}`
+				} else {
+					url = `/message/private/readed?friendId=${this.chat.targetId}`
+				}
+				this.$http({
+					url: url,
+					method: 'PUT'
+				}).then(() => {})
 			}
-			this.$http({
-				url: url,
-				method: 'PUT'
-			}).then(() => {
-				this.chatStore.resetUnreadCount(this.chat)
-			})
+			this.chatStore.resetUnreadCount(this.chat)
 		},
 		loadGroup(groupId) {
 			this.$http({

+ 1 - 1
im-uniapp/pages/chat/chat.vue

@@ -104,7 +104,7 @@ export default {
 		unreadCount() {
 			let count = 0;
 			this.chatStore.chats.forEach(chat => {
-				if (!chat.delete) {
+				if (!chat.isDnd && !chat.delete) {
 					count += chat.unreadCount;
 				}
 			})

+ 1 - 5
im-uniapp/store/chatStore.js

@@ -195,7 +195,7 @@ export default defineStore('chatStore', {
 			chat.lastSendTime = msgInfo.sendTime;
 			chat.sendNickName = msgInfo.sendNickName;
 			// 未读加1
-			if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
+			if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
 				msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) {
 				chat.unreadCount++;
 			}
@@ -354,7 +354,6 @@ export default defineStore('chatStore', {
 			let chat = this.findChat(chatInfo);
 			if (chat) {
 				chat.isDnd = isDnd;
-				chat.unreadCount = 0;
 			}
 		},
 		refreshChats() {
@@ -374,9 +373,6 @@ export default defineStore('chatStore', {
 						chat.isDnd = group.isDnd
 					}
 				}
-				if (chat.isDnd) {
-					chat.unreadCount = 0;
-				}
 			})
 			// 排序
 			cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime);

+ 14 - 17
im-web/src/components/chat/ChatBox.vue

@@ -11,10 +11,9 @@
 						<el-main class="im-chat-main" id="chatScrollBox" @scroll="onScroll">
 							<div class="im-chat-box">
 								<div v-for="(msgInfo, idx) in showMessages" :key="showMinIdx + idx">
-									<chat-message-item @call="onCall(msgInfo.type)"
-										:mine="msgInfo.sendId == mine.id" :headImage="headImage(msgInfo)"
-										:showName="showName(msgInfo)" :msgInfo="msgInfo" :groupMembers="groupMembers"
-										@delete="deleteMessage" @recall="recallMessage">
+									<chat-message-item @call="onCall(msgInfo.type)" :mine="msgInfo.sendId == mine.id"
+										:headImage="headImage(msgInfo)" :showName="showName(msgInfo)" :msgInfo="msgInfo"
+										:groupMembers="groupMembers" @delete="deleteMessage" @recall="recallMessage">
 									</chat-message-item>
 								</div>
 							</div>
@@ -505,19 +504,18 @@ export default {
 			});
 		},
 		readedMessage() {
-			if (this.chat.unreadCount == 0) {
-				return;
-			}
-			this.chatStore.resetUnreadCount(this.chat)
-			if (this.chat.type == "GROUP") {
-				var url = `/message/group/readed?groupId=${this.chat.targetId}`
-			} else {
-				url = `/message/private/readed?friendId=${this.chat.targetId}`
+			if (this.chat.unreadCount > 0) {
+				if (this.isGroup) {
+					var url = `/message/group/readed?groupId=${this.chat.targetId}`
+				} else {
+					url = `/message/private/readed?friendId=${this.chat.targetId}`
+				}
+				this.$http({
+					url: url,
+					method: 'put'
+				}).then(() => { })
+				this.chatStore.resetUnreadCount(this.chat)
 			}
-			this.$http({
-				url: url,
-				method: 'put'
-			}).then(() => { })
 		},
 		loadReaded(fId) {
 			this.$http({
@@ -682,7 +680,6 @@ export default {
 			return this.chat.unreadCount;
 		},
 		showMessages() {
-			console.log("this.chat.messages.slice(this.showMinIdx):",this.chat.messages.slice(this.showMinIdx))
 			return this.chat.messages.slice(this.showMinIdx)
 		},
 		messageSize() {

+ 1 - 1
im-web/src/components/chat/ChatItem.vue

@@ -3,7 +3,7 @@
 		<div class="chat-left">
 			<head-image :url="chat.headImage" :name="chat.showName" :size="42"
 				:id="chat.type == 'PRIVATE' ? chat.targetId : 0" :isShowUserInfo="false"></head-image>
-			<div v-show="chat.unreadCount > 0" class="unread-text">{{ chat.unreadCount }}</div>
+			<div v-show="!chat.isDnd && chat.unreadCount > 0" class="unread-text">{{ chat.unreadCount }}</div>
 		</div>
 		<div class="chat-right">
 			<div class="chat-name">

+ 1 - 5
im-web/src/store/chatStore.js

@@ -196,7 +196,7 @@ export default defineStore('chatStore', {
 			chat.lastSendTime = msgInfo.sendTime;
 			chat.sendNickName = msgInfo.sendNickName;
 			// 未读加1
-			if (!chat.isDnd && !msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
+			if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED &&
 				msgInfo.status != MESSAGE_STATUS.RECALL && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) {
 				chat.unreadCount++;
 			}
@@ -350,7 +350,6 @@ export default defineStore('chatStore', {
 			let chat = this.findChat(chatInfo);
 			if (chat) {
 				chat.isDnd = isDnd;
-				chat.unreadCount = 0;
 			}
 		},
 		refreshChats() {
@@ -370,9 +369,6 @@ export default defineStore('chatStore', {
 						chat.isDnd = group.isDnd
 					}
 				}
-				if (chat.isDnd) {
-					chat.unreadCount = 0;
-				}
 			})
 			// 排序
 			cacheChats.sort((chat1, chat2) => chat2.lastSendTime - chat1.lastSendTime);

+ 2 - 6
im-web/src/view/Home.vue

@@ -392,10 +392,6 @@ export default {
 			location.href = "/";
 		},
 		playAudioTip() {
-			// 离线消息不播放铃声
-			if (this.chatStore.isLoading()) {
-				return;
-			}
 			// 防止过于密集播放
 			if (new Date().getTime() - this.lastPlayAudioTime > 1000) {
 				this.lastPlayAudioTime = new Date().getTime();
@@ -439,8 +435,8 @@ export default {
 		unreadCount() {
 			let unreadCount = 0;
 			let chats = this.chatStore.chats;
-			chats.forEach((chat) => {
-				if (!chat.delete) {
+			chats.forEach(chat => {
+				if (!chat.delete && !chat.isDnd) {
 					unreadCount += chat.unreadCount
 				}
 			});