From df5b94bdb49927b3b4bb9afcd329d6a4ef1fa6da Mon Sep 17 00:00:00 2001 From: Linkon <116425752+Linkon-lcw@users.noreply.github.com> Date: Sun, 18 Jan 2026 20:36:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8B=86=E5=88=86=20sidebar=20?= =?UTF-8?q?=E5=92=8C=E5=86=85=E5=AE=B9=E5=8C=BA=E4=B8=BA=E7=8B=AC=E7=AB=8B?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/src/App.tsx | 116 +++----------------- src/renderer/src/components/ContentArea.tsx | 103 +++++++++++++++++ src/renderer/src/components/Sidebar.tsx | 85 ++++++++++++++ 3 files changed, 201 insertions(+), 103 deletions(-) create mode 100644 src/renderer/src/components/ContentArea.tsx create mode 100644 src/renderer/src/components/Sidebar.tsx diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index d218bcc..a295f92 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -1,18 +1,11 @@ -import { Layout, Menu, Space, Dialog, Input, Button, Tag, MessagePlugin } from 'tdesign-react' +import { Layout, Dialog, Input, MessagePlugin } from 'tdesign-react' import { useEffect, useMemo, useState } from 'react' -import { UserIcon, SettingIcon, HistoryIcon, RootListIcon, ViewListIcon } from 'tdesign-icons-react' -import { HashRouter, Navigate, Route, Routes, useLocation, useNavigate } from 'react-router-dom' -import { StudentManager } from './components/StudentManager' -import { Settings } from './components/Settings' -import { ReasonManager } from './components/ReasonManager' -import { ScoreManager } from './components/ScoreManager' -import { Leaderboard } from './components/Leaderboard' -import { SettlementHistory } from './components/SettlementHistory' +import { HashRouter, useLocation, useNavigate } from 'react-router-dom' +import { Sidebar } from './components/Sidebar' +import { ContentArea } from './components/ContentArea' import { Wizard } from './components/Wizard' import { ThemeProvider } from './contexts/ThemeContext' -const { Header, Content, Aside } = Layout - function MainContent(): React.JSX.Element { const navigate = useNavigate() const location = useLocation() @@ -95,99 +88,16 @@ function MainContent(): React.JSX.Element { if (key === 'settings') navigate('/settings') } - const permissionTag = ( - - {permission === 'admin' ? '管理权限' : permission === 'points' ? '积分权限' : '只读'} - - ) - return ( - - - - - - {permissionTag} - {hasAnyPassword && ( - <> - setAuthVisible(true)}> - 输入密码 - - - 锁定 - - > - )} - - - - - } /> - } /> - } - /> - } /> - } /> - } /> - } /> - } /> - - - + + + setAuthVisible(true)} + onLogout={logout} + /> + setWizardVisible(false)} /> void + onLogout: () => void +} + +export function ContentArea({ + permission, + hasAnyPassword, + onAuthClick, + onLogout +}: ContentAreaProps): React.JSX.Element { + const permissionTag = ( + + {permission === 'admin' ? '管理权限' : permission === 'points' ? '积分权限' : '只读'} + + ) + + return ( + + + + + + {permissionTag} + {hasAnyPassword && ( + <> + + 输入密码 + + + 锁定 + + > + )} + + + + + + + + } /> + } /> + } + /> + } /> + } /> + } /> + } /> + } /> + + + + ) +} diff --git a/src/renderer/src/components/Sidebar.tsx b/src/renderer/src/components/Sidebar.tsx new file mode 100644 index 0000000..f90b11e --- /dev/null +++ b/src/renderer/src/components/Sidebar.tsx @@ -0,0 +1,85 @@ +import { Layout, Menu } from 'tdesign-react' +import { UserIcon, SettingIcon, HistoryIcon, RootListIcon, ViewListIcon } from 'tdesign-icons-react' +import appLogo from '../assets/logo.svg' + +const { Aside } = Layout + +interface SidebarProps { + activeMenu: string + permission: 'admin' | 'points' | 'view' + onMenuChange: (value: string | number) => void +} + +export function Sidebar({ activeMenu, permission, onMenuChange }: SidebarProps): React.JSX.Element { + return ( + + ) +}