From d9e19ff9b7f4ac4d42aa83230282553816906305 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Fri, 17 Mar 2023 12:45:13 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=20=D0=BF=D0=BE=20=D1=82?= =?UTF-8?q?=D0=B8=D0=BF=D1=83=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/components/Search/BaseList.js | 8 ++++++ client/components/Search/Search.vue | 2 ++ .../SelectExtDialog/SelectExtDialog.vue | 28 +++++++++++++------ server/core/DbSearcher.js | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/client/components/Search/BaseList.js b/client/components/Search/BaseList.js index ddc7b9d..ba734a6 100644 --- a/client/components/Search/BaseList.js +++ b/client/components/Search/BaseList.js @@ -450,6 +450,13 @@ export default class BaseList { librateFound = searchLibrate.has(book.librate); } + //ext + let extFound = !s.ext; + if (!extFound) { + const searchExt = new Set(s.ext.split('|')); + extFound = searchExt.has(book.ext.toLowerCase() || emptyFieldValue); + } + return (this.showDeleted || !book.del) && authorFound && filterBySearch(book.series, s.series) @@ -458,6 +465,7 @@ export default class BaseList { && langFound && dateFound && librateFound + && extFound ; }); } diff --git a/client/components/Search/Search.vue b/client/components/Search/Search.vue index b91d940..585e79f 100644 --- a/client/components/Search/Search.vue +++ b/client/components/Search/Search.vue @@ -725,6 +725,7 @@ class Search { result.push(s.genre ? 'Жанр' : ''); result.push(s.date ? 'Дата поступления' : ''); result.push(s.librate ? 'Оценка' : ''); + result.push(s.ext ? 'Тип файла' : ''); return result.filter(s => s).join(', '); } @@ -1104,6 +1105,7 @@ class Search { lang: (typeof(query.lang) == 'string' ? query.lang : this.langDefault), date: query.date, librate: query.librate, + ext: query.ext, page: parseInt(query.page, 10), limit: parseInt(query.limit, 10) || this.search.limit, diff --git a/client/components/Search/SelectExtDialog/SelectExtDialog.vue b/client/components/Search/SelectExtDialog/SelectExtDialog.vue index 5622105..60c3c14 100644 --- a/client/components/Search/SelectExtDialog/SelectExtDialog.vue +++ b/client/components/Search/SelectExtDialog/SelectExtDialog.vue @@ -16,7 +16,13 @@ :options="optionsPre" type="checkbox" inline - /> + > + + @@ -57,12 +63,12 @@ const componentOptions = { dialogVisible(newValue) { this.$emit('update:modelValue', newValue); }, - lang() { + ext() { this.updateTicked(); }, ticked() { this.checkAllTicked(); - this.updateLang(); + this.updateExt(); }, } }; @@ -95,7 +101,13 @@ class SelectExtDialog { const result = []; for (const ext of this.extList) { - result.push({label: ext, value: ext}); + if (ext.length <= 4) + result.push({label: ext, value: ext}); + } + + for (const ext of this.extList) { + if (ext.length > 4) + result.push({label: ext, value: ext}); } return result; @@ -104,7 +116,7 @@ class SelectExtDialog { get optionsPre() { const result = []; - for (const ext of ['fb2', 'pdf']) { + for (const ext of ['fb2', 'epub', 'mobi', 'pdf', 'djvu', 'doc', 'docx', 'rtf', 'xml', 'html', 'txt', 'zip']) { if (this.extList.includes(ext)) { result.push({label: ext, value: ext}); } @@ -145,11 +157,11 @@ class SelectExtDialog { } updateTicked() { - this.ticked = this.ext.split(',').filter(s => s); + this.ticked = this.ext.split('|').filter(s => s); } - updateLang() { - this.$emit('update:ext', this.ticked.join(',')); + updateExt() { + this.$emit('update:ext', this.ticked.join('|')); } okClick() { diff --git a/server/core/DbSearcher.js b/server/core/DbSearcher.js index 8bd36e8..7ba8970 100644 --- a/server/core/DbSearcher.js +++ b/server/core/DbSearcher.js @@ -298,7 +298,7 @@ class DbSearcher { table: 'ext', rawResult: true, where: ` - const exts = ${db.esc(query.ext.split(','))}; + const exts = ${db.esc(query.ext.split('|'))}; const ids = new Set(); for (const l of exts) {