Работа над проектом

This commit is contained in:
Book Pauk
2022-09-25 17:53:44 +07:00
parent e6d0c6e519
commit 66e5985335
3 changed files with 38 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
<template> <template>
<div class="root column fit" style="position: relative"> <div class="root column fit" style="position: relative">
<a ref="download" style="display: none;"></a>
<div v-show="loadingMessage" class="fit row justify-center items-center" style="position: absolute; background-color: rgba(0, 0, 0, 0.2); z-index: 2"> <div v-show="loadingMessage" class="fit row justify-center items-center" style="position: absolute; background-color: rgba(0, 0, 0, 0.2); z-index: 2">
<div class="bg-white row justify-center items-center q-px-lg" style="min-width: 180px; height: 50px; border-radius: 10px; box-shadow: 2px 2px 10px #333333"> <div class="bg-white row justify-center items-center q-px-lg" style="min-width: 180px; height: 50px; border-radius: 10px; box-shadow: 2px 2px 10px #333333">
<q-icon class="la la-spinner icon-rotate text-blue-8" size="28px" /> <q-icon class="la la-spinner icon-rotate text-blue-8" size="28px" />
@@ -554,16 +555,36 @@ class Search {
} }
async download(book, copy = false) { async download(book, copy = false) {
let downloadFlag = true;
(async() => {
await utils.sleep(200);
if (downloadFlag)
this.loadingMessage2 = 'Подготовка файла...';
})();
try { try {
const bookPath = `${book.folder}/${book.file}.${book.ext}`; const bookPath = `${book.folder}/${book.file}.${book.ext}`;
const response = await this.api.getBookLink(bookPath); const response = await this.api.getBookLink(bookPath);
const href = `${window.location.origin}${response.link}`;
if (!copy) { if (!copy) {
// const d = this.$refs.download;
d.href = href;
d.click();
} else {
if (utils.copyTextToClipboard(href))
this.$root.notify.success('Ссылка успешно скопирована');
else
this.$root.notify.error('Копирование ссылки не удалось');
} }
console.log(response);
} catch(e) { } catch(e) {
this.$root.stdDialog.alert(e.message, 'Ошибка'); this.$root.stdDialog.alert(e.message, 'Ошибка');
} finally {
downloadFlag = false;
this.loadingMessage2 = '';
} }
} }

View File

@@ -78,11 +78,11 @@ const directives = {Ripple, ClosePopup};
//plugins //plugins
//import AppFullscreen from 'quasar/src/plugins/AppFullscreen'; //import AppFullscreen from 'quasar/src/plugins/AppFullscreen';
//import Notify from 'quasar/src/plugins/Notify'; import Notify from 'quasar/src/plugins/Notify';
const plugins = { const plugins = {
//AppFullscreen, //AppFullscreen,
//Notify, Notify,
}; };
//icons //icons

View File

@@ -42,3 +42,15 @@ export function wordEnding(num, type = 0) {
return endings[type][num % 10]; return endings[type][num % 10];
} }
} }
export async function copyTextToClipboard(text) {
let result = false;
try {
await navigator.clipboard.writeText(text);
result = true;
} catch (e) {
//
}
return result;
}