From 49fd516d45bb8ada96c6f8334c83719ddddfe963 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Thu, 4 Apr 2024 14:08:15 +0700 Subject: [PATCH] =?UTF-8?q?=D0=92=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D1=82=D1=80=20bookReadLink=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?= =?UTF-8?q?=D0=B3=D0=B0=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D1=8B=20DOWNLOAD=5FURI=20=D0=BD=D0=B0=20uri?= =?UTF-8?q?=20=D0=B8=D0=B7=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D1=81=D0=BA=D0=B0=D1=87=D0=B8=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=BA=D0=BD=D0=B8=D0=B3=D0=B8=20(#29)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 ++ client/components/Search/BaseList.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64f88c7..53038cc 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,8 @@ Options: // содержимое кнопки-ссылки "(читать)", если не задано - кнопка "(читать)" не показывается // пример: "https://omnireader.ru/#/reader?url=${DOWNLOAD_LINK}" // на место ${DOWNLOAD_LINK} будет подставлена ссылка на скачивание файла книги + // пример: "https://mydomain.ru/#/reader?url=http://127.0.0.1:8086${DOWNLOAD_URI}" + // на место ${DOWNLOAD_URI} будут подставлены параметры (без имени хоста) из ссылки на скачивание файла книги "bookReadLink": "", // включить(true)/выключить(false) журналирование diff --git a/client/components/Search/BaseList.js b/client/components/Search/BaseList.js index d1d98af..f8f7a34 100644 --- a/client/components/Search/BaseList.js +++ b/client/components/Search/BaseList.js @@ -178,7 +178,18 @@ export default class BaseList { if (this.list.liberamaReady) { this.$emit('listEvent', {action: 'submitUrl', data: href}); } else { - const url = this.config.bookReadLink.replace('${DOWNLOAD_LINK}', href); + const bookReadLink = this.config.bookReadLink; + let url = bookReadLink; + + if (bookReadLink.indexOf('${DOWNLOAD_LINK}') >= 0) { + url = bookReadLink.replace('${DOWNLOAD_LINK}', href); + + } else if (bookReadLink.indexOf('${DOWNLOAD_URI}') >= 0) { + const hrefUrl = new URL(href); + const urlWithoutHost = hrefUrl.pathname + hrefUrl.search + hrefUrl.hash; + url = bookReadLink.replace('${DOWNLOAD_URI}', urlWithoutHost); + } + window.open(url, '_blank'); } } else if (action == 'bookInfo') {