Добавлено избранное в отдельный фрагмент

This commit is contained in:
2026-03-11 22:20:05 +10:00
parent 6e818fd4c2
commit 87fa5e8e08
4 changed files with 67 additions and 35 deletions

View File

@@ -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>