added vision chat from server in client

This commit is contained in:
Kostya
2024-01-15 23:16:57 +03:00
parent f193fea9d2
commit e2713f5ff8
5 changed files with 30 additions and 5 deletions

View File

@@ -33,11 +33,14 @@
<script>
import '@/assets/css/ComponentsStyles/chat.css'
import WritechatComponent from "@/components/WritechatComponent.vue";
import { SendMessageToChat } from "@/assets/js/chat/ChatLogic.js";
import {eventBus} from "@/main";
export default {
components: { WritechatComponent },
inject: [ 'eventBus' ],
data() {
return {
array: [],
@@ -54,13 +57,26 @@ export default {
}
this.array.push(MsgUser)
SendMessageToChat(msg[0]);
if(this.array.length > 7) {
this.array.shift()
}
}
},
mounted() {
eventBus.on('dataChat', (dataFromServer) => {
const MsgUser = {
id: this.id + 1,
msg: dataFromServer,
username: dataFromServer,
icon: dataFromServer
}
this.array.push(MsgUser)
console.log(dataFromServer)
})
}
}
</script>