import React, {useContext, useState} from 'react';
import {Link, useNavigate} from 'react-router-dom';
import {UserContext} from '../context/User';
import {Button, Container, Icon, Menu, Segment} from 'semantic-ui-react';
import {API, getLogo, getSystemName, isAdmin, isMobile, showSuccess} from '../helpers';
import '../index.css';
import {
IconAt,
IconHistogram,
IconGift,
IconKey,
IconUser,
IconLayers,
IconSetting,
IconCreditCard,
IconComment,
IconHome,
IconImage
} from '@douyinfe/semi-icons';
import {Nav, Avatar, Dropdown, Layout} from '@douyinfe/semi-ui';
// HeaderBar Buttons
let headerButtons = [
{
text: '首页',
itemKey: 'home',
to: '/',
icon:
},
{
text: '渠道',
itemKey: 'channel',
to: '/channel',
icon: ,
className: isAdmin()?'semi-navigation-item-normal':'tableHiddle',
},
{
text: '聊天',
itemKey: 'chat',
to: '/chat',
icon: ,
className: localStorage.getItem('chat_link')?'semi-navigation-item-normal':'tableHiddle',
},
{
text: '令牌',
itemKey: 'token',
to: '/token',
icon:
},
{
text: '兑换码',
itemKey: 'redemption',
to: '/redemption',
icon: ,
className: isAdmin()?'semi-navigation-item-normal':'tableHiddle',
},
{
text: '钱包',
itemKey: 'topup',
to: '/topup',
icon:
},
{
text: '用户管理',
itemKey: 'user',
to: '/user',
icon: ,
className: isAdmin()?'semi-navigation-item-normal':'tableHiddle',
},
{
text: '日志',
itemKey: 'log',
to: '/log',
icon:
},
{
text: '绘图',
itemKey: 'midjourney',
to: '/midjourney',
icon:
},
{
text: '设置',
itemKey: 'setting',
to: '/setting',
icon:
},
// {
// text: '关于',
// itemKey: 'about',
// to: '/about',
// icon:
// }
];
const SiderBar = () => {
const [userState, userDispatch] = useContext(UserContext);
let navigate = useNavigate();
const [selectedKeys, setSelectedKeys] = useState(['home']);
const [showSidebar, setShowSidebar] = useState(false);
const systemName = getSystemName();
const logo = getLogo();
async function logout() {
setShowSidebar(false);
await API.get('/api/user/logout');
showSuccess('注销成功!');
userDispatch({type: 'logout'});
localStorage.removeItem('user');
navigate('/login');
}
return (
<>
>
);
};
export default SiderBar;