Добавлено избранное в отдельный фрагмент
This commit is contained in:
47
src/App.vue
47
src/App.vue
@@ -3,9 +3,9 @@ import { onMounted, ref, watch } from "vue";
|
|||||||
import My_naw from "./components/My_naw.vue";
|
import My_naw from "./components/My_naw.vue";
|
||||||
import Section from "./components/Section.vue";
|
import Section from "./components/Section.vue";
|
||||||
import Setings from "./components/Setings.vue";
|
import Setings from "./components/Setings.vue";
|
||||||
import Status from "./components/Status.vue";
|
// import Status from "./components/Status.vue";
|
||||||
import Authe from "./components/Authe.vue";
|
import Authe from "./components/Authe.vue";
|
||||||
import axios from "axios";
|
// import axios from "axios";
|
||||||
|
|
||||||
// Инициализация темы при загрузке приложения
|
// Инициализация темы при загрузке приложения
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -24,31 +24,29 @@ onMounted(() => {
|
|||||||
|
|
||||||
// Состояния страницы и данные для входа
|
// Состояния страницы и данные для входа
|
||||||
const currentPage = ref("admin-panel");
|
const currentPage = ref("admin-panel");
|
||||||
const items = ref([]);
|
// const items = ref([]);
|
||||||
const items_status = ref([]);
|
// const items_status = ref([]);
|
||||||
|
|
||||||
// Универсальная функция для получения данных
|
// Универсальная функция для получения данных
|
||||||
const fetchData = async (url, targetRef) => {
|
// const fetchData = async (url, targetRef) => {
|
||||||
try {
|
// try {
|
||||||
const { data } = await axios.get(url);
|
// const { data } = await axios.get(url);
|
||||||
targetRef.value = data;
|
// targetRef.value = data;
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error(`Ошибка при получении данных с ${url}:`, err);
|
// console.error(`Ошибка при получении данных с ${url}:`, err);
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
|
|
||||||
// Обертки для вызова
|
// const loadItems_status = () =>
|
||||||
const loadItems = () =>
|
// fetchData("http://45.129.78.228:8002/records_all_status", items_status);
|
||||||
fetchData("http://45.129.78.228:8002/records_all", items); //http://127.0.0.1:8002/records_all http://45.129.78.228:8002/records_all
|
|
||||||
const loadItems_status = () =>
|
|
||||||
fetchData("http://45.129.78.228:8002/records_all_status", items_status);
|
|
||||||
|
|
||||||
onMounted(() => {
|
// onMounted(() => {
|
||||||
(loadItems(), loadItems_status());
|
// (loadItems(), loadItems_status());
|
||||||
});
|
// (loadItems_status());
|
||||||
|
// });
|
||||||
|
|
||||||
watch(items, loadItems);
|
// watch(items, loadItems);
|
||||||
watch(items_status, loadItems_status);
|
// watch(items_status, loadItems_status);
|
||||||
|
|
||||||
function handleUpdate(newValue) {
|
function handleUpdate(newValue) {
|
||||||
currentPage.value = newValue; // изменение значения в родителе
|
currentPage.value = newValue; // изменение значения в родителе
|
||||||
@@ -60,7 +58,8 @@ function handleUpdate(newValue) {
|
|||||||
<div v-if="currentPage === 'rezylt'">
|
<div v-if="currentPage === 'rezylt'">
|
||||||
<div class="sm:flex">
|
<div class="sm:flex">
|
||||||
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
||||||
<Section :items="items" />
|
<!-- <Section :items="items" /> -->
|
||||||
|
<Section filter="all"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -74,7 +73,7 @@ function handleUpdate(newValue) {
|
|||||||
<div v-if="currentPage === 'status'">
|
<div v-if="currentPage === 'status'">
|
||||||
<div class="sm:flex">
|
<div class="sm:flex">
|
||||||
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
||||||
<Status :items="items_status" />
|
<Section filter='status' />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="w-full sm:w-4/5 dark:text-neutral-300">
|
<div class="w-full sm:w-4/5 dark:text-neutral-300">
|
||||||
<div class="bg-white flex justify-between p-3 lg:p-5 dark:bg-gray-800">
|
<div class="bg-white flex justify-between p-3 lg:p-5 dark:bg-gray-800">
|
||||||
<div class="flex flex-col lg:flex-row">
|
<div class="flex flex-col md:flex-row">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<img
|
<img
|
||||||
v-if="isDarkMode"
|
v-if="isDarkMode"
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<select
|
<select
|
||||||
class="dark:bg-gray-900 border-slate-100 shadow rounded-xl h-12 p-3 mt-3 lg:mt-0 lg:ml-4 "
|
@change="onfilterItems($event.target.value)"
|
||||||
|
class="dark:bg-gray-900 border-slate-100 shadow rounded-xl h-12 p-3 mt-3 md:mt-0 md:ml-4"
|
||||||
>
|
>
|
||||||
<option value="all">Все</option>
|
<option value="all">Все</option>
|
||||||
|
<option value="time">По времени</option>
|
||||||
<option value="viewed">Просмотренные</option>
|
<option value="viewed">Просмотренные</option>
|
||||||
<option value="not_viewed">Непросмотренные</option>
|
<option value="status">Избранные</option>
|
||||||
<option value="status_true">Статус: True</option>
|
|
||||||
<option value="status_false">Статус: False</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<Time />
|
<Time />
|
||||||
@@ -54,9 +54,10 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
import { ref, onMounted, watch } from "vue";
|
||||||
import Stat from "./Stat.vue";
|
import Stat from "./Stat.vue";
|
||||||
import Time from "./Time.vue";
|
import Time from "./Time.vue";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
|
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
|
||||||
// Следим за изменениями класса dark на html
|
// Следим за изменениями класса dark на html
|
||||||
@@ -71,9 +72,41 @@ onMounted(() => {
|
|||||||
attributes: true,
|
attributes: true,
|
||||||
attributeFilter: ["class"],
|
attributeFilter: ["class"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Загружаем данные при монтировании
|
||||||
|
loadItems(props.filter);
|
||||||
});
|
});
|
||||||
|
|
||||||
defineProps({
|
// Состояния страницы и данные для входа
|
||||||
items: Array,
|
const items = ref([]);
|
||||||
|
// const filter = ref();
|
||||||
|
const time = ref("");
|
||||||
|
|
||||||
|
// Универсальная функция для получения данных
|
||||||
|
const fetchData = async (url, targetRef) => {
|
||||||
|
try {
|
||||||
|
const { data } = await axios.get(url);
|
||||||
|
targetRef.value = data;
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Ошибка при получении данных с ${url}:`, err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const onfilterItems = (filterValue) => {
|
||||||
|
console.log(filterValue);
|
||||||
|
loadItems(filterValue);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Обертки для вызова
|
||||||
|
const loadItems = (filterValue) => {
|
||||||
|
fetchData(`http://127.0.0.1:8002/records_all?item=${filterValue}`, items);
|
||||||
|
};
|
||||||
|
//watch(items, loadItems(filter.value));
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
filter: {
|
||||||
|
type: String,
|
||||||
|
default: "all",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ const saveSources = async () => {
|
|||||||
// Запуск парсинга 1
|
// Запуск парсинга 1
|
||||||
const start_parser_1 = async () => {
|
const start_parser_1 = async () => {
|
||||||
try {
|
try {
|
||||||
await axios.post("http://127.0.0.1:8001/parser_1", {
|
await axios.post("http://45.129.78.228:8001/parser_1", {
|
||||||
time: time.value,
|
time: time.value,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ function handleClickOutside(event) {
|
|||||||
|
|
||||||
const viewed_b = async () => {
|
const viewed_b = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
await axios.post(
|
||||||
"http://45.129.78.228:8002/update_viewed_status",
|
"http://45.129.78.228:8002/update_viewed_status",
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ const viewed_b = async () => {
|
|||||||
|
|
||||||
const status_b = async () => {
|
const status_b = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post(
|
await axios.post(
|
||||||
"http://45.129.78.228:8002/update_status_status",
|
"http://45.129.78.228:8002/update_status_status",
|
||||||
null,
|
null,
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user