diff --git a/client/api/reader.js b/client/api/reader.js
index 52bfbde6..b3e2da87 100644
--- a/client/api/reader.js
+++ b/client/api/reader.js
@@ -56,7 +56,11 @@ class Reader {
}
}
- async loadCachedBook(url, callback){
+ async checkUrl(url) {
+ return await axios.head(url, {headers: {'Cache-Control': 'no-cache'}});
+ }
+
+ async loadCachedBook(url, callback) {
const response = await axios.head(url);
let estSize = 1000000;
diff --git a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
index 200dc9c1..c39e8845 100644
--- a/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
+++ b/client/components/Reader/RecentBooksPage/RecentBooksPage.vue
@@ -5,6 +5,7 @@
Список загружается
+
Оригинал
- Скачать FB2
+ Скачать FB2
@@ -104,6 +105,7 @@ import _ from 'lodash';
import * as utils from '../../../share/utils';
import Window from '../../share/Window.vue';
import bookManager from '../share/bookManager';
+import readerApi from '../../../api/reader';
export default @Component({
components: {
@@ -268,8 +270,20 @@ class RecentBooksPage extends Vue {
return result;
}
- getFileNameFromPath(fb2Path) {
- return path.basename(fb2Path).substr(0, 10) + '.fb2';
+ async downloadBook(fb2path) {
+ try {
+ await readerApi.checkUrl(fb2path);
+
+ const d = this.$refs.download;
+ d.href = fb2path;
+ d.download = path.basename(fb2path).substr(0, 10) + '.fb2';
+ d.click();
+ } catch (e) {
+ let errMes = e.message;
+ if (errMes.indexOf('404') >= 0)
+ errMes = 'Файл не найден на сервере (возможно был удален как устаревший)';
+ this.$alert(errMes, 'Ошибка', {type: 'error'});
+ }
}
openOriginal(url) {