feat: 实现账户批量导出功能和界面优化
- 新增批量导出功能,支持text模式导出账户数据 - 添加导出弹窗,支持文本全选和文件下载 - 移动刷新按钮到全局位置,统一刷新账户和统计数据 - 在统计卡片中将已导出状态计入可用账户 - 创建自定义确认对话框替换系统confirm弹窗 - 统一按钮尺寸,修复刷新和上传按钮大小不一致 - 添加已导出状态的中文映射和样式 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -2,8 +2,11 @@
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { RefreshCw } from 'lucide-react';
|
||||
import { Account } from '@/lib/types';
|
||||
import { useAccounts } from '@/lib/hooks/use-accounts';
|
||||
import { useConfirmDialog } from '@/components/ui/confirm-dialog';
|
||||
|
||||
// 组件导入
|
||||
import { StatsCards } from './accounts/stats-cards';
|
||||
@@ -14,6 +17,8 @@ import { AccountTable } from './accounts/account-table';
|
||||
import { AccountDetails } from './accounts/account-details';
|
||||
|
||||
export function AccountsManager() {
|
||||
const { showConfirm, ConfirmDialogComponent } = useConfirmDialog();
|
||||
|
||||
const {
|
||||
accounts,
|
||||
stats,
|
||||
@@ -34,6 +39,11 @@ export function AccountsManager() {
|
||||
setSelectedIds
|
||||
} = useAccounts();
|
||||
|
||||
// 全局刷新函数
|
||||
const handleGlobalRefresh = async () => {
|
||||
await Promise.all([fetchAccounts(), fetchStats()]);
|
||||
};
|
||||
|
||||
// 账户详情状态
|
||||
const [detailsDialog, setDetailsDialog] = useState(false);
|
||||
const [detailsMode, setDetailsMode] = useState<'view' | 'edit'>('view');
|
||||
@@ -55,16 +65,23 @@ export function AccountsManager() {
|
||||
|
||||
// 处理删除单个账户
|
||||
const handleDeleteAccount = async (account: Account) => {
|
||||
if (!confirm('确认删除此账户?')) return;
|
||||
|
||||
try {
|
||||
// 设置选中的账户ID
|
||||
setSelectedIds([account.id]);
|
||||
// 执行删除
|
||||
await handleBatchDelete();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete account:', error);
|
||||
}
|
||||
showConfirm({
|
||||
title: '确认删除',
|
||||
description: `确认删除账户 "${account.customId}"?此操作不可撤销。`,
|
||||
confirmText: '确认删除',
|
||||
cancelText: '取消',
|
||||
variant: 'destructive',
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
// 设置选中的账户ID
|
||||
setSelectedIds([account.id]);
|
||||
// 执行删除
|
||||
await handleBatchDelete();
|
||||
} catch (error) {
|
||||
console.error('Failed to delete account:', error);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 处理保存编辑
|
||||
@@ -114,7 +131,18 @@ export function AccountsManager() {
|
||||
<h1 className="text-3xl font-bold tracking-tight">账户管理系统</h1>
|
||||
<p className="text-muted-foreground">轻量化账户管理平台</p>
|
||||
</div>
|
||||
<AccountUpload onUpload={handleUploadAccounts} stats={stats} />
|
||||
<div className="flex items-center space-x-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={handleGlobalRefresh}
|
||||
disabled={loading}
|
||||
>
|
||||
<RefreshCw className={`h-4 w-4 mr-1 ${loading ? 'animate-spin' : ''}`} />
|
||||
刷新数据
|
||||
</Button>
|
||||
<AccountUpload onUpload={handleUploadAccounts} stats={stats} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
@@ -142,7 +170,8 @@ export function AccountsManager() {
|
||||
selectedAccounts={accounts.filter(account => selectedIds.includes(account.id))}
|
||||
stats={stats}
|
||||
onBatchUpdate={handleBatchUpdate}
|
||||
onBatchDelete={handleBatchDelete}
|
||||
onBatchDelete={() => handleBatchDelete(showConfirm)}
|
||||
onRefresh={handleGlobalRefresh}
|
||||
/>
|
||||
|
||||
{/* 账户表格 - 移除高度限制 */}
|
||||
@@ -156,7 +185,6 @@ export function AccountsManager() {
|
||||
onSelectOne={handleSelectOne}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
onRefresh={fetchAccounts}
|
||||
onView={handleViewAccount}
|
||||
onEdit={handleEditAccount}
|
||||
onDelete={handleDeleteAccount}
|
||||
@@ -176,6 +204,9 @@ export function AccountsManager() {
|
||||
onSave={handleSaveAccount}
|
||||
onDelete={handleDeleteAccount}
|
||||
/>
|
||||
|
||||
{/* 确认删除对话框 */}
|
||||
<ConfirmDialogComponent />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user