This commit is contained in:
2026-02-26 22:34:44 +03:00
parent 2cc21bb284
commit 54fa90b2a5
22 changed files with 1108 additions and 451 deletions

View File

@@ -7,19 +7,13 @@ const authStore = useAuthStore()
</script>
<template>
<v-app>
<v-main class="chat-fullscreen">
<v-container fluid class="h-100 pa-0">
<chat-view v-if="authStore.isAuth" />
<sign-in-view v-else />
<!-- <sign-in-view />-->
</v-container>
</v-main>
</v-app>
<div class="chat-fullscreen">
<div class="h-100 w-50r margin-auto py-4">
<chat-view />
<!-- <chat-view v-if="authStore.isAuth" />-->
<!-- <sign-in-view v-else />-->
</div>
</div>
</template>
<style scoped>
.chat-fullscreen {
height: 100vh;
}
</style>
<style></style>

415
src/assets/clean.css Normal file
View File

@@ -0,0 +1,415 @@
/*! destyle.css v4.0.1 | MIT License | https://github.com/nicolas-cusan/destyle.css */
/* Reset box-model and set borders */
/* ============================================ */
*,
::before,
::after {
box-sizing: border-box;
border-style: solid;
border-width: 0;
min-width: 0;
}
/* Document */
/* ============================================ */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
* 3. Remove gray overlay on links for iOS.
*/
html {
line-height: 1.15; /* 1 */
-webkit-text-size-adjust: 100%; /* 2 */
-webkit-tap-highlight-color: transparent; /* 3*/
}
/* Sections */
/* ============================================ */
/**
* Remove the margin in all browsers.
*/
body {
margin: 0;
}
/**
* Render the `main` element consistently in IE.
*/
main {
display: block;
}
/* Vertical rhythm */
/* ============================================ */
p,
table,
blockquote,
address,
pre,
iframe,
form,
figure,
dl {
margin: 0;
}
/* Headings */
/* ============================================ */
h1,
h2,
h3,
h4,
h5,
h6 {
font-size: inherit;
font-weight: inherit;
margin: 0;
}
/* Lists (enumeration) */
/* ============================================ */
ul,
ol {
margin: 0;
padding: 0;
list-style: none;
}
/* Lists (definition) */
/* ============================================ */
dt {
font-weight: bold;
}
dd {
margin-left: 0;
}
/* Grouping content */
/* ============================================ */
/**
* 1. Add the correct box sizing in Firefox.
* 2. Show the overflow in Edge and IE.
*/
hr {
box-sizing: content-box; /* 1 */
height: 0; /* 1 */
overflow: visible; /* 2 */
border-top-width: 1px;
margin: 0;
clear: both;
color: inherit;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
pre {
font-family: monospace, monospace; /* 1 */
font-size: inherit; /* 2 */
}
address {
font-style: inherit;
}
/* Text-level semantics */
/* ============================================ */
/**
* Remove the gray background on active links in IE 10.
*/
a {
background-color: transparent;
text-decoration: none;
color: inherit;
}
/**
* 1. Remove the bottom border in Chrome 57-
* 2. Add the correct text decoration in Chrome, Edge, IE, Opera, and Safari.
*/
abbr[title] {
text-decoration: underline dotted; /* 2 */
}
/**
* Add the correct font weight in Chrome, Edge, and Safari.
*/
b,
strong {
font-weight: bolder;
}
/**
* 1. Correct the inheritance and scaling of font size in all browsers.
* 2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp {
font-family: monospace, monospace; /* 1 */
font-size: inherit; /* 2 */
}
/**
* Add the correct font size in all browsers.
*/
small {
font-size: 80%;
}
/**
* Prevent `sub` and `sup` elements from affecting the line height in
* all browsers.
*/
sub,
sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
/* Replaced content */
/* ============================================ */
/**
* Prevent vertical alignment issues.
*/
svg,
img,
embed,
object,
iframe {
vertical-align: bottom;
}
/* Forms */
/* ============================================ */
/**
* Reset form fields to make them styleable.
* 1. Make form elements stylable across systems iOS especially.
* 2. Inherit text-transform from parent.
*/
button,
input,
optgroup,
select,
textarea {
-webkit-appearance: none; /* 1 */
appearance: none;
vertical-align: middle;
color: inherit;
font: inherit;
background: transparent;
padding: 0;
margin: 0;
border-radius: 0;
text-align: inherit;
text-transform: inherit; /* 2 */
}
/**
* Correct cursors for clickable elements.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
cursor: pointer;
}
button:disabled,
[type="button"]:disabled,
[type="reset"]:disabled,
[type="submit"]:disabled {
cursor: default;
}
/**
* Improve outlines for Firefox and unify style with input elements & buttons.
*/
:-moz-focusring {
outline: auto;
}
select:disabled {
opacity: inherit;
}
/**
* Remove padding
*/
option {
padding: 0;
}
/**
* Reset to invisible
*/
fieldset {
margin: 0;
padding: 0;
min-width: 0;
}
legend {
padding: 0;
}
/**
* Add the correct vertical alignment in Chrome, Firefox, and Opera.
*/
progress {
vertical-align: baseline;
}
/**
* Remove the default vertical scrollbar in IE 10+.
*/
textarea {
overflow: auto;
}
/**
* Correct the cursor style of increment and decrement buttons in Chrome.
*/
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
/**
* Correct the outline style in Safari.
*/
[type="search"] {
outline-offset: -2px; /* 1 */
}
/**
* Remove the inner padding in Chrome and Safari on macOS.
*/
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
/**
* 1. Correct the inability to style clickable types in iOS and Safari.
* 2. Fix font inheritance.
*/
::-webkit-file-upload-button {
-webkit-appearance: button; /* 1 */
font: inherit; /* 2 */
}
/**
* Fix appearance for Firefox
*/
[type="number"] {
-moz-appearance: textfield;
}
/**
* Clickable labels
*/
label[for] {
cursor: pointer;
}
/* Interactive */
/* ============================================ */
/*
* Add the correct display in Edge, IE 10+, and Firefox.
*/
details {
display: block;
}
/*
* Add the correct display in all browsers.
*/
summary {
display: list-item;
}
/*
* Remove outline for editable content.
*/
[contenteditable]:focus {
outline: auto;
}
/* Tables */
/* ============================================ */
/**
1. Correct table border color inheritance in all Chrome and Safari.
*/
table {
border-color: inherit; /* 1 */
border-collapse: collapse;
}
caption {
text-align: left;
}
td,
th {
vertical-align: top;
padding: 0;
}
th {
text-align: left;
font-weight: bold;
}

