Browse Source

!114 修复断线重连时丢消息的bug

Merge pull request !114 from blue/v_3.0.0
master
blue 1 year ago
committed by Gitee
parent
commit
4c6f713121
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
  1. 1
      im-uniapp/App.vue
  2. 1
      im-uniapp/components/chat-item/chat-item.vue
  3. 10
      im-uniapp/pages/chat/chat-box.vue
  4. 7
      im-uniapp/store/chatStore.js
  5. 2
      im-web/src/components/chat/ChatMessageItem.vue
  6. 3
      im-web/src/components/group/AddGroupMember.vue
  7. 7
      im-web/src/store/chatStore.js

1
im-uniapp/App.vue

@ -311,6 +311,7 @@
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (!loginInfo || !loginInfo.refreshToken) { if (!loginInfo || !loginInfo.refreshToken) {
reject(); reject();
return;
} }
http({ http({
url: '/refreshToken', url: '/refreshToken',

1
im-uniapp/components/chat-item/chat-item.vue

@ -100,6 +100,7 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
z-index: 99;
} }
.left { .left {

10
im-uniapp/pages/chat/chat-box.vue

@ -1,7 +1,6 @@
<template> <template>
<view class="page chat-box"> <view class="page chat-box">
<view class="header"> <view class="header">
<uni-icons class="btn-side left" type="back" size="30" @click="onNavBack()"></uni-icons>
<text class="title">{{title}}</text> <text class="title">{{title}}</text>
<uni-icons class="btn-side right" type="more-filled" size="30" @click="onShowMore()"></uni-icons> <uni-icons class="btn-side right" type="more-filled" size="30" @click="onShowMore()"></uni-icons>
</view> </view>
@ -344,11 +343,6 @@
selectEmoji(emoText) { selectEmoji(emoText) {
this.sendText += `#${emoText};`; this.sendText += `#${emoText};`;
}, },
onNavBack() {
uni.switchTab({
url: "/pages/chat/chat"
})
},
onKeyboardheightchange(e) { onKeyboardheightchange(e) {
if (e.detail.height > 0) { if (e.detail.height > 0) {
this.showKeyBoard = true; this.showKeyBoard = true;
@ -797,10 +791,6 @@
font-size: 28rpx; font-size: 28rpx;
cursor: pointer; cursor: pointer;
&.left {
left: 30rpx;
}
&.right { &.right {
right: 30rpx; right: 30rpx;
} }

7
im-uniapp/store/chatStore.js

@ -302,7 +302,7 @@ export default defineStore('chatStore', {
}); });
// 将消息一次性装载回来 // 将消息一次性装载回来
this.chats = cacheChats; this.chats = cacheChats;
// 清空缓存 // 清空缓存,不再使用
cacheChats = null; cacheChats = null;
this.saveToStorage(); this.saveToStorage();
}, },
@ -375,7 +375,10 @@ export default defineStore('chatStore', {
return state.loadingPrivateMsg || state.loadingGroupMsg return state.loadingPrivateMsg || state.loadingGroupMsg
}, },
curChats: (state) => { curChats: (state) => {
return state.isLoading() ? cacheChats : state.chats; if(cacheChats && state.isLoading()){
return cacheChats;
}
return state.chats;
}, },
findChatIdx: (state) => (chat) => { findChatIdx: (state) => (chat) => {
let chats = state.curChats; let chats = state.curChats;

2
im-web/src/components/chat/ChatMessageItem.vue

@ -36,7 +36,7 @@
<div class="chat-file-box" v-loading="loading"> <div class="chat-file-box" v-loading="loading">
<div class="chat-file-info"> <div class="chat-file-info">
<el-link class="chat-file-name" :underline="true" target="_blank" type="primary" <el-link class="chat-file-name" :underline="true" target="_blank" type="primary"
:href="data.url">{{ data.name }}</el-link> :href="data.url" :download="data.name">{{ data.name }}</el-link>
<div class="chat-file-size">{{ fileSize }}</div> <div class="chat-file-size">{{ fileSize }}</div>
</div> </div>
<div class="chat-file-icon"> <div class="chat-file-icon">

3
im-web/src/components/group/AddGroupMember.vue

@ -2,8 +2,7 @@
<el-dialog title="邀请好友" :visible.sync="visible" width="50%" :before-close="onClose"> <el-dialog title="邀请好友" :visible.sync="visible" width="50%" :before-close="onClose">
<div class="agm-container"> <div class="agm-container">
<div class="agm-l-box"> <div class="agm-l-box">
<el-input placeholder="搜索好友" v-model="searchText" <el-input placeholder="搜索好友" v-model="searchText">
@keyup.enter.native="onSearch()">
<i class="el-icon-search el-input__icon" slot="suffix"> </i> <i class="el-icon-search el-input__icon" slot="suffix"> </i>
</el-input> </el-input>
<el-scrollbar style="height:400px;"> <el-scrollbar style="height:400px;">

7
im-web/src/store/chatStore.js

@ -289,7 +289,7 @@ export default {
}); });
// 将消息一次性装载回来 // 将消息一次性装载回来
state.chats = cacheChats; state.chats = cacheChats;
// 清空缓存 // 清空缓存,不再使用
cacheChats = null; cacheChats = null;
this.commit("saveToStorage"); this.commit("saveToStorage");
}, },
@ -369,7 +369,10 @@ export default {
return state.loadingPrivateMsg || state.loadingGroupMsg return state.loadingPrivateMsg || state.loadingGroupMsg
}, },
findChats: (state, getters) => () => { findChats: (state, getters) => () => {
return getters.isLoading() ? cacheChats : state.chats; if(cacheChats && getters.isLoading()){
return cacheChats;
}
return state.chats;
}, },
findChatIdx: (state, getters) => (chat) => { findChatIdx: (state, getters) => (chat) => {
let chats = getters.findChats(); let chats = getters.findChats();

Loading…
Cancel
Save