mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Improve: Migrate i18nprops to models
This commit is contained in:
parent
26541f22fc
commit
d79d03ea16
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { Route } from 'react-router-dom'
|
import { Route } from 'react-router-dom'
|
||||||
import { hot } from 'react-hot-loader'
|
import { hot } from 'react-hot-loader'
|
||||||
import { I18nProps } from '@i18n'
|
import { I18nProps } from '@models'
|
||||||
import './App.scss'
|
import './App.scss'
|
||||||
|
|
||||||
import Overview from '@containers/Overview'
|
import Overview from '@containers/Overview'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import * as dayjs from 'dayjs'
|
import * as dayjs from 'dayjs'
|
||||||
import { translate } from 'react-i18next'
|
import { translate } from 'react-i18next'
|
||||||
import { I18nProps } from '@i18n'
|
import { I18nProps } from '@models'
|
||||||
import { Card, Header } from '@components'
|
import { Card, Header } from '@components'
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
|
|
||||||
|
@ -1,7 +1,18 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
|
import { Header } from '@components'
|
||||||
|
import { translate } from 'react-i18next'
|
||||||
|
import { I18nProps } from '@models'
|
||||||
|
|
||||||
export default class Rules extends React.Component<{}, {}> {
|
class Rules extends React.Component<I18nProps, {}> {
|
||||||
render () {
|
render () {
|
||||||
return 'Rules'
|
const { t } = this.props
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="page">
|
||||||
|
<Header title={t('title')} />
|
||||||
|
</div>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default translate(['Rules'])(Rules)
|
||||||
|
@ -2,7 +2,7 @@ import * as React from 'react'
|
|||||||
import { Header, Card, Row, Col, Switch, ButtonSelect, ButtonSelectOptions, Input, Icon } from '@components'
|
import { Header, Card, Row, Col, Switch, ButtonSelect, ButtonSelectOptions, Input, Icon } from '@components'
|
||||||
import { translate } from 'react-i18next'
|
import { translate } from 'react-i18next'
|
||||||
import { changeLanguage } from 'i18next'
|
import { changeLanguage } from 'i18next'
|
||||||
import { I18nProps } from '@i18n'
|
import { I18nProps } from '@models'
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
|
|
||||||
class Settings extends React.Component<I18nProps, {}> {
|
class Settings extends React.Component<I18nProps, {}> {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { NavLink } from 'react-router-dom'
|
import { NavLink } from 'react-router-dom'
|
||||||
import { translate } from 'react-i18next'
|
import { translate } from 'react-i18next'
|
||||||
import { I18nProps } from '@i18n'
|
import { I18nProps } from '@models'
|
||||||
|
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
const logo = require('@assets/logo.png')
|
const logo = require('@assets/logo.png')
|
||||||
|
@ -30,5 +30,8 @@ export default {
|
|||||||
},
|
},
|
||||||
Logs: {
|
Logs: {
|
||||||
title: 'Logs'
|
title: 'Logs'
|
||||||
|
},
|
||||||
|
Rules: {
|
||||||
|
title: 'Rules'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,9 +24,4 @@ const options = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface I18nProps {
|
|
||||||
t? (key: string, variables?: { [key: string]: any }): string
|
|
||||||
lng?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export default i18n.use(LanguageDetector).init(options)
|
export default i18n.use(LanguageDetector).init(options)
|
||||||
|
@ -30,5 +30,8 @@ export default {
|
|||||||
},
|
},
|
||||||
Logs: {
|
Logs: {
|
||||||
title: '日志'
|
title: '日志'
|
||||||
|
},
|
||||||
|
Rules: {
|
||||||
|
title: '规则'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
src/models/I18n.ts
Normal file
10
src/models/I18n.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
export interface I18nProps {
|
||||||
|
t? (
|
||||||
|
key: string,
|
||||||
|
variables?: {
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
): string
|
||||||
|
|
||||||
|
lng?: string
|
||||||
|
}
|
@ -2,3 +2,4 @@ export * from './BaseProps'
|
|||||||
export * from './Config'
|
export * from './Config'
|
||||||
export * from './Proxy'
|
export * from './Proxy'
|
||||||
export * from './Rule'
|
export * from './Rule'
|
||||||
|
export * from './I18n'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user