137
src/assets/main.css Normal file
View File

@@ -0,0 +1,137 @@
.chat-fullscreen {
height: 100vh;
}
input,
button {
border: 1px solid black;
}
.h-100 {
height: 100%;
}
.h-20r {
height: 20rem;
}
.h-40r {
height: 40rem;
}
.w-100 {
width: 100%;
}
.w-5r {
width: 5rem
}
.w-20r {
width: 20rem
}
.w-40r {
width: 40rem
}
.w-50r {
width: 50rem
}
.w-60r {
width: 60rem
}
.margin-auto {
margin: 0 auto;
}
.border {
border: 1px solid black;
}
.d-flex {
display: flex;
}
.flex-column {
flex-direction: column;
}
.flex-row-reverse {
flex-direction: row-reverse;
}
.flex-column-reverse {
flex-direction: column-reverse;
}
.flex-grow-0 {
flex-grow: 0;
}
.flex-grow-1 {
flex-grow: 1;
}
.align-center {
align-items: center;
}
.justify-center {
justify-content: center;
}
.overflow-y-auto{
overflow-y: auto;
}
.overflow-hidden {
overflow: hidden;
}
.ga-2 {
gap: .5rem;
}
.ga-4 {
gap: 1rem;
}
.pa-1 {
padding: .25rem;
}
.pa-2 {
padding: .5rem;
}
.pa-4 {
padding: 1rem;
}
.py-4 {
padding: 1rem 0;
}
.px-4 {
padding: 0 1rem;
}
.px-8 {
padding: 0 2rem;
}
.red {
background: #e68181;
}
.blue {
background: #5d5ded;
}
.green {
background: #82e882;
}
.yellow {
background: #eaea83;
}

View File

@@ -0,0 +1,17 @@
<script setup lang="ts"></script>
<template>
<div class="red w-5r d-flex flex-column align-center pa-1">
<div>
<span class="mdi mdi-account"></span>
</div>
<div>
<span class="mdi mdi-message"></span>
</div>
<div>
<span class="mdi mdi-cog"></span>
</div>
</div>
</template>
<style scoped></style>

View File

