Добавлено избранное в отдельный фрагмент
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 Section from "./components/Section.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 axios from "axios";
|
||||
// import axios from "axios";
|
||||
|
||||
// Инициализация темы при загрузке приложения
|
||||
onMounted(() => {
|
||||
@@ -24,31 +24,29 @@ onMounted(() => {
|
||||
|
||||
// Состояния страницы и данные для входа
|
||||
const currentPage = ref("admin-panel");
|
||||
const items = ref([]);
|
||||
const items_status = ref([]);
|
||||
// const items = ref([]);
|
||||
// const items_status = ref([]);
|
||||
|
||||
// Универсальная функция для получения данных
|
||||
const fetchData = async (url, targetRef) => {
|
||||
try {
|
||||
const { data } = await axios.get(url);
|
||||
targetRef.value = data;
|
||||
} catch (err) {
|
||||
console.error(`Ошибка при получении данных с ${url}:`, err);
|
||||
}
|
||||
};
|
||||
// const fetchData = async (url, targetRef) => {
|
||||
// try {
|
||||
// const { data } = await axios.get(url);
|
||||
// targetRef.value = data;
|
||||
// } catch (err) {
|
||||
// console.error(`Ошибка при получении данных с ${url}:`, err);
|
||||
// }
|
||||
// };
|
||||
|
||||
// Обертки для вызова
|
||||
const loadItems = () =>
|
||||
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);
|
||||
// const loadItems_status = () =>
|
||||
// fetchData("http://45.129.78.228:8002/records_all_status", items_status);
|
||||
|
||||
onMounted(() => {
|
||||
(loadItems(), loadItems_status());
|
||||
});
|
||||
// onMounted(() => {
|
||||
// (loadItems(), loadItems_status());
|
||||
// (loadItems_status());
|
||||
// });
|
||||
|
||||
watch(items, loadItems);
|
||||
watch(items_status, loadItems_status);
|
||||
// watch(items, loadItems);
|
||||
// watch(items_status, loadItems_status);
|
||||
|
||||
function handleUpdate(newValue) {
|
||||
currentPage.value = newValue; // изменение значения в родителе
|
||||
@@ -60,7 +58,8 @@ function handleUpdate(newValue) {
|
||||
<div v-if="currentPage === 'rezylt'">
|
||||
<div class="sm:flex">
|
||||
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
||||
<Section :items="items" />
|
||||
<!-- <Section :items="items" /> -->
|
||||
<Section filter="all"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -74,7 +73,7 @@ function handleUpdate(newValue) {
|
||||
<div v-if="currentPage === 'status'">
|
||||
<div class="sm:flex">
|
||||
<My_naw :currentPage="currentPage" @update="handleUpdate" />
|
||||
<Status :items="items_status" />
|
||||
<Section filter='status' />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<template>
|
||||
<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="flex flex-col lg:flex-row">
|
||||
<div class="flex flex-col md:flex-row">
|
||||
<div class="relative">
|
||||
<img
|
||||
v-if="isDarkMode"
|
||||
@@ -22,13 +22,13 @@
|
||||
/>
|
||||
</div>
|
||||
<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="time">По времени</option>
|
||||
<option value="viewed">Просмотренные</option>
|
||||
<option value="not_viewed">Непросмотренные</option>
|
||||
<option value="status_true">Статус: True</option>
|
||||
<option value="status_false">Статус: False</option>
|
||||
<option value="status">Избранные</option>
|
||||
</select>
|
||||
</div>
|
||||
<Time />
|
||||
@@ -54,9 +54,10 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, onMounted, onBeforeUnmount } from "vue";
|
||||
import { ref, onMounted, watch } from "vue";
|
||||
import Stat from "./Stat.vue";
|
||||
import Time from "./Time.vue";
|
||||
import axios from "axios";
|
||||
|
||||
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
|
||||
// Следим за изменениями класса dark на html
|
||||
@@ -71,9 +72,41 @@ onMounted(() => {
|
||||
attributes: true,
|
||||
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>
|
||||
|
||||
@@ -248,7 +248,7 @@ const saveSources = async () => {
|
||||
// Запуск парсинга 1
|
||||
const start_parser_1 = async () => {
|
||||
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,
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -49,7 +49,7 @@ function handleClickOutside(event) {
|
||||
|
||||
const viewed_b = async () => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
await axios.post(
|
||||
"http://45.129.78.228:8002/update_viewed_status",
|
||||
null,
|
||||
{
|
||||
@@ -66,7 +66,7 @@ const viewed_b = async () => {
|
||||
|
||||
const status_b = async () => {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
await axios.post(
|
||||
"http://45.129.78.228:8002/update_status_status",
|
||||
null,
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user