chat WIP
This commit is contained in:
Binary file not shown.
10
client/app/components.d.ts
vendored
10
client/app/components.d.ts
vendored
@@ -13,17 +13,19 @@ declare module 'vue' {
|
||||
PrimeButton: typeof import('primevue/button')['default']
|
||||
PrimeButtonGroup: typeof import('primevue/buttongroup')['default']
|
||||
PrimeCard: typeof import('primevue/card')['default']
|
||||
PrimeDivider: typeof import('primevue/divider')['default']
|
||||
PrimeFloatLabel: typeof import('primevue/floatlabel')['default']
|
||||
PrimeInputText: typeof import('primevue/inputtext')['default']
|
||||
PrimePassword: typeof import('primevue/password')['default']
|
||||
PrimeProgressBar: typeof import('primevue/progressbar')['default']
|
||||
PrimeScrollPanel: typeof import('primevue/scrollpanel')['default']
|
||||
PrimeSelect: typeof import('primevue/select')['default']
|
||||
PrimeSelectButton: typeof import('primevue/selectbutton')['default']
|
||||
PrimeSlider: typeof import('primevue/slider')['default']
|
||||
PrimeTab: typeof import('primevue/tab')['default']
|
||||
PrimeTabList: typeof import('primevue/tablist')['default']
|
||||
PrimeTabPanel: typeof import('primevue/tabpanel')['default']
|
||||
PrimeTabPanels: typeof import('primevue/tabpanels')['default']
|
||||
PrimeTabs: typeof import('primevue/tabs')['default']
|
||||
PrimeTextarea: typeof import('primevue/textarea')['default']
|
||||
PrimeToast: typeof import('primevue/toast')['default']
|
||||
PrimeToggleSwitch: typeof import('primevue/toggleswitch')['default']
|
||||
RouterLink: typeof import('vue-router')['RouterLink']
|
||||
RouterView: typeof import('vue-router')['RouterView']
|
||||
}
|
||||
|
||||
28
client/app/components/chat/ChatEditor.vue
Normal file
28
client/app/components/chat/ChatEditor.vue
Normal file
@@ -0,0 +1,28 @@
|
||||
<template>
|
||||
<div class="chat-editor">
|
||||
<PrimeTextarea v-model="msg" />
|
||||
<PrimeButton :disabled="!msg" @click="handleSend()">
|
||||
Send
|
||||
</PrimeButton>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
interface Emits {
|
||||
(e: 'send', msg: string): void
|
||||
}
|
||||
|
||||
const emit = defineEmits<Emits>()
|
||||
|
||||
const msg = ref<string | undefined>()
|
||||
|
||||
function handleSend() {
|
||||
emit('send', msg.value!)
|
||||
|
||||
msg.value = ''
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
||||
</style>
|
||||
27
client/app/components/chat/ChatMessage.vue
Normal file
27
client/app/components/chat/ChatMessage.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<PrimeCard>
|
||||
<template #header>
|
||||
<span class="font-bold">
|
||||
{{ username }}
|
||||
</span>
|
||||
</template>
|
||||
<template #content>
|
||||
{{ message }}
|
||||
</template>
|
||||
<template #footer>
|
||||
{{ createdAt }}
|
||||
</template>
|
||||
</PrimeCard>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
interface Props {
|
||||
username: string
|
||||
message: string
|
||||
createdAt: Date
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
33
client/app/components/chat/ChatWidget.vue
Normal file
33
client/app/components/chat/ChatWidget.vue
Normal file
@@ -0,0 +1,33 @@
|
||||
<template>
|
||||
<div class="chat-tabs">
|
||||
<div class="chat-tabs__messages">
|
||||
<ChatMessage v-for="msg in messages" :key="msg.id" :created-at="msg.createdAt" :username="msg.username" :message="msg.message" />
|
||||
</div>
|
||||
|
||||
<PrimeTabs :value="channels[0]">
|
||||
<PrimeTabList>
|
||||
<PrimeTab v-for="channel in channels" :key="channel" :value="channel">
|
||||
Channel: {{ channel }}
|
||||
</PrimeTab>
|
||||
</PrimeTabList>
|
||||
<PrimeTabPanels>
|
||||
<PrimeTabPanel :value="channel">
|
||||
<ChatEditor />
|
||||
</PrimeTabPanel>
|
||||
</PrimeTabPanels>
|
||||
</PrimeTabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
const {
|
||||
channel,
|
||||
|
||||
messages,
|
||||
channels,
|
||||
} = useChat()
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
||||
</style>
|
||||
44
client/app/composables/use-chat.ts
Normal file
44
client/app/composables/use-chat.ts
Normal 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,
|
||||
}
|
||||
})
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="flex items-center justify-center">
|
||||
<PrimeCard>
|
||||
<template #content>
|
||||
The chat is under development.
|
||||
<ChatWidget />
|
||||
</template>
|
||||
</PrimeCard>
|
||||
</div>
|
||||
|
||||
@@ -4,7 +4,7 @@ pub fn run() {
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(tauri_plugin_updater::Builder::new().build())
|
||||
.plugin(tauri_plugin_single_instance::init(|_, _, _| {}))
|
||||
// .plugin(tauri_plugin_single_instance::init(|_, _, _| {}))
|
||||
.setup(|app| {
|
||||
if cfg!(debug_assertions) {
|
||||
app.handle().plugin(
|
||||
|
||||
Reference in New Issue
Block a user