Browse Source

会话置顶bug修复

master
Blue 2 years ago
parent
commit
aaf883b46e
  1. 20
      im-platform/src/main/java/com/bx/implatform/IMPlatformApp.java
  2. 1
      im-platform/src/main/resources/application.yml
  3. 14
      im-ui/src/components/chat/ChatBox.vue
  4. 9
      im-ui/src/store/chatStore.js
  5. 2
      im-uniapp/components/chat-group-readed/chat-group-readed.vue
  6. 10
      im-uniapp/pages/chat/chat-box.vue
  7. 9
      im-uniapp/store/chatStore.js

20
im-platform/src/main/java/com/bx/implatform/IMPlatformApp.java

@ -22,28 +22,10 @@ import java.util.Set;
@EnableAspectJAutoProxy(exposeProxy = true)
@MapperScan(basePackages = {"com.bx.implatform.mapper"})
@SpringBootApplication(exclude = {SecurityAutoConfiguration.class})// 禁用secrity
public class IMPlatformApp implements ApplicationRunner {
public class IMPlatformApp {
public static void main(String[] args) {
SpringApplication.run(IMPlatformApp.class, args);
}
@Autowired
private RedisTemplate<String,Object> redisTemplate;
@Override
public void run(ApplicationArguments args) throws Exception {
// String matchKey = RedisKey.IM_GROUP_READED_POSITION+"*";
// Set<String> keys = redisTemplate.keys(matchKey);
// Map<String, Map<String,Object>> map = new HashMap<>();
// for(String key:keys){
// String[] arr = key.split(":");
// String groupId = arr[4];
// String userId = arr[5];
// Object messageId = redisTemplate.opsForValue().get(key);
// String newKey = StrUtil.join(":",RedisKey.IM_GROUP_READED_POSITION,groupId);
// redisTemplate.opsForHash().put(newKey,userId,messageId);
// redisTemplate.delete(key);
// log.info("key:{},value:{}",newKey,messageId);
// }
}
}

1
im-platform/src/main/resources/application.yml

@ -16,7 +16,6 @@ spring:
host: 127.0.0.1
port: 6379
servlet:
multipart:
max-file-size: 50MB

14
im-ui/src/components/chat/ChatBox.vue

@ -131,6 +131,11 @@ export default {
}
},
methods: {
moveChatToTop(){
let chatIdx = this.$store.getters.findChatIdx(this.chat);
console.log(chatIdx);
this.$store.commit("moveTop",chatIdx);
},
closeRefBox() {
this.$refs.emoBox.close();
this.$refs.atBox.close();
@ -320,6 +325,8 @@ export default {
this.fillTargetId(msgInfo, this.chat.targetId);
//
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
//
this.scrollToBottom();
// file
@ -372,6 +379,8 @@ export default {
this.fillTargetId(msgInfo, this.chat.targetId);
//
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
//
this.scrollToBottom();
// file
@ -456,6 +465,8 @@ export default {
msgInfo.status = this.$enums.MESSAGE_STATUS.UNSEND;
msgInfo.readedCount = 0;
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
//
this.$refs.editBox.focus();
//
@ -463,6 +474,7 @@ export default {
//
this.showVoice = false;
this.isReceipt = false;
})
},
fillTargetId(msgInfo, targetId) {
@ -530,6 +542,8 @@ export default {
msgInfo.readedCount = 0;
msgInfo.status = this.$enums.MESSAGE_STATUS.UNSEND;
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
}).finally(() => {
//
this.lockMessage = false;

9
im-ui/src/store/chatStore.js

@ -273,6 +273,15 @@ export default {
}
},
getters: {
findChatIdx: (state) => (chat) => {
for (let idx in state.chats) {
if (state.chats[idx].type == chat.type &&
state.chats[idx].targetId === chat.targetId) {
chat = state.chats[idx];
return idx
}
}
},
findChat: (state) => (msgInfo) => {
// 获取对方id或群id
let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE';

2
im-uniapp/components/chat-group-readed/chat-group-readed.vue

@ -66,7 +66,7 @@
}).then(userIds => {
this.groupMembers.forEach(member => {
// 退
if (member.userId == this.msgInfo.sendId && member.quit) {
if (member.userId == this.msgInfo.sendId || member.quit) {
return;
}
//

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

@ -118,6 +118,10 @@
icon: "none"
})
},
moveChatToTop(){
let chatIdx = this.$store.getters.findChatIdx(this.chat);
this.$store.commit("moveTop",chatIdx);
},
switchReceipt(){
this.isReceipt = !this.isReceipt;
},
@ -179,6 +183,8 @@
msgInfo.readedCount = 0,
msgInfo.status = this.$enums.MESSAGE_STATUS.UNSEND;
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
this.sendText = "";
}).finally(() => {
//
@ -275,6 +281,8 @@
this.fillTargetId(msgInfo, this.chat.targetId);
//
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
// file
file.msgInfo = msgInfo;
//
@ -322,6 +330,8 @@
this.fillTargetId(msgInfo, this.chat.targetId);
//
this.$store.commit("insertMessage", msgInfo);
//
this.moveChatToTop();
// file
file.msgInfo = msgInfo;
//

9
im-uniapp/store/chatStore.js

@ -309,6 +309,15 @@ export default {
}
},
getters: {
findChatIdx: (state) => (chat) => {
for (let idx in state.chats) {
if (state.chats[idx].type == chat.type &&
state.chats[idx].targetId === chat.targetId) {
chat = state.chats[idx];
return idx;
}
}
},
findChat: (state) => (msgInfo) => {
// 获取对方id或群id
let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE';

Loading…
Cancel
Save