From c739c5abbbdcafd8415dad543f0d5335a1b0170c Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 14 Oct 2022 16:56:30 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D1=84=D0=BE=D1=80=D0=BC=D0=B8=D1=80=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/Search.vue | 41 ++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index 57d3520..3bb2eb2 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -316,7 +316,7 @@ const componentOptions = { }, watch: { config() { - this.makeTitle(); + this.makeProjectName(); }, settings() { this.loadSettings(); @@ -324,6 +324,7 @@ const componentOptions = { search: { handler(newValue) { this.limit = newValue.limit; + this.makeTitle(); this.refresh(); }, deep: true, @@ -495,12 +496,46 @@ class Search { window.open('https://github.com/bookpauk/inpx-web', '_blank'); } - makeTitle() { + makeProjectName() { const collection = this.config.dbConfig.inpxInfo.collection.split('\n'); this.collection = collection[0].trim(); this.projectName = `${this.config.name} v${this.config.webAppVersion}`; - this.$root.setAppTitle(`Коллекция ${this.collection}`); + this.makeTitle(); + } + + makeTitle() { + if (!this.collection) + return; + + let result = `Коллекция ${this.collection}`; + + const search = this.search; + const specSym = new Set(['*', '#']); + const correctValue = (v) => { + if (v) { + if (v[0] === '=') + v = v.substring(1); + else if (!specSym.has(v[0])) + v = '^' + v; + } + return v || ''; + }; + + if (search.author || search.series || search.title) { + const as = (search.author ? search.author.split(',') : []); + const author = (as.length ? as[0] : '') + (as.length > 1 ? ' и др.' : ''); + + const a = correctValue(author); + const sc = correctValue(search.series); + const s = (sc ? `(${sc})` : ''); + const t = correctValue(search.title); + + result = [s, t].filter(v => v).join(' '); + result = [a, result].filter(v => v).join(' - '); + } + + this.$root.setAppTitle(result); } showSearchHelp() {