From 181cc5203b6e7ba69995618f15abe0bae5bc87f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=81=97=E5=BF=98=E7=9A=84=E8=AE=B0=E5=BF=86?= <32097237+YIWANG-sketch@users.noreply.github.com> Date: Tue, 29 Oct 2024 23:33:46 +0800 Subject: [PATCH] fix 'unusual query volume' check --- you_providers/youProvider.mjs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/you_providers/youProvider.mjs b/you_providers/youProvider.mjs index 1c87a59..49d3f70 100644 --- a/you_providers/youProvider.mjs +++ b/you_providers/youProvider.mjs @@ -529,23 +529,18 @@ class YouProvider { } checkAndSwitchMode() { - // 如果当前模式不可用,或者达到轮换阈值 - if (!this.modeStatus[this.currentMode] || (this.rotationEnabled && this.switchCounter >= this.switchThreshold)) { - console.log(`当前模式 ${this.currentMode} 已达到请求次数阈值`); + // 如果当前模式不可用 + if (!this.modeStatus[this.currentMode]) { const availableModes = Object.keys(this.modeStatus).filter(mode => this.modeStatus[mode]); if (availableModes.length === 0) { - throw new Error("两种模式达到请求上限。"); + console.log("两种模式达到请求上限。"); } else if (availableModes.length === 1) { + console.log(`当前模式 ${this.currentMode} 已达到请求次数阈值`); this.currentMode = availableModes[0]; this.rotationEnabled = false; - } else { - this.switchMode(); } - this.switchCounter = 0; - this.requestsInCurrentMode = 0; - this.switchThreshold = this.getRandomSwitchThreshold(); } } @@ -574,6 +569,9 @@ class YouProvider { this.switchCounter++; this.requestsInCurrentMode++; console.log(`当前模式: ${this.currentMode}, 本模式下的请求次数: ${this.requestsInCurrentMode}, 距离下次切换还有 ${this.switchThreshold - this.switchCounter} 次请求`); + if (this.switchCounter >= this.switchThreshold) { + this.switchMode(); + } } // 根据轮换状态决定是否使用自定义模式