mirror of
https://github.com/yawaflua/LuckyDiamond.git
synced 2025-12-10 04:09:29 +02:00
refactor code for send and claim data msg
This commit is contained in:
@@ -14,14 +14,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ChatHistory from "@/mocks/ChatHistory";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
msg: '',
|
msg: '',
|
||||||
username: 'TEST USER',
|
username: 'TEST USER',
|
||||||
icon: '@/assets/icon-test/person-icon-chat.png'
|
icon: require('../assets/icons-test/person-icon-chat.png'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -29,18 +28,8 @@ export default {
|
|||||||
return this.msg === ''
|
return this.msg === ''
|
||||||
},
|
},
|
||||||
SendmsgData() {
|
SendmsgData() {
|
||||||
const object = {
|
this.$emit('send', [this.msg, this.username, this.icon])
|
||||||
msg: this.msg,
|
|
||||||
username: this.username,
|
|
||||||
icon: this.icon
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatHistory.push(object)
|
|
||||||
console.log(ChatHistory)
|
|
||||||
|
|
||||||
this.msg = ''
|
this.msg = ''
|
||||||
|
|
||||||
return this.$emit('dataclaim')
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export default [
|
|
||||||
|
|
||||||
]
|
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chat__content--users" @dataclaim="ClaimDatamsg">
|
<div class="chat__content--users">
|
||||||
<ul>
|
<ul>
|
||||||
<li
|
<li
|
||||||
v-for="msg in array"
|
v-for="msg in array"
|
||||||
@@ -28,25 +28,32 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<writechat-component></writechat-component>
|
<writechat-component @send="ClaimDatamsg"></writechat-component>
|
||||||
</aside>
|
</aside>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import '@/assets/css/ElementsStyles/chat.css'
|
import '@/assets/css/ElementsStyles/chat.css'
|
||||||
import ChatHistory from "@/mocks/ChatHistory";
|
|
||||||
import WritechatComponent from "@/components/WritechatComponent.vue";
|
import WritechatComponent from "@/components/WritechatComponent.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { WritechatComponent },
|
components: { WritechatComponent },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
array: ChatHistory
|
array: [],
|
||||||
|
id: 0,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
ClaimDatamsg() {
|
ClaimDatamsg(msg) {
|
||||||
this.array = ChatHistory
|
const MsgUser = {
|
||||||
|
id: this.id + 1,
|
||||||
|
msg: msg[0],
|
||||||
|
username: msg[1],
|
||||||
|
icon: msg[2]
|
||||||
|
}
|
||||||
|
|
||||||
|
this.array.push(MsgUser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user