2025-05-25 23:11:02 +07:00
|
|
|
|
<template>
|
|
|
|
|
<div class="admin-dashboard">
|
|
|
|
|
<div class="admin-header">
|
2025-05-26 00:11:44 +07:00
|
|
|
|
<div class="admin-header-left">
|
|
|
|
|
<button v-if="isMobile" @click="toggleSidebar" class="menu-toggle-btn">
|
|
|
|
|
<i class="bi-list"></i>
|
|
|
|
|
</button>
|
|
|
|
|
<h1>Административная панель</h1>
|
|
|
|
|
</div>
|
2025-05-25 23:11:02 +07:00
|
|
|
|
<div class="admin-user-info">
|
2025-05-26 00:11:44 +07:00
|
|
|
|
<span class="user-name">{{ user?.name || 'Администратор' }}</span>
|
|
|
|
|
<button @click="logout" class="logout-btn">
|
|
|
|
|
<span class="logout-text">Выйти</span>
|
|
|
|
|
<i class="bi-box-arrow-right"></i>
|
|
|
|
|
</button>
|
2025-05-25 23:11:02 +07:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="admin-content">
|
2025-05-26 00:11:44 +07:00
|
|
|
|
<!-- Десктопная боковая панель -->
|
|
|
|
|
<div v-if="!isMobile" class="admin-sidebar">
|
2025-05-25 23:11:02 +07:00
|
|
|
|
<nav>
|
2025-05-26 00:11:44 +07:00
|
|
|
|
<router-link :to="{ name: 'AdminUsers' }" active-class="active">
|
|
|
|
|
<i class="bi-people"></i> Пользователи
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminConversations' }" active-class="active">
|
|
|
|
|
<i class="bi-chat-dots"></i> Диалоги
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminStatistics' }" active-class="active">
|
|
|
|
|
<i class="bi-graph-up"></i> Статистика
|
|
|
|
|
</router-link>
|
2025-05-25 23:11:02 +07:00
|
|
|
|
</nav>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-26 00:11:44 +07:00
|
|
|
|
<!-- Мобильное боковое меню -->
|
|
|
|
|
<div v-if="isMobile" class="admin-sidebar-mobile" :class="{ 'sidebar-open': sidebarOpen }">
|
|
|
|
|
<div class="sidebar-overlay" @click="toggleSidebar"></div>
|
|
|
|
|
<div class="sidebar-content">
|
|
|
|
|
<div class="sidebar-header">
|
|
|
|
|
<span>Меню</span>
|
|
|
|
|
<button @click="toggleSidebar" class="close-sidebar-btn">
|
|
|
|
|
<i class="bi-x-lg"></i>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
<nav>
|
|
|
|
|
<router-link :to="{ name: 'AdminUsers' }" active-class="active" @click="sidebarOpen = false">
|
|
|
|
|
<i class="bi-people"></i> Пользователи
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminConversations' }" active-class="active" @click="sidebarOpen = false">
|
|
|
|
|
<i class="bi-chat-dots"></i> Диалоги
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminStatistics' }" active-class="active" @click="sidebarOpen = false">
|
|
|
|
|
<i class="bi-graph-up"></i> Статистика
|
|
|
|
|
</router-link>
|
|
|
|
|
<div class="mobile-logout-container">
|
|
|
|
|
<button @click="logout" class="mobile-logout-btn">
|
|
|
|
|
<i class="bi-box-arrow-right"></i> Выйти
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-25 23:11:02 +07:00
|
|
|
|
<div class="admin-main-content">
|
|
|
|
|
<router-view></router-view>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-05-26 00:11:44 +07:00
|
|
|
|
|
|
|
|
|
<!-- Мобильная нижняя навигация -->
|
|
|
|
|
<nav v-if="isMobile" class="admin-mobile-nav">
|
|
|
|
|
<router-link :to="{ name: 'AdminUsers' }" class="nav-item" active-class="active">
|
|
|
|
|
<div class="nav-icon">
|
|
|
|
|
<i class="bi-people"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="nav-text">Пользователи</span>
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminConversations' }" class="nav-item" active-class="active">
|
|
|
|
|
<div class="nav-icon">
|
|
|
|
|
<i class="bi-chat-dots"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="nav-text">Диалоги</span>
|
|
|
|
|
</router-link>
|
|
|
|
|
<router-link :to="{ name: 'AdminStatistics' }" class="nav-item" active-class="active">
|
|
|
|
|
<div class="nav-icon">
|
|
|
|
|
<i class="bi-graph-up"></i>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="nav-text">Статистика</span>
|
|
|
|
|
</router-link>
|
|
|
|
|
</nav>
|
2025-05-25 23:11:02 +07:00
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { useAuth } from '../../auth';
|
|
|
|
|
import { useRouter } from 'vue-router';
|
2025-05-26 00:11:44 +07:00
|
|
|
|
import { computed, ref, onMounted, onBeforeUnmount, watch } from 'vue';
|
2025-05-25 23:11:02 +07:00
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'AdminDashboard',
|
|
|
|
|
setup() {
|
|
|
|
|
const { user, logout: authLogout } = useAuth();
|
|
|
|
|
const router = useRouter();
|
2025-05-26 00:11:44 +07:00
|
|
|
|
const isMobile = ref(window.innerWidth < 768);
|
|
|
|
|
const sidebarOpen = ref(false);
|
|
|
|
|
|
|
|
|
|
const handleResize = () => {
|
|
|
|
|
isMobile.value = window.innerWidth < 768;
|
|
|
|
|
if (!isMobile.value) {
|
|
|
|
|
sidebarOpen.value = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const toggleSidebar = () => {
|
|
|
|
|
sidebarOpen.value = !sidebarOpen.value;
|
|
|
|
|
};
|
2025-05-25 23:11:02 +07:00
|
|
|
|
|
|
|
|
|
const logout = async () => {
|
|
|
|
|
try {
|
|
|
|
|
await authLogout();
|
|
|
|
|
router.push({ name: 'Login' });
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('Ошибка при выходе:', error);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-26 00:11:44 +07:00
|
|
|
|
onMounted(() => {
|
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
|
|
|
|
window.removeEventListener('resize', handleResize);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Закрываем боковое меню при изменении маршрута
|
|
|
|
|
watch(() => router.currentRoute.value.path, () => {
|
|
|
|
|
if (sidebarOpen.value) {
|
|
|
|
|
sidebarOpen.value = false;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-25 23:11:02 +07:00
|
|
|
|
return {
|
|
|
|
|
user: computed(() => user.value),
|
2025-05-26 00:11:44 +07:00
|
|
|
|
logout,
|
|
|
|
|
isMobile,
|
|
|
|
|
sidebarOpen,
|
|
|
|
|
toggleSidebar
|
2025-05-25 23:11:02 +07:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
.admin-dashboard {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
height: 100vh;
|
|
|
|
|
background-color: #f5f5f5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
padding: 0.5rem 1rem;
|
|
|
|
|
background-color: #ff3e68;
|
|
|
|
|
color: white;
|
|
|
|
|
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
2025-05-26 00:11:44 +07:00
|
|
|
|
z-index: 100;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-header-left {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.75rem;
|
2025-05-25 23:11:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-header h1 {
|
|
|
|
|
font-size: 1.5rem;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 00:11:44 +07:00
|
|
|
|
.menu-toggle-btn {
|
|
|
|
|
background: none;
|
|
|
|
|
border: none;
|
|
|
|
|
color: white;
|
|
|
|
|
font-size: 1.5rem;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
padding: 0.25rem;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-25 23:11:02 +07:00
|
|
|
|
.admin-user-info {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logout-btn {
|
|
|
|
|
padding: 0.4rem 1rem;
|
|
|
|
|
background-color: white;
|
|
|
|
|
color: #ff3e68;
|
|
|
|
|
border: none;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-weight: 500;
|
2025-05-26 00:11:44 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.5rem;
|
2025-05-25 23:11:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-content {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex: 1;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 00:11:44 +07:00
|
|
|
|
/* Стили для десктопной боковой панели */
|
2025-05-25 23:11:02 +07:00
|
|
|
|
.admin-sidebar {
|
|
|
|
|
width: 200px;
|
|
|
|
|
background-color: white;
|
|
|
|
|
box-shadow: 1px 0 3px rgba(0,0,0,0.1);
|
|
|
|
|
overflow-y: auto;
|
2025-05-26 00:11:44 +07:00
|
|
|
|
flex-shrink: 0;
|
2025-05-25 23:11:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar nav {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
padding: 1rem 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar a {
|
|
|
|
|
padding: 0.75rem 1.5rem;
|
|
|
|
|
color: #333;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
transition: background-color 0.3s;
|
2025-05-26 00:11:44 +07:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.75rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar a i {
|
|
|
|
|
font-size: 1.2rem;
|
2025-05-25 23:11:02 +07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar a:hover {
|
|
|
|
|
background-color: #f0f0f0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar a.active {
|
|
|
|
|
background-color: #ff3e68;
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-26 00:11:44 +07:00
|
|
|
|
/* Стили для мобильной боковой панели */
|
|
|
|
|
.admin-sidebar-mobile {
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar-mobile.sidebar-open {
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar-overlay {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-color: rgba(0,0,0,0.5);
|
|
|
|
|
z-index: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar-content {
|
|
|
|
|
position: absolute;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 80%;
|
|
|
|
|
max-width: 300px;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background-color: white;
|
|
|
|
|
z-index: 2;
|
|
|
|
|
box-shadow: 2px 0 10px rgba(0,0,0,0.2);
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
animation: slideIn 0.25s ease-out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes slideIn {
|
|
|
|
|
from {
|
|
|
|
|
transform: translateX(-100%);
|
|
|
|
|
}
|
|
|
|
|
to {
|
|
|
|
|
transform: translateX(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.sidebar-header {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
background-color: #ff3e68;
|
|
|
|
|
color: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.close-sidebar-btn {
|
|
|
|
|
background: none;
|
|
|
|
|
border: none;
|
|
|
|
|
color: white;
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar-mobile nav {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
flex: 1;
|
|
|
|
|
padding: 1rem 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar-mobile a {
|
|
|
|
|
padding: 1rem 1.5rem;
|
|
|
|
|
color: #333;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.75rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar-mobile a i {
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-sidebar-mobile a.active {
|
|
|
|
|
background-color: rgba(255, 62, 104, 0.1);
|
|
|
|
|
color: #ff3e68;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mobile-logout-container {
|
|
|
|
|
margin-top: auto;
|
|
|
|
|
padding: 1rem 1.5rem;
|
|
|
|
|
border-top: 1px solid #eee;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mobile-logout-btn {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.75rem;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 0.75rem;
|
|
|
|
|
background-color: #f8f9fa;
|
|
|
|
|
color: #dc3545;
|
|
|
|
|
border: 1px solid #dee2e6;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
text-align: left;
|
|
|
|
|
}
|
|
|
|
|
|
2025-05-25 23:11:02 +07:00
|
|
|
|
.admin-main-content {
|
|
|
|
|
flex: 1;
|
|
|
|
|
padding: 1.5rem;
|
|
|
|
|
overflow-y: auto;
|
2025-05-26 00:11:44 +07:00
|
|
|
|
height: calc(100vh - var(--header-height) - var(--nav-height, 0px));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Мобильная навигация */
|
|
|
|
|
.admin-mobile-nav {
|
|
|
|
|
display: none;
|
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
right: 0;
|
|
|
|
|
height: var(--nav-height, 60px);
|
|
|
|
|
background: white;
|
|
|
|
|
box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
|
|
|
|
|
z-index: 1000;
|
|
|
|
|
padding-bottom: env(safe-area-inset-bottom, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* На мобильных устройствах */
|
|
|
|
|
@media (max-width: 767px) {
|
|
|
|
|
.admin-header h1 {
|
|
|
|
|
font-size: 1.25rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.user-name {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logout-text {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logout-btn {
|
|
|
|
|
padding: 0.4rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.logout-btn i {
|
|
|
|
|
font-size: 1.2rem;
|
|
|
|
|
margin: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-main-content {
|
|
|
|
|
padding: 1rem;
|
|
|
|
|
height: calc(100vh - 56px - 56px - env(safe-area-inset-bottom, 0px)); /* header + nav + safe area */
|
|
|
|
|
padding-bottom: 1rem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav {
|
|
|
|
|
display: flex;
|
|
|
|
|
--nav-height: 56px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* CSS для мобильной навигации в админ-панели */
|
|
|
|
|
.admin-mobile-nav .nav-item {
|
|
|
|
|
flex: 1;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
text-decoration: none;
|
|
|
|
|
color: #6c757d;
|
|
|
|
|
transition: all 0.2s ease;
|
|
|
|
|
padding: 0;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-icon {
|
|
|
|
|
position: relative;
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
margin-bottom: 3px;
|
|
|
|
|
height: 28px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-text {
|
|
|
|
|
font-size: 0.7rem;
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
transform: translateY(-10px);
|
|
|
|
|
display: block;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-item.active {
|
|
|
|
|
color: #ff3e68;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-item.active .nav-icon i {
|
|
|
|
|
color: #ff3e68;
|
|
|
|
|
transform: translateY(-2px);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:root {
|
|
|
|
|
--header-height: 56px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Поддержка устройств с вырезом (iPhone X и новее) */
|
|
|
|
|
@supports (padding: env(safe-area-inset-bottom)) {
|
|
|
|
|
.admin-mobile-nav {
|
|
|
|
|
height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
|
|
|
|
|
padding-bottom: env(safe-area-inset-bottom, 0px);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Ландшафтная ориентация на мобильных */
|
|
|
|
|
@media (max-height: 450px) and (orientation: landscape) {
|
|
|
|
|
.admin-mobile-nav {
|
|
|
|
|
--nav-height: 50px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-item {
|
|
|
|
|
flex-direction: row;
|
|
|
|
|
gap: 5px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-mobile-nav .nav-icon {
|
|
|
|
|
margin-bottom: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.admin-main-content {
|
|
|
|
|
height: calc(100vh - 56px - 50px);
|
|
|
|
|
}
|
2025-05-25 23:11:02 +07:00
|
|
|
|
}
|
|
|
|
|
</style>
|