1
1
import { useRouter } from 'next/router'
2
2
import { ConfigProvider , Layout , App as AntdApp , theme as antdTheme , Avatar , Space , Button , Typography , Spin } from 'antd'
3
- import Icon , {
3
+ import AntIcon , {
4
4
MenuFoldOutlined ,
5
5
MenuUnfoldOutlined ,
6
6
ApiOutlined ,
@@ -13,6 +13,7 @@ import Icon, {
13
13
ReadOutlined ,
14
14
RadiusSettingOutlined ,
15
15
} from '@ant-design/icons'
16
+ import Icon from '@/components/Icon'
16
17
const { Header, Sider, Content } = Layout
17
18
import React , { useEffect , useState } from 'react'
18
19
import { useSiteContext } from '@/contexts/site'
@@ -24,7 +25,7 @@ import IconLight from '@/assets/icons/light.svg'
24
25
import IconDark from '@/assets/icons/dark.svg'
25
26
import { tool } from '@/utils'
26
27
27
- const { version : packageVersion , name : packageName } = require ( '@/../package.json' )
28
+ const { version : packageVersion , name : packageName } = require ( '@/../package.json' )
28
29
29
30
// default colorPrimary
30
31
export const colorPrimary = '#1677ff'
@@ -41,12 +42,12 @@ export default function LayoutBase(props: any) {
41
42
const [ side , setSide ] = useState ( true )
42
43
const iconColor = '#CCC'
43
44
const menuList = [
44
- { name : 'c.message' , path : '/chat' , icon : < MessageOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
45
- { name : 'c.prompt' , path : '/prompt' , icon : < BulbOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
46
- { name : 'c.plugin' , path : '/plugin' , icon : < ApiOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
47
- // { name: 'c.store', path: '/store', icon: <ShoppingOutlined />, iconColor: iconColor, iconColorActive: colorPrimary },
48
- // { name: 'c.share', path: '/share', icon: <ShareAltOutlined />, iconColor: iconColor, iconColorActive: colorPrimary },
49
- { name : 'c.readme' , path : '/readme' , icon : < ReadOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
45
+ { name : 'c.message' , path : '/chat' , iconName : 'MessageOutlined' , icon : < MessageOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
46
+ { name : 'c.prompt' , path : '/prompt' , iconName : 'BulbOutlined' , icon : < BulbOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
47
+ { name : 'c.plugin' , path : '/plugin' , iconName : 'ApiOutlined' , icon : < ApiOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
48
+ // { name: 'c.store', path: '/store',iconName: 'ShoppingOutlined', icon: <ShoppingOutlined />, iconColor: iconColor, iconColorActive: colorPrimary },
49
+ // { name: 'c.share', path: '/share',iconName: 'ShareAltOutlined', icon: <ShareAltOutlined />, iconColor: iconColor, iconColorActive: colorPrimary },
50
+ { name : 'c.readme' , path : '/readme' , iconName : 'ReadOutlined' , icon : < ReadOutlined /> , iconColor : iconColor , iconColorActive : colorPrimary } ,
50
51
]
51
52
const [ menu , setMenu ] = useState < any > ( menuList [ 0 ] )
52
53
const [ headTitle , setHeadTitle ] = useState < any > ( t ( menuList [ 0 ] ?. [ 'name' ] ) )
@@ -122,7 +123,7 @@ export default function LayoutBase(props: any) {
122
123
algorithm : [ theme === 'dark' ? antdTheme . darkAlgorithm : antdTheme . defaultAlgorithm , ...( surfaceConfig ?. loose == 'loose' ? [ antdTheme . compactAlgorithm ] : [ ] ) ] ,
123
124
} }
124
125
>
125
- < AntdApp style = { { height : '100vh' , width : '100vw' , overflow :'hidden' , display :'flex' } } >
126
+ < AntdApp style = { { height : '100vh' , width : '100vw' , overflow : 'hidden' , display : 'flex' } } >
126
127
< Head >
127
128
< title > { title || 'ChatGPT-Plus' } </ title >
128
129
< meta property = "og:title" content = { title } key = { title } />
@@ -162,12 +163,14 @@ export default function LayoutBase(props: any) {
162
163
setHeadTitle ( t ( item . name ) )
163
164
toUrl ( item . path )
164
165
} }
166
+ type = { getActive ( item . path ) ? 'primary' : 'text' }
165
167
ghost = { getActive ( item . path ) ? false : true }
166
168
size = { 'large' }
167
- icon = { item . icon }
169
+ icon = { < Icon name = { item . iconName } style = { { color : getActive ( item . path ) ? '#fff' : theme === 'dark' ? '#fff' : '#555' } } /> }
168
170
// @ts -ignore
169
171
title = { t ( item . name ) }
170
- style = { { border : getActive ( item . path ) ? undefined : 'none' , color : getActive ( item . path ) ? item . iconColorActive : theme === 'dark' ? item . iconColor : '#555' } }
172
+ style = { { border : 'none' } }
173
+ // style={{ border: getActive(item.path) ? undefined : 'none', color: getActive(item.path) ? item.iconColorActive : theme === 'dark' ? '#fff' : '#555' }}
171
174
>
172
175
{ collapsed ? '' : t ( item . name ) }
173
176
</ Button >
@@ -184,7 +187,9 @@ export default function LayoutBase(props: any) {
184
187
style = { { border : 'none' , color : '#fff' } }
185
188
size = { 'large' }
186
189
// icon={theme === 'dark' ? <SkinFilled style={{ color: iconColor }} /> : <SkinOutlined style={{ color: '#555' }} /> }
187
- icon = { theme === 'dark' ? < Icon component = { IconDark } style = { { color : iconColor , fontSize : '18px' } } /> : < Icon component = { IconLight } style = { { color : '#333' , fontSize : '20px' } } /> }
190
+ icon = {
191
+ theme === 'dark' ? < AntIcon component = { IconDark } style = { { color : iconColor , fontSize : '20px' } } /> : < AntIcon component = { IconLight } style = { { color : '#333' , fontSize : '22px' } } />
192
+ }
188
193
> </ Button >
189
194
< Button
190
195
onClick = { ( ) => {
@@ -196,7 +201,7 @@ export default function LayoutBase(props: any) {
196
201
size = { 'large' }
197
202
icon = { < SettingOutlined style = { { color : theme === 'dark' ? iconColor : '#555' } } /> }
198
203
> </ Button >
199
- { /* <Button
204
+ < Button
200
205
onClick = { ( ) => {
201
206
setCollapsed ( ! collapsed )
202
207
// setSide(!side)
@@ -208,7 +213,7 @@ export default function LayoutBase(props: any) {
208
213
className : 'trigger' ,
209
214
style : { color : theme === 'dark' ? iconColor : '#555' } ,
210
215
} ) }
211
- ></Button> */ }
216
+ > </ Button >
212
217
< Button
213
218
onClick = { ( ) => {
214
219
setHeadTitle ( t ( 'c.github' ) )
@@ -219,9 +224,11 @@ export default function LayoutBase(props: any) {
219
224
size = { 'large' }
220
225
icon = { < GithubOutlined style = { { color : theme === 'dark' ? iconColor : '#555' } } /> }
221
226
> </ Button >
222
- { packageVersion && < Typography . Paragraph type = "secondary" style = { { color : theme === 'dark' ? '#555' : '#ccc' , fontSize :'8px' , marginBottom :0 } } >
223
- { 'v' + packageVersion }
224
- </ Typography . Paragraph > }
227
+ { packageVersion && (
228
+ < Typography . Paragraph type = "secondary" style = { { color : theme === 'dark' ? '#555' : '#ccc' , fontSize : '8px' , marginBottom : 0 } } >
229
+ { 'v' + packageVersion }
230
+ </ Typography . Paragraph >
231
+ ) }
225
232
</ Space >
226
233
</ div >
227
234
</ Sider >
0 commit comments