feat: 账号管理支持按账号名批量选号打标签,并支持复制账号名
This commit is contained in:
@@ -25,6 +25,8 @@ import {
|
||||
clearStoredFilters,
|
||||
} from './accounts/storage';
|
||||
import { AccountToolbar } from './accounts/components/AccountToolbar';
|
||||
import { AccountNameBatchSelector } from './accounts/components/AccountNameBatchSelector';
|
||||
import type { AccountNameMatchInfo } from './accounts/components/AccountNameBatchSelector';
|
||||
import { StatusCards } from './accounts/components/StatusCards';
|
||||
import { FilterPanel } from './accounts/components/FilterPanel';
|
||||
import { buildAccountColumns } from './accounts/components/AccountColumns';
|
||||
@@ -35,6 +37,23 @@ import {
|
||||
ExchangeRecordsModal,
|
||||
} from './accounts/components/AccountModals';
|
||||
|
||||
function parseAccountNames(raw: string): string[] {
|
||||
const names: string[] = [];
|
||||
const seen = new Set<string>();
|
||||
raw
|
||||
.replace(/\r\n/g, '\n')
|
||||
.replace(/\r/g, '\n')
|
||||
.split('\n')
|
||||
.forEach((line) => {
|
||||
const name = line.trim();
|
||||
if (name && !seen.has(name)) {
|
||||
names.push(name);
|
||||
seen.add(name);
|
||||
}
|
||||
});
|
||||
return names;
|
||||
}
|
||||
|
||||
export default function AccountsPage() {
|
||||
const navigate = useNavigate();
|
||||
const { modal } = App.useApp();
|
||||
@@ -64,6 +83,12 @@ export default function AccountsPage() {
|
||||
const [searchText, setSearchText] = useState(() => initialFilters.searchText || '');
|
||||
const [exporting, setExporting] = useState(false);
|
||||
|
||||
// 按账号名批量选号:粘贴名单 -> 匹配 ID -> 自动勾选 -> 批量改标签
|
||||
const [accountNameText, setAccountNameText] = useState('');
|
||||
const [accountNamesFilter, setAccountNamesFilter] = useState('');
|
||||
const [accountNameMatchInfo, setAccountNameMatchInfo] = useState<AccountNameMatchInfo | null>(null);
|
||||
const [accountNameMatching, setAccountNameMatching] = useState(false);
|
||||
|
||||
// 高价值资产与高级自定义筛选状态
|
||||
const [highValueFilter, setHighValueFilter] = useState<string>(() => initialFilters.highValueFilter || '');
|
||||
const [minPoints, setMinPoints] = useState<number | undefined>(() => initialFilters.minPoints);
|
||||
@@ -99,8 +124,12 @@ export default function AccountsPage() {
|
||||
setBindFilter('');
|
||||
setAssignFilter('');
|
||||
setSearchText('');
|
||||
setAccountNameText('');
|
||||
setAccountNamesFilter('');
|
||||
setAccountNameMatchInfo(null);
|
||||
resetAdvancedFiltersState();
|
||||
setCurrentPage(1);
|
||||
clearSelection();
|
||||
clearStoredFilters();
|
||||
message.success('已重置所有筛选条件');
|
||||
};
|
||||
@@ -172,6 +201,7 @@ export default function AccountsPage() {
|
||||
include_sensitive: canViewFull && sensitiveVisible,
|
||||
};
|
||||
if (tagFilter) params.tag = tagFilter;
|
||||
if (accountNamesFilter) params.account_names = accountNamesFilter;
|
||||
if (statusFilter) params.status = statusFilter;
|
||||
if (ckFilter) params.ck_status = ckFilter;
|
||||
if (failureKindFilter) params.failure_kind = failureKindFilter;
|
||||
@@ -206,6 +236,7 @@ export default function AccountsPage() {
|
||||
searchText,
|
||||
sensitiveVisible,
|
||||
tagFilter,
|
||||
accountNamesFilter,
|
||||
statusFilter,
|
||||
ckFilter,
|
||||
failureKindFilter,
|
||||
@@ -271,6 +302,7 @@ export default function AccountsPage() {
|
||||
all_matching: selectedAllMatching,
|
||||
search: searchText.trim(),
|
||||
tag: tagFilter,
|
||||
account_names: accountNamesFilter || undefined,
|
||||
status: statusFilter || undefined,
|
||||
ck_status: ckFilter || undefined,
|
||||
failure_kind: failureKindFilter || undefined,
|
||||
@@ -291,6 +323,7 @@ export default function AccountsPage() {
|
||||
selectedAllMatching,
|
||||
selectedRowKeys,
|
||||
tagFilter,
|
||||
accountNamesFilter,
|
||||
statusFilter,
|
||||
ckFilter,
|
||||
failureKindFilter,
|
||||
@@ -468,6 +501,61 @@ export default function AccountsPage() {
|
||||
roleBindStatus,
|
||||
]);
|
||||
|
||||
const handleApplyAccountNames = async () => {
|
||||
const names = parseAccountNames(accountNameText);
|
||||
if (names.length === 0) {
|
||||
message.warning('请先粘贴斗鱼账号名,每行一个');
|
||||
return;
|
||||
}
|
||||
setAccountNameMatching(true);
|
||||
try {
|
||||
const result = await accountApi.listIds({
|
||||
search: searchText.trim() || undefined,
|
||||
tag: tagFilter || undefined,
|
||||
status: statusFilter || undefined,
|
||||
ck_status: ckFilter || undefined,
|
||||
failure_kind: failureKindFilter || undefined,
|
||||
bind_status: bindFilter || undefined,
|
||||
assign_status: assignStatusParam || undefined,
|
||||
assigned_user_id: assignedUserIdParam,
|
||||
high_value_filter: highValueFilter || undefined,
|
||||
min_points: minPoints,
|
||||
max_points: maxPoints,
|
||||
min_gold: minGold,
|
||||
max_gold: maxGold,
|
||||
elite_opened: eliteOpened,
|
||||
esports_opened: esportsOpened,
|
||||
role_bind_status: roleBindStatus || undefined,
|
||||
account_names: names.join('\n'),
|
||||
});
|
||||
if (result.total === 0) {
|
||||
message.warning('没有匹配到账号,请检查账号名或当前筛选条件');
|
||||
return;
|
||||
}
|
||||
setAccountNamesFilter(names.join('\n'));
|
||||
setAccountNameMatchInfo({ submitted: names.length, matched: result.total });
|
||||
setSelectedRowKeys(result.account_ids);
|
||||
setSelectedAllMatching(false);
|
||||
setCurrentPage(1);
|
||||
const unmatched = Math.max(0, names.length - result.total);
|
||||
message.success(
|
||||
`已匹配并勾选 ${result.total} 个账号${unmatched > 0 ? `,${unmatched} 个账号名未匹配` : ''}`,
|
||||
);
|
||||
} catch (e: unknown) {
|
||||
message.error(getErrorMessage(e));
|
||||
} finally {
|
||||
setAccountNameMatching(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleClearAccountNames = () => {
|
||||
setAccountNameText('');
|
||||
setAccountNamesFilter('');
|
||||
setAccountNameMatchInfo(null);
|
||||
clearSelection();
|
||||
setCurrentPage(1);
|
||||
};
|
||||
|
||||
const handleImport = async () => {
|
||||
if (!importText.trim()) {
|
||||
message.warning('请输入账号数据');
|
||||
@@ -642,7 +730,8 @@ export default function AccountsPage() {
|
||||
);
|
||||
|
||||
const hasAnyFilter = Boolean(
|
||||
tagFilter ||
|
||||
accountNamesFilter ||
|
||||
tagFilter ||
|
||||
statusFilter ||
|
||||
ckFilter ||
|
||||
failureKindFilter ||
|
||||
@@ -750,6 +839,21 @@ export default function AccountsPage() {
|
||||
setCurrentPage={setCurrentPage}
|
||||
/>
|
||||
|
||||
<AccountNameBatchSelector
|
||||
value={accountNameText}
|
||||
onChange={setAccountNameText}
|
||||
onApply={handleApplyAccountNames}
|
||||
onClear={handleClearAccountNames}
|
||||
onOpenBatchTag={() => {
|
||||
setBatchTagInput('');
|
||||
setBatchTagVisible(true);
|
||||
}}
|
||||
loading={accountNameMatching}
|
||||
canTag={canTag}
|
||||
selectedCount={selectedCount}
|
||||
matchInfo={accountNameMatchInfo}
|
||||
/>
|
||||
|
||||
<StatusCards
|
||||
summary={summary}
|
||||
statusFilter={statusFilter}
|
||||
|
||||
Reference in New Issue
Block a user