Jelajahi Sumber

Добавлена ссылка "читать"

Book Pauk 2 tahun lalu
induk
melakukan
d3f1e19b8f

+ 12 - 0
client/components/Search/BookView/BookView.vue

@@ -40,6 +40,10 @@
             <q-icon name="la la-copy" size="20px" />
         </div>
 
+        <div v-if="config.bookReadLink" class="q-ml-sm clickable" @click="readBook">
+            (читать)
+        </div>
+
         <div v-if="showGenres && book.genre" class="q-ml-sm">
             {{ bookGenre }}
         </div>
@@ -86,6 +90,10 @@ class BookView {
         this.showDeleted = settings.showDeleted;
     }
 
+    get config() {
+        return this.$store.state.config;
+    }
+
     get settings() {
         return this.$store.state.settings;
     }
@@ -132,6 +140,10 @@ class BookView {
     copyLink() {
         this.$emit('bookEvent', {action: 'copyLink', book: this.book});
     }
+
+    readBook() {
+        this.$emit('bookEvent', {action: 'readBook', book: this.book});
+    }
 }
 
 export default vueComponent(BookView);

+ 8 - 6
client/components/Search/Search.vue

@@ -654,7 +654,7 @@ class Search {
         this.search.series = `=${series}`;
     }
 
-    async download(book, copy = false) {
+    async download(book, action) {
         if (this.downloadFlag)
             return;
 
@@ -691,19 +691,22 @@ class Search {
             const link = response.link;
             const href = `${window.location.origin}${link}`;
 
-            if (!copy) {
+            if (action == 'download') {
                 //скачивание
                 const d = this.$refs.download;
                 d.href = href;
                 d.download = downFileName;
 
                 d.click();
-            } else {
+            } else if (action == 'copyLink') {
                 //копирование ссылки
                 if (utils.copyTextToClipboard(href))
                     this.$root.notify.success('Ссылка успешно скопирована');
                 else
                     this.$root.notify.error('Копирование ссылки не удалось');
+            } else if (action == 'readBook') {
+                const url = this.config.bookReadLink.replace('${DOWNLOAD_LINK}', href);
+                window.open(url, '_blank');
             }
         } catch(e) {
             this.$root.stdDialog.alert(e.message, 'Ошибка');
@@ -719,10 +722,9 @@ class Search {
                 this.search.title = `=${event.book.title}`;
                 break;
             case 'download':
-                this.download(event.book);//no await
-                break;
             case 'copyLink':
-                this.download(event.book, true);//no await
+            case 'readBook':
+                this.download(event.book, event.action);//no await
                 break;
         }
     }

+ 2 - 1
server/config/base.js

@@ -16,6 +16,7 @@ module.exports = {
     publicDir: `${dataDir}/public`,
 
     accessPassword: '',
+    bookReadLink: '',
     loggingEnabled: true,
 
     maxFilesDirSize: 1024*1024*1024,//1Gb
@@ -23,7 +24,7 @@ module.exports = {
     cacheCleanInterval: 60,//minutes
     lowMemoryMode: false,
 
-    webConfigParams: ['name', 'version', 'branch'],
+    webConfigParams: ['name', 'version', 'branch', 'bookReadLink'],
 
     server: {
         ip: '0.0.0.0',

+ 1 - 0
server/config/index.js

@@ -5,6 +5,7 @@ const branchFilename = __dirname + '/application_env';
 
 const propsToSave = [
     'accessPassword',
+    'bookReadLink',
     'loggingEnabled',
     'maxFilesDirSize',
     'queryCacheEnabled',