#161: Store chats into database
This commit is contained in:
parent
faf887163a
commit
bdb6dd0d54
18
package-lock.json
generated
18
package-lock.json
generated
@ -3621,9 +3621,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.5.57",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.57.tgz",
|
||||
"integrity": "sha512-xS65H/tqgOwUBa5UmOuNSLuslDo7zho0y/lgQw35pnrqiZh7UOWHCeL/Bt6noJATbA6tpQJGCifsFsIRZj1Fqg==",
|
||||
"version": "1.5.58",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.58.tgz",
|
||||
"integrity": "sha512-al2l4r+24ZFL7WzyPTlyD0fC33LLzvxqLCwurtBibVPghRGO9hSTl+tis8t1kD7biPiH/en4U0I7o/nQbYeoVA==",
|
||||
"dev": true,
|
||||
"license": "ISC"
|
||||
},
|
||||
@ -5818,9 +5818,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/phaser": {
|
||||
"version": "3.86.0",
|
||||
"resolved": "https://registry.npmjs.org/phaser/-/phaser-3.86.0.tgz",
|
||||
"integrity": "sha512-A7rog3GhXYcWsPimteQmudyY6W0fx0eviOoo9Cwpzae1RPeJBDkhmWv5IFrQO9dL+T907E4dprQPnd2D4WhoEw==",
|
||||
"version": "3.87.0",
|
||||
"resolved": "https://registry.npmjs.org/phaser/-/phaser-3.87.0.tgz",
|
||||
"integrity": "sha512-AyI1b3T5fp05gzf6WUmu2FNqaZL+Y7w88yBRLf7YZXF9bncUSHpnDrupnTGoPqy/RKHRLBcay7zWeqQ2wiMWcw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"eventemitter3": "^5.0.1"
|
||||
@ -7023,9 +7023,9 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/tinypool": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.1.tgz",
|
||||
"integrity": "sha512-URZYihUbRPcGv95En+sz6MfghfIc2OJ1sv/RmhWZLouPY0/8Vo80viwPvg3dlaS9fuq7fQMEfgRRK7BBZThBEA==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz",
|
||||
"integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
|
@ -195,8 +195,8 @@ const setupSocketListeners = () => {
|
||||
}
|
||||
|
||||
const updateEffectWindowSize = () => {
|
||||
if(rainEmitter.value) rainEmitter.value.updateConfig({x: {min: 0, max: window.innerWidth}})
|
||||
if(fogSprite.value) {
|
||||
if (rainEmitter.value) rainEmitter.value.updateConfig({ x: { min: 0, max: window.innerWidth } })
|
||||
if (fogSprite.value) {
|
||||
fogSprite.value.setX(window.innerWidth / 2)
|
||||
fogSprite.value.setY(window.innerHeight / 2)
|
||||
}
|
||||
@ -206,12 +206,12 @@ const updateEffectWindowSize = () => {
|
||||
watch(() => zoneStore.zone?.zoneEffects, updateEffects, { deep: true })
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener("resize", updateEffectWindowSize);
|
||||
window.addEventListener('resize', updateEffectWindowSize)
|
||||
})
|
||||
|
||||
// Cleanup
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener("resize", updateEffectWindowSize);
|
||||
window.removeEventListener('resize', updateEffectWindowSize)
|
||||
if (sceneRef.value) sceneRef.value.scene.remove('effects')
|
||||
gameStore.connection?.off('weather')
|
||||
})
|
||||
|
@ -20,9 +20,9 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount, onMounted, ref, nextTick } from 'vue'
|
||||
import { onBeforeUnmount, ref, nextTick } from 'vue'
|
||||
import { useGameStore } from '@/stores/gameStore'
|
||||
import type { Character, ChatMessage } from '@/types'
|
||||
import type { Chat } from '@/types'
|
||||
import { useZoneStore } from '@/stores/zoneStore'
|
||||
import { useScene } from 'phavuer'
|
||||
|
||||
@ -31,12 +31,12 @@ const gameStore = useGameStore()
|
||||
const zoneStore = useZoneStore()
|
||||
|
||||
const message = ref('')
|
||||
const chats = ref([] as ChatMessage[])
|
||||
const chats = ref([] as Chat[])
|
||||
const chatWindow = ref<HTMLElement | null>(null)
|
||||
|
||||
const sendMessage = () => {
|
||||
if (!message.value.trim()) return
|
||||
gameStore.connection?.emit('chat:send_message', { message: message.value }, (response: boolean) => {})
|
||||
gameStore.connection?.emit('chat:message', { message: message.value }, (response: boolean) => {})
|
||||
message.value = ''
|
||||
}
|
||||
|
||||
@ -60,7 +60,8 @@ const scrollToBottom = () => {
|
||||
})
|
||||
}
|
||||
|
||||
gameStore.connection?.on('chat:message', (data: ChatMessage) => {
|
||||
gameStore.connection?.on('chat:message', (data: Chat) => {
|
||||
console.log(data)
|
||||
chats.value.push(data)
|
||||
scrollToBottom()
|
||||
|
||||
|
@ -218,11 +218,6 @@ export type Chat = {
|
||||
createdAt: Date
|
||||
}
|
||||
|
||||
export type ChatMessage = {
|
||||
character: Character
|
||||
message: string
|
||||
}
|
||||
|
||||
export type WorldSettings = {
|
||||
date: Date
|
||||
isRainEnabled: boolean
|
||||
|
Loading…
x
Reference in New Issue
Block a user