fix: provider proxy sort by delay
This commit is contained in:
parent
45fc84d8be
commit
0bb1790206
@ -59,17 +59,7 @@ const ProxyItem = (props: Props) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (!proxy) return;
|
||||
|
||||
if (!proxy.provider) {
|
||||
setDelay(delayManager.getDelay(proxy.name, groupName));
|
||||
return;
|
||||
}
|
||||
|
||||
const { history = [] } = proxy;
|
||||
if (history.length > 0) {
|
||||
// 0ms以error显示
|
||||
setDelay(history[history.length - 1].delay || 1e6);
|
||||
}
|
||||
setDelay(delayManager.getDelayFix(proxy, groupName));
|
||||
}, [proxy]);
|
||||
|
||||
const onDelay = useLockFn(async () => {
|
||||
|
@ -61,7 +61,7 @@ function filterProxies(
|
||||
symbol2 === "error" ? 1e5 : symbol2 === "timeout" ? 3000 : +symbol2;
|
||||
|
||||
return proxies.filter((p) => {
|
||||
const delay = delayManager.getDelay(p.name, groupName);
|
||||
const delay = delayManager.getDelayFix(p, groupName);
|
||||
|
||||
if (delay < 0) return false;
|
||||
if (symbol === "=" && symbol2 === "error") return delay >= 1e5;
|
||||
@ -98,8 +98,8 @@ function sortProxies(
|
||||
|
||||
if (sortType === 1) {
|
||||
list.sort((a, b) => {
|
||||
const ad = delayManager.getDelay(a.name, groupName);
|
||||
const bd = delayManager.getDelay(b.name, groupName);
|
||||
const ad = delayManager.getDelayFix(a, groupName);
|
||||
const bd = delayManager.getDelayFix(b, groupName);
|
||||
|
||||
if (ad === -1 || ad === -2) return 1;
|
||||
if (bd === -1 || bd === -2) return -1;
|
||||
|
@ -55,6 +55,17 @@ class DelayManager {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// 暂时修复provider的节点延迟排序的问题
|
||||
getDelayFix(proxy: ApiType.ProxyItem, group: string) {
|
||||
if (!proxy.provider) return this.getDelay(proxy.name, group);
|
||||
|
||||
if (proxy.history.length > 0) {
|
||||
// 0ms以error显示
|
||||
return proxy.history[proxy.history.length - 1].delay || 1e6;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
async checkDelay(name: string, group: string) {
|
||||
let delay = -1;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user