From e267781ab63b2bc1bdafaa5917225c67b7d86979 Mon Sep 17 00:00:00 2001 From: ShukeBta <272197458+ShukeBta@users.noreply.github.com> Date: Wed, 24 Jun 2026 23:19:22 +0800 Subject: [PATCH] refactor: split sites page sections --- web/src/pages/SitesPage.tsx | 90 ++++------------------ web/src/pages/SitesPageSections.tsx | 113 ++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+), 76 deletions(-) create mode 100644 web/src/pages/SitesPageSections.tsx diff --git a/web/src/pages/SitesPage.tsx b/web/src/pages/SitesPage.tsx index 7659a89..d26fd1a 100644 --- a/web/src/pages/SitesPage.tsx +++ b/web/src/pages/SitesPage.tsx @@ -1,10 +1,8 @@ import { type FormEvent, useEffect, useState } from "react"; import toast from "react-hot-toast"; -import { Globe, Plus, RefreshCw } from "lucide-react"; import { sitesAPI } from "../api/sites"; import type { Site } from "../types"; -import { ManagementShortcuts } from "../components/ManagementShortcuts"; import { confirmAction } from "../components/confirmAction"; import { @@ -12,8 +10,12 @@ import { siteFormToPayload, siteToForm, } from "./sitesPageModel"; -import { SiteCard } from "./SiteCard"; import { SiteFormModal } from "./SiteFormModal"; +import { + SitesGrid, + SitesManagementShortcuts, + SitesPageHeader, +} from "./SitesPageSections"; function apiErrorMessage(err: unknown, fallback: string): string { const data = (err as { response?: { data?: { message?: string; error?: string } } }) @@ -152,81 +154,17 @@ export function SitesPage() { return (
- + + -
-

- 站点管理 -

- -
- -
- {sites.map((site) => ( - handleTest(site.id)} - onEdit={() => openEdit(site.id)} - onDelete={() => handleDelete(site)} - /> - ))} - - {!loading && sites.length === 0 && ( -
- -

暂无站点

-

- 点击「添加站点」添加 PT/BT 站点 -

-
- )} - - {loading && ( -
- -

加载中...

-
- )} -
- {showModal && ( + ); +} + +export function SitesPageHeader({ onCreate }: { onCreate: () => void }) { + return ( +
+

+ 站点管理 +

+ +
+ ); +} + +export function SitesGrid({ + sites, + loading, + testingId, + onTest, + onEdit, + onDelete, +}: { + sites: Site[]; + loading: boolean; + testingId: string | null; + onTest: (id: string) => void; + onEdit: (id: string) => void; + onDelete: (site: Site) => void; +}) { + return ( +
+ {sites.map((site) => ( + onTest(site.id)} + onEdit={() => onEdit(site.id)} + onDelete={() => onDelete(site)} + /> + ))} + + {!loading && sites.length === 0 && } + {loading && } +
+ ); +} + +function SitesEmptyState() { + return ( +
+ +

暂无站点

+

+ 点击「添加站点」添加 PT/BT 站点 +

+
+ ); +} + +function SitesLoadingState() { + return ( +
+ +

加载中...

+
+ ); +}