ваше сообщение коммита
This commit is contained in:
82
frontend/src/views/content/ContentListView.vue
Normal file
82
frontend/src/views/content/ContentListView.vue
Normal file
@@ -0,0 +1,82 @@
|
||||
<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>
|
||||
</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 { 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' }); }
|
||||
|
||||
const pages = ref([]);
|
||||
onMounted(async () => {
|
||||
pages.value = await pagesService.getPages();
|
||||
});
|
||||
</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;
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.content-header-nav {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.nav-btn {
|
||||
background: #f5f5f5;
|
||||
border: 1px solid #d0d0d0;
|
||||
border-radius: 6px;
|
||||
padding: 7px 18px;
|
||||
font-size: 1em;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
.nav-btn:hover {
|
||||
background: #e0e0e0;
|
||||
}
|
||||
.empty-list-placeholder {
|
||||
color: #888;
|
||||
font-size: 1.1em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
.pages-list {
|
||||
margin-top: 1.5em;
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.pages-list li {
|
||||
padding: 0.5em 0;
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
font-size: 1.08em;
|
||||
}
|
||||
.pages-list li:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
</style>
|
||||
30
frontend/src/views/content/ContentSettingsView.vue
Normal file
30
frontend/src/views/content/ContentSettingsView.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<template>
|
||||
<BaseLayout>
|
||||
<div class="content-settings-block">
|
||||
<h2>Настройки контента</h2>
|
||||
<div class="empty-settings-placeholder">Здесь будут настройки для управления страницами.</div>
|
||||
</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import BaseLayout from '../../components/BaseLayout.vue';
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.content-settings-block {
|
||||
background: #fff;
|
||||
border-radius: 16px;
|
||||
box-shadow: 0 4px 32px rgba(0,0,0,0.12);
|
||||
padding: 32px 24px 24px 24px;
|
||||
width: 100%;
|
||||
margin-top: 40px;
|
||||
position: relative;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.empty-settings-placeholder {
|
||||
color: #888;
|
||||
font-size: 1.1em;
|
||||
margin-top: 2em;
|
||||
}
|
||||
</style>
|
||||
46
frontend/src/views/content/PageEditView.vue
Normal file
46
frontend/src/views/content/PageEditView.vue
Normal file
@@ -0,0 +1,46 @@
|
||||
<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>
|
||||
</div>
|
||||
<div v-else>Загрузка...</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
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);
|
||||
});
|
||||
|
||||
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 } });
|
||||
}
|
||||
|
||||
function goBack() {
|
||||
router.push({ name: 'page-view', params: { id: route.params.id } });
|
||||
}
|
||||
</script>
|
||||
38
frontend/src/views/content/PageView.vue
Normal file
38
frontend/src/views/content/PageView.vue
Normal file
@@ -0,0 +1,38 @@
|
||||
<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>
|
||||
</div>
|
||||
<div v-else>Загрузка...</div>
|
||||
</BaseLayout>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
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);
|
||||
});
|
||||
|
||||
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' });
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user