feat(web): 虎牙账号管理界面优化 — 登录渠道区分 (Web 旧版 / App 协议 / 短信)
后端: - HuyaAccount 新增 login_channel 字段 + 迁移 20260829_0030 (启动自动升级) - 5 个登录端点成功后记录渠道: web/app 批量与单账号 + 短信 - HuyaAccountOut 输出 login_channel 前端: - 账号表新增『登录渠道』列 (App 协议/Web 旧版/短信/仅导入) - 工具栏登录按钮分组: App 协议登录(primary 推荐) 与 Web 登录(旧版, Tooltip 说明) - 行内操作新增单账号 App/Web 登录按钮 (复用批量端点传单 id) - tsc + vite build 通过
This commit is contained in:
@@ -451,6 +451,8 @@ export interface HuyaAccountItem {
|
||||
tag: string;
|
||||
remark: string;
|
||||
status: string;
|
||||
/** 上次成功登录渠道: web=旧版Web协议 / app=App协议(推荐) / sms=短信; 空=仅导入 */
|
||||
login_channel?: string;
|
||||
points: number | null;
|
||||
game_name: string;
|
||||
game_channel: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import {
|
||||
Alert, Button, Card, Col, Input, Modal, Popconfirm, Row, Select, Space, Statistic, Table, Tag, Typography,
|
||||
Alert, Button, Card, Col, Divider, Input, Modal, Popconfirm, Row, Select, Space, Statistic, Table, Tag, Tooltip, Typography,
|
||||
} from 'antd';
|
||||
import { message } from '../utils/antdMessage';
|
||||
import type { TableProps } from 'antd';
|
||||
@@ -30,6 +30,13 @@ const STATUS_LABELS: Record<string, string> = {
|
||||
invalid: '失效',
|
||||
};
|
||||
|
||||
// 登录渠道展示 (对应后端 HuyaAccount.login_channel: web/app/sms)
|
||||
const LOGIN_CHANNEL_LABELS: Record<string, { label: string; color: string }> = {
|
||||
app: { label: 'App 协议', color: 'processing' },
|
||||
web: { label: 'Web 旧版', color: 'warning' },
|
||||
sms: { label: '短信', color: 'cyan' },
|
||||
};
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
imported: 'blue',
|
||||
updated: 'cyan',
|
||||
@@ -321,6 +328,29 @@ export default function HuyaAccountsPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// 行内单账号登录: 复用批量端点, 只传该行 id (需已导入密码)
|
||||
const [rowLoginKey, setRowLoginKey] = useState('');
|
||||
const handleRowLogin = async (record: HuyaAccountItem, channel: 'app' | 'web') => {
|
||||
setRowLoginKey(`${channel}-${record.id}`);
|
||||
try {
|
||||
const payload = { account_ids: [record.id], all_matching: false, search: '', tag: '' };
|
||||
const result = channel === 'app'
|
||||
? await huyaApi.appPasswordLoginSelected(payload)
|
||||
: await huyaApi.passwordLoginSelected(payload);
|
||||
setPasswordLoginResults(result.results || []);
|
||||
setLoginModalTitle(channel === 'app' ? 'App 协议登录结果' : 'Web 旧版登录结果');
|
||||
setPasswordLoginResultOpen(true);
|
||||
const ok = (result.results || []).some((r) => r.success);
|
||||
if (ok) { message.success('登录成功,Cookie 已保存'); } else { message.warning(result.message || '登录失败'); }
|
||||
loadAccounts();
|
||||
loadSummary();
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
} finally {
|
||||
setRowLoginKey('');
|
||||
}
|
||||
};
|
||||
|
||||
const handleWebLoginSelected = async () => {
|
||||
if (selectedCount === 0) {
|
||||
message.warning('请先选择虎牙账号');
|
||||
@@ -550,6 +580,18 @@ export default function HuyaAccountsPage() {
|
||||
<Tag color={STATUS_COLORS[status] || 'default'}>{STATUS_LABELS[status] || status || '-'}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: '登录渠道',
|
||||
dataIndex: 'login_channel',
|
||||
width: 100,
|
||||
align: 'center',
|
||||
render: (channel: string) => {
|
||||
const info = LOGIN_CHANNEL_LABELS[channel];
|
||||
return info
|
||||
? <Tag color={info.color}>{info.label}</Tag>
|
||||
: <Tag>仅导入</Tag>;
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '更新时间',
|
||||
dataIndex: 'updated_at',
|
||||
@@ -558,15 +600,38 @@ export default function HuyaAccountsPage() {
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
width: 90,
|
||||
width: 150,
|
||||
fixed: 'right',
|
||||
align: 'center',
|
||||
render: (_: unknown, record) => (
|
||||
canDelete ? (
|
||||
<Popconfirm title="确认删除这条虎牙账号?" onConfirm={() => handleDelete(record.id)}>
|
||||
<Button danger size="small" icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
) : null
|
||||
<Space size={4}>
|
||||
{canImport && record.has_password && (
|
||||
<>
|
||||
<Tooltip title="App 协议登录此账号 (推荐)">
|
||||
<Button
|
||||
size="small"
|
||||
type="primary"
|
||||
icon={<MobileOutlined />}
|
||||
loading={rowLoginKey === `app-${record.id}`}
|
||||
onClick={() => handleRowLogin(record, 'app')}
|
||||
/>
|
||||
</Tooltip>
|
||||
<Tooltip title="Web 旧版协议登录此账号">
|
||||
<Button
|
||||
size="small"
|
||||
icon={<LoginOutlined />}
|
||||
loading={rowLoginKey === `web-${record.id}`}
|
||||
onClick={() => handleRowLogin(record, 'web')}
|
||||
/>
|
||||
</Tooltip>
|
||||
</>
|
||||
)}
|
||||
{canDelete && (
|
||||
<Popconfirm title="确认删除这条虎牙账号?" onConfirm={() => handleDelete(record.id)}>
|
||||
<Button danger size="small" icon={<DeleteOutlined />} />
|
||||
</Popconfirm>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
@@ -605,27 +670,33 @@ export default function HuyaAccountsPage() {
|
||||
批量打标签
|
||||
</Button>
|
||||
)}
|
||||
{canImport && <Divider type="vertical" />}
|
||||
{canImport && (
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={selectedCount === 0}
|
||||
icon={<MobileOutlined />}
|
||||
loading={appPasswordLogging}
|
||||
onClick={handleAppLoginSelected}
|
||||
>
|
||||
App 登录选中 ({selectedCount})
|
||||
</Button>
|
||||
<Tooltip title="App 协议登录: 自动注册设备环境并过滑块, 推荐; 登录渠道将记为 App">
|
||||
<Button
|
||||
type="primary"
|
||||
disabled={selectedCount === 0}
|
||||
icon={<MobileOutlined />}
|
||||
loading={appPasswordLogging}
|
||||
onClick={handleAppLoginSelected}
|
||||
>
|
||||
App 协议登录 ({selectedCount})
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{canImport && (
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<LoginOutlined />}
|
||||
loading={passwordLogging}
|
||||
onClick={handleWebLoginSelected}
|
||||
>
|
||||
Web 登录 (旧版)
|
||||
</Button>
|
||||
<Tooltip title="旧版 Web 协议登录, 仅作兜底; 新账号请优先使用 App 协议登录">
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<LoginOutlined />}
|
||||
loading={passwordLogging}
|
||||
onClick={handleWebLoginSelected}
|
||||
>
|
||||
Web 登录 (旧版)
|
||||
</Button>
|
||||
</Tooltip>
|
||||
)}
|
||||
{canImport && <Divider type="vertical" />}
|
||||
{canDelete && selectedCount > 0 && (
|
||||
<Popconfirm title={`确认删除${selectedAllMatching ? '当前筛选下' : '选中的'} ${selectedCount} 条虎牙账号?`} onConfirm={handleDeleteSelected}>
|
||||
<Button danger icon={<DeleteOutlined />}>
|
||||
|
||||
Reference in New Issue
Block a user