mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-04-18 11:49:32 +08:00
feat: 正则排序支持顺序/倒序/原顺序(前端 > 2.15.10)
This commit is contained in:
parent
80955aa339
commit
e0c6cc4453
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.19.10",
|
||||
"version": "2.19.11",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -284,7 +284,15 @@ function SortOperator(order = 'asc') {
|
||||
}
|
||||
|
||||
// sort by regex
|
||||
function RegexSortOperator(expressions) {
|
||||
function RegexSortOperator(input) {
|
||||
const order = input.order || 'asc';
|
||||
let expressions = input.expressions;
|
||||
if (Array.isArray(input)) {
|
||||
expressions = input;
|
||||
}
|
||||
if (!Array.isArray(expressions)) {
|
||||
expressions = [];
|
||||
}
|
||||
return {
|
||||
name: 'Regex Sort Operator',
|
||||
func: (proxies) => {
|
||||
@ -295,8 +303,13 @@ function RegexSortOperator(expressions) {
|
||||
if (oA && !oB) return -1;
|
||||
if (oB && !oA) return 1;
|
||||
if (oA && oB) return oA < oB ? -1 : 1;
|
||||
if ((!oA && !oB) || (oA && oB && oA === oB))
|
||||
return a.name < b.name ? -1 : 1; // fallback to normal sort
|
||||
if (order === 'original') {
|
||||
return 0;
|
||||
} else if (order === 'desc') {
|
||||
return a.name < b.name ? 1 : -1;
|
||||
} else {
|
||||
return a.name < b.name ? -1 : 1;
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user