mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
fix(proxy): place timeout nodes at the end when sorting by latency
This commit is contained in:
@@ -109,12 +109,14 @@ function sortProxies(
|
||||
const list = proxies.slice();
|
||||
|
||||
if (sortType === 1) {
|
||||
list.sort((a, b) => {
|
||||
const ad = delayManager.getDelayFix(a, groupName);
|
||||
const bd = delayManager.getDelayFix(b, groupName);
|
||||
const toSortableValue = (delay: number) => {
|
||||
if (!Number.isFinite(delay) || delay <= 0) return Number.MAX_SAFE_INTEGER;
|
||||
return delay;
|
||||
};
|
||||
|
||||
if (ad === -1 || ad === -2) return 1;
|
||||
if (bd === -1 || bd === -2) return -1;
|
||||
list.sort((a, b) => {
|
||||
const ad = toSortableValue(delayManager.getDelayFix(a, groupName));
|
||||
const bd = toSortableValue(delayManager.getDelayFix(b, groupName));
|
||||
|
||||
return ad - bd;
|
||||
});
|
||||
|
||||
@@ -197,7 +197,7 @@ class DelayManager {
|
||||
formatDelay(delay: number, timeout = 10000) {
|
||||
if (delay === -1) return "-";
|
||||
if (delay === -2) return "testing";
|
||||
if (delay === 0 || (delay >= timeout && delay <= 1e5)) return "timeout";
|
||||
if (delay === 0 || (delay >= timeout && delay <= 1e5)) return "Timeout";
|
||||
if (delay > 1e5) return "Error";
|
||||
return `${delay}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user