This commit is contained in:
2026-03-28 18:16:40 +10:00
parent 69bce6caad
commit 4aa6a469aa

View File

@@ -25,8 +25,18 @@ const localStatus = ref(props.status);
// Следим за изменениями props и обновляем локальные значения // Следим за изменениями props и обновляем локальные значения
import { watch } from "vue"; import { watch } from "vue";
watch(() => props.viewed, (val) => { localViewed.value = val; }); watch(
watch(() => props.status, (val) => { localStatus.value = val; }); () => props.viewed,
(val) => {
localViewed.value = val;
},
);
watch(
() => props.status,
(val) => {
localStatus.value = val;
},
);
// Тема // Тема
const isDarkMode = ref(document.documentElement.classList.contains("dark")); const isDarkMode = ref(document.documentElement.classList.contains("dark"));
@@ -61,12 +71,12 @@ const viewed_b = async () => {
const newValue = !localViewed.value; const newValue = !localViewed.value;
localViewed.value = newValue; // Локальное обновление сразу localViewed.value = newValue; // Локальное обновление сразу
emit("update:viewed", { url: props.url, viewed: newValue }); emit("update:viewed", { url: props.url, viewed: newValue });
try { try {
await axios.post( await axios.post(
"https://allowlgroup.ru/api/8002/update_viewed_status", "https://allowlgroup.ru/api/8002/update_viewed_status",
null, null,
{ params: { url: props.url, viewed: newValue } } { params: { url: props.url, viewed: newValue } },
); );
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@@ -79,12 +89,12 @@ const status_b = async () => {
const newValue = !localStatus.value; const newValue = !localStatus.value;
localStatus.value = newValue; // Локальное обновление сразу localStatus.value = newValue; // Локальное обновление сразу
emit("update:status", { url: props.url, status: newValue }); emit("update:status", { url: props.url, status: newValue });
try { try {
await axios.post( await axios.post(
"https://allowlgroup.ru/api/8002/update_status_status", "https://allowlgroup.ru/api/8002/update_status_status",
null, null,
{ params: { url: props.url, status: newValue } } { params: { url: props.url, status: newValue } },
); );
} catch (err) { } catch (err) {
console.log(err); console.log(err);
@@ -94,13 +104,16 @@ const status_b = async () => {
const download = async () => { const download = async () => {
try { try {
const rez = await axios.get("https://allowlgroup.ru/api/8001/file_download", { const rez = await axios.get(
params: { "https://allowlgroup.ru/api/8001/file_download",
path: props.article_date.split(" ")[0], {
title: props.title, params: {
path: props.article_date.split(" ")[0],
title: props.title,
},
responseType: "blob",
}, },
responseType: "blob", );
});
const blobUrl = window.URL.createObjectURL( const blobUrl = window.URL.createObjectURL(
new Blob([rez.data], { new Blob([rez.data], {
type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document", type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
@@ -113,12 +126,21 @@ const download = async () => {
if (disposition) { if (disposition) {
const match = disposition.match(/filename\*?=([^;\n]+)/i); const match = disposition.match(/filename\*?=([^;\n]+)/i);
if (match) { if (match) {
let name = match[1].replace(/UTF-8''/, "").replace(/"/g, ""); 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"; if (!name.endsWith(".docx")) name += ".docx";
filename = name; filename = name;
} }
} }
} catch (e) { /* ignore */ } } catch (e) {
/* ignore */
}
link.href = blobUrl; link.href = blobUrl;
link.setAttribute("download", filename); link.setAttribute("download", filename);
document.body.appendChild(link); document.body.appendChild(link);