1
+ import './i18n' ;
1
2
import React , { useState } from 'react' ;
2
3
import { Layout , Menu , theme } from 'antd' ;
4
+ import { useTranslation } from 'react-i18next' ;
3
5
import './App.css' ;
4
6
import { DownloadProvider } from './context/DownloadContext' ;
5
7
import DownloadNovel from './components/DownloadNovel' ;
6
8
import CheckUpdate from './components/CheckUpdate' ;
7
9
import ViewConfig from './components/ViewConfig' ;
8
10
import UsageInfo from './components/UsageInfo' ;
11
+ import LanguageSwitcher from './components/LanguageSwitcher' ;
9
12
10
13
const { Header, Content, Footer } = Layout ;
11
- const options = [
12
- "下载小说" ,
13
- "检查更新" ,
14
- "查看配置文件" ,
15
- "使用须知" ,
16
- ] ;
17
14
18
15
const App : React . FC = ( ) => {
16
+ const { t } = useTranslation ( ) ;
19
17
const {
20
18
token : { colorBgContainer, borderRadiusLG } ,
21
19
} = theme . useToken ( ) ;
22
20
23
21
const [ selectedOption , setSelectedOption ] = useState < number > ( 0 ) ;
24
22
23
+ const options = [
24
+ { key : '0' , label : t ( 'app.menu.downloadNovel' ) } ,
25
+ { key : '1' , label : t ( 'app.menu.checkUpdate' ) } ,
26
+ { key : '2' , label : t ( 'app.menu.viewConfig' ) } ,
27
+ { key : '3' , label : t ( 'app.menu.usageInfo' ) } ,
28
+ ] ;
29
+
25
30
const handleMenuClick = ( e : any ) => {
26
31
const index = parseInt ( e . key , 10 ) ;
27
32
setSelectedOption ( index ) ;
@@ -42,31 +47,25 @@ const App: React.FC = () => {
42
47
case 3 :
43
48
return < UsageInfo /> ;
44
49
default :
45
- return < p > 请选择一个选项 </ p > ;
50
+ return < p > { t ( 'app.menu.selectOption' ) } </ p > ;
46
51
}
47
52
} ;
48
53
49
- const items = options . map ( ( option , index ) => ( {
50
- key : index . toString ( ) ,
51
- label : option ,
52
- } ) ) ;
53
-
54
54
return (
55
55
< Layout >
56
- < Header style = { { display : 'flex' , justifyContent : 'center ' , alignItems : 'center' } } >
56
+ < Header style = { { display : 'flex' , justifyContent : 'space-between ' , alignItems : 'center' } } >
57
57
< Menu
58
58
theme = "dark"
59
59
mode = "horizontal"
60
- items = { items }
61
- defaultSelectedKeys = { [ `0` ] }
60
+ items = { options }
61
+ defaultSelectedKeys = { [ '0' ] }
62
62
style = { {
63
- flex : 'none' ,
63
+ flex : 1 ,
64
64
minWidth : 0 ,
65
- display : 'flex' ,
66
- justifyContent : 'center' ,
67
65
} }
68
66
onClick = { handleMenuClick }
69
67
/>
68
+ < LanguageSwitcher />
70
69
</ Header >
71
70
< Content style = { { padding : '0 48px' } } >
72
71
< div
@@ -81,7 +80,7 @@ const App: React.FC = () => {
81
80
</ div >
82
81
</ Content >
83
82
< Footer style = { { textAlign : 'center' } } >
84
- 我是混子 © { new Date ( ) . getFullYear ( ) } Created by 呵呵呵
83
+ { t ( 'app.footer' , { year : new Date ( ) . getFullYear ( ) } ) }
85
84
</ Footer >
86
85
</ Layout >
87
86
) ;
0 commit comments