Initial commit
This commit is contained in:
59
src/App.vue
Normal file
59
src/App.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<script setup>
|
||||
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 Authe from "./components/Authe.vue";
|
||||
import axios from "axios";
|
||||
// Состояния страницы и данные для входа
|
||||
const currentPage = ref("admin-panel");
|
||||
const items = ref([]);
|
||||
|
||||
// Универсальная функция для получения данных
|
||||
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
|
||||
|
||||
onMounted(() => {
|
||||
loadItems()
|
||||
})
|
||||
|
||||
watch(items, loadItems)
|
||||
|
||||
function handleUpdate(newValue) {
|
||||
currentPage.value = newValue; // изменение значения в родителе
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<template>
|
||||
<Authe :currentPage="currentPage" @update="handleUpdate"/>
|
||||
<div v-if="currentPage === 'rezylt'">
|
||||
<div class="sm:flex">
|
||||
|
||||
<My_naw :currentPage="currentPage" @update="handleUpdate"/>
|
||||
<Section :items="items"/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="currentPage === 'setings'">
|
||||
<div class="sm:flex">
|
||||
<My_naw :currentPage="currentPage" @update="handleUpdate"/>
|
||||
<Setings/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Добавьте стили по необходимости */
|
||||
</style>
|
||||
Reference in New Issue
Block a user