From af3b4ba8f433b150773b927435b26cd7e22392b1 Mon Sep 17 00:00:00 2001 From: wangziqi Date: Mon, 6 Jul 2026 00:05:48 +0800 Subject: [PATCH] feat: add useCampus hook and CampusSwitcher component --- apps/admin/src/components/CampusSwitcher.tsx | 36 ++++++++++++++++++ apps/admin/src/hooks/useCampus.ts | 40 ++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 apps/admin/src/components/CampusSwitcher.tsx create mode 100644 apps/admin/src/hooks/useCampus.ts diff --git a/apps/admin/src/components/CampusSwitcher.tsx b/apps/admin/src/components/CampusSwitcher.tsx new file mode 100644 index 0000000..9104a70 --- /dev/null +++ b/apps/admin/src/components/CampusSwitcher.tsx @@ -0,0 +1,36 @@ +import React from 'react'; +import { Select, Typography } from 'antd'; +import { EnvironmentOutlined } from '@ant-design/icons'; +import { useCampus } from '../hooks/useCampus'; + +const CampusSwitcher: React.FC = () => { + const { campuses, currentId, switchCampus, loading } = useCampus(); + + if (campuses.length <= 1) { + return ( + + + {campuses[0]?.name || '主校区'} + + ); + } + + const options = [ + ...campuses.map((c) => ({ value: String(c.id), label: c.name })), + { value: '', label: '全部校区' }, + ]; + + return ( +