解决 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", "name": "cool-admin-vue",
"version": "3.1.6", "version": "3.1.7",
"scripts": { "scripts": {
"serve": "vue-cli-service serve", "serve": "vue-cli-service serve",
"build": "vue-cli-service build", "build": "vue-cli-service build",

View File

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

View File

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

View File

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

View File

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

View File

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