feat: 账号管理支持按账号名批量选号打标签,并支持复制账号名
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import type { TableProps } from 'antd';
|
||||
import { Space, Button, Typography, Tag, Tooltip, Select, Popconfirm } from 'antd';
|
||||
import { DeleteOutlined } from '@ant-design/icons';
|
||||
import { CopyOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||
import type { NavigateFunction } from 'react-router-dom';
|
||||
import type { AccountItem } from '../../../api/modules';
|
||||
import { message } from '../../../utils/antdMessage';
|
||||
import { copyTextToClipboard } from '../../../utils/clipboard';
|
||||
import { formatTimeShort } from '../../../utils/time';
|
||||
import {
|
||||
type AccountSortKey,
|
||||
@@ -86,15 +88,49 @@ export function buildAccountColumns({
|
||||
ellipsis: true,
|
||||
render: (username: string, record: AccountItem) => (
|
||||
<Space direction="vertical" size={0} style={{ maxWidth: '100%' }}>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{ padding: 0, maxWidth: '100%', overflow: 'hidden', textOverflow: 'ellipsis' }}
|
||||
title={username}
|
||||
onClick={() => navigate(`/accounts/${record.id}`)}
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 2,
|
||||
maxWidth: '100%',
|
||||
minWidth: 0,
|
||||
}}
|
||||
>
|
||||
{username}
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
style={{
|
||||
padding: 0,
|
||||
minWidth: 0,
|
||||
flex: '0 1 auto',
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
title={username}
|
||||
onClick={() => navigate(`/accounts/${record.id}`)}
|
||||
>
|
||||
{username}
|
||||
</Button>
|
||||
<Tooltip title="复制账号名">
|
||||
<Button
|
||||
type="text"
|
||||
size="small"
|
||||
aria-label="复制账号名"
|
||||
icon={<CopyOutlined style={{ fontSize: 12, color: '#8c8c8c' }} />}
|
||||
style={{ padding: 0, width: 18, height: 18, minWidth: 18, flex: 'none' }}
|
||||
onClick={async () => {
|
||||
try {
|
||||
await copyTextToClipboard(username);
|
||||
message.success('账号名已复制');
|
||||
} catch {
|
||||
message.error('复制失败');
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Tooltip>
|
||||
</div>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>
|
||||
#{record.id}
|
||||
</Text>
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { Button, Card, Input, Space, Typography } from 'antd';
|
||||
import {
|
||||
CheckSquareOutlined,
|
||||
ClearOutlined,
|
||||
TagsOutlined,
|
||||
} from '@ant-design/icons';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
export interface AccountNameMatchInfo {
|
||||
submitted: number;
|
||||
matched: number;
|
||||
}
|
||||
|
||||
export interface AccountNameBatchSelectorProps {
|
||||
value: string;
|
||||
onChange: (value: string) => void;
|
||||
onApply: () => void;
|
||||
onClear: () => void;
|
||||
onOpenBatchTag: () => void;
|
||||
loading: boolean;
|
||||
canTag: boolean;
|
||||
selectedCount: number;
|
||||
matchInfo: AccountNameMatchInfo | null;
|
||||
}
|
||||
|
||||
export function AccountNameBatchSelector({
|
||||
value,
|
||||
onChange,
|
||||
onApply,
|
||||
onClear,
|
||||
onOpenBatchTag,
|
||||
loading,
|
||||
canTag,
|
||||
selectedCount,
|
||||
matchInfo,
|
||||
}: AccountNameBatchSelectorProps) {
|
||||
const unmatched = matchInfo ? matchInfo.submitted - matchInfo.matched : 0;
|
||||
|
||||
return (
|
||||
<Card
|
||||
size="small"
|
||||
title={
|
||||
<Space size={6}>
|
||||
<TagsOutlined />
|
||||
<span>按账号名批量选号</span>
|
||||
</Space>
|
||||
}
|
||||
style={{ marginBottom: 16 }}
|
||||
>
|
||||
<Space direction="vertical" style={{ width: '100%' }} size={8}>
|
||||
<Input.TextArea
|
||||
value={value}
|
||||
onChange={(event) => onChange(event.target.value)}
|
||||
placeholder="从 Excel 复制斗鱼账号名后粘贴到这里,每行一个;匹配后会自动勾选,可直接批量改标签"
|
||||
autoSize={{ minRows: 3, maxRows: 7 }}
|
||||
/>
|
||||
<Space wrap>
|
||||
<Button
|
||||
type="primary"
|
||||
icon={<CheckSquareOutlined />}
|
||||
loading={loading}
|
||||
onClick={onApply}
|
||||
>
|
||||
匹配并选中
|
||||
</Button>
|
||||
<Button
|
||||
icon={<TagsOutlined />}
|
||||
disabled={!canTag || selectedCount === 0}
|
||||
onClick={onOpenBatchTag}
|
||||
>
|
||||
批量改标签{selectedCount > 0 ? `(${selectedCount})` : ''}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<ClearOutlined />}
|
||||
disabled={!value.trim() && selectedCount === 0 && !matchInfo}
|
||||
onClick={onClear}
|
||||
>
|
||||
清空
|
||||
</Button>
|
||||
{matchInfo && (
|
||||
<Text type={unmatched > 0 ? 'warning' : 'secondary'}>
|
||||
已粘贴 {matchInfo.submitted} 个账号名,匹配到 {matchInfo.matched} 个账号
|
||||
{unmatched > 0
|
||||
? `;${unmatched} 个未匹配或不在当前筛选范围内`
|
||||
: ''}
|
||||
</Text>
|
||||
)}
|
||||
</Space>
|
||||
</Space>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user