- {systemName}
+
{systemName}
{(isSelfUseMode || isDemoSiteMode) && (
{
+
Happy New Year!!!
@@ -274,6 +354,7 @@ const HeaderBar = () => {
size={styleState.isMobile?'default':'large'}
checked={theme === 'dark'}
uncheckedText='🌙'
+ style={switchStyle}
onChange={(checked) => {
setTheme(checked);
}}
@@ -282,7 +363,7 @@ const HeaderBar = () => {
+
handleLanguageChange('zh')}
type={currentLang === 'zh' ? 'primary' : 'tertiary'}
@@ -300,7 +381,7 @@ const HeaderBar = () => {
>
}
+ icon={}
/>
{userState.user ? (
@@ -308,7 +389,7 @@ const HeaderBar = () => {
+
{t('退出')}
}
@@ -316,11 +397,11 @@ const HeaderBar = () => {
{userState.user.username[0]}
- {styleState.isMobile?null:{userState.user.username}}
+ {styleState.isMobile?null:{userState.user.username}}
>
) : (
@@ -328,7 +409,7 @@ const HeaderBar = () => {
}
+ icon={}
/>
{
// Hide register option in self-use mode
@@ -336,7 +417,7 @@ const HeaderBar = () => {
}
+ icon={}
/>
)
}
diff --git a/web/src/components/PageLayout.js b/web/src/components/PageLayout.js
index da1c09f9..c6e6dc2f 100644
--- a/web/src/components/PageLayout.js
+++ b/web/src/components/PageLayout.js
@@ -62,20 +62,57 @@ const PageLayout = () => {
if (savedLang) {
i18n.changeLanguage(savedLang);
}
+
+ // 默认显示侧边栏
+ styleDispatch({ type: 'SET_SIDER', payload: true });
}, [i18n]);
+ // 获取侧边栏折叠状态
+ const isSidebarCollapsed = localStorage.getItem('default_collapse_sidebar') === 'true';
+
return (
-
+
-
-
- {styleState.showSider ? : null}
-
-
+
+ {styleState.showSider && (
+
+
+
+ )}
+
diff --git a/web/src/components/SiderBar.js b/web/src/components/SiderBar.js
index f2a27c8f..4424f0b0 100644
--- a/web/src/components/SiderBar.js
+++ b/web/src/components/SiderBar.js
@@ -1,5 +1,5 @@
import React, { useContext, useEffect, useMemo, useState } from 'react';
-import { Link, useNavigate } from 'react-router-dom';
+import { Link, useNavigate, useLocation } from 'react-router-dom';
import { UserContext } from '../context/User';
import { StatusContext } from '../context/Status';
import { useTranslation } from 'react-i18next';
@@ -34,7 +34,34 @@ import { stringToColor } from '../helpers/render.js';
import { useSetTheme, useTheme } from '../context/Theme/index.js';
import { StyleContext } from '../context/Style/index.js';
-// HeaderBar Buttons
+// 自定义侧边栏按钮样式
+const navItemStyle = {
+ borderRadius: '6px',
+ margin: '4px 8px',
+ transition: 'all 0.3s ease'
+};
+
+// 自定义侧边栏按钮悬停样式
+const navItemHoverStyle = {
+ backgroundColor: 'var(--semi-color-primary-light-default)',
+ color: 'var(--semi-color-primary)'
+};
+
+// 自定义侧边栏按钮选中样式
+const navItemSelectedStyle = {
+ backgroundColor: 'var(--semi-color-primary-light-default)',
+ color: 'var(--semi-color-primary)',
+ fontWeight: '600'
+};
+
+// 自定义图标样式
+const iconStyle = (itemKey, selectedKeys) => {
+ return {
+ fontSize: '18px',
+ color: selectedKeys.includes(itemKey) ? 'var(--semi-color-primary)' : 'var(--semi-color-text-2)',
+ transition: 'all 0.3s ease'
+ };
+};
const SiderBar = () => {
const { t } = useTranslation();
@@ -46,8 +73,30 @@ const SiderBar = () => {
const [selectedKeys, setSelectedKeys] = useState(['home']);
const [isCollapsed, setIsCollapsed] = useState(defaultIsCollapsed);
const [chatItems, setChatItems] = useState([]);
+ const [openedKeys, setOpenedKeys] = useState([]);
const theme = useTheme();
const setTheme = useSetTheme();
+ const location = useLocation();
+
+ // 预先计算所有可能的图标样式
+ const allItemKeys = useMemo(() => {
+ const keys = ['home', 'channel', 'token', 'redemption', 'topup', 'user', 'log', 'midjourney',
+ 'setting', 'about', 'chat', 'detail', 'pricing', 'task', 'playground', 'personal'];
+ // 添加聊天项的keys
+ for (let i = 0; i < chatItems.length; i++) {
+ keys.push('chat' + i);
+ }
+ return keys;
+ }, [chatItems]);
+
+ // 使用useMemo一次性计算所有图标样式
+ const iconStyles = useMemo(() => {
+ const styles = {};
+ allItemKeys.forEach(key => {
+ styles[key] = iconStyle(key, selectedKeys);
+ });
+ return styles;
+ }, [allItemKeys, selectedKeys]);
const routerMap = {
home: '/',
@@ -190,11 +239,14 @@ const SiderBar = () => {
);
useEffect(() => {
- let localKey = window.location.pathname.split('/')[1];
- if (localKey === '') {
- localKey = 'home';
+ const currentPath = location.pathname;
+ const matchingKey = Object.keys(routerMap).find(key => routerMap[key] === currentPath);
+
+ if (matchingKey) {
+ setSelectedKeys([matchingKey]);
+ } else if (currentPath.startsWith('/chat/')) {
+ setSelectedKeys(['chat']);
}
- setSelectedKeys([localKey]);
let chats = localStorage.getItem('chats');
if (chats) {
@@ -222,7 +274,7 @@ const SiderBar = () => {
}
setIsCollapsed(localStorage.getItem('default_collapse_sidebar') === 'true');
- }, []);
+ }, [location.pathname]);
// Custom divider style
const dividerStyle = {
@@ -235,21 +287,54 @@ const SiderBar = () => {
padding: '8px 16px',
color: 'var(--semi-color-text-2)',
fontSize: '12px',
- fontWeight: 'normal',
+ fontWeight: 'bold',
+ textTransform: 'uppercase',
+ letterSpacing: '0.5px',
};
return (
<>