增加代理展示
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<AccountCheckBatch | null>(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%' }}
|
||||
/>
|
||||
</Col>
|
||||
<Col xs={24} md={12}>
|
||||
<Col xs={12} md={4}>
|
||||
<Text type="secondary">代理</Text>
|
||||
<div style={{ height: 32, display: 'flex', alignItems: 'center' }}>
|
||||
<Switch
|
||||
checked={useProxy}
|
||||
checkedChildren="开"
|
||||
unCheckedChildren="关"
|
||||
onChange={setUseProxy}
|
||||
disabled={isRunning}
|
||||
/>
|
||||
</div>
|
||||
</Col>
|
||||
<Col xs={24} md={8}>
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
|
||||
Reference in New Issue
Block a user