feat(douyu): 支持账号批量撤回并刷新未分配状态
新增按勾选或标签批量撤回账号归属,撤回只处理确实已分配的账号。账号管理和分配管理增加可见时自动刷新、窗口聚焦刷新及手动刷新,解决批量登录完成后未分配账号延迟出现。
This commit is contained in:
@@ -1,4 +1,15 @@
|
||||
import { Modal, Button, Input, Select, Typography, Table, Spin, Space } from 'antd';
|
||||
import {
|
||||
Modal,
|
||||
Alert,
|
||||
Button,
|
||||
Input,
|
||||
Select,
|
||||
Typography,
|
||||
Table,
|
||||
Spin,
|
||||
Space,
|
||||
Radio,
|
||||
} from 'antd';
|
||||
import type { AccountItem, AccountExchangeRecords, SupportUserItem } from '../../../api/modules';
|
||||
import { EXCHANGE_SCOPES, EXCHANGE_COLUMNS } from '../types';
|
||||
|
||||
@@ -116,6 +127,115 @@ export interface BatchAssignModalProps {
|
||||
onBatchAssign: (target: number | null) => void;
|
||||
}
|
||||
|
||||
export type BatchUnassignMode = 'selected' | 'tag';
|
||||
|
||||
export interface BatchUnassignModalProps {
|
||||
open: boolean;
|
||||
onCancel: () => void;
|
||||
onConfirm: () => void;
|
||||
unassigning: boolean;
|
||||
selectedCount: number;
|
||||
selectedAllMatching: boolean;
|
||||
mode: BatchUnassignMode;
|
||||
setMode: (mode: BatchUnassignMode) => void;
|
||||
tag: string;
|
||||
setTag: (tag: string) => void;
|
||||
tags: string[];
|
||||
tagCount: number | null;
|
||||
tagCountLoading: boolean;
|
||||
}
|
||||
|
||||
export function BatchUnassignModal({
|
||||
open,
|
||||
onCancel,
|
||||
onConfirm,
|
||||
unassigning,
|
||||
selectedCount,
|
||||
selectedAllMatching,
|
||||
mode,
|
||||
setMode,
|
||||
tag,
|
||||
setTag,
|
||||
tags,
|
||||
tagCount,
|
||||
tagCountLoading,
|
||||
}: BatchUnassignModalProps) {
|
||||
const noSelection = selectedCount === 0;
|
||||
const noTag = !tag.trim();
|
||||
const noTagMatch = mode === 'tag' && tagCount === 0;
|
||||
const description = selectedAllMatching
|
||||
? `当前筛选下全部 ${selectedCount} 个账号`
|
||||
: `已勾选的 ${selectedCount} 个账号`;
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title="批量撤回已分配账号"
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
confirmLoading={unassigning}
|
||||
okText="确认撤回"
|
||||
okButtonProps={{
|
||||
danger: true,
|
||||
disabled: (mode === 'selected' && noSelection) || (mode === 'tag' && (noTag || noTagMatch)),
|
||||
}}
|
||||
onOk={onConfirm}
|
||||
width={480}
|
||||
>
|
||||
<Space direction="vertical" size={14} style={{ width: '100%' }}>
|
||||
<Alert
|
||||
type="warning"
|
||||
showIcon
|
||||
message="撤回只会清空账号归属,不会删除账号或 CK。"
|
||||
description="撤回后的账号会回到「未分配」。未通过登录、没有 CK 的账号不会出现在分配管理页的未分配池中。"
|
||||
/>
|
||||
|
||||
<Radio.Group
|
||||
value={mode}
|
||||
onChange={(event) => setMode(event.target.value as BatchUnassignMode)}
|
||||
style={{ display: 'flex', gap: 20 }}
|
||||
>
|
||||
<Radio value="selected" disabled={noSelection}>
|
||||
勾选/当前筛选账号
|
||||
</Radio>
|
||||
<Radio value="tag" disabled={tags.length === 0}>
|
||||
按标签撤回
|
||||
</Radio>
|
||||
</Radio.Group>
|
||||
|
||||
{mode === 'selected' ? (
|
||||
<Text>
|
||||
{noSelection ? '请先勾选账号,或先点「全选当前筛选」。' : `将撤回${description}的分配归属。`}
|
||||
</Text>
|
||||
) : (
|
||||
<Space direction="vertical" size={8} style={{ width: '100%' }}>
|
||||
<Select
|
||||
showSearch
|
||||
allowClear
|
||||
optionFilterProp="label"
|
||||
style={{ width: '100%' }}
|
||||
placeholder="选择要撤回的账号标签"
|
||||
value={tag || undefined}
|
||||
onChange={(value) => setTag(value || '')}
|
||||
options={tags.map((item) => ({ value: item, label: item }))}
|
||||
/>
|
||||
<Text type="secondary">
|
||||
{!tag
|
||||
? '选择标签后会统计该标签下当前仍处于已分配状态的账号。'
|
||||
: tagCountLoading
|
||||
? '正在统计该标签下的已分配账号…'
|
||||
: tagCount === null
|
||||
? '暂时无法统计,仍可提交后由后端确认。'
|
||||
: tagCount === 0
|
||||
? `标签「${tag}」下没有已分配账号。`
|
||||
: `标签「${tag}」下共有 ${tagCount} 个已分配账号,将全部撤回。`}
|
||||
</Text>
|
||||
</Space>
|
||||
)}
|
||||
</Space>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
export function BatchAssignModal({
|
||||
open,
|
||||
onCancel,
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
ThunderboltOutlined,
|
||||
ImportOutlined,
|
||||
ClearOutlined,
|
||||
ReloadOutlined,
|
||||
UndoOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import {
|
||||
CK_OPTIONS,
|
||||
@@ -46,6 +48,7 @@ export interface AccountToolbarProps {
|
||||
onOpenBatchTag: () => void;
|
||||
canAssign: boolean;
|
||||
onOpenBatchAssign: () => void;
|
||||
onOpenBatchUnassign: () => void;
|
||||
canDelete: boolean;
|
||||
selectedAllMatching: boolean;
|
||||
onBatchDelete: () => void;
|
||||
@@ -54,6 +57,8 @@ export interface AccountToolbarProps {
|
||||
onBatchOverview: () => void;
|
||||
canImport: boolean;
|
||||
onOpenImport: () => void;
|
||||
onRefresh: () => void;
|
||||
refreshing: boolean;
|
||||
setCurrentPage: (page: number) => void;
|
||||
}
|
||||
|
||||
@@ -84,6 +89,7 @@ export function AccountToolbar({
|
||||
onOpenBatchTag,
|
||||
canAssign,
|
||||
onOpenBatchAssign,
|
||||
onOpenBatchUnassign,
|
||||
canDelete,
|
||||
selectedAllMatching,
|
||||
onBatchDelete,
|
||||
@@ -92,6 +98,8 @@ export function AccountToolbar({
|
||||
onBatchOverview,
|
||||
canImport,
|
||||
onOpenImport,
|
||||
onRefresh,
|
||||
refreshing,
|
||||
setCurrentPage,
|
||||
}: AccountToolbarProps) {
|
||||
return (
|
||||
@@ -205,6 +213,9 @@ export function AccountToolbar({
|
||||
{sensitiveVisible ? '隐藏凭据' : '显示凭据'}
|
||||
</Button>
|
||||
)}
|
||||
<Button icon={<ReloadOutlined />} loading={refreshing} onClick={onRefresh}>
|
||||
刷新
|
||||
</Button>
|
||||
{canTag && (
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
@@ -215,13 +226,23 @@ export function AccountToolbar({
|
||||
</Button>
|
||||
)}
|
||||
{canAssign && (
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<UsergroupAddOutlined />}
|
||||
onClick={onOpenBatchAssign}
|
||||
>
|
||||
批量分配
|
||||
</Button>
|
||||
<>
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<UsergroupAddOutlined />}
|
||||
onClick={onOpenBatchAssign}
|
||||
>
|
||||
批量分配
|
||||
</Button>
|
||||
<Button
|
||||
disabled={selectedCount === 0 && tags.length === 0}
|
||||
icon={<UndoOutlined />}
|
||||
onClick={onOpenBatchUnassign}
|
||||
title="可撤回勾选账号,也可按标签撤回全部已分配账号"
|
||||
>
|
||||
批量撤回
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
{canDelete && (
|
||||
<Popconfirm
|
||||
|
||||
Reference in New Issue
Block a user