解决 chat 消息多次监听问题

This commit is contained in:
icssoa 2021-03-25 10:47:44 +08:00
parent 006d0dc83a
commit 3fecc4f64b
6 changed files with 29 additions and 28 deletions

View File

@ -1,6 +1,6 @@
{
"name": "cool-admin-vue",
"version": "3.1.6",
"version": "3.1.7",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",

View File

@ -15,11 +15,17 @@
:controls="['slot-session', 'cl-flex1', 'fullscreen', 'close']"
>
<div class="cl-chat">
<!-- 会话列表 -->
<chat-session />
<div class="cl-chat__detail" v-if="session">
<div class="cl-chat__detail">
<!-- 消息列表 -->
<chat-message />
<template v-if="session">
<!-- 输入框 -->
<chat-input />
</template>
</div>
</div>

View File

@ -194,19 +194,22 @@ export default {
}
},
beforeCreate() {
//
eventBus.$off("message.refresh");
eventBus.$off("message.scrollToBottom");
},
created() {
//
eventBus.$on("message.refresh", this.refresh);
//
eventBus.$on("message.scrollToBottom", this.scrollToBottom);
if (this.session) {
this.refresh();
}
},
destroyed() {
//
clearTimeout(this.voice.timer);
this.messageList.map(e => {

View File

@ -89,6 +89,11 @@ export default {
}
},
beforeCreate() {
//
eventBus.$off("session.refresh");
},
created() {
//
eventBus.$on("session.refresh", this.refresh);

View File

@ -1,20 +1,11 @@
<template>
<el-scrollbar>
<div class="demo">
<div class="demo scroller1">
<el-row :gutter="10">
<el-col
v-for="(item, index) in list"
:key="index"
:xs="24"
:sm="12"
:md="8"
:lg="6"
>
<el-col v-for="(item, index) in list" :key="index" :xs="24" :sm="12" :md="8" :lg="6">
<component :is="item"></component>
</el-col>
</el-row>
</div>
</el-scrollbar>
</template>
<script>
@ -58,8 +49,6 @@ export default {
<style lang="scss">
.demo {
overflow: hidden;
.scope {
background-color: #fff;
border-radius: 3px;

View File

@ -1,5 +1,5 @@
<template>
<div class="demo-upload">
<div class="demo-upload scroller1">
<div class="demo-upload__item">
<p>普通上传</p>
<cl-upload :before-upload="onBeforeUpload"></cl-upload>
@ -63,8 +63,6 @@ export default {
<style lang="scss" scoped>
.demo-upload {
overflow: hidden auto;
.demo-upload__item {
margin-bottom: 10px;
background-color: #fff;