начало положено
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-11 22:28:46 +10:00
parent bbe39f2bd3
commit 3942501a94
2 changed files with 112 additions and 253 deletions

View File

@@ -71,19 +71,22 @@
</button>
</div>
</div>
<!-- Список источников -->
<div class="p-4">
<Istochnik_one_kard
v-for="item in items"
:key="item.url"
:url="item.url"
:promt="item.promt"
/>
<div
v-for="source in filteredSources"
:key="source.url"
class="mb-4"
>
<Istochnik_one_kard :source="source" />
</div>
</div>
</div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import { ref, onMounted, computed } from "vue";
import axios from "axios";
import Istochnik_one_kard from "./Istochnik_one_kard.vue";
@@ -92,7 +95,7 @@ const newSourceUrl = ref("");
const newSourceCategory = ref("");
const categories = ref([]);
const poisk = ref("");
const items = ref([]);
const sources = ref([]);
const fetchCategories = async () => {
try {
@@ -105,6 +108,25 @@ const fetchCategories = async () => {
}
};
const fetchSources = async () => {
try {
const data = await axios.get(
"https://allowlgroup.ru/api/8001/all_sources",
);
sources.value = data.data.sources || [];
} catch (err) {
console.error("Ошибка загрузки источников:", err);
}
};
const filteredSources = computed(() => {
if (!poisk.value) return sources.value;
return sources.value.filter(source =>
source.url.toLowerCase().includes(poisk.value.toLowerCase()) ||
source.promt.toLowerCase().includes(poisk.value.toLowerCase())
);
});
const addSource = async () => {
if (!newSourceUrl.value.trim() || !newSourceCategory.value) {
alert("Заполните все поля");
@@ -113,12 +135,12 @@ const addSource = async () => {
try {
await axios.post("https://allowlgroup.ru/api/8001/add_sources", {
// await axios.post("http://127.0.0.1:8001/add_sources", {
url: newSourceUrl.value,
promt: newSourceCategory.value,
});
newSourceUrl.value = "";
newSourceCategory.value = "";
fetchSources(); // Обновляем список после добавления
} catch (err) {
console.error("Ошибка добавления источника:", err);
alert("Ошибка при добавлении источника");
@@ -140,5 +162,6 @@ onMounted(() => {
});
fetchCategories();
fetchSources();
});
</script>
</script>