From 85fc3a8564e89f457166867c21ff654ab6bdf41f 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: Mon, 11 Nov 2024 18:42:07 +0800 Subject: [PATCH] fix rotation mode --- you_providers/youProvider.mjs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/you_providers/youProvider.mjs b/you_providers/youProvider.mjs index 8344476..d69b1dc 100644 --- a/you_providers/youProvider.mjs +++ b/you_providers/youProvider.mjs @@ -33,8 +33,8 @@ class YouProvider { }; // 记录可用状态 this.switchCounter = 0; this.requestsInCurrentMode = 0; - this.switchThreshold = this.getRandomSwitchThreshold(); this.lastDefaultThreshold = 0; // 记录上一次default的阈值 + this.switchThreshold = this.getRandomSwitchThreshold(); this.networkMonitor = new NetworkMonitor(); this.isTeamAccount = false; // 是否为Team账号 } @@ -43,8 +43,16 @@ class YouProvider { if (this.currentMode === "default") { return Math.floor(Math.random() * 3) + 1; } else { - // custom模式回合不小于上一次default - return Math.floor(Math.random() * (4 - this.lastDefaultThreshold)) + this.lastDefaultThreshold; + const minThreshold = this.lastDefaultThreshold || 1; + const maxThreshold = 4; + const range = maxThreshold - minThreshold; + + if (range <= 0) { + this.lastDefaultThreshold = 1; + } + // 重新计算范围 + const adjustedRange = maxThreshold - this.lastDefaultThreshold; + return Math.floor(Math.random() * adjustedRange) + this.lastDefaultThreshold; } }