fix(proxy): place timeout nodes at the end when sorting by latency

This commit is contained in:
Slinetrac
2025-10-16 11:51:57 +08:00
parent 41bc0e62a1
commit 88cde5d99d
2 changed files with 8 additions and 6 deletions

View File

@@ -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;
});

View File

@@ -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}`;
}