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: (
-
+ <>
+ {
+ styleState.showSider ?
+ } theme="light" style={{ marginRight: 10 }} aria-label="展开侧边栏" onClick={
+ () => styleDispatch({ type: 'SET_SIDER', payload: false })
+ } />:
+ } theme="light" style={{ marginRight: 10 }} aria-label="关闭侧边栏" onClick={
+ () => styleDispatch({ type: 'SET_SIDER', payload: true })
+ } />
+ }
+ >
),
}:{
logo: (
),
text: systemName,
-
}}
items={buttons}
footer={
@@ -159,17 +162,15 @@ const HeaderBar = () => {
)}
} />
<>
- {!isMobile() && (
- {
- setTheme(checked);
- }}
- />
- )}
+ {
+ setTheme(checked);
+ }}
+ />
>
{userState.user ? (
<>
diff --git a/web/src/components/PageLayout.js b/web/src/components/PageLayout.js
new file mode 100644
index 00000000..06f31f06
--- /dev/null
+++ b/web/src/components/PageLayout.js
@@ -0,0 +1,40 @@
+import HeaderBar from './HeaderBar.js';
+import { Layout } from '@douyinfe/semi-ui';
+import SiderBar from './SiderBar.js';
+import App from '../App.js';
+import FooterBar from './Footer.js';
+import { ToastContainer } from 'react-toastify';
+import React, { useContext } from 'react';
+import { StyleContext } from '../context/Style/index.js';
+const { Sider, Content, Header, Footer } = Layout;
+
+
+const PageLayout = () => {
+ const [styleState, styleDispatch] = useContext(StyleContext);
+
+ return (
+
+
+
+
+ {styleState.showSider ? null : }
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+}
+
+export default PageLayout;
\ No newline at end of file
diff --git a/web/src/components/SiderBar.js b/web/src/components/SiderBar.js
index a7310382..58fea10d 100644
--- a/web/src/components/SiderBar.js
+++ b/web/src/components/SiderBar.js
@@ -31,14 +31,15 @@ import { Avatar, Dropdown, Layout, Nav, Switch } from '@douyinfe/semi-ui';
import { setStatusData } from '../helpers/data.js';
import { stringToColor } from '../helpers/render.js';
import { useSetTheme, useTheme } from '../context/Theme/index.js';
+import { StyleContext } from '../context/Style/index.js';
// HeaderBar Buttons
const SiderBar = () => {
- const [userState, userDispatch] = useContext(UserContext);
+ const [styleState, styleDispatch] = useContext(StyleContext);
const [statusState, statusDispatch] = useContext(StatusContext);
const defaultIsCollapsed =
- isMobile() || localStorage.getItem('default_collapse_sidebar') === 'true';
+ localStorage.getItem('default_collapse_sidebar') === 'true';
const [selectedKeys, setSelectedKeys] = useState(['home']);
const [isCollapsed, setIsCollapsed] = useState(defaultIsCollapsed);
@@ -196,7 +197,6 @@ const SiderBar = () => {
useEffect(() => {
loadStatus().then(() => {
setIsCollapsed(
- isMobile() ||
localStorage.getItem('default_collapse_sidebar') === 'true',
);
});
@@ -239,7 +239,6 @@ const SiderBar = () => {