Commit 4fd2e1d8 by 吴云建

会话调整

parent 10cc168f
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="search-wrap" v-if="!modelName"> <div class="search-wrap" v-if="!modelName">
<el-input <el-input
class="keyword-input" class="keyword-input"
placeholder="昵称、手机、Email、备注" placeholder="会话标题"
prefix-icon="el-icon-search" prefix-icon="el-icon-search"
v-model="searchKeyword" v-model="searchKeyword"
v-on:keyup.enter.native="search" v-on:keyup.enter.native="search"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
></el-input> ></el-input>
<i v-if="!isInPage" class="close-btn el-icon-close" @click="$emit('close')"></i> <i v-if="!isInPage" class="close-btn el-icon-close" @click="$emit('close')"></i>
</div> </div>
<chat-list v-if="!modelName" :searchKeyword="searchKeyword" ref="chatListComp" /> <chat-list v-if="!modelName" ref="chatListComp" />
<chat-list-model v-if="modelName" @update-page-info="$emit('update-page-info', $event)" ref="chatListModel"/> <chat-list-model v-if="modelName" @update-page-info="$emit('update-page-info', $event)" ref="chatListModel"/>
<div class="chat-content-wrap" v-if="chatVisible && onShow" > <div class="chat-content-wrap" v-if="chatVisible && onShow" >
<chat :modelName="modelName"/> <chat :modelName="modelName"/>
...@@ -54,9 +54,8 @@ export default class ChatContainer extends Vue { ...@@ -54,9 +54,8 @@ export default class ChatContainer extends Vue {
@Ref("chatListModel") chatListModel: ChatListModel; @Ref("chatListModel") chatListModel: ChatListModel;
@buttonThrottle()
private search() { private search() {
this.chatListComp.search() this.chatListComp.search(this.searchKeyword)
} }
@Watch("$route") routeUpdate() { @Watch("$route") routeUpdate() {
......
...@@ -75,7 +75,7 @@ export function parserMessage(type: string, rawMsg: string) { ...@@ -75,7 +75,7 @@ export function parserMessage(type: string, rawMsg: string) {
@Component({ components: { avatar } }) @Component({ components: { avatar } })
export default class ChatList extends Vue { export default class ChatList extends Vue {
@Prop(String) searchKeyword; private searchKeyword = "";
@chatStore.Action(ChatStore.ACTION_GET_MY_CHAT_LIST) @chatStore.Action(ChatStore.ACTION_GET_MY_CHAT_LIST)
private readonly getMyChatList!: ChatStore.ACTION_GET_MY_CHAT_LIST; private readonly getMyChatList!: ChatStore.ACTION_GET_MY_CHAT_LIST;
...@@ -110,8 +110,10 @@ export default class ChatList extends Vue { ...@@ -110,8 +110,10 @@ export default class ChatList extends Vue {
@Ref("scrollbar") @Ref("scrollbar")
private scrollbar: Vue & { update: () => void }; private scrollbar: Vue & { update: () => void };
private sseTs = 0;
private get chatRooms() { private get chatRooms() {
return this.chatList?.list || []; return this.chatList?.list.filter(chat => chat.title.indexOf(this.searchKeyword) > -1) || [];
} }
private isSelected(item: ChatType) { private isSelected(item: ChatType) {
...@@ -137,8 +139,12 @@ export default class ChatList extends Vue { ...@@ -137,8 +139,12 @@ export default class ChatList extends Vue {
} }
onTransportMessage() { onTransportMessage() {
this.getMyChatList() const ts = new Date().getTime();
// this.hideChat() if (ts - this.sseTs > 100) {
this.getMyChatList()
// this.hideChat()
this.sseTs = ts;
}
} }
private goToOnlyRoom() { private goToOnlyRoom() {
...@@ -155,13 +161,8 @@ export default class ChatList extends Vue { ...@@ -155,13 +161,8 @@ export default class ChatList extends Vue {
this.saveChatId(chat_id); this.saveChatId(chat_id);
} }
public async search() { public async search(searchKeyword: string) {
let searchKeyword = this.searchKeyword.trim(); this.searchKeyword = searchKeyword.trim();
if (!searchKeyword) {
await this.getMyChatList();
} else {
await this.getMyChatList(searchKeyword);
}
} }
private async goToChatRoom(data: ChatType) { private async goToChatRoom(data: ChatType) {
......
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