From 512d9fc8cb5550f322b010e3452816990eb373e1 Mon Sep 17 00:00:00 2001 From: Book Pauk Date: Tue, 6 Dec 2022 14:41:26 +0700 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BA?= =?UTF-8?q?=D0=B0=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/core/opds/BasePage.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/core/opds/BasePage.js b/server/core/opds/BasePage.js index abd12d5..ccfc4dc 100644 --- a/server/core/opds/BasePage.js +++ b/server/core/opds/BasePage.js @@ -11,6 +11,7 @@ const ruAlphabet = 'абвгдеёжзийклмнопрстуфхцчшщъыь const enAlphabet = 'abcdefghijklmnopqrstuvwxyz'; const enruArr = (ruAlphabet + enAlphabet).split(''); const enru = new Set(enruArr); +const ruOnly = new Set(ruAlphabet.split('')); class BasePage { constructor(config) { @@ -162,6 +163,7 @@ class BasePage { return await this.search(from, query); } else { let len = 0; + const enResult = []; for (const row of queryRes.found) { const value = row.value; len += value.length; @@ -182,13 +184,20 @@ class BasePage { count: row.count, }; } - if (query.depth > 1 || enru.has(value[0])) { - result.push(rec); + if (query.depth > 1 || enru.has(value[0]) ) { + //такой костыль из-за проблем с локалями в pkg + //русский язык всегда идет первым! + if (ruOnly.has(value[0])) + result.push(rec) + else + enResult.push(rec); } else { others.push(rec); } } + result = result.concat(enResult); + if (query[from] && query.depth > 1 && result.length < 10 && len > prevLen) { //рекурсия, с увеличением глубины, для облегчения навигации const newQuery = _.cloneDeep(query);