wip
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { type Chat, useChatsStore } from '@/stores/chats.ts'
|
import { type Chat, useChatsStore } from '@/stores/chats.ts'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useMessagesStore } from '@/stores/messages.ts'
|
import { shortDate } from '@/helpers'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
chat: Chat
|
chat: Chat
|
||||||
@@ -15,8 +15,7 @@ const chatInfo = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const convertDate = (dateString: string) => {
|
const convertDate = (dateString: string) => {
|
||||||
const date = new Date(dateString)
|
return shortDate(new Date(dateString))
|
||||||
return date.toLocaleTimeString('ru-RU', { timeStyle: 'short' })
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ const convertDate = (dateString: string) => {
|
|||||||
|
|
||||||
<template v-if="chat.message" #subtitle>
|
<template v-if="chat.message" #subtitle>
|
||||||
<div class="flex justify-between">
|
<div class="flex justify-between">
|
||||||
<div>{{ chat.message.message }}</div>
|
<div class="truncate text-nowrap">{{ chat.message.message }}</div>
|
||||||
<div class="text-xs">
|
<div class="text-xs">
|
||||||
<!-- <VChip v-show="true" size="small" text="0" />-->
|
<!-- <VChip v-show="true" size="small" text="0" />-->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -22,9 +22,9 @@ const component = computed(() => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col h-full gap-2">
|
<VSheet theme="dark" class="d-flex flex-col h-100">
|
||||||
<slot :component="component" />
|
<slot :component="component" />
|
||||||
</div>
|
</VSheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -1,27 +1,25 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
import { shortDate } from '@/helpers'
|
||||||
|
import { useAuthStore } from '@/stores/auth.ts'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
createdAt?: string
|
createdAt?: string
|
||||||
username?: string
|
userId: number
|
||||||
onRightSide?: boolean
|
|
||||||
message?: string
|
message?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const { message, username, createdAt } = withDefaults(defineProps<Props>(), {
|
const authStore = useAuthStore()
|
||||||
my: false,
|
|
||||||
message: 'foobar',
|
const { message = 'foobar', userId, createdAt } = defineProps<Props>()
|
||||||
username: 'robot',
|
|
||||||
})
|
|
||||||
|
|
||||||
const messageDate = computed(() => {
|
const messageDate = computed(() => {
|
||||||
return createdAt
|
const date = createdAt ? new Date(createdAt) : new Date()
|
||||||
? new Date(createdAt).toLocaleTimeString('ru-RU', { timeStyle: 'short' })
|
return shortDate(date)
|
||||||
: new Date().toLocaleTimeString('ru-RU', { timeStyle: 'short' })
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const avatarLetter = computed(() => {
|
const isMyMessage = computed(() => {
|
||||||
return username.slice(0, 1).toUpperCase()
|
return authStore.me?.id === userId
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -39,17 +37,12 @@ const avatarLetter = computed(() => {
|
|||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
<!-- </div>-->
|
<!-- </div>-->
|
||||||
|
|
||||||
<div class="flex gap-2" :class="{ 'flex-row-reverse': onRightSide }">
|
<VSheet class="d-flex" color="transparent" :class="{ 'flex-row-reverse': isMyMessage }">
|
||||||
<!-- <v-avatar size="36" color="deep-purple-lighten-4">-->
|
<div class="flex gap-2 pa-4 rounded" :class="isMyMessage ? 'bg-blue-200' : 'bg-white'">
|
||||||
<!-- <span class="text-deep-purple-darken-2">{{ avatarLetter }}</span>-->
|
<span>{{ message }}</span>
|
||||||
<!-- </v-avatar>-->
|
|
||||||
|
|
||||||
<!-- :class="props.my ? 'message-shaped-right' : 'message-shaped'"-->
|
|
||||||
<div class="flex gap-1 pa-4" :class="onRightSide ? 'bg-blue-400' : 'bg-white'">
|
|
||||||
<span class="">{{ message }}</span>
|
|
||||||
<span class="text-xs self-end">{{ messageDate }}</span>
|
<span class="text-xs self-end">{{ messageDate }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</VSheet>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style scoped></style>
|
<style scoped></style>
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
<script setup lang="ts">
|
|
||||||
import MessageData from '@/components/Messages/MessageData.vue'
|
|
||||||
import type { Message } from '@/stores/messages.ts'
|
|
||||||
|
|
||||||
const { messages } = defineProps<{ messages: Message[] }>()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<MessageData v-for="message in messages" :key="message.id" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,7 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, ref, useTemplateRef, watch } from 'vue'
|
import { computed } from 'vue'
|
||||||
import { useScroll } from '@vueuse/core'
|
|
||||||
import type { User } from '@/stores/users.ts'
|
|
||||||
import { useChatsStore } from '@/stores/chats.ts'
|
import { useChatsStore } from '@/stores/chats.ts'
|
||||||
import { useMessagesStore } from '@/stores/messages.ts'
|
import { useMessagesStore } from '@/stores/messages.ts'
|
||||||
|
|
||||||
@@ -24,8 +22,6 @@ const chatInfo = computed(() => {
|
|||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
})
|
})
|
||||||
|
|
||||||
const messages = ref([])
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
3
src/helpers/index.ts
Normal file
3
src/helpers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export function shortDate(date: Date) {
|
||||||
|
return date.toLocaleTimeString('ru-RU', { timeStyle: 'short' })
|
||||||
|
}
|
||||||
@@ -12,7 +12,6 @@ import * as directives from 'vuetify/directives'
|
|||||||
|
|
||||||
import App from './App.vue'
|
import App from './App.vue'
|
||||||
import { version } from 'vue'
|
import { version } from 'vue'
|
||||||
import theme from '@/themes/noir.ts'
|
|
||||||
|
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
console.log('version', version)
|
console.log('version', version)
|
||||||
@@ -29,7 +28,7 @@ const vuetify = createVuetify({
|
|||||||
defaults: {
|
defaults: {
|
||||||
VAvatar: { density: 'compact' },
|
VAvatar: { density: 'compact' },
|
||||||
VChip: { density: 'compact' },
|
VChip: { density: 'compact' },
|
||||||
VBtn: { color: 'black', variant: 'flat' },
|
VBtn: { variant: 'flat' },
|
||||||
VSwitch: { color: 'black', hideDetails: true },
|
VSwitch: { color: 'black', hideDetails: true },
|
||||||
VOtpInput: { density: 'compact' },
|
VOtpInput: { density: 'compact' },
|
||||||
VTextField: { color: 'black', density: 'compact', variant: 'outlined', hideDetails: true },
|
VTextField: { color: 'black', density: 'compact', variant: 'outlined', hideDetails: true },
|
||||||
|
|||||||
Reference in New Issue
Block a user