Commit a07362f4 by 吴云建

会话优化

parent a18fd1f6
...@@ -168,13 +168,17 @@ export default class ModelChatList extends Vue { ...@@ -168,13 +168,17 @@ export default class ModelChatList extends Vue {
await this.getList(); await this.getList();
this.setSource(ChatStore.StateChatSourceDirection.Server); this.setSource(ChatStore.StateChatSourceDirection.Server);
this.scrollbar.update(); this.scrollbar.update();
this.$onBeforeDestroy( await this.sdk.model("UniplatChat").registerOnChange(this.onTransportMessage);
await this.sdk.model("UniplatChat").registerOnChange(this.onTransportMessage) await this.sdk.model("general_order").registerOnChange(this.onTransportMessage);
)
} }
onTransportMessage(e: any) { onTransportMessage(e: any) {
let index = e.dataUpdates.findIndex(it => it.action === "startChat" || it.action === "csExitChat" || it.action === "finishChat"); let index = e.dataUpdates.findIndex(it => it.action === "startChat" ||
it.action === "createChat" ||
it.action === "csExitChat" ||
it.action === "finishChat" ||
it.action === "delete" && it.model === "general_order"
);
if (index > -1) { if (index > -1) {
this.refreshListDebounce(); this.refreshListDebounce();
} }
......
...@@ -10,10 +10,8 @@ ...@@ -10,10 +10,8 @@
:class="{ selected: isSelected(item) }" :class="{ selected: isSelected(item) }"
@click="goToChatRoom(item)" @click="goToChatRoom(item)"
> >
<div <div class="red-dot" v-if="item.unread_msg_count > 0">
class="chat-avatar pos-rel" {{ item.unread_msg_count }}
:class="{ 'red-dot': item.unread_msg_count > 0 }"
>
</div> </div>
<div class="chat-info"> <div class="chat-info">
<div <div
...@@ -115,7 +113,11 @@ export default class ChatList extends Vue { ...@@ -115,7 +113,11 @@ export default class ChatList extends Vue {
private get chatRooms() { private get chatRooms() {
const list = this.chatList?.list.filter(chat => chat.title.indexOf(this.searchKeyword) > -1) || []; const list = this.chatList?.list.filter(chat => chat.title.indexOf(this.searchKeyword) > -1) || [];
this.unReadMsgCount = list.filter(chat => chat.unread_msg_count > 0).length; let unReadMsgCount = 0;
list.filter(chat => chat.unread_msg_count > 0).forEach(chat => {
unReadMsgCount += chat.unread_msg_count
})
this.unReadMsgCount = unReadMsgCount;
this.$emit("list-count-update", this.unReadMsgCount); this.$emit("list-count-update", this.unReadMsgCount);
this.$eventHub.$emit(EVENTS.NewMsg, this.unReadMsgCount); this.$eventHub.$emit(EVENTS.NewMsg, this.unReadMsgCount);
return list; return list;
...@@ -223,6 +225,7 @@ export default class ChatList extends Vue { ...@@ -223,6 +225,7 @@ export default class ChatList extends Vue {
} }
.chat-list { .chat-list {
.chat-item { .chat-item {
position: relative;
cursor: pointer; cursor: pointer;
padding: 4px 15px 10px; padding: 4px 15px 10px;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
...@@ -233,24 +236,19 @@ export default class ChatList extends Vue { ...@@ -233,24 +236,19 @@ export default class ChatList extends Vue {
&.selected { &.selected {
background: #f0f0f0; background: #f0f0f0;
} }
.red-dot {
.chat-avatar { position: absolute;
display: inline-block; min-width: 14px;
vertical-align: middle; height: 14px;
width: 0; line-height: 14px;
height: 0; padding: 0 2px;
margin-right: 5px; background: #e87005;
&.red-dot::before { border-radius: 7px;
content: ""; z-index: 1;
position: absolute; right: 10px;
width: 8px; bottom: 10px;
height: 8px; font-size: 12px;
background: #e87005; color: #fff;
border-radius: 50%;
z-index: 1;
right: 0px;
top: -4px;
}
} }
.chat-info { .chat-info {
display: inline-block; display: inline-block;
......
...@@ -568,10 +568,10 @@ export default { ...@@ -568,10 +568,10 @@ export default {
commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID, info.uniplatId); commit(ChatStore.MUTATION_SAVE_CURRENT_CHAT_UNIPLAT_ID, info.uniplatId);
commit(ChatStore.MUTATION_INITING_CHAT); commit(ChatStore.MUTATION_INITING_CHAT);
removeRegisterChatEvents.forEach((k) => k()); removeRegisterChatEvents.forEach((k) => k());
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS)
await Promise.all([ await Promise.all([
dispatch(ChatStore.ACTION_REGISTER_EVENT), dispatch(ChatStore.ACTION_REGISTER_EVENT),
dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES), dispatch(ChatStore.ACTION_GET_CHAT_MESSAGES)
dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS),
]); ]);
commit(ChatStore.MUTATION_SAVE_CHAT_TITLE, wantedChatRoom.title || chatId); commit(ChatStore.MUTATION_SAVE_CHAT_TITLE, wantedChatRoom.title || chatId);
commit(ChatStore.MUTATION_INITING_CHAT_DONE); commit(ChatStore.MUTATION_INITING_CHAT_DONE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment