This commit is contained in:
Ivan Grachyov
2025-12-26 23:36:21 +03:00
parent 0f218c1519
commit ca773a56c6
18 changed files with 315 additions and 7 deletions

View File

@@ -0,0 +1,44 @@
import { createGlobalState } from '@vueuse/core'
interface ChatMessage {
id: string
username: string
message: string
}
interface ChatChannel {
id: number
name: string
}
export const useChat = createGlobalState(() => {
const messages = ref([
{
id: '1337',
username: 'Yes',
message: 'Fisting is 300 bucks',
createdAt: Date.now(),
},
])
const channel = ref<number>(0)
async function sendMsg(channelId: ChatChannel['id'], msg: ChatMessage['message']) {
console.log('Trying to send message', channelId, msg)
}
watch(channel, async (id) => {
await console.log('Yes', id)
}, {
immediate: true,
})
return {
channel,
channels,
messages,
sendMsg,
}
})