@@ -7,10 +7,8 @@ const authStore = useAuthStore()
const chatsStore = useChatsStore()
const socketsStore = useSocketsStore()
function onSelect(value: { id: unknown }) {
console.log('onSelectChat', value.id)
const chatId = value.id as string
function onSelect(id: string) {
const chatId = id
chatsStore.selected = chatId
socketsStore.send({
@@ -32,26 +30,21 @@ function getChatName(chat: Chat) {
</script>
<template>
<v-list theme="dark" density="compact" lines="two" @click:select="onSelect">
<v-list-subheader>Чаты</v-list-subheader>
<v-list-item
v-for="chat in chatsStore.chats"
:key="chat.id"
:value="chat.id"
subtitle="last message..."
>
<template v-slot:title>{{ getChatName(chat) }} </template>
<template v-slot:prepend>
<v-avatar color="grey-lighten-1" text="V"> </v-avatar>
</template>
<template v-slot:append>
<div class="d-flex flex-column align-end">
<v-chip density="compact" size="small">0</v-chip>
<div class="text-caption">00:00</div>
</div>
</template>
</v-list-item>
</v-list>
<div class="d-flex flex-column ga-2 h-100 overflow-hidden">
<div>chats</div>
<!-- <div class="overflow-y-auto">-->
<!-- <div v-for="i in 30" :key="i" class="pa-4 border">bla</div>-->
<!-- </div>-->
<div v-for="chat in chatsStore.chats" :key="chat.id" @click="onSelect(chat.id)" class="border">
<div>{{ getChatName(chat) }}</div>
<div>avatar</div>
<div>
<div>0</div>
<div>00:00</div>
</div>
</div>
</div>
</template>
<style scoped></style>

View File

@@ -6,18 +6,8 @@ const search = ref('')
<template>
<div class="d-flex align-center ga-4">
<v-btn icon="mdi-menu" variant="text"></v-btn>
<v-text-field
v-model="search"
rounded="xl"
density="compact"
hide-details
variant="outlined"
bg-color="black"
base-color="black"
color="primary"
placeholder="Search..."
/>
<button>menu</button>
<input v-model="search" placeholder="Search..." />
</div>
</template>

View File

@@ -1,13 +1,43 @@
<script setup lang="ts">
import ChatToolbar from '@/components/ChatToolbar.vue'
import ChatList from '@/components/ChatList.vue'
import { useAuthStore } from '@/stores/auth.ts'
import { type Chat, useChatsStore } from '@/stores/chats.ts'
import { SocketDataReq, useSocketsStore } from '@/stores/sockets.ts'
import AppMenu from '@/components/AppMenu.vue'
const authStore = useAuthStore()
const chatsStore = useChatsStore()
const socketsStore = useSocketsStore()
function onSelect(value: { id: unknown }) {
const chatId = value.id as string
chatsStore.selected = chatId
socketsStore.send({
type: SocketDataReq.GET_MESSAGES,
data: { chat_id: chatId },
})
}
function getChatName(chat: Chat) {
if (chat.type_id === 2) {
return chat.name
} else if (chat.type_id === 1) {
const otherUsers = chat.users.filter((user) => user.id !== authStore.me?.id)
return otherUsers[0]?.name ?? otherUsers[0]?.email ?? 'unknown'
}
return 'unknown ID'
}
</script>
<template>
<v-sheet class="pa-4 d-flex flex-column h-100" theme="dark">
<div class="w-100 d-flex h-100 flex-column ga-2 yellow">
<chat-toolbar />
<chat-list />
</v-sheet>
</div>
</template>
<style scoped></style>

View File

@@ -35,29 +35,17 @@ const avatarLetter = computed(() => {
<!-- </div>-->
<!-- </div>-->
<v-sheet color="transparent" class="d-flex ga-2" :class="{ 'flex-row-reverse': props.my }">
<div class="d-flex ga-2 border" :class="{ 'flex-row-reverse': props.my }">
<!-- <v-avatar size="36" color="deep-purple-lighten-4">-->
<!-- <span class="text-deep-purple-darken-2">{{ avatarLetter }}</span>-->
<!-- </v-avatar>-->
<!-- :class="props.my ? 'message-shaped-right' : 'message-shaped'"-->
<v-sheet class="pa-4 message-width rounded-lg" :color="props.my ? 'primary' : 'white'">
<div class="pa-4" :class="props.my ? 'red' : 'blue'">
<span class="text-body-1">{{ props.text }}</span>
<span class="text-caption ml-2">{{ createdAt }}</span>
</v-sheet>
</v-sheet>
</div>
</div>
</template>
<style scoped>
.message-shaped {
border-radius: 0 24px;
}
.message-shaped-right {
border-radius: 24px 0;
}
.message-width {
max-width: 66%;
}
</style>
<style scoped></style>

View File

@@ -27,37 +27,14 @@ const isEmptyText = computed(() => {
</script>
<template>
<v-row dense align="center">
<v-col>
<v-text-field
rounded="lg"
bg-color="white"
variant="outlined"
hide-details
label="Message"
v-model="text"
@keyup.enter="sendMessage"
>
<template v-slot:prepend-inner>
<v-btn icon variant="text" density="compact" color="grey-darken-1">
<v-icon>mdi-emoticon-outline</v-icon>
</v-btn>
</template>
</v-text-field>
</v-col>
<v-col v-if="false" cols="auto">
<v-btn icon variant="text" color="grey-darken-1">
<v-icon>mdi-paperclip</v-icon>
</v-btn>
</v-col>
<v-col cols="auto">
<v-btn :disabled="isEmptyText" icon variant="flat" color="primary" @click="sendMessage">
<v-icon>mdi-send</v-icon>
</v-btn>
</v-col>
</v-row>
<div class="d-flex ga-2 border pa-4">
<input v-model="text" placeholder="message" @keyup.enter="sendMessage" />
<button><span class="mdi mdi-emoticon-outline"></span></button>
<button><span class="mdi mdi-paperclip"></span></button>
<button :disabled="isEmptyText" @click="sendMessage">
<span class="mdi mdi-send"></span>
</button>
</div>
</template>
<style scoped></style>

View File

@@ -1,10 +1,10 @@
<script setup lang="ts"></script>
<template>
<v-toolbar color="white" class="flex-grow-0 px-4">
<v-avatar color="grey-lighten-1" text="V"></v-avatar>
<v-toolbar-title class="">name</v-toolbar-title>
</v-toolbar>
<div class="d-flex ga-2 pa-4 border">
<div>V</div>
<div>name</div>
</div>
</template>
<style scoped></style>

View File

@@ -4,41 +4,64 @@ import MessageForm from '@/components/MessageForm.vue'
import MessageData from '@/components/MessageData.vue'
import { useMessagesStore } from '@/stores/messages.ts'
import { useAuthStore } from '@/stores/auth.ts'
import { computed } from 'vue'
import { computed, nextTick, useTemplateRef, watch } from 'vue'
import { useScroll } from '@vueuse/core'
import { useChatsStore } from '@/stores/chats.ts'
const authStore = useAuthStore()
const messagesStore = useMessagesStore()
const chatsStore = useChatsStore()
const area = useTemplateRef('messageArea')
const { y, arrivedState } = useScroll(area)
const messages = computed(() => {
return [...messagesStore.messages]
})
async function scrollToBottom() {
await nextTick()
if (area.value) y.value = area.value?.scrollHeight
}
watch(messages, async () => {
await scrollToBottom()
})
</script>
<template>
<div class="h-100 d-flex flex-column">
<message-toolbar />
<div class="w-100 green h-100">
<!-- <button class="position-absolute scroll-down" @click="scrollToBottom">UP</button>-->
<div class="d-flex flex-column h-100">
<div class="d-flex h-100 flex-column overflow-hidden">
<message-toolbar class="flex-grow-0" />
<v-card
rounded="0"
variant="flat"
color="grey-lighten-3"
class="flex-grow-1 d-flex flex-column overflow-hidden"
>
<v-card-text class="flex-grow-1 d-flex ga-1 flex-column overflow-y-auto justify-end">
<message-data
v-for="message in messages"
:key="message.id"
:text="message.text"
:my="authStore.me?.id === message.user_id"
:created-at="message.created_at"
/>
</v-card-text>
<div
class="px-8 ga-2 flex-grow-1 d-flex flex-column flex-column-reverse overflow-y-auto"
ref="messageArea"
>
<!-- <message-data-->
<!-- v-for="message in messages"-->
<!-- :key="message.id"-->
<!-- :text="message.text"-->
<!-- :my="authStore.me?.id === message.user_id"-->
<!-- :created-at="message.created_at"-->
<!-- ></message-data>-->
<div class="pa-4 border" v-for="v in 101" :key="v">text {{ v }}</div>
</div>
<v-card-actions class="flex-grow-0 bg-white pa-4">
<message-form />
</v-card-actions>
</v-card>
<message-form class="flex-grow-0 blue" />
</div>
</div>
</div>
</template>
<style scoped></style>
<style scoped>
.scroll-down {
right: 16px;
bottom: 104px;
}
.test {
height: 400px;
}
</style>

View File

@@ -0,0 +1,270 @@
<template>
<v-container class="d-flex" style="height: 600px; gap: 16px">
<!-- Постоянный rail drawer на v-card -->
<v-card width="72" height="100%" elevation="3" class="rail-drawer" rounded="lg">
<!-- Логотип/бренд -->
<div class="d-flex justify-center py-4">
<v-avatar color="primary" size="40" class="brand-avatar">
<span class="text-white font-weight-bold">V</span>
</v-avatar>
</div>
<v-divider></v-divider>
<!-- Основная навигация -->
<v-list density="compact" nav class="px-2 py-2">
<v-list-item
v-for="item in mainMenu"
:key="item.title"
:value="item.title"
:active="activeItem === item.title"
@click="activeItem = item.title"
class="rail-list-item mb-1"
:class="{ 'active-item': activeItem === item.title }"
>
<template v-slot:prepend>
<v-badge
v-if="item.badge"
:content="item.badge"
color="error"
dot
location="bottom end"
offset-x="2"
offset-y="2"
>
<v-icon :icon="item.icon" size="24"></v-icon>
</v-badge>
<v-icon v-else :icon="item.icon" size="24"></v-icon>
</template>
<!-- Тултип с названием -->
<v-tooltip
activator="parent"
location="right"
transition="slide-x-transition"
:open-delay="300"
>
{{ item.title }}
</v-tooltip>
</v-list-item>
</v-list>
<v-divider></v-divider>
<!-- Нижняя группа иконок -->
<v-list density="compact" nav class="px-2 py-2" style="margin-top: auto">
<v-list-item
v-for="item in bottomMenu"
:key="item.title"
:value="item.title"
:active="activeItem === item.title"
@click="activeItem = item.title"
class="rail-list-item mb-1"
>
<template v-slot:prepend>
<v-icon :icon="item.icon" size="24"></v-icon>
</template>
<v-tooltip
activator="parent"
location="right"
transition="slide-x-transition"
:open-delay="300"
>
{{ item.title }}
</v-tooltip>
</v-list-item>
</v-list>
<!-- Профиль пользователя внизу -->
<div class="mt-auto">
<v-divider></v-divider>
<div class="d-flex justify-center py-3">
<v-menu location="top right" offset="15">
<template v-slot:activator="{ props }">
<v-avatar
size="44"
color="grey-lighten-2"
v-bind="props"
class="profile-avatar cursor-pointer"
>
<v-img src="https://randomuser.me/api/portraits/women/44.jpg"></v-img>
<v-tooltip activator="parent" location="right" :open-delay="300">
Профиль
</v-tooltip>
</v-avatar>
</template>
<!-- Меню профиля -->
<v-card min-width="200" rounded="lg">
<v-list>
<v-list-item
prepend-avatar="https://randomuser.me/api/portraits/women/44.jpg"
title="Анна Петрова"
subtitle="anna@email.com"
></v-list-item>
</v-list>
<v-divider></v-divider>
<v-list>
<v-list-item
prepend-icon="mdi-account"
title="Мой профиль"
value="profile"
></v-list-item>
<v-list-item
prepend-icon="mdi-cog"
title="Настройки"
value="settings"
></v-list-item>
<v-list-item prepend-icon="mdi-logout" title="Выйти" value="logout"></v-list-item>
</v-list>
</v-card>
</v-menu>
</div>
</div>
</v-card>
<!-- Основной контент -->
<v-card class="flex-grow-1 content-area" elevation="2" rounded="lg">
<!-- Хедер контента -->
<div class="d-flex align-center pa-4">
<div class="text-h5 font-weight-medium">
{{ getActiveTitle }}
</div>
<v-spacer></v-spacer>
<v-btn icon="mdi-bell-outline" variant="text" size="small"></v-btn>
<v-btn icon="mdi-magnify" variant="text" size="small" class="mr-2"></v-btn>
</div>
<v-divider></v-divider>
<!-- Контент -->
<div class="pa-6">
<div class="text-h6 mb-4">Добро пожаловать в раздел "{{ getActiveTitle }}"</div>
<v-row>
<v-col v-for="n in 6" :key="n" cols="12" md="6" lg="4">
<v-card elevation="1" rounded="lg" class="content-card">
<v-card-item>
<v-card-title>Карточка {{ n }}</v-card-title>
<v-card-subtitle>Описание карточки {{ n }}</v-card-subtitle>
</v-card-item>
<v-card-text>
Контент карточки {{ n }}. Здесь может быть любая информация.
</v-card-text>
</v-card>
</v-col>
</v-row>
</div>
</v-card>
</v-container>
</template>
<script setup>
import { ref, computed } from 'vue'
const activeItem = ref('Главная')
const mainMenu = [
{ title: 'Главная', icon: 'mdi-home-outline', activeIcon: 'mdi-home' },
{ title: 'Профиль', icon: 'mdi-account-outline', activeIcon: 'mdi-account' },
{ title: 'Сообщения', icon: 'mdi-message-outline', activeIcon: 'mdi-message', badge: '3' },
{ title: 'Файлы', icon: 'mdi-folder-outline', activeIcon: 'mdi-folder' },
{ title: 'Аналитика', icon: 'mdi-chart-line', activeIcon: 'mdi-chart-line' },
{ title: 'Календарь', icon: 'mdi-calendar-outline', activeIcon: 'mdi-calendar' },
]
const bottomMenu = [
{ title: 'Настройки', icon: 'mdi-cog-outline', activeIcon: 'mdi-cog' },
{ title: 'Помощь', icon: 'mdi-help-circle-outline', activeIcon: 'mdi-help-circle' },
]
const getActiveTitle = computed(() => {
const found = [...mainMenu, ...bottomMenu].find((item) => item.title === activeItem.value)
return found ? found.title : 'Главная'
})
</script>
<style scoped>
.rail-drawer {
display: flex;
flex-direction: column;
overflow-y: auto;
scrollbar-width: none; /* Firefox */
-ms-overflow-style: none; /* IE/Edge */
}
.rail-drawer::-webkit-scrollbar {
display: none; /* Chrome/Safari */
}
.rail-list-item {
justify-content: center !important;
min-height: 48px !important;
padding: 0 8px !important;
border-radius: 12px !important;
transition: all 0.2s ease;
}
.rail-list-item:hover {
background-color: rgba(var(--v-theme-primary), 0.08) !important;
transform: scale(1.05);
}
.rail-list-item.active-item {
background-color: rgb(var(--v-theme-primary)) !important;
}
.rail-list-item.active-item .v-icon {
color: white !important;
}
.rail-list-item .v-icon {
transition: transform 0.2s ease;
}
.rail-list-item:hover .v-icon {
transform: scale(1.1);
}
.brand-avatar {
transition: all 0.3s ease;
}
.brand-avatar:hover {
transform: rotate(10deg) scale(1.1);
}
.profile-avatar {
transition: all 0.2s ease;
border: 2px solid transparent;
}
.profile-avatar:hover {
border-color: rgb(var(--v-theme-primary));
transform: scale(1.05);
}
.content-area {
overflow-y: auto;
background-color: rgb(var(--v-theme-background)) !important;
}
.content-card {
transition: all 0.2s ease;
}
.content-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}
/* Анимация для тултипов */
:deep(.v-tooltip .v-overlay__content) {
background-color: rgb(var(--v-theme-primary)) !important;
color: white !important;
font-weight: 500;
font-size: 0.85rem;
padding: 6px 12px !important;
border-radius: 8px !important;
}
</style>

View File

@@ -0,0 +1,72 @@
<template>
<v-container class="d-flex ga-4" style="height: 500px">
<!-- Простой rail drawer -->
<v-card width="72" height="100%" elevation="0" class="simple-rail">
<div class="d-flex flex-column align-center py-4">
<v-avatar color="primary" size="40" class="mb-4">
<v-icon icon="mdi-vuetify" color="white"></v-icon>
</v-avatar>
<v-divider class="w-100 mb-2"></v-divider>
<v-list density="compact" nav class="w-100 px-1">
<v-list-item
v-for="icon in icons"
:key="icon.name"
:value="icon.name"
:active="active === icon.name"
@click="active = icon.name"
class="simple-item"
>
<template v-slot:prepend>
<v-icon :icon="icon.icon"></v-icon>
</template>
</v-list-item>
</v-list>
<v-spacer></v-spacer>
<v-divider class="w-100 my-2"></v-divider>
<v-avatar size="44" class="mt-2 cursor-pointer" color="grey-lighten-3">
<v-img src="https://randomuser.me/api/portraits/men/32.jpg"></v-img>
<v-tooltip activator="parent" location="right">Профиль</v-tooltip>
</v-avatar>
</div>
</v-card>
</v-container>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const active = ref('Главная')
const icons = [
{ name: 'Главная', icon: 'mdi-home' },
{ name: 'Профиль', icon: 'mdi-account' },
{ name: 'Сообщения', icon: 'mdi-message' },
{ name: 'Настройки', icon: 'mdi-cog' },
]
</script>
<style scoped>
.simple-rail {
background-color: rgb(var(--v-theme-surface)) !important;
}
.simple-item {
justify-content: center !important;
min-height: 44px !important;
border-radius: 10px !important;
margin: 2px 0 !important;
}
.simple-item:hover {
background-color: rgba(var(--v-theme-primary), 0.1) !important;
}
.simple-item.v-list-item--active {
background-color: rgb(var(--v-theme-primary)) !important;
color: white !important;
}
</style>

View File

@@ -1,88 +0,0 @@
<script setup lang="ts">
import { ref } from 'vue'
const message = ref('')
const selectedChat = ref('')
// const { messages, chats, isConnected, error, send } = useSharedWebSocket({
// onMessage: (data) => {
// console.log('Received message:', data)
// },
// })
const onChatClick = (id: string) => {
console.log(id)
selectedChat.value = id
// send({
// type: WsDataType.GET_MESSAGES,
// data: { chat_id: id },
// })
}
const sendMessage = () => {
if (message.value.trim()) {
// send({
// type: WsDataType.CREATE_MESSAGE,
// data: {
// chat_id: selectedChat.value,
// text: message.value,
// },
})
message.value = ''
}
}
</script>
<template>
<v-row>
<v-col>
<!-- <div class="status" :class="{ isConnected, disconnected: !isConnected }">-->
<!-- status: {{ isConnected ? 'connected' : 'disconnected' }}-->
<!-- </div>-->
<div>selected chat {{ selectedChat }}</div>
<!-- <div class="error">Error: {{ error }}</div>-->
</v-col>
</v-row>
<v-row>
<v-col>
<div>
<!-- <div v-for="chat in chats" :key="chat.id" @click="onChatClick(chat.id)">-->
<!-- <div>{{ chat.id }}</div>-->
<!-- <div>{{ chat.users }}</div>-->
<!-- </div>-->
</div>
</v-col>
<v-col>
<v-sheet border class="pa-4 border-opacity-50">
<div v-if="selectedChat">
<v-sheet height="400px" class="overflow-y-auto">
<!-- <div v-for="message in messages" :key="message.id">-->
<!-- <div>{{ message }}</div>-->
<!-- </div>-->
</v-sheet>
<div class="d-flex align-center ga-1">
<v-text-field
rounded="lg"
hide-details
variant="outlined"
v-model="message"
@keyup.enter="sendMessage"
placeholder="Type message..."
>
</v-text-field>
<!-- <v-btn-->
<!-- :disabled="!isConnected"-->
<!-- variant="elevated"-->
<!-- color="primary"-->
<!-- icon="mdi-send"-->
<!-- @click="sendMessage"-->
<!-- />-->
</div>
</div>
</v-sheet>
</v-col>
</v-row>
</template>
<style scoped></style>

View File

@@ -1,141 +0,0 @@
import { ref, onUnmounted, onMounted } from 'vue'
export interface Message {
id: number
text: string
userId: string
createdAt: string
}
export interface Chat {
id: string
type_id: number
users: User[]
}
export interface User {
id: number
email: string
}
export interface WsData {
type: WsDataType2
// data: Chat | Message | User | User[] | Message[] | Chat[]
data: unknown
}
export enum WsDataType2 {
GET_CHATS = 'GET_CHATS',
GET_USERS = 'GET_USERS',
GET_MESSAGES = 'GET_MESSAGES',
CREATE_MESSAGE = 'CREATE_MESSAGE',
CHATS = 'CHATS',
USER = 'USER',
MESSAGES = 'MESSAGES',
STATUS = 'STATUS',
ERROR = 'ERROR',
}
export enum COMMAND2 {
CONNECT = 'CONNECT',
SEND = 'SEND',
CLOSE = 'CLOSE',
}
export function useSharedWebSocket(options?: { url?: string; autoConnect?: true }) {
const url = options?.url || 'ws://localhost:3000/ws'
const autoConnect = options?.autoConnect ?? false
const messages = ref<Message[]>([])
const chats = ref<Chat[]>([])
const users = ref<unknown[]>([])
const isConnected = ref(false)
const error = ref<string>()
const worker = ref<SharedWorker>()
const init = () => {
console.log('INIT WORKER')
if (!window.SharedWorker) {
console.log('SharedWorker not supported')
error.value = 'SharedWorker not supported'
}
worker.value = new SharedWorker(new URL('@/workers/worker.js', import.meta.url), {
type: 'module',
})
worker.value.port.onmessage = (event) => {
const { type, data, connected, message } = event.data
switch (type) {
case WsDataType2.USER:
break
case WsDataType2.CHATS:
chats.value = data
break
case WsDataType2.MESSAGES:
messages.value = data
// if (options.onMessage) {
// options.onMessage(data)
// }
break
case WsDataType2.CREATE_MESSAGE:
messages.value.push(data)
break
case WsDataType2.STATUS:
isConnected.value = connected
break
case WsDataType2.ERROR:
error.value = message
logout()
break
}
}
worker.value.port.postMessage({
command: COMMAND2.CONNECT,
data: { url: url, token: getToken() },
})
}
function logout() {
return localStorage.removeItem('token')
}
function getToken() {
return localStorage.getItem('token')
}
const send = (data: WsData) => {
if (worker.value) {
worker.value.port.postMessage({
command: COMMAND2.SEND,
data: data,
})
}
}
const close = () => {
if (worker.value) {
worker.value.port.postMessage({ command: COMMAND2.CLOSE })
}
}
onMounted(() => {
if (autoConnect) init()
})
onUnmounted(() => {
if (worker.value) close()
})
return {
messages,
chats,
isConnected,
error,
send,
close,
init,
}
}

View File

@@ -1,28 +1,12 @@
import '@fontsource/roboto/100.css'
import '@fontsource/roboto/300.css'
import '@fontsource/roboto/400.css'
import '@mdi/font/css/materialdesignicons.css'
import './assets/clean.css'
import './assets/main.css'
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'
const app = createApp(App)
app.use(createPinia())
const vuetify = createVuetify({
components,
directives,
icons: {
defaultSet: 'mdi',
},
})
app.use(vuetify)
app.mount('#app')

View File

@@ -1,6 +1,5 @@
import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import type { WsData } from '@/composables/useSharedWebSocket.ts'
import type { User } from '@/stores/users.ts'
export const useAuthStore = defineStore('auth', () => {

View File

@@ -70,14 +70,14 @@ export const useSocketsStore = defineStore('sockets', () => {
case SocketDataRes.MESSAGES:
console.log('MESSAGES', data)
messagesStore.messages = data.reverse()
messagesStore.messages = data
// if (options.onMessage) {
// options.onMessage(data)
// }
break
case SocketDataRes.MESSAGE:
console.log('MESSAGE', data)
messagesStore.messages.push(data)
messagesStore.messages.unshift(data)
break
case SocketDataRes.STATUS:
isConnected.value = connected

View File

@@ -4,6 +4,7 @@ import ChatsPane from '@/components/ChatsPane.vue'
import MessagesPane from '@/components/MessagesPane.vue'
import { useSocketsStore } from '@/stores/sockets.ts'
import { useChatsStore } from '@/stores/chats.ts'
import AppMenu from '@/components/AppMenu.vue'
const socketsStore = useSocketsStore()
// const { messages, chats, isConnected, error, send } = useSharedWebSocket({ autoConnect: true })
@@ -42,14 +43,13 @@ onMounted(() => {
</script>
<template>
<v-row no-gutters class="h-100">
<v-col cols="12" md="4" lg="3" sm="5">
<div class="d-flex h-100">
<div class="d-flex w-100">
<app-menu />
<chats-pane />
</v-col>
<v-col cols="12" md="8" lg="9" sm="7" class="h-100">
<messages-pane v-if="chatsStore.selected" />
</v-col>
</v-row>
</div>
<messages-pane />
</div>
</template>
<style scoped></style>

View File

@@ -5,37 +5,28 @@ import { useAuthStore } from '@/stores/auth.ts'
const authStore = useAuthStore()
const email = ref('vadim.olonin@gmail.com')
const name = ref('')
async function onSubmit() {
await authStore.login(email.value)
}
</script>
<template>
<v-row justify="center" align="center" class="h-100">
<v-col cols="12" md="4" lg="4">
<v-card elevation="0" border rounded="lg">
<v-card-title class="mb-2">Sign in</v-card-title>
<v-card-text>
<form @submit.prevent="onSubmit">
<div class="d-flex flex-column ga-4">
<v-text-field
hide-details
variant="outlined"
v-model="email"
placeholder="email"
type="email"
rounded="lg"
/>
<div class="d-flex ga-4 align-center justify-space-between">
<v-switch color="black" label="Keep me signed in" hide-details></v-switch>
<v-btn variant="flat" rounded="lg" type="submit" color="black">login</v-btn>
</div>
</div>
</form>
</v-card-text>
</v-card>
</v-col>
</v-row>
<div class="h-100 d-flex flex-column align-center justify-center red">
<div class="w-20r border pa-4 blue">
<form @submit.prevent="onSubmit">
<div class="d-flex flex-column ga-4">
<div class="">Sign in</div>
<input v-model="email" placeholder="email" type="email" class="border" />
<input v-if="false" v-model="name" placeholder="name" />
<div class="d-flex ga-4 align-center">
<input type="checkbox" v-if="false" />
<button type="submit">login</button>
</div>
</div>
</form>
</div>
</div>
</template>
<style scoped></style>