2025-05-21 22:13:09 +07:00
|
|
|
|
<template>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<div class="app-chatlist-view">
|
|
|
|
|
<!-- Фиксированный хедер -->
|
2025-05-23 16:02:15 +07:00
|
|
|
|
<div class="chatlist-header">
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<h2 class="section-title">Диалоги</h2>
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<!-- Основное содержимое -->
|
|
|
|
|
<main class="chatlist-content">
|
|
|
|
|
<!-- Loading State -->
|
|
|
|
|
<div v-if="loading" class="loading-section">
|
|
|
|
|
<div class="loading-spinner">
|
|
|
|
|
<div class="spinner"></div>
|
|
|
|
|
<p>Загрузка диалогов...</p>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<!-- Conversations List -->
|
|
|
|
|
<div v-if="!loading && isAuthenticated" class="conversations-container">
|
2025-05-23 16:02:15 +07:00
|
|
|
|
<!-- Empty State -->
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<div v-if="conversations.length === 0" class="empty-chats">
|
|
|
|
|
<div class="empty-chats-content">
|
|
|
|
|
<i class="bi-chat-dots"></i>
|
|
|
|
|
<h3>Нет диалогов</h3>
|
|
|
|
|
<p>У вас пока нет активных диалогов. Начните общение с теми, кто вам понравился!</p>
|
|
|
|
|
<router-link to="/swipe" class="action-btn primary">Найти собеседников</router-link>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<!-- Conversations List -->
|
|
|
|
|
<div v-else class="conversations-list">
|
|
|
|
|
<router-link
|
|
|
|
|
v-for="conversation in conversationsSorted"
|
|
|
|
|
:key="conversation._id"
|
|
|
|
|
:to="`/chat/${conversation._id}`"
|
|
|
|
|
class="conversation-card"
|
|
|
|
|
>
|
|
|
|
|
<!-- User Photo -->
|
|
|
|
|
<div class="user-photo-container">
|
|
|
|
|
<img
|
|
|
|
|
v-if="getOtherParticipant(conversation)?.mainPhotoUrl"
|
|
|
|
|
:src="getOtherParticipant(conversation)?.mainPhotoUrl"
|
|
|
|
|
:alt="getOtherParticipantName(conversation) || 'Фото собеседника'"
|
|
|
|
|
class="user-photo"
|
|
|
|
|
/>
|
|
|
|
|
<div v-else class="user-photo-placeholder">
|
|
|
|
|
<i class="bi-person"></i>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Conversation Info -->
|
|
|
|
|
<div class="conversation-info">
|
|
|
|
|
<div class="conversation-header">
|
|
|
|
|
<h3 class="user-name">{{ getOtherParticipantName(conversation) || 'Собеседник' }}</h3>
|
|
|
|
|
<span class="timestamp">{{ formatTimestamp(conversation.updatedAt) }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<p class="last-message">
|
|
|
|
|
<span v-if="conversation.typing" class="typing-text">
|
|
|
|
|
<span class="typing-animation">
|
|
|
|
|
<span class="dot"></span>
|
|
|
|
|
<span class="dot"></span>
|
|
|
|
|
<span class="dot"></span>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</span>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
печатает...
|
|
|
|
|
</span>
|
|
|
|
|
<template v-else>
|
|
|
|
|
{{ formatLastMessage(conversation) }}
|
|
|
|
|
</template>
|
|
|
|
|
</p>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</div>
|
2025-05-24 23:52:52 +07:00
|
|
|
|
|
|
|
|
|
<!-- Right side: Unread badge and arrow -->
|
|
|
|
|
<div class="conversation-right">
|
|
|
|
|
<span
|
|
|
|
|
v-if="conversation.unreadCount > 0"
|
|
|
|
|
class="unread-badge"
|
|
|
|
|
>
|
|
|
|
|
{{ conversation.unreadCount < 100 ? conversation.unreadCount : '99+' }}
|
|
|
|
|
</span>
|
|
|
|
|
<div class="conversation-arrow">
|
|
|
|
|
<i class="bi-chevron-right"></i>
|
|
|
|
|
</div>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
</div>
|
|
|
|
|
</router-link>
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</div>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
<!-- No Auth State -->
|
|
|
|
|
<div v-if="!isAuthenticated && !loading" class="not-authenticated-section">
|
|
|
|
|
<div class="not-auth-card">
|
2025-05-23 16:02:15 +07:00
|
|
|
|
<i class="bi-person-lock"></i>
|
|
|
|
|
<h3>Доступ ограничен</h3>
|
|
|
|
|
<p>Пожалуйста, войдите в систему, чтобы просматривать диалоги.</p>
|
|
|
|
|
<router-link to="/login" class="action-btn primary">Войти в систему</router-link>
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</div>
|
2025-05-23 16:02:15 +07:00
|
|
|
|
</div>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
</main>
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
import { ref, onMounted, computed, onUnmounted, watch } from 'vue';
|
2025-05-21 22:13:09 +07:00
|
|
|
|
import api from '@/services/api';
|
2025-05-23 18:42:29 +07:00
|
|
|
|
import { useAuth } from '@/auth';
|
2025-05-23 16:02:15 +07:00
|
|
|
|
import { getSocket, connectSocket } from '@/services/socketService';
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const { user, isAuthenticated } = useAuth();
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Состояния
|
2025-05-21 22:13:09 +07:00
|
|
|
|
const conversations = ref([]);
|
|
|
|
|
const loading = ref(true);
|
|
|
|
|
const error = ref('');
|
2025-05-23 18:42:29 +07:00
|
|
|
|
let socket = null;
|
|
|
|
|
|
|
|
|
|
// Сортировка диалогов
|
|
|
|
|
const conversationsSorted = computed(() => {
|
|
|
|
|
return [...conversations.value].sort((a, b) => {
|
|
|
|
|
// Диалоги с непрочитанными сообщениями в начало
|
|
|
|
|
if (a.unreadCount !== b.unreadCount) {
|
|
|
|
|
return b.unreadCount - a.unreadCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Диалоги, где собеседник печатает, в начало
|
|
|
|
|
if (a.typing !== b.typing) {
|
|
|
|
|
return a.typing ? -1 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Сортировка по времени обновления (последнее сообщение)
|
|
|
|
|
return new Date(b.updatedAt) - new Date(a.updatedAt);
|
|
|
|
|
});
|
|
|
|
|
});
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Получение данных
|
2025-05-21 22:13:09 +07:00
|
|
|
|
const fetchConversations = async () => {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
if (!isAuthenticated.value) {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-21 22:13:09 +07:00
|
|
|
|
loading.value = true;
|
|
|
|
|
error.value = '';
|
|
|
|
|
try {
|
2025-05-23 18:47:16 +07:00
|
|
|
|
const response = await api.getUserConversations();
|
2025-05-23 18:42:29 +07:00
|
|
|
|
conversations.value = response.data.map(conv => ({
|
|
|
|
|
...conv,
|
|
|
|
|
typing: false
|
|
|
|
|
}));
|
|
|
|
|
console.log('[ChatListView] Получено диалогов:', conversations.value.length);
|
2025-05-21 22:13:09 +07:00
|
|
|
|
} catch (err) {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
console.error('[ChatListView] Ошибка при загрузке диалогов:', err.response ? err.response.data : err);
|
|
|
|
|
error.value = err.response?.data?.message || 'Не удалось загрузить диалоги';
|
2025-05-21 22:13:09 +07:00
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Вспомогательные методы
|
|
|
|
|
const getOtherParticipant = (conversation) => {
|
|
|
|
|
if (!conversation || !conversation.participants || !user.value) return null;
|
|
|
|
|
return conversation.participants.find(p => p._id !== user.value._id);
|
2025-05-21 22:13:09 +07:00
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const getOtherParticipantName = (conversation) => {
|
|
|
|
|
const participant = getOtherParticipant(conversation);
|
|
|
|
|
return participant ? participant.name : 'Собеседник';
|
2025-05-21 22:13:09 +07:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const formatTimestamp = (timestamp) => {
|
|
|
|
|
if (!timestamp) return '';
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
2025-05-21 22:13:09 +07:00
|
|
|
|
const date = new Date(timestamp);
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const now = new Date();
|
|
|
|
|
const today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
2025-05-21 22:13:09 +07:00
|
|
|
|
const yesterday = new Date(today);
|
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1);
|
2025-05-23 18:42:29 +07:00
|
|
|
|
|
|
|
|
|
if (date >= today) {
|
|
|
|
|
// Сегодня: показываем только время
|
2025-05-21 22:13:09 +07:00
|
|
|
|
return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' });
|
2025-05-23 18:42:29 +07:00
|
|
|
|
} else if (date >= yesterday) {
|
|
|
|
|
// Вчера: показываем "вчера"
|
|
|
|
|
return 'вчера';
|
|
|
|
|
} else if (now.getFullYear() === date.getFullYear()) {
|
|
|
|
|
// В этом году: день и месяц
|
|
|
|
|
return date.toLocaleDateString([], { day: 'numeric', month: 'short' });
|
2025-05-21 22:13:09 +07:00
|
|
|
|
} else {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Другой год: день, месяц, год
|
|
|
|
|
return date.toLocaleDateString([], { day: 'numeric', month: 'short', year: 'numeric' });
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const formatLastMessage = (conversation) => {
|
|
|
|
|
if (!conversation.lastMessage) {
|
|
|
|
|
return 'Нет сообщений';
|
|
|
|
|
}
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
let text = conversation.lastMessage.text || '';
|
|
|
|
|
if (text.length > 30) {
|
|
|
|
|
text = text.substring(0, 30) + '...';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Если последнее сообщение от текущего пользователя, добавляем "Вы: "
|
|
|
|
|
if (conversation.lastMessage.sender === user.value._id) {
|
|
|
|
|
text = 'Вы: ' + text;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
2025-05-23 18:42:29 +07:00
|
|
|
|
|
|
|
|
|
return text;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Обработка событий
|
|
|
|
|
const handleNewMessageEvent = (message) => {
|
|
|
|
|
const conversation = conversations.value.find(c => c._id === message.conversationId);
|
|
|
|
|
if (conversation) {
|
|
|
|
|
// Обновляем диалог с новым сообщением
|
|
|
|
|
conversation.lastMessage = message;
|
|
|
|
|
conversation.updatedAt = new Date().toISOString();
|
|
|
|
|
|
|
|
|
|
// Если сообщение пришло от другого пользователя, увеличиваем счетчик непрочитанных
|
|
|
|
|
if (message.sender !== user.value._id) {
|
|
|
|
|
conversation.unreadCount = (conversation.unreadCount || 0) + 1;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Сбрасываем статус печати
|
|
|
|
|
conversation.typing = false;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const handleMessagesReadEvent = ({ conversationId, readerId }) => {
|
|
|
|
|
// Обрабатываем только если текущий пользователь прочитал сообщения
|
|
|
|
|
if (readerId === user.value._id) {
|
|
|
|
|
const conversation = conversations.value.find(c => c._id === conversationId);
|
|
|
|
|
if (conversation) {
|
|
|
|
|
conversation.unreadCount = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
const handleTypingEvent = ({ conversationId, senderId }) => {
|
|
|
|
|
// Если тот, кто печатает - другой пользователь
|
|
|
|
|
if (senderId !== user.value._id) {
|
|
|
|
|
const conversation = conversations.value.find(c => c._id === conversationId);
|
|
|
|
|
if (conversation) {
|
|
|
|
|
conversation.typing = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleStopTypingEvent = ({ conversationId, senderId }) => {
|
|
|
|
|
if (senderId !== user.value._id) {
|
|
|
|
|
const conversation = conversations.value.find(c => c._id === conversationId);
|
|
|
|
|
if (conversation) {
|
|
|
|
|
conversation.typing = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Жизненный цикл
|
|
|
|
|
onMounted(async () => {
|
|
|
|
|
await fetchConversations();
|
|
|
|
|
|
|
|
|
|
if (isAuthenticated.value) {
|
|
|
|
|
// Подключаем сокет
|
2025-05-21 22:13:09 +07:00
|
|
|
|
socket = getSocket();
|
|
|
|
|
if (!socket) {
|
|
|
|
|
socket = connectSocket();
|
|
|
|
|
}
|
2025-05-23 18:42:29 +07:00
|
|
|
|
|
|
|
|
|
// Подписываемся на события
|
2025-05-21 22:13:09 +07:00
|
|
|
|
if (socket) {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
socket.on('getMessage', handleNewMessageEvent);
|
|
|
|
|
socket.on('messagesRead', handleMessagesReadEvent);
|
|
|
|
|
socket.on('userTyping', handleTypingEvent);
|
|
|
|
|
socket.on('userStopTyping', handleStopTypingEvent);
|
2025-05-21 22:13:09 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
// Присоединение к комнате для уведомлений
|
|
|
|
|
if (user.value?._id) {
|
|
|
|
|
socket.emit('joinNotificationRoom', user.value._id);
|
|
|
|
|
}
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onUnmounted(() => {
|
|
|
|
|
if (socket) {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
socket.off('getMessage', handleNewMessageEvent);
|
|
|
|
|
socket.off('messagesRead', handleMessagesReadEvent);
|
|
|
|
|
socket.off('userTyping', handleTypingEvent);
|
|
|
|
|
socket.off('userStopTyping', handleStopTypingEvent);
|
|
|
|
|
|
|
|
|
|
if (user.value?._id) {
|
|
|
|
|
socket.emit('leaveNotificationRoom', user.value._id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Следить за статусом аутентификации
|
|
|
|
|
watch(() => isAuthenticated.value, (newVal) => {
|
|
|
|
|
if (newVal) {
|
|
|
|
|
fetchConversations();
|
|
|
|
|
} else {
|
|
|
|
|
conversations.value = [];
|
|
|
|
|
loading.value = false;
|
|
|
|
|
// Можно перенаправить на логин здесь или положиться на router guard
|
|
|
|
|
// router.push('/login');
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
});
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
|
|
|
|
// Функция для определения правильного склонения слова "диалог"
|
|
|
|
|
const getDialogsCountText = (count) => {
|
|
|
|
|
const remainder10 = count % 10;
|
|
|
|
|
const remainder100 = count % 100;
|
|
|
|
|
|
|
|
|
|
if (remainder10 === 1 && remainder100 !== 11) {
|
|
|
|
|
return 'диалог';
|
|
|
|
|
} else if ([2, 3, 4].includes(remainder10) && ![12, 13, 14].includes(remainder100)) {
|
|
|
|
|
return 'диалога';
|
|
|
|
|
} else {
|
|
|
|
|
return 'диалогов';
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Основные стили */
|
|
|
|
|
.app-chatlist-view {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100vh;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
width: 100%;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
position: relative;
|
|
|
|
|
background-color: #f8f9fa;
|
|
|
|
|
background-image: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Хедер */
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.chatlist-header {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
background: rgba(33, 33, 60, 0.9);
|
2025-05-23 16:02:15 +07:00
|
|
|
|
backdrop-filter: blur(10px);
|
2025-05-23 18:42:29 +07:00
|
|
|
|
padding: 0.8rem 0;
|
|
|
|
|
text-align: center;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
color: white;
|
|
|
|
|
position: sticky;
|
|
|
|
|
top: 0;
|
|
|
|
|
z-index: 10;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
height: var(--header-height, 56px);
|
2025-05-23 16:02:15 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
justify-content: center;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
2025-05-23 16:02:15 +07:00
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.section-title {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
margin: 0;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
font-size: 1.3rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Основная область контента */
|
|
|
|
|
.chatlist-content {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
position: relative;
|
|
|
|
|
overflow-x: hidden;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Состояния загрузки */
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.loading-section {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
flex: 1;
|
|
|
|
|
padding: 1rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
color: white;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.loading-spinner {
|
|
|
|
|
text-align: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.spinner {
|
2025-05-21 22:13:09 +07:00
|
|
|
|
width: 50px;
|
|
|
|
|
height: 50px;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
border: 4px solid rgba(255, 255, 255, 0.3);
|
|
|
|
|
border-left: 4px solid white;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
animation: spin 1s linear infinite;
|
|
|
|
|
margin: 0 auto 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes spin {
|
|
|
|
|
0% { transform: rotate(0deg); }
|
|
|
|
|
100% { transform: rotate(360deg); }
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Контейнер диалогов */
|
|
|
|
|
.conversations-container {
|
|
|
|
|
flex: 1;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
display: flex;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
flex-direction: column;
|
|
|
|
|
padding: 0.5rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Пустое состояние */
|
|
|
|
|
.empty-chats {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
flex: 1;
|
|
|
|
|
padding: 1rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.empty-chats-content {
|
|
|
|
|
background: white;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
border-radius: 20px;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
padding: 2rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
text-align: center;
|
|
|
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
2025-05-23 18:42:29 +07:00
|
|
|
|
max-width: 400px;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.empty-chats-content i {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
font-size: 3rem;
|
|
|
|
|
margin-bottom: 1rem;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
color: #6c757d;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.empty-chats-content h3 {
|
|
|
|
|
color: #343a40;
|
|
|
|
|
margin-bottom: 0.5rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.empty-chats-content p {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
margin-bottom: 1.5rem;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
color: #6c757d;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.action-btn.primary {
|
|
|
|
|
background: linear-gradient(45deg, #667eea, #764ba2);
|
|
|
|
|
color: white;
|
|
|
|
|
border: none;
|
|
|
|
|
padding: 0.75rem 1.5rem;
|
|
|
|
|
border-radius: 50px;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Список диалогов */
|
|
|
|
|
.conversations-list {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
gap: 0.5rem;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
padding-bottom: 0.5rem;
|
|
|
|
|
-webkit-overflow-scrolling: touch;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Карточка диалога */
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.conversation-card {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
padding: 0.8rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
background: white;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
border-radius: 12px;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
text-decoration: none;
|
|
|
|
|
color: inherit;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.conversation-card:active {
|
|
|
|
|
transform: scale(0.98);
|
|
|
|
|
background-color: #f8f9fa;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Аватар */
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.user-photo-container {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
width: 50px;
|
|
|
|
|
height: 50px;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
overflow: hidden;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
position: relative;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-photo {
|
2025-05-21 22:13:09 +07:00
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
object-fit: cover;
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.user-photo-placeholder {
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2025-05-23 18:42:29 +07:00
|
|
|
|
background: #e9ecef;
|
|
|
|
|
color: #6c757d;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-photo-placeholder i {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
font-size: 1.5rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-24 23:52:52 +07:00
|
|
|
|
/* Правая часть диалога с счетчиком и стрелкой */
|
|
|
|
|
.conversation-right {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.5rem;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Индикатор непрочитанных сообщений - теперь в правой части */
|
|
|
|
|
.conversation-right .unread-badge {
|
|
|
|
|
position: static;
|
2025-05-24 23:46:45 +07:00
|
|
|
|
background: linear-gradient(135deg, #ff6b6b, #ff5252);
|
2025-05-23 16:02:15 +07:00
|
|
|
|
color: white;
|
2025-05-24 23:46:45 +07:00
|
|
|
|
font-size: 0.65rem;
|
|
|
|
|
font-weight: 700;
|
2025-05-24 23:52:52 +07:00
|
|
|
|
border-radius: 12px;
|
|
|
|
|
min-width: 22px;
|
|
|
|
|
height: 22px;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
2025-05-24 23:52:52 +07:00
|
|
|
|
padding: 0 8px;
|
2025-05-24 23:46:45 +07:00
|
|
|
|
box-shadow: 0 3px 8px rgba(255, 107, 107, 0.4);
|
|
|
|
|
border: 2px solid white;
|
|
|
|
|
animation: subtle-pulse 2s ease-in-out infinite;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Стрелка для перехода в диалог */
|
|
|
|
|
.conversation-arrow {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
color: #adb5bd;
|
|
|
|
|
transition: transform 0.2s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.conversation-card:active .conversation-arrow {
|
|
|
|
|
transform: translateX(2px);
|
|
|
|
|
color: #667eea;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Неавторизованное состояние */
|
|
|
|
|
.not-authenticated-section {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.not-auth-card {
|
|
|
|
|
background: white;
|
|
|
|
|
border-radius: 20px;
|
|
|
|
|
padding: 2rem;
|
|
|
|
|
text-align: center;
|
|
|
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
|
|
|
|
|
max-width: 400px;
|
|
|
|
|
width: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.not-auth-card i {
|
|
|
|
|
font-size: 3rem;
|
|
|
|
|
margin-bottom: 1rem;
|
|
|
|
|
color: #6c757d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.not-auth-card h3 {
|
|
|
|
|
color: #343a40;
|
|
|
|
|
margin-bottom: 0.5rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.not-auth-card p {
|
|
|
|
|
margin-bottom: 1.5rem;
|
|
|
|
|
color: #6c757d;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-24 23:52:52 +07:00
|
|
|
|
/* Мягкая анимация пульсации для непрочитанных сообщений */
|
|
|
|
|
@keyframes subtle-pulse {
|
|
|
|
|
0%, 100% {
|
|
|
|
|
transform: scale(1);
|
|
|
|
|
box-shadow: 0 3px 8px rgba(255, 107, 107, 0.4);
|
|
|
|
|
}
|
|
|
|
|
50% {
|
|
|
|
|
transform: scale(1.05);
|
|
|
|
|
box-shadow: 0 4px 12px rgba(255, 107, 107, 0.6);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Информация о диалоге */
|
|
|
|
|
.conversation-info {
|
|
|
|
|
flex: 1;
|
|
|
|
|
min-width: 0; /* Для корректной работы text-overflow */
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Адаптивные стили */
|
|
|
|
|
@media (max-width: 576px) {
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.conversation-card {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
padding: 0.7rem;
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-photo-container {
|
2025-05-23 17:13:32 +07:00
|
|
|
|
width: 45px;
|
|
|
|
|
height: 45px;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 16:02:15 +07:00
|
|
|
|
.user-name {
|
2025-05-23 17:13:32 +07:00
|
|
|
|
font-size: 0.95rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.last-message {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
font-size: 0.8rem;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@media (max-width: 375px) {
|
|
|
|
|
.conversation-card {
|
|
|
|
|
padding: 0.6rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-photo-container {
|
|
|
|
|
width: 40px;
|
|
|
|
|
height: 40px;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.user-photo-placeholder i {
|
|
|
|
|
font-size: 1.3rem;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Ландшафтная ориентация */
|
|
|
|
|
@media (max-height: 450px) and (orientation: landscape) {
|
|
|
|
|
.chatlist-header {
|
|
|
|
|
height: 46px;
|
|
|
|
|
padding: 0.5rem 0;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.section-title {
|
|
|
|
|
font-size: 1.1rem;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.conversations-container {
|
|
|
|
|
padding: 0.3rem;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
.conversation-card {
|
|
|
|
|
padding: 0.5rem 0.7rem;
|
2025-05-23 17:13:32 +07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-23 18:42:29 +07:00
|
|
|
|
/* Учитываем Safe Area для iPhone X+ */
|
|
|
|
|
@supports (padding-bottom: env(safe-area-inset-bottom)) {
|
2025-05-23 17:13:32 +07:00
|
|
|
|
.conversations-list {
|
2025-05-23 18:42:29 +07:00
|
|
|
|
padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
|
2025-05-23 16:02:15 +07:00
|
|
|
|
}
|
2025-05-21 22:13:09 +07:00
|
|
|
|
}
|
2025-05-24 23:52:52 +07:00
|
|
|
|
|
|
|
|
|
/* Стили для элементов диалога, которые были в старой структуре */
|
|
|
|
|
.conversation-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: baseline;
|
|
|
|
|
margin-bottom: 0.25rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-name {
|
|
|
|
|
margin: 0;
|
|
|
|
|
font-size: 1rem;
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
color: #212529;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.timestamp {
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
color: #6c757d;
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.last-message {
|
|
|
|
|
margin: 0;
|
|
|
|
|
font-size: 0.85rem;
|
|
|
|
|
color: #6c757d;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.typing-text {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.4rem;
|
|
|
|
|
font-style: italic;
|
|
|
|
|
color: #667eea;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.typing-animation {
|
|
|
|
|
display: flex;
|
|
|
|
|
gap: 3px;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dot {
|
|
|
|
|
width: 3px;
|
|
|
|
|
height: 3px;
|
|
|
|
|
background-color: #667eea;
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
display: inline-block;
|
|
|
|
|
animation: bouncingDots 1.4s infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dot:nth-child(2) {
|
|
|
|
|
animation-delay: 0.2s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.dot:nth-child(3) {
|
|
|
|
|
animation-delay: 0.4s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes bouncingDots {
|
|
|
|
|
0%, 100% { transform: translateY(0); }
|
|
|
|
|
50% { transform: translateY(-3px); }
|
|
|
|
|
}
|
2025-05-21 22:13:09 +07:00
|
|
|
|
</style>
|