From baec2ab0fb39b80b34d2fac150c829a0eded2292 Mon Sep 17 00:00:00 2001 From: yml2213 Date: Fri, 10 Jul 2026 00:21:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BB=A3=E7=90=86=E5=B1=95?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/backend/routers/account_check.py | 3 ++- web/backend/schemas.py | 2 ++ web/backend/services/account_check_service.py | 16 ++++++++++++-- web/frontend/src/api/types.ts | 2 ++ web/frontend/src/pages/AccountCheckPage.tsx | 22 +++++++++++++++++-- 5 files changed, 40 insertions(+), 5 deletions(-) diff --git a/web/backend/routers/account_check.py b/web/backend/routers/account_check.py index bb3b6f5..7900e68 100644 --- a/web/backend/routers/account_check.py +++ b/web/backend/routers/account_check.py @@ -55,13 +55,14 @@ def create_account_check_batch( if not accounts: raise HTTPException(status_code=400, detail="没有识别到有效账号") - proxy_config = db.query(ProxyConfigModel).first() + proxy_config = db.query(ProxyConfigModel).first() if req.use_proxy else None runner = account_check_registry.create( accounts=accounts, created_by=current.id, concurrency=req.concurrency, max_login_retries=req.max_login_retries, max_total_time=req.max_total_time, + use_proxy=req.use_proxy, proxy_config=proxy_config, ) thread = threading.Thread(target=runner.run, daemon=True) diff --git a/web/backend/schemas.py b/web/backend/schemas.py index 523dd8f..28cc5e4 100644 --- a/web/backend/schemas.py +++ b/web/backend/schemas.py @@ -175,6 +175,7 @@ class AccountCheckBatchRequest(BaseModel): concurrency: int = Field(3, ge=1, le=10) max_login_retries: int = Field(0, ge=0, le=50) max_total_time: float = Field(300, ge=0, le=3600) + use_proxy: bool = False class AccountCheckItemOut(BaseModel): @@ -195,6 +196,7 @@ class AccountCheckBatchOut(BaseModel): concurrency: int max_login_retries: int max_total_time: float + use_proxy: bool total: int finished_count: int running_count: int diff --git a/web/backend/services/account_check_service.py b/web/backend/services/account_check_service.py index e6a43d9..9a0db2f 100644 --- a/web/backend/services/account_check_service.py +++ b/web/backend/services/account_check_service.py @@ -93,6 +93,7 @@ class AccountCheckBatch: concurrency: int max_login_retries: int max_total_time: float + use_proxy: bool items: list[AccountCheckItemState] status: str = "pending" message: str = "等待开始" @@ -146,7 +147,12 @@ class AccountCheckRunner: def _create_proxy_fetcher(self) -> ProxyFetcher | None: """按全局代理配置创建 API 代理获取器。""" - if not self.proxy_config or not self.proxy_config.enabled or not self.proxy_config.api_url: + if ( + not self.batch.use_proxy + or not self.proxy_config + or not self.proxy_config.enabled + or not self.proxy_config.api_url + ): return None wl_platform = "xiequ" @@ -169,9 +175,12 @@ class AccountCheckRunner: def _resolve_static_proxy(self) -> tuple[dict[str, str] | None, str]: """解析静态代理;API 代理由 DouyuLogin 内部通过 proxy_fetcher 获取。""" - if not self.proxy_config or not self.proxy_config.enabled: + if not self.batch.use_proxy: return None, "" + if not self.proxy_config or not self.proxy_config.enabled: + return None, "代理不可用: 未启用代理配置" + if self.proxy_config.http or self.proxy_config.https: proxy_url = self.proxy_config.http or self.proxy_config.https return {"http": proxy_url, "https": proxy_url}, "" @@ -261,6 +270,7 @@ class AccountCheckRunner: "concurrency": self.batch.concurrency, "max_login_retries": self.batch.max_login_retries, "max_total_time": self.batch.max_total_time, + "use_proxy": self.batch.use_proxy, "total": len(self.batch.items), "finished_count": finished_count, "running_count": running_count, @@ -338,6 +348,7 @@ class AccountCheckRegistry: concurrency: int, max_login_retries: int, max_total_time: float, + use_proxy: bool = False, proxy_config: Optional[ProxyConfigModel] = None, ) -> AccountCheckRunner: batch_id = uuid.uuid4().hex[:12] @@ -348,6 +359,7 @@ class AccountCheckRegistry: concurrency=max(1, min(int(concurrency or 1), 10)), max_login_retries=normalized_retries, max_total_time=max(0.0, float(max_total_time or 0)), + use_proxy=bool(use_proxy), items=[ AccountCheckItemState( line=account.line, diff --git a/web/frontend/src/api/types.ts b/web/frontend/src/api/types.ts index a9172be..db50651 100644 --- a/web/frontend/src/api/types.ts +++ b/web/frontend/src/api/types.ts @@ -101,6 +101,7 @@ export interface AccountCheckBatchRequest { concurrency?: number; max_login_retries?: number; max_total_time?: number; + use_proxy?: boolean; } export interface AccountCheckItem { @@ -121,6 +122,7 @@ export interface AccountCheckBatch { concurrency: number; max_login_retries: number; max_total_time: number; + use_proxy: boolean; total: number; finished_count: number; running_count: number; diff --git a/web/frontend/src/pages/AccountCheckPage.tsx b/web/frontend/src/pages/AccountCheckPage.tsx index d45c7db..918f27e 100644 --- a/web/frontend/src/pages/AccountCheckPage.tsx +++ b/web/frontend/src/pages/AccountCheckPage.tsx @@ -1,6 +1,6 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { - Button, Card, Col, Input, InputNumber, message, Popconfirm, Row, Space, Statistic, Table, Tag, Typography, + Button, Card, Col, Input, InputNumber, message, Popconfirm, Row, Space, Statistic, Switch, Table, Tag, Typography, } from 'antd'; import type { TableProps } from 'antd'; import { DownloadOutlined, PlayCircleOutlined, ReloadOutlined, StopOutlined } from '@ant-design/icons'; @@ -88,6 +88,7 @@ export default function AccountCheckPage() { const [concurrency, setConcurrency] = useState(() => readStoredNumber('account_check_concurrency', 3)); const [maxTotalTime, setMaxTotalTime] = useState(() => readStoredNumber('account_check_max_total_time', 300)); const [maxLoginRetries, setMaxLoginRetries] = useState(() => readStoredNumber('account_check_max_login_retries', 0)); + const [useProxy, setUseProxy] = useState(() => localStorage.getItem('account_check_use_proxy') === 'true'); const [batch, setBatch] = useState(null); const [starting, setStarting] = useState(false); const [refreshing, setRefreshing] = useState(false); @@ -141,6 +142,10 @@ export default function AccountCheckPage() { localStorage.setItem('account_check_max_login_retries', String(maxLoginRetries)); }, [maxLoginRetries]); + useEffect(() => { + localStorage.setItem('account_check_use_proxy', String(useProxy)); + }, [useProxy]); + useEffect(() => { if (restoredBatchRef.current) return; restoredBatchRef.current = true; @@ -178,6 +183,7 @@ export default function AccountCheckPage() { concurrency, max_total_time: maxTotalTime, max_login_retries: maxLoginRetries, + use_proxy: useProxy, }); setBatch(data); localStorage.setItem(BATCH_STORAGE_KEY, data.batch_id); @@ -290,7 +296,19 @@ export default function AccountCheckPage() { style={{ width: '100%' }} /> - + + 代理 +
+ +
+ +