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