完成品

This commit is contained in:
2025-09-19 02:58:43 +08:00
parent ffa1e45f63
commit b5e8cce2f3
10 changed files with 926 additions and 16 deletions

View File

@@ -165,7 +165,7 @@ export function AppManagement() {
})
const [pagination, setPagination] = useState({
page: 1,
limit: 10,
limit: 5,
total: 0,
totalPages: 0
})
@@ -608,7 +608,7 @@ export function AppManagement() {
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-gray-600"></p>
<p className="text-2xl font-bold">{apps.length}</p>
<p className="text-2xl font-bold">{stats.totalApps}</p>
</div>
<Bot className="w-8 h-8 text-blue-600" />
</div>
@@ -620,7 +620,7 @@ export function AppManagement() {
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-gray-600"></p>
<p className="text-2xl font-bold">{apps.filter((a) => a.status === "published").length}</p>
<p className="text-2xl font-bold">{stats.activeApps}</p>
</div>
<CheckCircle className="w-8 h-8 text-green-600" />
</div>
@@ -632,7 +632,7 @@ export function AppManagement() {
<div className="flex items-center justify-between">
<div>
<p className="text-sm text-gray-600"></p>
<p className="text-2xl font-bold">{apps.filter((a) => a.status === "draft").length}</p>
<p className="text-2xl font-bold">{stats.inactiveApps}</p>
</div>
<XCircle className="w-8 h-8 text-red-600" />
</div>
@@ -695,7 +695,7 @@ export function AppManagement() {
{/* Apps Table */}
<Card>
<CardHeader>
<CardTitle> ({filteredApps.length})</CardTitle>
<CardTitle> ({pagination.total})</CardTitle>
<CardDescription> AI </CardDescription>
</CardHeader>
<CardContent>
@@ -842,6 +842,65 @@ export function AppManagement() {
</CardContent>
</Card>
{/* 分頁控制元件 */}
{pagination.totalPages > 1 && (
<div className="flex flex-col items-center space-y-4 mt-6">
<div className="text-sm text-gray-600">
{pagination.page} {pagination.totalPages} ( {pagination.total} )
</div>
<div className="flex items-center space-x-2">
<Button
variant="outline"
size="sm"
onClick={() => setPagination(prev => ({ ...prev, page: Math.max(1, prev.page - 1) }))}
disabled={pagination.page === 1}
className="flex items-center space-x-1"
>
<span></span>
<span></span>
</Button>
<div className="flex items-center space-x-1">
{Array.from({ length: Math.min(pagination.totalPages, 5) }, (_, i) => {
let page;
if (pagination.totalPages <= 5) {
page = i + 1;
} else if (pagination.page <= 3) {
page = i + 1;
} else if (pagination.page >= pagination.totalPages - 2) {
page = pagination.totalPages - 4 + i;
} else {
page = pagination.page - 2 + i;
}
return (
<Button
key={page}
variant={pagination.page === page ? "default" : "outline"}
size="sm"
onClick={() => setPagination(prev => ({ ...prev, page }))}
className="w-10 h-10 p-0"
>
{page}
</Button>
)
})}
</div>
<Button
variant="outline"
size="sm"
onClick={() => setPagination(prev => ({ ...prev, page: Math.min(prev.totalPages, prev.page + 1) }))}
disabled={pagination.page === pagination.totalPages}
className="flex items-center space-x-1"
>
<span></span>
<span></span>
</Button>
</div>
</div>
)}
{/* Add App Dialog */}
<Dialog open={showAddApp} onOpenChange={setShowAddApp}>
<DialogContent className="max-w-4xl max-h-[85vh] overflow-y-auto">