diff --git a/src/assets/word.png b/src/assets/word.png new file mode 100644 index 0000000..4700b96 Binary files /dev/null and b/src/assets/word.png differ diff --git a/src/components/Setings.vue b/src/components/Setings.vue index d214ee2..de6fbc9 100644 --- a/src/components/Setings.vue +++ b/src/components/Setings.vue @@ -130,7 +130,6 @@ {{ task.finished_at }} diff --git a/src/components/Stat.vue b/src/components/Stat.vue index 21514a2..2a5d273 100644 --- a/src/components/Stat.vue +++ b/src/components/Stat.vue @@ -46,6 +46,42 @@ const viewed_b = async () => { console.log(err); } }; +const download = async () => { + try { + const rez = await axios.get("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"); + // Принудительно добавляем .docx к имени файла + let filename = props.title + ".docx"; + try { + const disposition = rez.headers && rez.headers["content-disposition"]; + if (disposition) { + const match = disposition.match(/filename\*?=([^;\n]+)/i); + if (match) { + let name = match[1].replace(/UTF-8''/, "").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); @@ -57,26 +93,24 @@ onBeforeUnmount(() => { \ No newline at end of file +