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 , { MenuFoldOutlined , MenuUnfoldOutlined , ApiOutlined , BulbOutlined , SettingOutlined , MessageOutlined , ShoppingOutlined , ShareAltOutlined , ReadOutlined , RadiusSettingOutlined } from '@ant-design/icons'
3
+ import Icon , {
4
+ MenuFoldOutlined ,
5
+ MenuUnfoldOutlined ,
6
+ ApiOutlined ,
7
+ GithubOutlined ,
8
+ BulbOutlined ,
9
+ SettingOutlined ,
10
+ MessageOutlined ,
11
+ ShoppingOutlined ,
12
+ ShareAltOutlined ,
13
+ ReadOutlined ,
14
+ RadiusSettingOutlined ,
15
+ } from '@ant-design/icons'
4
16
const { Header, Sider, Content } = Layout
5
17
import React , { useEffect , useState } from 'react'
6
18
import { useSiteContext } from '@/contexts/site'
@@ -12,14 +24,16 @@ import IconLight from '@/assets/icons/light.svg'
12
24
import IconDark from '@/assets/icons/dark.svg'
13
25
import { tool } from '@/utils'
14
26
27
+ const { version : packageVersion , name : packageName } = require ( '@/../package.json' )
28
+
15
29
// default colorPrimary
16
30
export const colorPrimary = '#1677ff'
17
31
18
32
export default function LayoutBase ( props : any ) {
19
33
const { token } = antdTheme . useToken ( )
20
34
const { t } = useTranslation ( )
21
35
const { title, theme, setTheme, event$ } = useSiteContext ( )
22
- const { surface : surfaceConfig , common : commonConfig } = useSettingContext ( )
36
+ const { surface : surfaceConfig , common : commonConfig } = useSettingContext ( )
23
37
const router = useRouter ( )
24
38
const [ colorBgContainer , setColorBgContainer ] = useState ( token . colorBgContainer )
25
39
const [ colorPrimary , setColorPrimary ] = useState ( token . colorPrimary )
@@ -76,8 +90,8 @@ export default function LayoutBase(props: any) {
76
90
console . log ( 'switchTheme' , theme , newTheme )
77
91
setTheme ( newTheme )
78
92
}
79
- useEffect ( ( ) => {
80
- if ( surfaceConfig ?. colorPrimary ) {
93
+ useEffect ( ( ) => {
94
+ if ( surfaceConfig ?. colorPrimary ) {
81
95
let _colorPrimary = surfaceConfig ?. colorPrimary
82
96
setColorPrimary ( _colorPrimary )
83
97
}
@@ -146,6 +160,8 @@ export default function LayoutBase(props: any) {
146
160
ghost = { getActive ( item . path ) ? false : true }
147
161
size = { 'large' }
148
162
icon = { item . icon }
163
+ // @ts -ignore
164
+ title = { t ( item . name ) }
149
165
style = { { border : getActive ( item . path ) ? undefined : 'none' , color : getActive ( item . path ) ? item . iconColorActive : theme === 'dark' ? item . iconColor : '#555' } }
150
166
>
151
167
{ collapsed ? '' : t ( item . name ) }
@@ -169,20 +185,13 @@ export default function LayoutBase(props: any) {
169
185
onClick = { ( ) => {
170
186
setHeadTitle ( t ( 'c.setting' ) )
171
187
router . push ( '/setting' )
172
- // // 设置弹窗
173
- // tool.showModal(<Setting></Setting>, {
174
- // title: t('c.setting'),
175
- // width: 600,
176
- // bodyStyle: { minHeight: 400 },
177
- // footer: null
178
- // })
179
188
} }
180
189
ghost = { getActive ( '/setting' ) ? false : true }
181
190
style = { { border : getActive ( '/setting' ) ? undefined : 'none' , color : getActive ( '/setting' ) ? colorPrimary : theme === 'dark' ? iconColor : '#555' } }
182
191
size = { 'large' }
183
192
icon = { < SettingOutlined style = { { color : theme === 'dark' ? iconColor : '#555' } } /> }
184
193
> </ Button >
185
- < Button
194
+ { /* <Button
186
195
onClick={() => {
187
196
setCollapsed(!collapsed)
188
197
// setSide(!side)
@@ -194,7 +203,20 @@ export default function LayoutBase(props: any) {
194
203
className: 'trigger',
195
204
style: { color: theme === 'dark' ? iconColor : '#555' },
196
205
}) }
206
+ ></Button> */ }
207
+ < Button
208
+ onClick = { ( ) => {
209
+ setHeadTitle ( t ( 'c.github' ) )
210
+ window . open ( 'https://github.com/zhpd/chatgpt-plus' )
211
+ } }
212
+ ghost = { getActive ( '/github' ) ? false : true }
213
+ style = { { border : getActive ( '/github' ) ? undefined : 'none' , color : getActive ( '/github' ) ? colorPrimary : theme === 'dark' ? iconColor : '#555' } }
214
+ size = { 'large' }
215
+ icon = { < GithubOutlined style = { { color : theme === 'dark' ? iconColor : '#555' } } /> }
197
216
> </ Button >
217
+ { packageVersion && < Typography . Paragraph type = "secondary" style = { { color : theme === 'dark' ? iconColor : '#555' , fontSize :'10px' , marginBottom :0 } } >
218
+ { 'v' + packageVersion }
219
+ </ Typography . Paragraph > }
198
220
</ Space >
199
221
</ div >
200
222
</ Sider >
0 commit comments