feat: 实现账户批量导出功能和界面优化
- 新增批量导出功能,支持text模式导出账户数据 - 添加导出弹窗,支持文本全选和文件下载 - 移动刷新按钮到全局位置,统一刷新账户和统计数据 - 在统计卡片中将已导出状态计入可用账户 - 创建自定义确认对话框替换系统confirm弹窗 - 统一按钮尺寸,修复刷新和上传按钮大小不一致 - 添加已导出状态的中文映射和样式 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -46,7 +46,7 @@ export interface UseAccountsReturn {
|
||||
handleSortChange: (field: keyof Account, order: 'asc' | 'desc') => void;
|
||||
handleSelectAll: (checked: boolean) => void;
|
||||
handleSelectOne: (id: number, checked: boolean) => void;
|
||||
handleBatchDelete: () => Promise<void>;
|
||||
handleBatchDelete: (showConfirm?: (options: any) => void) => Promise<void>;
|
||||
handleBatchUpdate: (payload: Partial<Pick<Account, 'status' | 'ownerId' | 'notes' | 'platform'>>, targetIds?: number[]) => Promise<void>;
|
||||
handleUploadAccounts: (accounts: ScriptUploadItem[], ownerId: string) => Promise<void>;
|
||||
setSelectedIds: (ids: number[]) => void;
|
||||
@@ -160,22 +160,38 @@ export function useAccounts(): UseAccountsReturn {
|
||||
};
|
||||
|
||||
// 批量删除
|
||||
const handleBatchDelete = async () => {
|
||||
const handleBatchDelete = async (showConfirm?: (options: any) => void) => {
|
||||
if (selectedIds.length === 0) return;
|
||||
|
||||
if (!confirm(`确认删除 ${selectedIds.length} 个账户?`)) return;
|
||||
|
||||
try {
|
||||
const response = await apiClient.batchDeleteAccounts({ ids: selectedIds });
|
||||
if (response.code === BusinessCode.Success) {
|
||||
setSelectedIds([]);
|
||||
await fetchAccounts();
|
||||
await fetchStats();
|
||||
toast.success(`成功删除 ${response.data?.deletedCount || 0} 个账户`);
|
||||
const executeDelete = async () => {
|
||||
try {
|
||||
const response = await apiClient.batchDeleteAccounts({ ids: selectedIds });
|
||||
if (response.code === BusinessCode.Success) {
|
||||
setSelectedIds([]);
|
||||
await fetchAccounts();
|
||||
await fetchStats();
|
||||
toast.success(`成功删除 ${response.data?.deletedCount || 0} 个账户`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to delete accounts:', error);
|
||||
toast.error('删除失败,请检查网络连接后重试');
|
||||
}
|
||||
};
|
||||
|
||||
if (showConfirm) {
|
||||
showConfirm({
|
||||
title: '确认删除',
|
||||
description: `确认删除 ${selectedIds.length} 个账户?此操作不可撤销。`,
|
||||
confirmText: '确认删除',
|
||||
cancelText: '取消',
|
||||
variant: 'destructive',
|
||||
onConfirm: executeDelete
|
||||
});
|
||||
} else {
|
||||
// 如果没有提供确认函数,直接执行删除(用于兼容)
|
||||
if (confirm(`确认删除 ${selectedIds.length} 个账户?`)) {
|
||||
await executeDelete();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to delete accounts:', error);
|
||||
toast.error('删除失败,请检查网络连接后重试');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user