修复虎牙注册续跑逻辑:默认从停止处继续,不重试已失败项
「继续未完成」只跑 pending/stopped;另提供「重试失败」可选重跑 error。避免大批量中途停止后把失败号全部再跑一遍。
This commit is contained in:
@@ -224,6 +224,8 @@ export interface HuyaAutoRegisterRequest {
|
||||
}
|
||||
|
||||
export interface HuyaAutoRegisterRetryRequest {
|
||||
/** continue=从停止处继续(默认,不重试失败);retry_failed=只重试失败;all_unfinished=失败+未完成 */
|
||||
mode?: 'continue' | 'retry_failed' | 'all_unfinished';
|
||||
concurrency?: number;
|
||||
wait_seconds?: number;
|
||||
poll_interval?: number;
|
||||
|
||||
@@ -145,12 +145,34 @@ export default function HuyaRegisterPage() {
|
||||
|
||||
const batchId = batch?.batch_id || '';
|
||||
const isRunning = !!batch && batch.status === 'running';
|
||||
const hasUnfinished = !!batch && (
|
||||
(batch.failed_count || 0) + (batch.stopped_count || 0) > 0
|
||||
|| (batch.items || []).some((item) => item.status !== 'success')
|
||||
|| ((batch.success_count || 0) < (batch.total || 0))
|
||||
);
|
||||
const canRetry = !!batch && !isRunning && hasUnfinished
|
||||
// 默认可「继续」的条目:未开始/已停止/中断中(不含 error、success)
|
||||
const resumableCount = useMemo(() => {
|
||||
if (!batch?.items?.length) {
|
||||
// 摘要无明细时:用 停止数 + (总数-成功-失败-停止) 估算未完成
|
||||
const total = batch?.total || 0;
|
||||
const success = batch?.success_count || 0;
|
||||
const failed = batch?.failed_count || 0;
|
||||
const stopped = batch?.stopped_count || 0;
|
||||
return Math.max(0, stopped + (total - success - failed - stopped));
|
||||
}
|
||||
return batch.items.filter((item) => (
|
||||
item.status === 'pending'
|
||||
|| item.status === 'stopped'
|
||||
|| item.status === 'sending'
|
||||
|| item.status === 'waiting'
|
||||
|| item.status === 'changing'
|
||||
|| item.status === 'logging'
|
||||
)).length;
|
||||
}, [batch]);
|
||||
|
||||
const failedCount = useMemo(() => {
|
||||
if (!batch?.items?.length) return batch?.failed_count || 0;
|
||||
return batch.items.filter((item) => item.status === 'error').length;
|
||||
}, [batch]);
|
||||
|
||||
const canContinue = !!batch && !isRunning && resumableCount > 0
|
||||
&& (RETRYABLE_BATCH.has(batch.status) || batch.status === 'pending');
|
||||
const canRetryFailed = !!batch && !isRunning && failedCount > 0
|
||||
&& (RETRYABLE_BATCH.has(batch.status) || batch.status === 'pending');
|
||||
|
||||
const loadBatchById = useCallback(async (id: string) => {
|
||||
@@ -257,13 +279,6 @@ export default function HuyaRegisterPage() {
|
||||
[batch],
|
||||
);
|
||||
|
||||
const retryableCount = useMemo(() => {
|
||||
if (!batch?.items?.length) {
|
||||
return (batch?.failed_count || 0) + (batch?.stopped_count || 0);
|
||||
}
|
||||
return batch.items.filter((item) => item.status !== 'success').length;
|
||||
}, [batch]);
|
||||
|
||||
const handleStart = async () => {
|
||||
if (!text.trim()) {
|
||||
message.warning('请先粘贴手机号池');
|
||||
@@ -309,20 +324,38 @@ export default function HuyaRegisterPage() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleRetry = async () => {
|
||||
const buildRetryPayload = (mode: 'continue' | 'retry_failed' | 'all_unfinished' = 'continue') => ({
|
||||
mode,
|
||||
concurrency,
|
||||
wait_seconds: waitSeconds,
|
||||
poll_interval: pollInterval,
|
||||
password_prefix: passwordMode === 'random' ? (passwordPrefix.trim() || 'hy') : undefined,
|
||||
fixed_password: passwordMode === 'fixed' ? fixedPassword.trim() : undefined,
|
||||
use_proxy: useProxy,
|
||||
});
|
||||
|
||||
const handleContinue = async () => {
|
||||
if (!batchId) return;
|
||||
setRetrying(true);
|
||||
try {
|
||||
const data = await huyaApi.retryAutoRegisterBatch(batchId, {
|
||||
concurrency,
|
||||
wait_seconds: waitSeconds,
|
||||
poll_interval: pollInterval,
|
||||
password_prefix: passwordMode === 'random' ? (passwordPrefix.trim() || 'hy') : undefined,
|
||||
fixed_password: passwordMode === 'fixed' ? fixedPassword.trim() : undefined,
|
||||
use_proxy: useProxy,
|
||||
});
|
||||
const data = await huyaApi.retryAutoRegisterBatch(batchId, buildRetryPayload('continue'));
|
||||
setBatch(data);
|
||||
message.success(`已开始续跑 ${retryableCount} 条失败/未完成项`);
|
||||
message.success(`已从停止处继续,处理 ${resumableCount} 条未完成号码(跳过已成功/已失败)`);
|
||||
loadHistory();
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
} finally {
|
||||
setRetrying(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleRetryFailed = async () => {
|
||||
if (!batchId) return;
|
||||
setRetrying(true);
|
||||
try {
|
||||
const data = await huyaApi.retryAutoRegisterBatch(batchId, buildRetryPayload('retry_failed'));
|
||||
setBatch(data);
|
||||
message.success(`已开始重试 ${failedCount} 条失败号码`);
|
||||
loadHistory();
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
@@ -484,13 +517,14 @@ export default function HuyaRegisterPage() {
|
||||
try {
|
||||
setRetrying(true);
|
||||
const data = await huyaApi.retryAutoRegisterBatch(row.batch_id, {
|
||||
mode: 'continue',
|
||||
concurrency,
|
||||
wait_seconds: waitSeconds,
|
||||
poll_interval: pollInterval,
|
||||
use_proxy: useProxy,
|
||||
});
|
||||
setBatch(data);
|
||||
message.success('已开始续跑失败/未完成项');
|
||||
message.success('已从停止处继续未完成号码');
|
||||
loadHistory();
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
@@ -499,7 +533,7 @@ export default function HuyaRegisterPage() {
|
||||
}
|
||||
}}
|
||||
>
|
||||
续跑
|
||||
继续
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
@@ -670,10 +704,17 @@ export default function HuyaRegisterPage() {
|
||||
<Button
|
||||
icon={<RedoOutlined />}
|
||||
loading={retrying}
|
||||
disabled={!canRetry}
|
||||
onClick={handleRetry}
|
||||
disabled={!canContinue}
|
||||
onClick={handleContinue}
|
||||
>
|
||||
续跑失败项{retryableCount > 0 ? ` (${retryableCount})` : ''}
|
||||
继续未完成{resumableCount > 0 ? ` (${resumableCount})` : ''}
|
||||
</Button>
|
||||
<Button
|
||||
loading={retrying}
|
||||
disabled={!canRetryFailed}
|
||||
onClick={handleRetryFailed}
|
||||
>
|
||||
重试失败{failedCount > 0 ? ` (${failedCount})` : ''}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<DownloadOutlined />}
|
||||
@@ -686,7 +727,7 @@ export default function HuyaRegisterPage() {
|
||||
</Col>
|
||||
</Row>
|
||||
<Text type="secondary">
|
||||
成功账号会立即写入数据库成功流水;服务重启后可从历史批次查看并续跑失败项。换电脑登录同一服务即可导出 txt。
|
||||
「继续未完成」从停止处往下跑,跳过已成功和已失败;需要重跑失败号再用「重试失败」。成功账号会立即写入流水,换电脑也可导出 txt。
|
||||
</Text>
|
||||
</Space>
|
||||
</Card>
|
||||
|
||||
Reference in New Issue
Block a user