mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 22:11:56 +08:00
Update: support change language
This commit is contained in:
parent
ba23a06d7f
commit
1a202dea98
@ -14,5 +14,6 @@
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
text-shadow: 0 2px 6px rgba($color: $color-primary-dark, $alpha: 0.4);
|
text-shadow: 0 2px 6px rgba($color: $color-primary-dark, $alpha: 0.4);
|
||||||
user-select: none;
|
user-select: none;
|
||||||
|
line-height: 32px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import * as React from 'react'
|
import * as React from 'react'
|
||||||
import { Header, Card, Row, Col, Switch, ButtonSelect, ButtonSelectOptions, Input } 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 { I18nProps } from '@i18n'
|
import { I18nProps } from '@i18n'
|
||||||
import './style.scss'
|
import './style.scss'
|
||||||
|
|
||||||
@ -8,10 +9,9 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
|
|
||||||
state = {
|
state = {
|
||||||
startAtLogin: false,
|
startAtLogin: false,
|
||||||
language: 'en',
|
|
||||||
setAsSystemProxy: true,
|
setAsSystemProxy: true,
|
||||||
allowConnectFromLan: true,
|
allowConnectFromLan: true,
|
||||||
proxyMode: 'rule',
|
proxyMode: 'Rule',
|
||||||
socks5ProxyPort: 7891,
|
socks5ProxyPort: 7891,
|
||||||
httpProxyPort: 7890,
|
httpProxyPort: 7890,
|
||||||
externalController: '127.0.0.1:7892'
|
externalController: '127.0.0.1:7892'
|
||||||
@ -22,17 +22,14 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
{ label: 'English', value: 'en' }
|
{ label: 'English', value: 'en' }
|
||||||
]
|
]
|
||||||
|
|
||||||
proxyModeOptions: ButtonSelectOptions[] = [
|
changeLanguage = (language: string) => {
|
||||||
{ label: '全局', value: 'global' },
|
changeLanguage(language)
|
||||||
{ label: '规则', value: 'rule' },
|
}
|
||||||
{ label: '直连', value: 'none' }
|
|
||||||
]
|
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { t } = this.props
|
const { t, lng } = this.props
|
||||||
const {
|
const {
|
||||||
startAtLogin,
|
startAtLogin,
|
||||||
language,
|
|
||||||
setAsSystemProxy,
|
setAsSystemProxy,
|
||||||
allowConnectFromLan,
|
allowConnectFromLan,
|
||||||
proxyMode,
|
proxyMode,
|
||||||
@ -40,6 +37,11 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
httpProxyPort,
|
httpProxyPort,
|
||||||
externalController
|
externalController
|
||||||
} = this.state
|
} = this.state
|
||||||
|
const proxyModeOptions: ButtonSelectOptions[] = [
|
||||||
|
{ label: t('values.global'), value: 'Global' },
|
||||||
|
{ label: t('values.rules'), value: 'Rule' },
|
||||||
|
{ label: t('values.direct'), value: 'Direct' }
|
||||||
|
]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="page">
|
<div className="page">
|
||||||
@ -61,8 +63,8 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
<Col span={7} className="value-column">
|
<Col span={7} className="value-column">
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
options={this.languageOptions}
|
options={this.languageOptions}
|
||||||
value={language}
|
value={lng}
|
||||||
onSelect={language => this.setState({ language })}
|
onSelect={this.changeLanguage}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
@ -87,6 +89,7 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Card className="settings-card">
|
<Card className="settings-card">
|
||||||
<Row gutter={24} align="middle">
|
<Row gutter={24} align="middle">
|
||||||
<Col span={3} offset={1}>
|
<Col span={3} offset={1}>
|
||||||
@ -94,7 +97,7 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
</Col>
|
</Col>
|
||||||
<Col span={7} className="value-column">
|
<Col span={7} className="value-column">
|
||||||
<ButtonSelect
|
<ButtonSelect
|
||||||
options={this.proxyModeOptions}
|
options={proxyModeOptions}
|
||||||
value={proxyMode}
|
value={proxyMode}
|
||||||
onSelect={proxyMode => this.setState({ proxyMode })}
|
onSelect={proxyMode => this.setState({ proxyMode })}
|
||||||
/>
|
/>
|
||||||
@ -107,20 +110,28 @@ class Settings extends React.Component<I18nProps, {}> {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
<Row gutter={24} align="middle">
|
<Row gutter={24} align="middle">
|
||||||
<Col span={4} offset={1}>
|
<Col span={5} offset={1}>
|
||||||
<span className="label">{t('labels.httpProxyPort')}</span>
|
<span className="label">{t('labels.httpProxyPort')}</span>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={3} offset={3}>
|
<Col span={3} offset={2}>
|
||||||
<Input value={httpProxyPort} onChange={httpProxyPort => this.setState({ httpProxyPort })}></Input>
|
<Input value={httpProxyPort} onChange={httpProxyPort => this.setState({ httpProxyPort })}></Input>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={4} offset={1}>
|
<Col span={5} offset={1}>
|
||||||
<span className="label">{t('labels.externalController')}</span>
|
<span className="label">{t('labels.externalController')}</span>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={5} offset={2}>
|
<Col span={5} offset={1}>
|
||||||
<Input value={externalController} ></Input>
|
<Input value={externalController} ></Input>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
|
<Card className="clash-version" style={{ display: 'none' }}>
|
||||||
|
<span className="check-icon">
|
||||||
|
<Icon type="check" size={20}/>
|
||||||
|
</span>
|
||||||
|
<p className="version-info">{t('versionString', { version: 'unknown' })}</p>
|
||||||
|
<span className="check-update-btn">{t('checkUpdate')}</span>
|
||||||
|
</Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
padding: 20px 0;
|
padding: 20px 0;
|
||||||
|
|
||||||
.column {
|
.column {
|
||||||
|
font-weight: bold;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,3 +18,47 @@
|
|||||||
color: $color-primary-darken;
|
color: $color-primary-darken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clash-version {
|
||||||
|
position: relative;
|
||||||
|
margin-top: 25px;
|
||||||
|
padding: 20px 45px;
|
||||||
|
display: flex;
|
||||||
|
|
||||||
|
.check-icon {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: linear-gradient(135deg, $color-primary, $color-primary-dark);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
|
> i {
|
||||||
|
transform: scale(0.5);
|
||||||
|
color: #fff;
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.version-info {
|
||||||
|
margin-left: 10px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 24px;
|
||||||
|
color: $color-primary-darken;
|
||||||
|
}
|
||||||
|
|
||||||
|
.check-update-btn {
|
||||||
|
position: absolute;
|
||||||
|
right: 45px;
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 24px;
|
||||||
|
color: $color-gray-dark;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 150ms ease;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: $color-primary-darken;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
> a.active {
|
> a.active {
|
||||||
background: linear-gradient(to right, $color-primary, $color-primary-dark);
|
background: linear-gradient(135deg, $color-primary, $color-primary-dark);
|
||||||
color: #fff;
|
color: #fff;
|
||||||
box-shadow: 0 2px 8px rgba($color: $color-primary-dark, $alpha: 0.5);
|
box-shadow: 0 2px 8px rgba($color: $color-primary-dark, $alpha: 0.5);
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,8 @@ const options = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface I18nProps {
|
export interface I18nProps {
|
||||||
t? (key: string): string
|
t? (key: string, variables?: { [key: string]: any }): string
|
||||||
|
lng?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default i18n.use(LanguageDetector).init(options)
|
export default i18n.use(LanguageDetector).init(options)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user