From 3622c664b627dca805f4af17b0cde491f982a625 Mon Sep 17 00:00:00 2001 From: CalciumIon <1808837298@qq.com> Date: Wed, 11 Dec 2024 16:11:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BE=A7=E8=BE=B9=E6=A0=8F=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E7=AB=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/src/components/HeaderBar.js | 53 ++++++++++++++--------------- web/src/components/PageLayout.js | 40 ++++++++++++++++++++++ web/src/components/SiderBar.js | 18 ++-------- web/src/context/Style/index.js | 57 ++++++++++++++++++++++++++++++++ web/src/index.js | 26 +++------------ 5 files changed, 132 insertions(+), 62 deletions(-) create mode 100644 web/src/components/PageLayout.js create mode 100644 web/src/context/Style/index.js diff --git a/web/src/components/HeaderBar.js b/web/src/components/HeaderBar.js index 43bd96f9..4b284e26 100644 --- a/web/src/components/HeaderBar.js +++ b/web/src/components/HeaderBar.js @@ -9,17 +9,19 @@ import '../index.css'; import fireworks from 'react-fireworks'; import { + IconClose, IconHelpCircle, IconHome, - IconHomeStroked, - IconKey, + IconHomeStroked, IconIndentLeft, + IconKey, IconMenu, IconNoteMoneyStroked, IconPriceTag, IconUser } from '@douyinfe/semi-icons'; -import { Avatar, Dropdown, Layout, Nav, Switch } from '@douyinfe/semi-ui'; +import { Avatar, Button, Dropdown, Layout, Nav, Switch } from '@douyinfe/semi-ui'; import { stringToColor } from '../helpers/render'; import Text from '@douyinfe/semi-ui/lib/es/typography/text'; +import { StyleContext } from '../context/Style/index.js'; // HeaderBar Buttons let headerButtons = [ @@ -36,14 +38,7 @@ let buttons = [ text: '首页', itemKey: 'home', to: '/', - // icon: , }, - // { - // text: 'Playground', - // itemKey: 'playground', - // to: '/playground', - // // icon: , - // }, ]; if (localStorage.getItem('chat_link')) { @@ -56,9 +51,9 @@ if (localStorage.getItem('chat_link')) { const HeaderBar = () => { const [userState, userDispatch] = useContext(UserContext); + const [styleState, styleDispatch] = useContext(StyleContext); let navigate = useNavigate(); - const [showSidebar, setShowSidebar] = useState(false); const systemName = getSystemName(); const logo = getLogo(); const currentDate = new Date(); @@ -70,7 +65,6 @@ const HeaderBar = () => { currentDate.getDate() <= 24); async function logout() { - setShowSidebar(false); await API.get('/api/user/logout'); showSuccess('注销成功!'); userDispatch({ type: 'logout' }); @@ -128,16 +122,25 @@ const HeaderBar = () => { selectedKeys={[]} // items={headerButtons} onSelect={(key) => {}} - header={isMobile()?{ + header={styleState.isMobile?{ logo: ( - logo + <> + { + styleState.showSider ? +