From 18e9d370577fa726bc0405060997e75c8aed3e0d Mon Sep 17 00:00:00 2001
From: CaIon <1808837298@qq.com>
Date: Sun, 7 Jan 2024 23:54:51 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=BE=A7=E8=BE=B9?=
=?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=E9=9C=80=E8=A6=81=E5=88=B7=E6=96=B0?=
=?UTF-8?q?=E6=89=8D=E5=87=BA=E7=8E=B0=E9=80=89=E9=A1=B9=E7=9A=84=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
web/src/components/SiderBar.js | 163 +++++++++++++++++----------------
1 file changed, 82 insertions(+), 81 deletions(-)
diff --git a/web/src/components/SiderBar.js b/web/src/components/SiderBar.js
index 3d1e497e..d8b69ffd 100644
--- a/web/src/components/SiderBar.js
+++ b/web/src/components/SiderBar.js
@@ -1,4 +1,4 @@
-import React, {useContext, useState} from 'react';
+import React, {useContext, useMemo, useState} from 'react';
import {Link, useNavigate} from 'react-router-dom';
import {UserContext} from '../context/User';
@@ -21,86 +21,6 @@ import {
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: 'detail',
- to: '/detail',
- icon: ,
- className: localStorage.getItem('enable_data_export') === 'true'?'semi-navigation-item-normal':'tableHiddle',
- },
- {
- text: '绘图',
- itemKey: 'midjourney',
- to: '/midjourney',
- icon: ,
- className: localStorage.getItem('enable_drawing') === 'true'?'semi-navigation-item-normal':'tableHiddle',
- },
- {
- text: '设置',
- itemKey: 'setting',
- to: '/setting',
- icon:
- },
- // {
- // text: '关于',
- // itemKey: 'about',
- // to: '/about',
- // icon:
- // }
-];
const SiderBar = () => {
const [userState, userDispatch] = useContext(UserContext);
@@ -109,6 +29,87 @@ const SiderBar = () => {
const [showSidebar, setShowSidebar] = useState(false);
const systemName = getSystemName();
const logo = getLogo();
+ const headerButtons = useMemo(() => [
+ {
+ 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: 'detail',
+ to: '/detail',
+ icon: ,
+ className: localStorage.getItem('enable_data_export') === 'true'?'semi-navigation-item-normal':'tableHiddle',
+ },
+ {
+ text: '绘图',
+ itemKey: 'midjourney',
+ to: '/midjourney',
+ icon: ,
+ className: localStorage.getItem('enable_drawing') === 'true'?'semi-navigation-item-normal':'tableHiddle',
+ },
+ {
+ text: '设置',
+ itemKey: 'setting',
+ to: '/setting',
+ icon:
+ },
+ // {
+ // text: '关于',
+ // itemKey: 'about',
+ // to: '/about',
+ // icon:
+ // }
+ ], [localStorage.getItem('enable_data_export'), localStorage.getItem('enable_drawing'), localStorage.getItem('chat_link'), isAdmin()]);
+
async function logout() {
setShowSidebar(false);