diff --git a/luckydiamond/src/assets/css/ComponentsStyles/chat.css b/luckydiamond/src/assets/css/ComponentsStyles/chat.css index 24f47f3..d5c9efd 100644 --- a/luckydiamond/src/assets/css/ComponentsStyles/chat.css +++ b/luckydiamond/src/assets/css/ComponentsStyles/chat.css @@ -23,15 +23,20 @@ font-weight: 700; } -.content p { +/* .content p { width: 80%; word-wrap: break-word; margin: 0 auto; -} +} */ + +.content p { + word-wrap: break-word; + overflow-wrap: break-word; + } .chat__content--users { height: 650px; - width: 250px; + width: auto; overflow-y: auto; overflow-x: auto; } diff --git a/luckydiamond/src/assets/js/chat/ChatLogic.js b/luckydiamond/src/assets/js/chat/ChatLogic.js index a955074..cc52922 100644 --- a/luckydiamond/src/assets/js/chat/ChatLogic.js +++ b/luckydiamond/src/assets/js/chat/ChatLogic.js @@ -38,9 +38,13 @@ export function ConnectToChat() { export function SendMessageToChat(message) { try { + + if (!GetCookie("SpUserName") && !GetCookie("AUTHTOKEN") && !GetCookie("SearchToken")) { + return; + } + const data = { SpUserName: GetCookie("SpUserName"), - SearchToken: GetCookie("SearchToken"), Message: message }; diff --git a/luckydiamond/src/components/ChatComponent.vue b/luckydiamond/src/components/ChatComponent.vue index 1b7ad64..66f5669 100644 --- a/luckydiamond/src/components/ChatComponent.vue +++ b/luckydiamond/src/components/ChatComponent.vue @@ -49,33 +49,32 @@ export default { }, methods: { ClaimDatamsg(msg) { - const MsgUser = { - id: this.id + 1, - msg: msg[0], - username: msg[1], - icon: msg[2] - } - - this.array.push(MsgUser) SendMessageToChat(msg[0]); - if(this.array.length > 7) { - this.array.shift() - } + // if(this.array.length > 7) { + // this.array.shift() + // } } }, mounted() { eventBus.on('dataChat', (dataFromServer) => { + try { + // Attempt to parse the JSON string + const dataObject = JSON.parse(dataFromServer); + let imageUrl = "https://avatar.spworlds.ru/face/55/" + dataObject.SpUserName; + const MsgUser = { id: this.id + 1, - msg: dataFromServer, - username: dataFromServer, - icon: dataFromServer - } + msg: dataObject.Message, + username: dataObject.SpUserName, + icon: imageUrl + }; - this.array.push(MsgUser) - console.log(dataFromServer) + this.array.push(MsgUser); + } catch (error) { + console.error('Error parsing JSON data:', error); + } }) } } diff --git a/luckydiamond/src/components/HeaderComponent.vue b/luckydiamond/src/components/HeaderComponent.vue index ee2a637..b3b47e5 100644 --- a/luckydiamond/src/components/HeaderComponent.vue +++ b/luckydiamond/src/components/HeaderComponent.vue @@ -1,7 +1,6 @@