|
@@ -9,17 +9,19 @@ import '../index.css';
|
|
|
import fireworks from 'react-fireworks';
|
|
import fireworks from 'react-fireworks';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
|
|
+ IconClose,
|
|
|
IconHelpCircle,
|
|
IconHelpCircle,
|
|
|
IconHome,
|
|
IconHome,
|
|
|
- IconHomeStroked,
|
|
|
|
|
- IconKey,
|
|
|
|
|
|
|
+ IconHomeStroked, IconIndentLeft,
|
|
|
|
|
+ IconKey, IconMenu,
|
|
|
IconNoteMoneyStroked,
|
|
IconNoteMoneyStroked,
|
|
|
IconPriceTag,
|
|
IconPriceTag,
|
|
|
IconUser
|
|
IconUser
|
|
|
} from '@douyinfe/semi-icons';
|
|
} 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 { stringToColor } from '../helpers/render';
|
|
|
import Text from '@douyinfe/semi-ui/lib/es/typography/text';
|
|
import Text from '@douyinfe/semi-ui/lib/es/typography/text';
|
|
|
|
|
+import { StyleContext } from '../context/Style/index.js';
|
|
|
|
|
|
|
|
// HeaderBar Buttons
|
|
// HeaderBar Buttons
|
|
|
let headerButtons = [
|
|
let headerButtons = [
|
|
@@ -36,14 +38,7 @@ let buttons = [
|
|
|
text: '首页',
|
|
text: '首页',
|
|
|
itemKey: 'home',
|
|
itemKey: 'home',
|
|
|
to: '/',
|
|
to: '/',
|
|
|
- // icon: <IconHomeStroked />,
|
|
|
|
|
},
|
|
},
|
|
|
- // {
|
|
|
|
|
- // text: 'Playground',
|
|
|
|
|
- // itemKey: 'playground',
|
|
|
|
|
- // to: '/playground',
|
|
|
|
|
- // // icon: <IconNoteMoneyStroked />,
|
|
|
|
|
- // },
|
|
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
if (localStorage.getItem('chat_link')) {
|
|
if (localStorage.getItem('chat_link')) {
|
|
@@ -56,9 +51,9 @@ if (localStorage.getItem('chat_link')) {
|
|
|
|
|
|
|
|
const HeaderBar = () => {
|
|
const HeaderBar = () => {
|
|
|
const [userState, userDispatch] = useContext(UserContext);
|
|
const [userState, userDispatch] = useContext(UserContext);
|
|
|
|
|
+ const [styleState, styleDispatch] = useContext(StyleContext);
|
|
|
let navigate = useNavigate();
|
|
let navigate = useNavigate();
|
|
|
|
|
|
|
|
- const [showSidebar, setShowSidebar] = useState(false);
|
|
|
|
|
const systemName = getSystemName();
|
|
const systemName = getSystemName();
|
|
|
const logo = getLogo();
|
|
const logo = getLogo();
|
|
|
const currentDate = new Date();
|
|
const currentDate = new Date();
|
|
@@ -70,7 +65,6 @@ const HeaderBar = () => {
|
|
|
currentDate.getDate() <= 24);
|
|
currentDate.getDate() <= 24);
|
|
|
|
|
|
|
|
async function logout() {
|
|
async function logout() {
|
|
|
- setShowSidebar(false);
|
|
|
|
|
await API.get('/api/user/logout');
|
|
await API.get('/api/user/logout');
|
|
|
showSuccess('注销成功!');
|
|
showSuccess('注销成功!');
|
|
|
userDispatch({ type: 'logout' });
|
|
userDispatch({ type: 'logout' });
|
|
@@ -128,16 +122,25 @@ const HeaderBar = () => {
|
|
|
selectedKeys={[]}
|
|
selectedKeys={[]}
|
|
|
// items={headerButtons}
|
|
// items={headerButtons}
|
|
|
onSelect={(key) => {}}
|
|
onSelect={(key) => {}}
|
|
|
- header={isMobile()?{
|
|
|
|
|
|
|
+ header={styleState.isMobile?{
|
|
|
logo: (
|
|
logo: (
|
|
|
- <img src={logo} alt='logo' style={{ marginRight: '0.75em' }} />
|
|
|
|
|
|
|
+ <>
|
|
|
|
|
+ {
|
|
|
|
|
+ styleState.showSider ?
|
|
|
|
|
+ <Button icon={<IconMenu />} theme="light" style={{ marginRight: 10 }} aria-label="展开侧边栏" onClick={
|
|
|
|
|
+ () => styleDispatch({ type: 'SET_SIDER', payload: false })
|
|
|
|
|
+ } />:
|
|
|
|
|
+ <Button icon={<IconIndentLeft />} theme="light" style={{ marginRight: 10 }} aria-label="关闭侧边栏" onClick={
|
|
|
|
|
+ () => styleDispatch({ type: 'SET_SIDER', payload: true })
|
|
|
|
|
+ } />
|
|
|
|
|
+ }
|
|
|
|
|
+ </>
|
|
|
),
|
|
),
|
|
|
}:{
|
|
}:{
|
|
|
logo: (
|
|
logo: (
|
|
|
<img src={logo} alt='logo' />
|
|
<img src={logo} alt='logo' />
|
|
|
),
|
|
),
|
|
|
text: systemName,
|
|
text: systemName,
|
|
|
-
|
|
|
|
|
}}
|
|
}}
|
|
|
items={buttons}
|
|
items={buttons}
|
|
|
footer={
|
|
footer={
|
|
@@ -159,17 +162,15 @@ const HeaderBar = () => {
|
|
|
)}
|
|
)}
|
|
|
<Nav.Item itemKey={'about'} icon={<IconHelpCircle />} />
|
|
<Nav.Item itemKey={'about'} icon={<IconHelpCircle />} />
|
|
|
<>
|
|
<>
|
|
|
- {!isMobile() && (
|
|
|
|
|
- <Switch
|
|
|
|
|
- checkedText='🌞'
|
|
|
|
|
- size={'large'}
|
|
|
|
|
- checked={theme === 'dark'}
|
|
|
|
|
- uncheckedText='🌙'
|
|
|
|
|
- onChange={(checked) => {
|
|
|
|
|
- setTheme(checked);
|
|
|
|
|
- }}
|
|
|
|
|
- />
|
|
|
|
|
- )}
|
|
|
|
|
|
|
+ <Switch
|
|
|
|
|
+ checkedText='🌞'
|
|
|
|
|
+ size={'large'}
|
|
|
|
|
+ checked={theme === 'dark'}
|
|
|
|
|
+ uncheckedText='🌙'
|
|
|
|
|
+ onChange={(checked) => {
|
|
|
|
|
+ setTheme(checked);
|
|
|
|
|
+ }}
|
|
|
|
|
+ />
|
|
|
</>
|
|
</>
|
|
|
{userState.user ? (
|
|
{userState.user ? (
|
|
|
<>
|
|
<>
|