From e4e3b8a7ead69175ded2c103a6671e61d614d2b2 Mon Sep 17 00:00:00 2001 From: TeLiu <208341024+Te0228@users.noreply.github.com> Date: Thu, 26 Nov 2026 10:18:01 +0800 Subject: [PATCH 1/3] fix(admin): unify user and group page headers --- apps/web/src/features/admin/console.tsx | 9 ++++-- apps/web/src/features/admin/groups.tsx | 43 +++++++++++-------------- apps/web/src/features/admin/page.tsx | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/web/src/features/admin/console.tsx b/apps/web/src/features/admin/console.tsx index 70bdef2..530588b 100644 --- a/apps/web/src/features/admin/console.tsx +++ b/apps/web/src/features/admin/console.tsx @@ -179,6 +179,13 @@ export function InstanceAdminPage({ {!rows.length &&

没有符合条件的任务

} ); + if (section === "users" || section === "groups") + return ( + <> + {!sidebar && } + {section === "users" ? : groups} + + ); return ( <>
@@ -395,8 +402,6 @@ export function InstanceAdminPage({ )} )} - {section === "users" && } - {section === "groups" && groups} {section === "audit" && (
diff --git a/apps/web/src/features/admin/groups.tsx b/apps/web/src/features/admin/groups.tsx index 8012510..c32bd2e 100644 --- a/apps/web/src/features/admin/groups.tsx +++ b/apps/web/src/features/admin/groups.tsx @@ -11,35 +11,36 @@ import { } from "@abridge/protocol"; import { api, objectResultSchema } from "../../lib/api.js"; import { Field, Form, Modal } from "../../components/forms.js"; +import { RefreshButton } from "./refresh-button.js"; export function GroupsPage({ notify }: { notify: (message: string) => void }) { const base = "/api/admin/groups"; const [groups, setGroups] = useState([]); const [error, setError] = useState(""); + const [loading, setLoading] = useState(true); const [creating, setCreating] = useState(false); const [selected, setSelected] = useState(null); const refresh = useCallback(async () => { - const result = await api(base, groupsListSchema); - setGroups(result.groups); + setLoading(true); + try { + const result = await api(base, groupsListSchema); + setGroups(result.groups); + setError(""); + } catch (caught) { + setError(caught instanceof Error ? caught.message : "读取小组失败"); + } finally { + setLoading(false); + } }, [base]); useEffect(() => { - let alive = true; - void api(base, groupsListSchema) - .then((r) => { - if (alive) setGroups(r.groups); - }) - .catch((e) => { - if (alive) setError(e instanceof Error ? e.message : "读取小组失败"); - }); - return () => { - alive = false; - }; - }, [base]); + void refresh(); + }, [refresh]); return ( <> -
-

全部小组

+
+

小组

+ @@ -49,13 +50,7 @@ export function GroupsPage({ notify }: { notify: (message: string) => void }) { {error && ( @@ -72,7 +67,7 @@ export function GroupsPage({ notify }: { notify: (message: string) => void }) {
))} - {!groups.length && !error &&

暂无小组

} + {!groups.length && !error && !loading &&

暂无小组

}
{creating && ( setCreating(false)}> diff --git a/apps/web/src/features/admin/page.tsx b/apps/web/src/features/admin/page.tsx index 88161a8..b767927 100644 --- a/apps/web/src/features/admin/page.tsx +++ b/apps/web/src/features/admin/page.tsx @@ -96,7 +96,7 @@ export function UserAdminPage({ return ( <>
-

实例管理

+

用户

diff --git a/apps/web/src/features/auth/page.tsx b/apps/web/src/features/auth/page.tsx index 8539320..801a04e 100644 --- a/apps/web/src/features/auth/page.tsx +++ b/apps/web/src/features/auth/page.tsx @@ -28,6 +28,16 @@ export function ExternalLogin() { ) : null; } +export function SessionLoading({ administrator = false }: { administrator?: boolean }) { + return ( +
+ +
+ ); +} export function Authentication({ phase, notice, @@ -37,15 +47,7 @@ export function Authentication({ notice: string; authenticate: (data: FormData) => Promise; }) { - if (phase === "loading") - return ( -
- -
- ); + if (phase === "loading") return ; return (