изменил правила хранения промтов
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-04-11 14:05:25 +10:00
parent 0c364fd36c
commit 855c06d313
6 changed files with 425 additions and 59 deletions

View File

@@ -4,6 +4,7 @@ import All_new_section from "./components/All_new_section.vue";
import General_section from "./components/General_section.vue"; import General_section from "./components/General_section.vue";
import Setings from "./components/Setings.vue"; import Setings from "./components/Setings.vue";
import Authe from "./components/Authe.vue"; import Authe from "./components/Authe.vue";
import Istochnik from "./components/Istochnik.vue";
// Инициализация темы при загрузке приложения // Инициализация темы при загрузке приложения
onMounted(() => { onMounted(() => {
@@ -50,6 +51,13 @@ function handleUpdate(newValue) {
<General_section filter="status" /> <General_section filter="status" />
</div> </div>
</div> </div>
<div v-if="currentPage === 'istochnik'">
<div class="sm:flex">
<All_new_section :currentPage="currentPage" @update="handleUpdate" />
<Istochnik />
</div>
</div>
</template> </template>
<style> <style>

View File

@@ -3,79 +3,44 @@
class="sticky top-0 w-full sm:w-1/5 sm:h-screen bg-white z-10 pt-5 md:p-5 dark:bg-gray-800 flex sm:justify-between flex-col" class="sticky top-0 w-full sm:w-1/5 sm:h-screen bg-white z-10 pt-5 md:p-5 dark:bg-gray-800 flex sm:justify-between flex-col"
> >
<div class=""> <div class="">
<!-- Фиксированный левый блок --> <div class="flex sm:flex-col">
<div v-if="currentPage === 'rezylt'" class="flex sm:flex-col">
<button <button
@click="ValueRezylt" @click="ValueRezylt"
class="bg-gray-600 w-full text-white min-w-30 px-4 py-2 rounded cursor-pointer" :class="getButtonClass('rezylt')"
> >
Результат Результат
</button> </button>
<button <button
@click="ValueSeting" @click="ValueSeting"
class="bg-gray-300 sm:mt-3 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer" :class="getButtonClass('setings')"
class="sm:mt-3"
> >
Настройка Настройка
</button> </button>
<button <button
@click="Valuestatus" @click="Valuestatus"
class="bg-gray-300 sm:mt-3 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer" :class="getButtonClass('status')"
class="sm:mt-3"
> >
Избранное Избранное
</button> </button>
</div>
<div v-if="currentPage === 'setings'" class="flex sm:flex-col">
<button
@click="ValueRezylt"
class="bg-gray-300 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer"
>
Результат
</button>
<button <button
@click="ValueSeting" @click="Valueistochnik"
class="bg-gray-600 sm:mt-3 w-full text-white min-w-30 px-4 py-2 rounded cursor-pointer" :class="getButtonClass('istochnik')"
class="sm:mt-3"
> >
Настройка Источники
</button>
<button
@click="Valuestatus"
class="bg-gray-300 sm:mt-3 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer"
>
Избранное
</button>
</div>
<div v-if="currentPage === 'status'" class="flex sm:flex-col">
<button
@click="ValueRezylt"
class="bg-gray-300 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer"
>
Результат
</button>
<button
@click="ValueSeting"
class="bg-gray-300 sm:mt-3 w-full min-w-30 hover:text-white hover:bg-gray-600 px-4 py-2 rounded cursor-pointer"
>
Настройка
</button>
<button
@click="Valuestatus"
class="bg-gray-600 sm:mt-3 w-full text-white min-w-30 px-4 py-2 rounded cursor-pointer"
>
Избранное
</button> </button>
</div> </div>
</div> </div>
<!-- Переключатель темы -->
<div class="hidden sm:block"><ThemeToggle /></div>
<!-- Переключатель темы -->
<div class="hidden sm:block">
<ThemeToggle />
</div>
</div> </div>
</template> </template>
@@ -86,9 +51,16 @@ const props = defineProps({
currentPage: String, currentPage: String,
}); });
// Макросы Vue 3.3+ не требуют явного импорта
const emit = defineEmits(["update"]); const emit = defineEmits(["update"]);
function getButtonClass(page) {
const baseClass = "w-full min-w-30 px-4 py-2 rounded cursor-pointer";
const activeClass = "bg-gray-600 text-white";
const inactiveClass = "bg-gray-300 hover:text-white hover:bg-gray-600";
return `${baseClass} ${props.currentPage === page ? activeClass : inactiveClass}`;
}
function ValueSeting() { function ValueSeting() {
emit("update", "setings"); emit("update", "setings");
} }
@@ -100,4 +72,8 @@ function ValueRezylt() {
function Valuestatus() { function Valuestatus() {
emit("update", "status"); emit("update", "status");
} }
function Valueistochnik() {
emit("update", "istochnik");
}
</script> </script>

View File

@@ -33,7 +33,6 @@
<Time /> <Time />
</div> </div>
<!-- Контейнер с рефом для отслеживания скролла -->
<div ref="scrollContainer" class="p-4"> <div ref="scrollContainer" class="p-4">
<Stat <Stat
v-for="item in items" v-for="item in items"
@@ -74,7 +73,7 @@ const props = defineProps({
// Константы // Константы
const LIMIT = 50; const LIMIT = 50;
const POLL_INTERVAL = 10000; // 10 секунд const POLL_INTERVAL = 15000; // 15 секунд
// Состояния // Состояния
const isDarkMode = ref(document.documentElement.classList.contains("dark")); const isDarkMode = ref(document.documentElement.classList.contains("dark"));
@@ -91,7 +90,6 @@ let currentOffset = 0;
let pollTimer = null; let pollTimer = null;
let lastScrollTop = 0; // Сохраняем позицию скролла let lastScrollTop = 0; // Сохраняем позицию скролла
// === API ===
const fetchData = async (url) => { const fetchData = async (url) => {
try { try {

View File

@@ -0,0 +1,140 @@
<template>
<div class="w-full sm:w-4/5 dark:text-neutral-300">
<div
class="bg-white flex flex-col lg:flex-row justify-between items-center p-3 lg:p-5 dark:bg-gray-800 gap-3 lg:gap-4"
>
<!-- Блок 1: Поиск + Фильтр (всегда в ряд) -->
<div class="flex flex-row w-full lg:w-auto">
<div class="relative w-2/3">
<img
v-if="isDarkMode"
src="https://img.icons8.com/?size=100&id=WwWusvLMTFd7&format=png&color=000000"
class="absolute top-1/2 -translate-y-1/2 left-3 h-5"
/>
<img
v-else
src="https://img.icons8.com/?size=100&id=zR5EBMqZTIBz&format=png&color=000000"
class="absolute top-1/2 -translate-y-1/2 left-3 h-5"
/>
<input
v-model="poisk"
type="text"
placeholder="Поиск..."
class="w-full h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 pl-11"
/>
</div>
<select
@change="onfilterItems($event.target.value)"
class="w-1/3 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 ml-2"
>
<option value="all">Все</option>
<option value="time">По времени</option>
<option value="viewed">Просмотренные</option>
<option value="status">Избранные</option>
</select>
</div>
<!-- Блок 2: URL + Категория + Кнопка (всегда в ряд) -->
<div
class="flex flex-row w-full lg:w-auto gap-2 p-2 bg-gray-50 dark:bg-gray-700 rounded-xl border border-gray-200 dark:border-gray-600"
>
<input
v-model="newSourceUrl"
type="text"
placeholder="введите url источника"
class="flex-1 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 min-w-0"
/>
<select
v-model="newSourceCategory"
class="w-28 h-12 dark:bg-gray-900 border-slate-100 shadow rounded-xl p-3 min-w-30"
>
<option value="" disabled>Категория</option>
<option
v-for="category in categories"
:key="category"
:value="category"
>
{{ category }}
</option>
</select>
<button
@click="addSource"
class="w-20 h-12 bg-green-600 text-white px-2 rounded-xl shadow hover:bg-green-700 cursor-pointer whitespace-nowrap"
>
+ Add
</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>
</div>
</template>
<script setup>
import { ref, onMounted } from "vue";
import axios from "axios";
import Istochnik_one_kard from "./Istochnik_one_kard.vue";
const isDarkMode = ref(false);
const newSourceUrl = ref("");
const newSourceCategory = ref("");
const categories = ref([]);
const poisk = ref("");
const items = ref([]);
const fetchCategories = async () => {
try {
const data = await axios.get(
"https://allowlgroup.ru/api/8001/categories_promt",
);
categories.value = data.data;
} catch (err) {
console.error("Ошибка загрузки категорий:", err);
}
};
const addSource = async () => {
if (!newSourceUrl.value.trim() || !newSourceCategory.value) {
alert("Заполните все поля");
return;
}
try {
await axios.post("https://allowlgroup.ru/api/8001/add_sources", {
url: newSourceUrl.value,
promt: newSourceCategory.value,
});
newSourceUrl.value = "";
newSourceCategory.value = "";
alert("Источник добавлен");
} catch (err) {
console.error("Ошибка добавления источника:", err);
alert("Ошибка при добавлении источника");
}
};
const onfilterItems = (filterValue) => {
console.log("Фильтр:", filterValue);
};
onMounted(() => {
isDarkMode.value = document.documentElement.classList.contains("dark");
const mutationObserver = new MutationObserver(() => {
isDarkMode.value = document.documentElement.classList.contains("dark");
});
mutationObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ["class"],
});
fetchCategories();
});
</script>

View File

@@ -0,0 +1,248 @@
<script setup>
import { ref, onMounted, onBeforeUnmount } from "vue";
import axios from "axios";
// Добавляем emit для уведомления родителя об изменениях
const emit = defineEmits(["update:viewed", "update:status"]);
const props = defineProps({
url: String,
parsed_at: String,
title: String,
category: String,
short_text: String,
article_date: String,
original_text: String,
translation_text: String,
other: String,
viewed: Boolean,
status: Boolean,
});
// Делаем viewed и status реактивными для локального обновления
const localViewed = ref(props.viewed);
const localStatus = ref(props.status);
// Следим за изменениями props и обновляем локальные значения
import { watch } from "vue";
watch(
() => props.viewed,
(val) => {
localViewed.value = val;
},
);
watch(
() => props.status,
(val) => {
localStatus.value = val;
},
);
// Тема
const isDarkMode = ref(document.documentElement.classList.contains("dark"));
onMounted(() => {
isDarkMode.value = document.documentElement.classList.contains("dark");
const observer = new MutationObserver(() => {
isDarkMode.value = document.documentElement.classList.contains("dark");
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["class"],
});
});
// Карточка
const isOpen = ref(false);
const cardRef = ref(null);
function toggle() {
isOpen.value = true;
}
function handleClickOutside(event) {
if (cardRef.value && !cardRef.value.contains(event.target)) {
isOpen.value = false;
}
}
// Обновляем локально + отправляем emit
const viewed_b = async () => {
const newValue = !localViewed.value;
localViewed.value = newValue; // Локальное обновление сразу
emit("update:viewed", { url: props.url, viewed: newValue });
try {
await axios.post(
"https://allowlgroup.ru/api/8002/update_viewed_status",
null,
{ params: { url: props.url, viewed: newValue } },
);
} catch (err) {
console.log(err);
// При ошибке откатываем локальное значение
localViewed.value = !newValue;
}
};
const status_b = async () => {
const newValue = !localStatus.value;
localStatus.value = newValue; // Локальное обновление сразу
emit("update:status", { url: props.url, status: newValue });
try {
await axios.post(
"https://allowlgroup.ru/api/8002/update_status_status",
null,
{ params: { url: props.url, status: newValue } },
);
} catch (err) {
console.log(err);
localStatus.value = !newValue;
}
};
const download = async () => {
try {
const rez = await axios.get(
"https://allowlgroup.ru/api/8001/file_download",
// "http://127.0.0.1:8001/file_download",
{
params: {
path: props.article_date.split(" ")[0],
title: props.title,
},
responseType: "blob",
},
);
const blobUrl = window.URL.createObjectURL(
new Blob([rez.data], {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
}),
);
const link = document.createElement("a");
let filename = props.title + ".docx";
try {
const disposition = rez.headers?.["content-disposition"];
if (disposition) {
const match = disposition.match(/filename\*?=([^;\n]+)/i);
if (match) {
let name = match[1];
// Убираем префикс utf-8'' (case insensitive)
const prefix = "utf-8''";
if (name.toLowerCase().startsWith(prefix)) {
name = name.substring(prefix.length);
}
// Убираем кавычки и декодируем
name = decodeURIComponent(name.replace(/"/g, ""));
if (!name.endsWith(".docx")) name += ".docx";
filename = name;
}
}
} catch (e) {
/* ignore */
}
link.href = blobUrl;
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
link.remove();
window.URL.revokeObjectURL(blobUrl);
} catch (err) {
console.log(err);
}
};
onMounted(() => {
document.addEventListener("click", handleClickOutside);
});
onBeforeUnmount(() => {
document.removeEventListener("click", handleClickOutside);
});
</script>
<template>
<div
class="bg-white dark:bg-gray-800 hover:-translate-y-2 hover:shadow-2xl rounded-xl transition pb-1 mb-3"
:class="{ 'opacity-50': localViewed }"
>
<div ref="cardRef" class="cursor-pointer" @click="toggle">
<div class="flex justify-between p-3">
<p>{{ article_date }}</p>
<a
:href="url"
class="max-w-100 text-blue-600 dark:text-gray-400 hover:text-blue-800 active:text-blue-800 underline flex"
style="overflow: hidden; white-space: nowrap; text-overflow: ellipsis"
>
<img src="/src/assets/href.webp" class="w-5 h-6 mr-2" />
{{ url }}
</a>
</div>
<div class="m-3 dark:bg-gray-900 shadow rounded-xl p-3">
<p>{{ title }}</p>
</div>
<div v-show="isOpen" class="transition-all">
<div class="m-3 dark:bg-gray-900 shadow rounded-xl p-3">
<p>{{ short_text }}</p>
</div>
<div class="m-3 dark:bg-gray-900 shadow rounded-xl p-3">
<p>{{ translation_text }}</p>
</div>
<div class="m-3 dark:bg-gray-900 shadow rounded-xl p-3">
<p>{{ category }}</p>
</div>
<div class="m-3 dark:bg-gray-900 shadow rounded-xl p-3">
<p>{{ original_text }}</p>
</div>
</div>
</div>
<div class="flex justify-between">
<div class="ml-4 mb-4">
<button class="cursor-pointer" @click="viewed_b">
<img
v-if="localViewed"
src="https://img.icons8.com/?size=100&id=IJNt9jGwqy9N&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
<img
v-else-if="isDarkMode"
src="https://img.icons8.com/?size=100&id=qliQ29ghmkZh&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
<img
v-else
src="https://img.icons8.com/?size=100&id=KDfrR4UXlVPn&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
</button>
<button class="cursor-pointer" @click="status_b">
<img
v-if="localStatus"
src="https://img.icons8.com/?size=100&id=fiJBCEhvIMyT&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
<img
v-else-if="isDarkMode"
src="https://img.icons8.com/?size=100&id=BmD1kkH92ppy&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
<img
v-else
src="https://img.icons8.com/?size=100&id=wVQaONwgqX8h&format=png&color=000000"
class="h-12 hover:opacity-75 active:opacity-75"
/>
</button>
</div>
<button
class="hover:opacity-75 active:opacity-75 mr-10 rounded-xl cursor-pointer"
@click="download"
>
<img src="/src/assets/word.png" class="h-10 mb-2" />
</button>
</div>
</div>
</template>

View File

@@ -148,11 +148,10 @@ import axios from "axios";
import Setings_downloads from "./Setings_downloads.vue"; import Setings_downloads from "./Setings_downloads.vue";
import DatePicker from "./DatePicker.vue"; import DatePicker from "./DatePicker.vue";
const sources = ref([{ url: "", name: "", promt: "" }]); const sources = ref([{ name: "", promt: "" }]);
const time = ref(getTodayDate()); const time = ref(getTodayDate());
const currentSource = ref(sources.value[0]); const currentSource = ref(sources.value[0]);
const promt = ref("Начальный текст"); const promt = ref("Начальный текст");
const promt_url = ref("https://");
const logs = ref([]); const logs = ref([]);
const tasks = ref([]); const tasks = ref([]);
const showLogs = ref(false); // скрыто по умолчанию const showLogs = ref(false); // скрыто по умолчанию
@@ -224,7 +223,6 @@ const loadSettings = async () => {
sources.value = response.data.sources; sources.value = response.data.sources;
currentSource.value = sources.value[0]; currentSource.value = sources.value[0];
promt.value = currentSource.value.promt; promt.value = currentSource.value.promt;
promt_url.value = currentSource.value.url;
} catch (error) { } catch (error) {
console.error("Ошибка при загрузке настроек:", error); console.error("Ошибка при загрузке настроек:", error);
} }
@@ -234,14 +232,12 @@ const loadSettings = async () => {
const selectSource = (index) => { const selectSource = (index) => {
currentSource.value = sources.value[index]; currentSource.value = sources.value[index];
promt.value = currentSource.value.promt; promt.value = currentSource.value.promt;
promt_url.value = currentSource.value.url;
}; };
// Сохранение источников // Сохранение источников
const saveSources = async () => { const saveSources = async () => {
try { try {
await axios.post("https://allowlgroup.ru/api/8001/settings", { await axios.post("https://allowlgroup.ru/api/8001/settings", {
url: currentSource.value.url,
name: currentSource.value.name, name: currentSource.value.name,
promt: promt.value, promt: promt.value,
}); });