diff --git a/frontend/src/components/header.tsx b/frontend/src/components/header.tsx index f873707..f7e4e0d 100644 --- a/frontend/src/components/header.tsx +++ b/frontend/src/components/header.tsx @@ -28,20 +28,12 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from "@/components/ui/select"; import { toast } from "sonner"; export function Header() { const { user, logout } = useAuth(); const router = useRouter(); - const { activeClassId, activeClassName, canSwitchClass, availableClasses, setActiveClassId } = - useActiveClass(); + const { activeClassName } = useActiveClass(); const { toggle } = useSidebar(); const { unreadCount, notifications, markRead, markAllRead, refresh } = useNotifications(); const [notifOpen, setNotifOpen] = useState(false); @@ -52,9 +44,7 @@ export function Header() { const [newPassword, setNewPassword] = useState(""); const [confirmPassword, setConfirmPassword] = useState(""); const [passwordLoading, setPasswordLoading] = useState(false); - const classDescriptor = activeClassName - ? activeClassName.split(" ").slice(0, 2).join(" ") - : "香港大学中国商业学院"; + const classDescriptor = activeClassName || "香港大学中国商业学院"; const handleChangePassword = async (e: React.FormEvent) => { e.preventDefault(); @@ -99,32 +89,11 @@ export function Header() {

HKU ICB

-

+

{classDescriptor}

- {canSwitchClass ? ( - - ) : activeClassName ? ( + {activeClassName ? ( 当前班级:{activeClassName} diff --git a/frontend/src/components/sidebar.tsx b/frontend/src/components/sidebar.tsx index b598b4f..4e33eed 100644 --- a/frontend/src/components/sidebar.tsx +++ b/frontend/src/components/sidebar.tsx @@ -8,6 +8,13 @@ import { cn } from "@/lib/utils"; import type { ClassPermission, UserRole } from "@/lib/types"; import { useAuth } from "@/hooks/use-auth"; import { hasClassPermission } from "@/lib/permissions"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; const navItems = [ { href: "/dashboard", label: "首页", icon: "M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6", moduleKey: undefined }, @@ -32,7 +39,14 @@ export function Sidebar() { const pathname = usePathname(); const { isOpen, close } = useSidebar(); const { user } = useAuth(); - const { enabledModules, activeClassId } = useActiveClass(); + const { + enabledModules, + activeClassId, + activeClassName, + canSwitchClass, + availableClasses, + setActiveClassId, + } = useActiveClass(); const visibleAdminItems = user ? adminItems.filter((item) => { if (!item.roles.includes(user.role)) return false; @@ -75,6 +89,39 @@ export function Sidebar() {

香港大学中国商业学院

HKU ICB

+ {activeClassName && ( +
+

+ 当前班级 +

+

+ {activeClassName} +

+ {canSwitchClass && availableClasses.length > 1 && ( +
+ +
+ )} +
+ )}