Поправка сортировки
This commit is contained in:
@@ -11,6 +11,7 @@ const ruAlphabet = 'абвгдеёжзийклмнопрстуфхцчшщъыь
|
|||||||
const enAlphabet = 'abcdefghijklmnopqrstuvwxyz';
|
const enAlphabet = 'abcdefghijklmnopqrstuvwxyz';
|
||||||
const enruArr = (ruAlphabet + enAlphabet).split('');
|
const enruArr = (ruAlphabet + enAlphabet).split('');
|
||||||
const enru = new Set(enruArr);
|
const enru = new Set(enruArr);
|
||||||
|
const ruOnly = new Set(ruAlphabet.split(''));
|
||||||
|
|
||||||
class BasePage {
|
class BasePage {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
@@ -162,6 +163,7 @@ class BasePage {
|
|||||||
return await this.search(from, query);
|
return await this.search(from, query);
|
||||||
} else {
|
} else {
|
||||||
let len = 0;
|
let len = 0;
|
||||||
|
const enResult = [];
|
||||||
for (const row of queryRes.found) {
|
for (const row of queryRes.found) {
|
||||||
const value = row.value;
|
const value = row.value;
|
||||||
len += value.length;
|
len += value.length;
|
||||||
@@ -182,13 +184,20 @@ class BasePage {
|
|||||||
count: row.count,
|
count: row.count,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (query.depth > 1 || enru.has(value[0])) {
|
if (query.depth > 1 || enru.has(value[0]) ) {
|
||||||
result.push(rec);
|
//такой костыль из-за проблем с локалями в pkg
|
||||||
|
//русский язык всегда идет первым!
|
||||||
|
if (ruOnly.has(value[0]))
|
||||||
|
result.push(rec)
|
||||||
|
else
|
||||||
|
enResult.push(rec);
|
||||||
} else {
|
} else {
|
||||||
others.push(rec);
|
others.push(rec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
result = result.concat(enResult);
|
||||||
|
|
||||||
if (query[from] && query.depth > 1 && result.length < 10 && len > prevLen) {
|
if (query[from] && query.depth > 1 && result.length < 10 && len > prevLen) {
|
||||||
//рекурсия, с увеличением глубины, для облегчения навигации
|
//рекурсия, с увеличением глубины, для облегчения навигации
|
||||||
const newQuery = _.cloneDeep(query);
|
const newQuery = _.cloneDeep(query);
|
||||||
|
|||||||
Reference in New Issue
Block a user