Commit d2f302c13aa9fa5f02914b59fb7b1477d5bd9c04
1 parent
e5dd9ad3
1.设置用户的语言设置系统组件的国际化
Showing
2 changed files
with
5 additions
and
4 deletions
src/components/Common/SearchComponent/index.js
| ... | ... | @@ -800,7 +800,6 @@ export default class SearchComponent extends Component { |
| 800 | 800 | showThirdConfig.sDateFormat = 'YYYY'; |
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | - console.log('23showTypeSecondProps3', showTypeSecondProps); | |
| 804 | 803 | |
| 805 | 804 | return ( |
| 806 | 805 | <div key={key} className={styles.addFilterBox}> | ... | ... |
src/routes/indexPage.js
| ... | ... | @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'; |
| 2 | 2 | import { connect } from 'umi'; |
| 3 | 3 | import { ConfigProvider, Layout } from 'antd-v4'; |
| 4 | 4 | import zhCN from 'antd-v4/lib/locale-provider/zh_CN'; |
| 5 | +import enUS from 'antd-v4/lib/locale-provider/en_US'; | |
| 5 | 6 | // import Search from '../components/Common/Search'; |
| 6 | 7 | import PersonCenter from './personCenter/personCenter'; |
| 7 | 8 | import Feedback from './feedback/feedback'; |
| ... | ... | @@ -11,8 +12,9 @@ import styles from './indexPage.less'; |
| 11 | 12 | |
| 12 | 13 | const { Header, Content } = Layout; |
| 13 | 14 | |
| 14 | -function IndexPage() { | |
| 15 | +function IndexPage({ app }) { | |
| 15 | 16 | const [key, setKey] = useState(0); |
| 17 | + const currentLanguage = app?.userinfo?.sLanguage || 'zhCN'; // 默认为中文 | |
| 16 | 18 | |
| 17 | 19 | useEffect(() => { |
| 18 | 20 | window.xlyReload = () => { |
| ... | ... | @@ -21,7 +23,7 @@ function IndexPage() { |
| 21 | 23 | }, []); |
| 22 | 24 | |
| 23 | 25 | return ( |
| 24 | - <ConfigProvider locale={zhCN}> | |
| 26 | + <ConfigProvider locale={currentLanguage === 'sEnglish' ? enUS : zhCN}> | |
| 25 | 27 | <Layout key={key}> |
| 26 | 28 | <Header className={styles.header}> |
| 27 | 29 | <div className={styles.headerRight}> |
| ... | ... | @@ -48,4 +50,4 @@ function IndexPage() { |
| 48 | 50 | |
| 49 | 51 | IndexPage.propTypes = {}; |
| 50 | 52 | |
| 51 | -export default connect()(IndexPage); | |
| 53 | +export default connect(({ app }) => ({ app }))(IndexPage); | ... | ... |