ваше сообщение коммита
This commit is contained in:
@@ -11,84 +11,748 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<BaseLayout>
|
||||
<div class="content-list-block">
|
||||
<div class="content-header-nav">
|
||||
<button class="nav-btn" @click="goToCreate">Создать</button>
|
||||
<button class="nav-btn" @click="goToList">Список страниц</button>
|
||||
<button class="nav-btn" @click="goToSettings">Настройки</button>
|
||||
<BaseLayout
|
||||
:is-authenticated="isAuthenticated"
|
||||
:identities="identities"
|
||||
:token-balances="tokenBalances"
|
||||
:is-loading-tokens="isLoadingTokens"
|
||||
@auth-action-completed="$emit('auth-action-completed')"
|
||||
>
|
||||
<div class="content-management-page">
|
||||
<!-- Заголовок страницы -->
|
||||
<div class="page-header">
|
||||
<div class="header-content">
|
||||
<h1>📄 Управление контентом</h1>
|
||||
<p>Создавайте и управляйте страницами вашего DLE</p>
|
||||
<button class="btn btn-primary" @click="goToCreate">
|
||||
<i class="fas fa-plus"></i>
|
||||
Создать страницу
|
||||
</button>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<button class="close-btn" @click="goBack">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Основной контент с тенью -->
|
||||
<div class="content-block">
|
||||
<!-- Навигация -->
|
||||
<div class="content-navigation">
|
||||
<div class="nav-tabs">
|
||||
<button
|
||||
class="nav-tab"
|
||||
:class="{ active: activeTab === 'pages' }"
|
||||
@click="activeTab = 'pages'"
|
||||
>
|
||||
<i class="fas fa-file-alt"></i>
|
||||
Страницы
|
||||
</button>
|
||||
<button
|
||||
class="nav-tab"
|
||||
:class="{ active: activeTab === 'templates' }"
|
||||
@click="activeTab = 'templates'"
|
||||
>
|
||||
<i class="fas fa-layer-group"></i>
|
||||
Шаблоны
|
||||
</button>
|
||||
<button
|
||||
class="nav-tab"
|
||||
:class="{ active: activeTab === 'settings' }"
|
||||
@click="activeTab = 'settings'"
|
||||
>
|
||||
<i class="fas fa-cog"></i>
|
||||
Настройки
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент в зависимости от активной вкладки -->
|
||||
<div class="content-section">
|
||||
<!-- Вкладка Страницы -->
|
||||
<div v-if="activeTab === 'pages'" class="pages-section">
|
||||
<div class="section-header">
|
||||
<h2>Созданные страницы</h2>
|
||||
<div class="search-box">
|
||||
<input
|
||||
v-model="searchQuery"
|
||||
type="text"
|
||||
placeholder="Поиск страниц..."
|
||||
class="search-input"
|
||||
>
|
||||
<i class="fas fa-search search-icon"></i>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Список страниц -->
|
||||
<div v-if="filteredPages.length" class="pages-grid">
|
||||
<div
|
||||
v-for="page in filteredPages"
|
||||
:key="page.id"
|
||||
class="page-card"
|
||||
@click="goToPage(page.id)"
|
||||
>
|
||||
<div class="page-card-header">
|
||||
<h3>{{ page.title }}</h3>
|
||||
<div class="page-actions">
|
||||
<button
|
||||
class="action-btn edit-btn"
|
||||
@click.stop="goToEdit(page.id)"
|
||||
title="Редактировать"
|
||||
>
|
||||
<i class="fas fa-edit"></i>
|
||||
</button>
|
||||
<button
|
||||
class="action-btn delete-btn"
|
||||
@click.stop="deletePage(page.id)"
|
||||
title="Удалить"
|
||||
>
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-card-content">
|
||||
<p class="page-summary">{{ page.summary || 'Без описания' }}</p>
|
||||
<div class="page-meta">
|
||||
<span class="page-date">
|
||||
<i class="fas fa-calendar"></i>
|
||||
{{ formatDate(page.createdAt) }}
|
||||
</span>
|
||||
<span class="page-status" :class="page.status">
|
||||
<i class="fas fa-circle"></i>
|
||||
{{ getStatusText(page.status) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Пустое состояние -->
|
||||
<div v-else-if="!isLoading" class="empty-state">
|
||||
<div class="empty-icon">
|
||||
<i class="fas fa-file-alt"></i>
|
||||
</div>
|
||||
<h3>Нет созданных страниц</h3>
|
||||
<p>Создайте первую страницу для вашего DLE</p>
|
||||
<button class="btn btn-primary" @click="goToCreate">
|
||||
<i class="fas fa-plus"></i>
|
||||
Создать страницу
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Загрузка -->
|
||||
<div v-else class="loading-state">
|
||||
<div class="loading-spinner"></div>
|
||||
<p>Загрузка страниц...</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Вкладка Шаблоны -->
|
||||
<div v-if="activeTab === 'templates'" class="templates-section">
|
||||
<div class="section-header">
|
||||
<h2>Шаблоны страниц</h2>
|
||||
<p>Готовые шаблоны для быстрого создания контента</p>
|
||||
</div>
|
||||
|
||||
<div class="templates-grid">
|
||||
<div
|
||||
v-for="template in templates"
|
||||
:key="template.id"
|
||||
class="template-card"
|
||||
@click="useTemplate(template)"
|
||||
>
|
||||
<div class="template-icon">
|
||||
<i :class="template.icon"></i>
|
||||
</div>
|
||||
<h3>{{ template.name }}</h3>
|
||||
<p>{{ template.description }}</p>
|
||||
<button class="btn btn-outline">Использовать шаблон</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Вкладка Настройки -->
|
||||
<div v-if="activeTab === 'settings'" class="settings-section">
|
||||
<div class="section-header">
|
||||
<h2>Настройки контента</h2>
|
||||
</div>
|
||||
|
||||
<div class="settings-grid">
|
||||
<div class="setting-card">
|
||||
<h3>SEO настройки</h3>
|
||||
<div class="setting-item">
|
||||
<label>Мета-теги по умолчанию</label>
|
||||
<textarea v-model="seoSettings.defaultMeta" placeholder="Введите мета-теги..."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="setting-card">
|
||||
<h3>Настройки публикации</h3>
|
||||
<div class="setting-item">
|
||||
<label>
|
||||
<input type="checkbox" v-model="publishSettings.autoPublish">
|
||||
Автоматическая публикация
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Список страниц</h2>
|
||||
<ul v-if="pages.length" class="pages-list">
|
||||
<li v-for="page in pages" :key="page.id">
|
||||
<router-link :to="{ name: 'page-view', params: { id: page.id } }">{{ page.title }}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else class="empty-list-placeholder">Нет созданных страниц.</div>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import BaseLayout from '../../components/BaseLayout.vue';
|
||||
import pagesService from '../../services/pagesService';
|
||||
const router = useRouter();
|
||||
function goToCreate() { router.push({ name: 'content-create' }); }
|
||||
function goToList() { router.push({ name: 'content-list' }); }
|
||||
function goToSettings() { router.push({ name: 'content-settings' }); }
|
||||
|
||||
// Props
|
||||
const props = defineProps({
|
||||
isAuthenticated: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
identities: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
tokenBalances: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
isLoadingTokens: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits(['auth-action-completed']);
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
// Состояние
|
||||
const activeTab = ref('pages');
|
||||
const pages = ref([]);
|
||||
onMounted(async () => {
|
||||
pages.value = await pagesService.getPages();
|
||||
const isLoading = ref(false);
|
||||
const searchQuery = ref('');
|
||||
|
||||
// Настройки
|
||||
const seoSettings = ref({
|
||||
defaultMeta: ''
|
||||
});
|
||||
|
||||
const publishSettings = ref({
|
||||
autoPublish: false
|
||||
});
|
||||
|
||||
// Шаблоны
|
||||
const templates = ref([
|
||||
{
|
||||
id: 1,
|
||||
name: 'О компании',
|
||||
description: 'Стандартная страница с информацией о компании',
|
||||
icon: 'fas fa-building'
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'Услуги',
|
||||
description: 'Страница с описанием услуг и сервисов',
|
||||
icon: 'fas fa-cogs'
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'Контакты',
|
||||
description: 'Контактная информация и форма обратной связи',
|
||||
icon: 'fas fa-address-book'
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'Блог',
|
||||
description: 'Шаблон для ведения блога и новостей',
|
||||
icon: 'fas fa-blog'
|
||||
}
|
||||
]);
|
||||
|
||||
// Вычисляемые свойства
|
||||
const filteredPages = computed(() => {
|
||||
if (!searchQuery.value) return pages.value;
|
||||
return pages.value.filter(page =>
|
||||
page.title.toLowerCase().includes(searchQuery.value.toLowerCase()) ||
|
||||
page.summary?.toLowerCase().includes(searchQuery.value.toLowerCase())
|
||||
);
|
||||
});
|
||||
|
||||
// Методы
|
||||
function goToCreate() {
|
||||
router.push({ name: 'content-create' });
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
router.go(-1);
|
||||
}
|
||||
|
||||
function goToPage(id) {
|
||||
router.push({ name: 'page-view', params: { id } });
|
||||
}
|
||||
|
||||
function goToEdit(id) {
|
||||
router.push({ name: 'page-edit', params: { id } });
|
||||
}
|
||||
|
||||
async function deletePage(id) {
|
||||
if (confirm('Вы уверены, что хотите удалить эту страницу?')) {
|
||||
try {
|
||||
await pagesService.deletePage(id);
|
||||
await loadPages();
|
||||
} catch (error) {
|
||||
console.error('Ошибка удаления страницы:', error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function useTemplate(template) {
|
||||
router.push({
|
||||
name: 'content-create',
|
||||
query: { template: template.id }
|
||||
});
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
if (!date) return 'Не указана';
|
||||
return new Date(date).toLocaleDateString('ru-RU');
|
||||
}
|
||||
|
||||
function getStatusText(status) {
|
||||
const statusMap = {
|
||||
draft: 'Черновик',
|
||||
published: 'Опубликовано',
|
||||
archived: 'Архив'
|
||||
};
|
||||
return statusMap[status] || 'Неизвестно';
|
||||
}
|
||||
|
||||
async function loadPages() {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
pages.value = await pagesService.getPages();
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки страниц:', error);
|
||||
pages.value = [];
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка данных
|
||||
onMounted(() => {
|
||||
loadPages();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.content-list-block {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 32px rgba(0,0,0,0.12);
|
||||
padding: 32px 24px 24px 24px;
|
||||
.content-management-page {
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.content-header-nav {
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #f0f0f0;
|
||||
}
|
||||
.nav-btn {
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 6px;
|
||||
padding: 7px 18px;
|
||||
font-size: 1em;
|
||||
|
||||
.header-content h1 {
|
||||
color: var(--color-primary);
|
||||
font-size: 2.5rem;
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.header-content p {
|
||||
color: var(--color-grey-dark);
|
||||
font-size: 1.1rem;
|
||||
margin: 0 0 20px 0;
|
||||
}
|
||||
|
||||
.header-content .btn {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.content-navigation {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.nav-tab {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 15px 20px;
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
border-bottom: 3px solid transparent;
|
||||
transition: all 0.3s ease;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.nav-tab:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.nav-tab.active {
|
||||
color: var(--color-primary);
|
||||
border-bottom-color: var(--color-primary);
|
||||
}
|
||||
|
||||
.nav-tab i {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.content-block {
|
||||
background: #f8f9fa;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 25px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.content-section {
|
||||
background: #f8f9fa;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 25px;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 25px;
|
||||
}
|
||||
|
||||
.section-header h2 {
|
||||
color: var(--color-primary);
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
position: relative;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 100%;
|
||||
padding: 10px 40px 10px 15px;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
position: absolute;
|
||||
right: 15px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.pages-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.page-card {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 20px;
|
||||
border: 1px solid #e9ecef;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.page-card:hover {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.page-card-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.page-card-header h3 {
|
||||
color: var(--color-primary);
|
||||
margin: 0;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
|
||||
.page-actions {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
padding: 5px;
|
||||
cursor: pointer;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.nav-btn:hover {
|
||||
background: #e0e0e0;
|
||||
|
||||
.edit-btn:hover {
|
||||
background: #e3f2fd;
|
||||
color: #2196f3;
|
||||
}
|
||||
.empty-list-placeholder {
|
||||
color: #888;
|
||||
font-size: 1.1em;
|
||||
margin-top: 2em;
|
||||
|
||||
.delete-btn:hover {
|
||||
background: #ffebee;
|
||||
color: #f44336;
|
||||
}
|
||||
.pages-list {
|
||||
margin-top: 1.5em;
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
|
||||
.page-summary {
|
||||
color: var(--color-grey-dark);
|
||||
margin: 0 0 15px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.pages-list li {
|
||||
padding: 0.5em 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
font-size: 1.08em;
|
||||
|
||||
.page-meta {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
font-size: 0.9rem;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
.pages-list li:last-child {
|
||||
border-bottom: none;
|
||||
|
||||
.page-date i,
|
||||
.page-status i {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.page-status.draft i {
|
||||
color: #ff9800;
|
||||
}
|
||||
|
||||
.page-status.published i {
|
||||
color: #4caf50;
|
||||
}
|
||||
|
||||
.page-status.archived i {
|
||||
color: #9e9e9e;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
}
|
||||
|
||||
.empty-icon {
|
||||
font-size: 4rem;
|
||||
color: var(--color-grey-dark);
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.empty-state h3 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.empty-state p {
|
||||
color: var(--color-grey-dark);
|
||||
margin: 0 0 25px 0;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
border: 3px solid #f3f3f3;
|
||||
border-top: 3px solid var(--color-primary);
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 20px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.templates-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.template-card {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 25px;
|
||||
text-align: center;
|
||||
border: 1px solid #e9ecef;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.template-card:hover {
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.template-icon {
|
||||
font-size: 3rem;
|
||||
color: var(--color-primary);
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.template-card h3 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.template-card p {
|
||||
color: var(--color-grey-dark);
|
||||
margin: 0 0 20px 0;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.settings-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
|
||||
gap: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
.setting-card {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 20px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.setting-card h3 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.setting-item {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
.setting-item label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.setting-item textarea {
|
||||
width: 100%;
|
||||
min-height: 100px;
|
||||
padding: 10px;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: var(--radius-sm);
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.setting-item input[type="checkbox"] {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--color-primary-dark);
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: white;
|
||||
color: var(--color-primary);
|
||||
border: 1px solid var(--color-primary);
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
color: var(--color-grey-dark);
|
||||
padding: 5px;
|
||||
border-radius: var(--radius-sm);
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
background: #f0f0f0;
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.page-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.nav-tabs {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.section-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.search-box {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.pages-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.templates-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.settings-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -11,48 +11,474 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<BaseLayout>
|
||||
<div v-if="page" class="page-edit-block">
|
||||
<h2>Редактировать страницу</h2>
|
||||
<form @submit.prevent="save">
|
||||
<label>Заголовок</label>
|
||||
<input v-model="page.title" required />
|
||||
<label>Описание</label>
|
||||
<textarea v-model="page.summary" />
|
||||
<label>Контент</label>
|
||||
<textarea v-model="page.content" />
|
||||
<button type="submit">Сохранить</button>
|
||||
<button type="button" @click="goBack">Отмена</button>
|
||||
</form>
|
||||
<BaseLayout
|
||||
:is-authenticated="isAuthenticated"
|
||||
:identities="identities"
|
||||
:token-balances="tokenBalances"
|
||||
:is-loading-tokens="isLoadingTokens"
|
||||
@auth-action-completed="$emit('auth-action-completed')"
|
||||
>
|
||||
<div v-if="page" class="page-edit-page">
|
||||
<!-- Заголовок страницы -->
|
||||
<div class="page-header">
|
||||
<div class="header-content">
|
||||
<h1>✏️ Редактирование страницы</h1>
|
||||
<p v-if="page">Редактируйте содержимое страницы "{{ page.title }}"</p>
|
||||
<p v-else>Загрузка страницы...</p>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<button class="close-btn" @click="goBack">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Основной контент с тенью -->
|
||||
<div class="content-block">
|
||||
<form class="content-form" @submit.prevent="save">
|
||||
<!-- Основная информация -->
|
||||
<div class="form-section">
|
||||
<h2>Основная информация</h2>
|
||||
<div class="form-group">
|
||||
<label for="title">Заголовок страницы *</label>
|
||||
<input
|
||||
v-model="page.title"
|
||||
id="title"
|
||||
type="text"
|
||||
required
|
||||
placeholder="Введите заголовок страницы"
|
||||
class="form-input"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="summary">Краткое описание *</label>
|
||||
<textarea
|
||||
v-model="page.summary"
|
||||
id="summary"
|
||||
required
|
||||
rows="3"
|
||||
placeholder="Краткое описание страницы"
|
||||
class="form-textarea"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент -->
|
||||
<div class="form-section">
|
||||
<h2>Содержание</h2>
|
||||
<div class="form-group">
|
||||
<label for="content">Основной контент *</label>
|
||||
<textarea
|
||||
v-model="page.content"
|
||||
id="content"
|
||||
required
|
||||
rows="10"
|
||||
placeholder="Введите основной контент страницы"
|
||||
class="form-textarea"
|
||||
/>
|
||||
<div class="content-stats">
|
||||
<span>Слов: {{ wordCount }}</span>
|
||||
<span>Символов: {{ characterCount }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SEO настройки -->
|
||||
<div class="form-section">
|
||||
<h2>SEO настройки</h2>
|
||||
<div class="form-group">
|
||||
<label for="seo-title">Meta Title</label>
|
||||
<input
|
||||
v-model="page.seo.title"
|
||||
id="seo-title"
|
||||
type="text"
|
||||
placeholder="SEO заголовок (если отличается от основного)"
|
||||
class="form-input"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="seo-description">Meta Description</label>
|
||||
<textarea
|
||||
v-model="page.seo.description"
|
||||
id="seo-description"
|
||||
rows="3"
|
||||
placeholder="SEO описание для поисковых систем"
|
||||
class="form-textarea"
|
||||
/>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="seo-keywords">Keywords</label>
|
||||
<input
|
||||
v-model="page.seo.keywords"
|
||||
id="seo-keywords"
|
||||
type="text"
|
||||
placeholder="Ключевые слова через запятую"
|
||||
class="form-input"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Настройки публикации -->
|
||||
<div class="form-section">
|
||||
<h2>Настройки публикации</h2>
|
||||
<div class="form-group">
|
||||
<label for="status">Статус</label>
|
||||
<select v-model="page.status" id="status" class="form-select">
|
||||
<option value="draft">Черновик</option>
|
||||
<option value="published">Опубликовано</option>
|
||||
<option value="pending">На модерации</option>
|
||||
<option value="archived">Архив</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Кнопки действий -->
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-outline" @click="goBack">
|
||||
<i class="fas fa-times"></i>
|
||||
Отмена
|
||||
</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isSubmitting">
|
||||
<i class="fas fa-save"></i>
|
||||
{{ isSubmitting ? 'Сохранение...' : 'Сохранить изменения' }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загрузка -->
|
||||
<div v-else class="loading-state">
|
||||
<div class="loading-spinner"></div>
|
||||
<p>Загрузка страницы...</p>
|
||||
</div>
|
||||
<div v-else>Загрузка...</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import BaseLayout from '../../components/BaseLayout.vue';
|
||||
import pagesService from '../../services/pagesService';
|
||||
|
||||
// Props
|
||||
const props = defineProps({
|
||||
isAuthenticated: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
identities: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
tokenBalances: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
isLoadingTokens: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits(['auth-action-completed']);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const page = ref(null);
|
||||
const isSubmitting = ref(false);
|
||||
|
||||
onMounted(async () => {
|
||||
page.value = await pagesService.getPage(route.params.id);
|
||||
// Вычисляемые свойства
|
||||
const wordCount = computed(() => {
|
||||
return page.value?.content ? page.value.content.split(/\s+/).length : 0;
|
||||
});
|
||||
|
||||
async function save() {
|
||||
await pagesService.updatePage(route.params.id, {
|
||||
title: page.value.title,
|
||||
summary: page.value.summary,
|
||||
content: page.value.content
|
||||
});
|
||||
router.push({ name: 'page-view', params: { id: route.params.id } });
|
||||
}
|
||||
const characterCount = computed(() => {
|
||||
return page.value?.content ? page.value.content.length : 0;
|
||||
});
|
||||
|
||||
// Методы
|
||||
function goBack() {
|
||||
router.push({ name: 'page-view', params: { id: route.params.id } });
|
||||
}
|
||||
</script>
|
||||
|
||||
async function save() {
|
||||
if (!page.value.title.trim()) {
|
||||
alert('Заполните заголовок страницы!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!page.value.summary.trim()) {
|
||||
alert('Заполните описание страницы!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!page.value.content.trim()) {
|
||||
alert('Заполните контент страницы!');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
isSubmitting.value = true;
|
||||
|
||||
const pageData = {
|
||||
title: page.value.title.trim(),
|
||||
summary: page.value.summary.trim(),
|
||||
content: page.value.content.trim(),
|
||||
seo: page.value.seo || {},
|
||||
status: page.value.status || 'draft'
|
||||
};
|
||||
|
||||
await pagesService.updatePage(route.params.id, pageData);
|
||||
|
||||
// Перенаправляем на просмотр страницы
|
||||
router.push({ name: 'page-view', params: { id: route.params.id } });
|
||||
} catch (error) {
|
||||
console.error('Ошибка при сохранении страницы:', error);
|
||||
alert('Ошибка при сохранении страницы: ' + (error?.message || error));
|
||||
} finally {
|
||||
isSubmitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка данных
|
||||
onMounted(async () => {
|
||||
try {
|
||||
page.value = await pagesService.getPage(route.params.id);
|
||||
|
||||
// Инициализируем SEO объект если его нет
|
||||
if (!page.value.seo) {
|
||||
page.value.seo = {
|
||||
title: '',
|
||||
description: '',
|
||||
keywords: ''
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка при загрузке страницы:', error);
|
||||
alert('Ошибка при загрузке страницы: ' + (error?.message || error));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-edit-page {
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-content h1 {
|
||||
color: var(--color-primary);
|
||||
font-size: 2.5rem;
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.header-content p {
|
||||
color: var(--color-grey-dark);
|
||||
font-size: 1.1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 2rem;
|
||||
color: var(--color-grey-dark);
|
||||
cursor: pointer;
|
||||
padding: 0 10px;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.content-block {
|
||||
background: #f8f9fa;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 25px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.content-form {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 30px;
|
||||
border: 1px solid #e9ecef;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
.form-section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-section h2 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 20px 0;
|
||||
font-size: 1.3rem;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.form-group:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.form-group label {
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
font-weight: 500;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.form-input,
|
||||
.form-textarea,
|
||||
.form-select {
|
||||
width: 100%;
|
||||
padding: 12px 15px;
|
||||
border: 1px solid #e9ecef;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 1rem;
|
||||
transition: border-color 0.3s ease;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.form-input:focus,
|
||||
.form-textarea:focus,
|
||||
.form-select:focus {
|
||||
outline: none;
|
||||
border-color: var(--color-primary);
|
||||
box-shadow: 0 0 0 3px rgba(45, 114, 217, 0.1);
|
||||
}
|
||||
|
||||
.form-textarea {
|
||||
resize: vertical;
|
||||
min-height: 100px;
|
||||
}
|
||||
|
||||
.content-stats {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-top: 8px;
|
||||
font-size: 0.9rem;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
display: flex;
|
||||
gap: 15px;
|
||||
justify-content: flex-end;
|
||||
margin-top: 30px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 12px 24px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background: var(--color-primary-dark);
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: white;
|
||||
color: var(--color-primary);
|
||||
border: 1px solid var(--color-primary);
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.loading-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 60px 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border: 4px solid #f3f3f3;
|
||||
border-top: 4px solid var(--color-primary);
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.loading-state p {
|
||||
color: var(--color-grey-dark);
|
||||
font-size: 1.1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.page-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.header-content h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.form-actions {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-stats {
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -11,15 +11,128 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<BaseLayout>
|
||||
<div v-if="page" class="page-view-block">
|
||||
<h2>{{ page.title }}</h2>
|
||||
<p><b>Описание:</b> {{ page.summary }}</p>
|
||||
<div><b>Контент:</b> {{ page.content }}</div>
|
||||
<button @click="goToEdit">Редактировать</button>
|
||||
<button @click="deletePage" style="color:red">Удалить</button>
|
||||
<BaseLayout
|
||||
:is-authenticated="isAuthenticated"
|
||||
:identities="identities"
|
||||
:token-balances="tokenBalances"
|
||||
:is-loading-tokens="isLoadingTokens"
|
||||
@auth-action-completed="$emit('auth-action-completed')"
|
||||
>
|
||||
<div class="page-view-container">
|
||||
<!-- Заголовок страницы -->
|
||||
<div v-if="page" class="page-header">
|
||||
<div class="header-content">
|
||||
<h1>📄 {{ page.title }}</h1>
|
||||
<div class="page-meta">
|
||||
<span class="page-status" :class="page.status">
|
||||
<i class="fas fa-circle"></i>
|
||||
{{ getStatusText(page.status) }}
|
||||
</span>
|
||||
<span class="page-date">
|
||||
<i class="fas fa-calendar"></i>
|
||||
Создано: {{ formatDate(page.createdAt) }}
|
||||
</span>
|
||||
<span v-if="page.updatedAt" class="page-date">
|
||||
<i class="fas fa-edit"></i>
|
||||
Обновлено: {{ formatDate(page.updatedAt) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="header-actions">
|
||||
<button class="btn btn-outline" @click="goToEdit">
|
||||
<i class="fas fa-edit"></i>
|
||||
Редактировать
|
||||
</button>
|
||||
<button class="btn btn-danger" @click="deletePage">
|
||||
<i class="fas fa-trash"></i>
|
||||
Удалить
|
||||
</button>
|
||||
<button class="close-btn" @click="goBack">×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Контент страницы -->
|
||||
<div v-if="page" class="page-content-block">
|
||||
<div class="page-content">
|
||||
<!-- Описание -->
|
||||
<div v-if="page.summary" class="content-section">
|
||||
<h2>Описание</h2>
|
||||
<div class="summary-content">
|
||||
{{ page.summary }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Основной контент -->
|
||||
<div class="content-section">
|
||||
<h2>Содержание</h2>
|
||||
<div class="main-content">
|
||||
<div v-if="page.content" v-html="formatContent(page.content)"></div>
|
||||
<div v-else class="empty-content">
|
||||
<i class="fas fa-file-alt"></i>
|
||||
<p>Контент не добавлен</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- SEO информация -->
|
||||
<div v-if="page.seo" class="content-section">
|
||||
<h2>SEO информация</h2>
|
||||
<div class="seo-info">
|
||||
<div class="seo-item">
|
||||
<label>Meta Title:</label>
|
||||
<span>{{ page.seo.title || 'Не указан' }}</span>
|
||||
</div>
|
||||
<div class="seo-item">
|
||||
<label>Meta Description:</label>
|
||||
<span>{{ page.seo.description || 'Не указан' }}</span>
|
||||
</div>
|
||||
<div class="seo-item">
|
||||
<label>Keywords:</label>
|
||||
<span>{{ page.seo.keywords || 'Не указаны' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Статистика -->
|
||||
<div class="content-section">
|
||||
<h2>Статистика</h2>
|
||||
<div class="stats-grid">
|
||||
<div class="stat-item">
|
||||
<div class="stat-value">{{ page.views || 0 }}</div>
|
||||
<div class="stat-label">Просмотров</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value">{{ page.wordCount || 0 }}</div>
|
||||
<div class="stat-label">Слов</div>
|
||||
</div>
|
||||
<div class="stat-item">
|
||||
<div class="stat-value">{{ page.characterCount || 0 }}</div>
|
||||
<div class="stat-label">Символов</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Загрузка -->
|
||||
<div v-else-if="isLoading" class="loading-state">
|
||||
<div class="loading-spinner"></div>
|
||||
<p>Загрузка страницы...</p>
|
||||
</div>
|
||||
|
||||
<!-- Ошибка -->
|
||||
<div v-else class="error-state">
|
||||
<div class="error-icon">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
</div>
|
||||
<h3>Страница не найдена</h3>
|
||||
<p>Запрашиваемая страница не существует или была удалена</p>
|
||||
<button class="btn btn-primary" @click="goBack">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
Вернуться назад
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>Загрузка...</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
@@ -29,22 +142,427 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import BaseLayout from '../../components/BaseLayout.vue';
|
||||
import pagesService from '../../services/pagesService';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const page = ref(null);
|
||||
|
||||
onMounted(async () => {
|
||||
page.value = await pagesService.getPage(route.params.id);
|
||||
// Props
|
||||
const props = defineProps({
|
||||
isAuthenticated: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
identities: {
|
||||
type: Array,
|
||||
default: () => []
|
||||
},
|
||||
tokenBalances: {
|
||||
type: Object,
|
||||
default: () => ({})
|
||||
},
|
||||
isLoadingTokens: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
});
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits(['auth-action-completed']);
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
// Состояние
|
||||
const page = ref(null);
|
||||
const isLoading = ref(false);
|
||||
|
||||
// Методы
|
||||
function goToEdit() {
|
||||
router.push({ name: 'page-edit', params: { id: route.params.id } });
|
||||
}
|
||||
|
||||
async function deletePage() {
|
||||
if (confirm('Удалить страницу?')) {
|
||||
await pagesService.deletePage(route.params.id);
|
||||
router.push({ name: 'content-list' });
|
||||
if (confirm('Вы уверены, что хотите удалить эту страницу? Это действие нельзя отменить.')) {
|
||||
try {
|
||||
await pagesService.deletePage(route.params.id);
|
||||
router.push({ name: 'content-list' });
|
||||
} catch (error) {
|
||||
console.error('Ошибка удаления страницы:', error);
|
||||
alert('Ошибка при удалении страницы');
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
function goBack() {
|
||||
router.go(-1);
|
||||
}
|
||||
|
||||
function formatDate(date) {
|
||||
if (!date) return 'Не указана';
|
||||
return new Date(date).toLocaleDateString('ru-RU', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
});
|
||||
}
|
||||
|
||||
function getStatusText(status) {
|
||||
const statusMap = {
|
||||
draft: 'Черновик',
|
||||
published: 'Опубликовано',
|
||||
archived: 'Архив',
|
||||
pending: 'На модерации'
|
||||
};
|
||||
return statusMap[status] || 'Неизвестно';
|
||||
}
|
||||
|
||||
function formatContent(content) {
|
||||
// Простое форматирование контента
|
||||
if (!content) return '';
|
||||
|
||||
// Заменяем переносы строк на <br>
|
||||
return content.replace(/\n/g, '<br>');
|
||||
}
|
||||
|
||||
async function loadPage() {
|
||||
try {
|
||||
isLoading.value = true;
|
||||
page.value = await pagesService.getPage(route.params.id);
|
||||
|
||||
// Подсчитываем статистику
|
||||
if (page.value) {
|
||||
page.value.wordCount = page.value.content ? page.value.content.split(/\s+/).length : 0;
|
||||
page.value.characterCount = page.value.content ? page.value.content.length : 0;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка загрузки страницы:', error);
|
||||
page.value = null;
|
||||
} finally {
|
||||
isLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Загрузка данных
|
||||
onMounted(() => {
|
||||
loadPage();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.page-view-container {
|
||||
padding: 20px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 30px;
|
||||
padding-bottom: 20px;
|
||||
border-bottom: 2px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.header-content {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.header-content h1 {
|
||||
color: var(--color-primary);
|
||||
font-size: 2.5rem;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
|
||||
.page-meta {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
align-items: center;
|
||||
font-size: 0.9rem;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.page-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 4px 12px;
|
||||
border-radius: 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.page-status.draft {
|
||||
background: #fff3e0;
|
||||
color: #e65100;
|
||||
}
|
||||
|
||||
.page-status.published {
|
||||
background: #e8f5e8;
|
||||
color: #2e7d32;
|
||||
}
|
||||
|
||||
.page-status.archived {
|
||||
background: #f5f5f5;
|
||||
color: #616161;
|
||||
}
|
||||
|
||||
.page-status.pending {
|
||||
background: #e3f2fd;
|
||||
color: #1565c0;
|
||||
}
|
||||
|
||||
.page-date,
|
||||
.page-updated {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.page-content-block {
|
||||
background: #f8f9fa;
|
||||
border-radius: var(--radius-lg);
|
||||
padding: 25px;
|
||||
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.page-content {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 25px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.content-section {
|
||||
background: white;
|
||||
border-radius: var(--radius-sm);
|
||||
padding: 25px;
|
||||
margin-bottom: 20px;
|
||||
border: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.content-section:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.content-section h2 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 20px 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.summary-content {
|
||||
color: var(--color-grey-dark);
|
||||
line-height: 1.6;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
|
||||
.main-content {
|
||||
line-height: 1.8;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.empty-content {
|
||||
text-align: center;
|
||||
padding: 40px 20px;
|
||||
color: var(--color-grey-dark);
|
||||
}
|
||||
|
||||
.empty-content i {
|
||||
font-size: 3rem;
|
||||
margin-bottom: 15px;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.seo-info {
|
||||
display: grid;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.seo-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: flex-start;
|
||||
padding: 10px 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
}
|
||||
|
||||
.seo-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.seo-item label {
|
||||
font-weight: 500;
|
||||
color: var(--color-grey-dark);
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.seo-item span {
|
||||
color: #333;
|
||||
flex: 1;
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background: #f8f9fa;
|
||||
border-radius: var(--radius-sm);
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 2rem;
|
||||
font-weight: bold;
|
||||
color: var(--color-primary);
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
color: var(--color-grey-dark);
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
.loading-state,
|
||||
.error-state {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
}
|
||||
|
||||
.loading-spinner {
|
||||
border: 3px solid #f3f3f3;
|
||||
border-top: 3px solid var(--color-primary);
|
||||
border-radius: 50%;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
animation: spin 1s linear infinite;
|
||||
margin: 0 auto 20px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% { transform: rotate(0deg); }
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.error-icon {
|
||||
font-size: 4rem;
|
||||
color: #f44336;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.error-state h3 {
|
||||
color: var(--color-primary);
|
||||
margin: 0 0 10px 0;
|
||||
}
|
||||
|
||||
.error-state p {
|
||||
color: var(--color-grey-dark);
|
||||
margin: 0 0 25px 0;
|
||||
}
|
||||
|
||||
.btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: var(--radius-sm);
|
||||
font-size: 1rem;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
text-decoration: none;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.btn-outline {
|
||||
background: white;
|
||||
color: var(--color-primary);
|
||||
border: 1px solid var(--color-primary);
|
||||
}
|
||||
|
||||
.btn-outline:hover {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger {
|
||||
background: #f44336;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-danger:hover {
|
||||
background: #d32f2f;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background: var(--color-primary);
|
||||
color: white;
|
||||
}
|
||||
|
||||
.btn-primary:hover {
|
||||
background: var(--color-primary-dark);
|
||||
}
|
||||
|
||||
.close-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 2rem;
|
||||
color: var(--color-grey-dark);
|
||||
cursor: pointer;
|
||||
padding: 0 10px;
|
||||
transition: color 0.3s ease;
|
||||
}
|
||||
|
||||
.close-btn:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.page-header {
|
||||
flex-direction: column;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.page-title-section h1 {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
||||
.page-meta {
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.header-actions {
|
||||
width: 100%;
|
||||
justify-content: stretch;
|
||||
}
|
||||
|
||||
.header-actions .btn {
|
||||
flex: 1;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.seo-item {
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
|
||||
.seo-item label {
|
||||
min-width: auto;
|
||||
}
|
||||
|
||||
.seo-item span {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user