Commit dab141ad authored by 张秀玲's avatar 张秀玲 Committed by 陈帅

translate settings page

parent 08ed2929
...@@ -72,6 +72,42 @@ export default { ...@@ -72,6 +72,42 @@ export default {
'app.analysis.table.search-keyword': 'Keyword', 'app.analysis.table.search-keyword': 'Keyword',
'app.analysis.table.users': 'Users', 'app.analysis.table.users': 'Users',
'app.analysis.table.weekly-range': 'Weekly Range', 'app.analysis.table.weekly-range': 'Weekly Range',
'app.settings.menuMap.basic': 'Basic Settings',
'app.settings.menuMap.security': 'Security Settings',
'app.settings.menuMap.binding': 'Account Binding',
'app.settings.menuMap.notification': 'New Message Notification',
'app.settings.basic.avatar': 'Change avatar',
'app.settings.basic.email': 'Email',
'app.settings.basic.email-message': 'Please input your email!',
'app.settings.basic.nickname': 'Nickname',
'app.settings.basic.nickname-message': 'Please input your Nickname!',
'app.settings.basic.profile': 'Personal profile',
'app.settings.basic.profile-message': 'Please input your personal profile!',
'app.settings.basic.profile-placeholder': 'Brief introduction to yourself',
'app.settings.basic.country': 'Country/Region',
'app.settings.basic.country-message': 'Please input your country!',
'app.settings.basic.geographic': 'Province or city',
'app.settings.basic.geographic-message': 'Please input your geographic info!',
'app.settings.basic.address': 'Street Address',
'app.settings.basic.address-message': 'Please input your address!',
'app.settings.basic.phone': 'Phone Number',
'app.settings.basic.phone-message': 'Please input your phone!',
'app.settings.basic.update': 'Update Information',
'app.settings.security.strong': 'Strong',
'app.settings.security.medium': 'Medium',
'app.settings.security.weak': 'Weak',
'app.settings.security.password': 'Account Password',
'app.settings.security.password-description': 'Current password strength:',
'app.settings.security.phone': 'Security Phone',
'app.settings.security.phone-description': 'Bound phone:',
'app.settings.security.question': 'Security Question',
'app.settings.security.question-description':
'The security question is not set, and the security policy can effectively protect the account security',
'app.settings.security.email': 'Backup Email',
'app.settings.security.email-description': 'Bound Email:',
'app.settings.security.mfa': 'MFA Device',
'app.settings.security.mfa-description':
'Unbound MFA device, after binding, can be confirmed twice',
// ...enMessages, // ...enMessages,
}, },
}; };
...@@ -72,6 +72,39 @@ export default { ...@@ -72,6 +72,39 @@ export default {
'app.analysis.table.search-keyword': '搜索关键词', 'app.analysis.table.search-keyword': '搜索关键词',
'app.analysis.table.users': '用户数', 'app.analysis.table.users': '用户数',
'app.analysis.table.weekly-range': '周涨幅', 'app.analysis.table.weekly-range': '周涨幅',
'app.settings.menuMap.basic': '基本设置',
'app.settings.menuMap.security': '安全设置',
'app.settings.menuMap.binding': '账号绑定',
'app.settings.menuMap.notification': '新消息通知',
'app.settings.basic.avatar': '更换头像',
'app.settings.basic.email': '邮箱',
'app.settings.basic.email-message': '请输入您的邮箱!',
'app.settings.basic.nickname': '昵称',
'app.settings.basic.nickname-message': '请输入您的昵称!',
'app.settings.basic.profile': '个人简介',
'app.settings.basic.profile-message': '请输入个人简介!',
'app.settings.basic.profile-placeholder': '个人简介',
'app.settings.basic.country': '国家/地区',
'app.settings.basic.country-message': '请输入您的国家或地区!',
'app.settings.basic.geographic': '所在省市',
'app.settings.basic.geographic-message': '请输入您的所在省市!',
'app.settings.basic.address': '街道地址',
'app.settings.basic.address-message': '请输入您的街道地址!',
'app.settings.basic.phone': '联系电话',
'app.settings.basic.phone-message': '请输入您的联系电话!',
'app.settings.security.strong': '',
'app.settings.security.medium': '',
'app.settings.security.weak': '',
'app.settings.security.password': '账户密码',
'app.settings.security.password-description': '当前密码强度:',
'app.settings.security.phone': '密保手机',
'app.settings.security.phone-description': '已绑定手机:',
'app.settings.security.question': '密保问题',
'app.settings.security.question-description': '未设置密保问题,密保问题可有效保护账户安全',
'app.settings.security.email': '备用邮箱',
'app.settings.security.email-description': '已绑定邮箱:',
'app.settings.security.mfa': 'MFA 设备',
'app.settings.security.mfa-description': '未绑定 MFA 设备,绑定后,可以进行二次确认',
// ...zhMessages, // ...zhMessages,
}, },
}; };
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { injectIntl, FormattedMessage } from 'react-intl';
import { Form, Input, Upload, Select, Button } from 'antd'; import { Form, Input, Upload, Select, Button } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import styles from './BaseView.less'; import styles from './BaseView.less';
import GeographicView from './GeographicView'; import GeographicView from './GeographicView';
import PhoneView from './PhoneView'; import PhoneView from './PhoneView';
// import { getTimeDistance } from '../../../utils/utils';
const FormItem = Form.Item; const FormItem = Form.Item;
const { Option } = Select; const { Option } = Select;
...@@ -11,13 +13,15 @@ const { Option } = Select; ...@@ -11,13 +13,15 @@ const { Option } = Select;
// 头像组件 方便以后独立,增加裁剪之类的功能 // 头像组件 方便以后独立,增加裁剪之类的功能
const AvatarView = ({ avatar }) => ( const AvatarView = ({ avatar }) => (
<Fragment> <Fragment>
<div className={styles.avatar_title}>头像</div> <div className={styles.avatar_title}>Avatar</div>
<div className={styles.avatar}> <div className={styles.avatar}>
<img src={avatar} alt="avatar" /> <img src={avatar} alt="avatar" />
</div> </div>
<Upload fileList={[]}> <Upload fileList={[]}>
<div className={styles.button_view}> <div className={styles.button_view}>
<Button icon="upload">更换头像</Button> <Button icon="upload">
<FormattedMessage id="app.settings.basic.avatar" defaultMessage="Change avatar" />
</Button>
</div> </div>
</Upload> </Upload>
</Fragment> </Fragment>
...@@ -49,7 +53,29 @@ const validatorPhone = (rule, value, callback) => { ...@@ -49,7 +53,29 @@ const validatorPhone = (rule, value, callback) => {
currentUser: user.currentUser, currentUser: user.currentUser,
})) }))
@Form.create() @Form.create()
export default class BaseView extends Component { class BaseView extends Component {
constructor(props) {
super(props);
const { intl } = props;
this.formLabelData = {
email: intl.formatMessage({ id: 'app.settings.basic.email' }, {}),
emailMessage: intl.formatMessage({ id: 'app.settings.basic.email-message' }, {}),
nickname: intl.formatMessage({ id: 'app.settings.basic.nickname' }, {}),
nicknameMessage: intl.formatMessage({ id: 'app.settings.basic.nickname-message' }, {}),
profile: intl.formatMessage({ id: 'app.settings.basic.profile' }, {}),
profileMessage: intl.formatMessage({ id: 'app.settings.basic.profile-message' }, {}),
profilePlaceholder: intl.formatMessage({ id: 'app.settings.basic.profile-placeholder' }, {}),
country: intl.formatMessage({ id: 'app.settings.basic.country' }, {}),
countryMessage: intl.formatMessage({ id: 'app.settings.basic.country-message' }, {}),
geographic: intl.formatMessage({ id: 'app.settings.basic.geographic' }, {}),
geographicMessage: intl.formatMessage({ id: 'app.settings.basic.geographic-message' }, {}),
address: intl.formatMessage({ id: 'app.settings.basic.address' }, {}),
addressMessage: intl.formatMessage({ id: 'app.settings.basic.address-message' }, {}),
phone: intl.formatMessage({ id: 'app.settings.basic.phone' }, {}),
phoneMessage: intl.formatMessage({ id: 'app.settings.basic.phone-message' }, {}),
};
}
componentDidMount() { componentDidMount() {
this.setBaseInfo(); this.setBaseInfo();
} }
...@@ -84,36 +110,36 @@ export default class BaseView extends Component { ...@@ -84,36 +110,36 @@ export default class BaseView extends Component {
<div className={styles.baseView} ref={this.getViewDom}> <div className={styles.baseView} ref={this.getViewDom}>
<div className={styles.left}> <div className={styles.left}>
<Form layout="vertical" onSubmit={this.handleSubmit} hideRequiredMark> <Form layout="vertical" onSubmit={this.handleSubmit} hideRequiredMark>
<FormItem label="邮箱"> <FormItem label={this.formLabelData.email}>
{getFieldDecorator('email', { {getFieldDecorator('email', {
rules: [{ required: true, message: 'Please input your email!' }], rules: [{ required: true, message: this.formLabelData.emailMessage }],
})(<Input />)} })(<Input />)}
</FormItem> </FormItem>
<FormItem label="昵称"> <FormItem label={this.formLabelData.nickname}>
{getFieldDecorator('name', { {getFieldDecorator('name', {
rules: [{ required: true, message: 'Please input your nick name!' }], rules: [{ required: true, message: this.formLabelData.nicknameMessage }],
})(<Input />)} })(<Input />)}
</FormItem> </FormItem>
<FormItem label="个人简介"> <FormItem label={this.formLabelData.profile}>
{getFieldDecorator('profile', { {getFieldDecorator('profile', {
rules: [{ required: true, message: 'Please input personal profile!' }], rules: [{ required: true, message: this.formLabelData.profileMessage }],
})(<Input.TextArea placeholder="简单的介绍下自己" rows={4} />)} })(<Input.TextArea placeholder={this.formLabelData.profilePlaceholder} rows={4} />)}
</FormItem> </FormItem>
<FormItem label="国家/地区"> <FormItem label={this.formLabelData.country}>
{getFieldDecorator('country', { {getFieldDecorator('country', {
rules: [{ required: true, message: 'Please input your country!' }], rules: [{ required: true, message: this.formLabelData.countryMessage }],
})( })(
<Select style={{ maxWidth: 220 }}> <Select style={{ maxWidth: 220 }}>
<Option value="China">中国</Option> <Option value="China">中国</Option>
</Select> </Select>
)} )}
</FormItem> </FormItem>
<FormItem label="所在省市"> <FormItem label={this.formLabelData.geographic}>
{getFieldDecorator('geographic', { {getFieldDecorator('geographic', {
rules: [ rules: [
{ {
required: true, required: true,
message: 'Please input your geographic info!', message: this.formLabelData.geographicMessage,
}, },
{ {
validator: validatorGeographic, validator: validatorGeographic,
...@@ -121,20 +147,25 @@ export default class BaseView extends Component { ...@@ -121,20 +147,25 @@ export default class BaseView extends Component {
], ],
})(<GeographicView />)} })(<GeographicView />)}
</FormItem> </FormItem>
<FormItem label="街道地址"> <FormItem label={this.formLabelData.address}>
{getFieldDecorator('address', { {getFieldDecorator('address', {
rules: [{ required: true, message: 'Please input your address!' }], rules: [{ required: true, message: this.formLabelData.addressMessage }],
})(<Input />)} })(<Input />)}
</FormItem> </FormItem>
<FormItem label="联系电话"> <FormItem label={this.formLabelData.phone}>
{getFieldDecorator('phone', { {getFieldDecorator('phone', {
rules: [ rules: [
{ required: true, message: 'Please input your phone!' }, { required: true, message: this.formLabelData.phoneMessage },
{ validator: validatorPhone }, { validator: validatorPhone },
], ],
})(<PhoneView />)} })(<PhoneView />)}
</FormItem> </FormItem>
<Button type="primary">更新信息</Button> <Button type="primary">
<FormattedMessage
id="app.settings.basic.update"
defaultMessage="Update Information"
/>
</Button>
</Form> </Form>
</div> </div>
<div className={styles.right}> <div className={styles.right}>
...@@ -144,3 +175,4 @@ export default class BaseView extends Component { ...@@ -144,3 +175,4 @@ export default class BaseView extends Component {
); );
} }
} }
export default injectIntl(BaseView);
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { routerRedux } from 'dva/router'; import { routerRedux } from 'dva/router';
import { FormattedMessage } from 'react-intl';
import { Menu } from 'antd'; import { Menu } from 'antd';
import styles from './Info.less'; import styles from './Info.less';
import GridContent from '../../layouts/GridContent'; import GridContent from '../../layouts/GridContent';
const { Item } = Menu; const { Item } = Menu;
const menuMap = {
base: '基本设置',
security: '安全设置',
binding: '账号绑定',
notification: '新消息通知',
};
@connect(({ user }) => ({ @connect(({ user }) => ({
currentUser: user.currentUser, currentUser: user.currentUser,
})) }))
...@@ -21,11 +15,27 @@ export default class Info extends Component { ...@@ -21,11 +15,27 @@ export default class Info extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
const { match, location } = props; const { match, location } = props;
let key = location.pathname.replace(`${match.path}/`, ''); const key = location.pathname.replace(`${match.path}/`, '');
key = menuMap[key] ? key : 'base'; // let key = location.pathname.replace(`${match.path}/`, '');
// key = this.state.menuMap[key] ? key : 'base';
this.state = { this.state = {
selectKey: key, selectKey: key,
mode: 'inline', mode: 'inline',
menuMap: {
base: <FormattedMessage id="app.settings.menuMap.basic" defaultMessage="Basic Settings" />,
security: (
<FormattedMessage id="app.settings.menuMap.security" defaultMessage="Security Settings" />
),
binding: (
<FormattedMessage id="app.settings.menuMap.binding" defaultMessage="Account Binding" />
),
notification: (
<FormattedMessage
id="app.settings.menuMap.notification"
defaultMessage="New Message Notification"
/>
),
},
}; };
} }
...@@ -41,7 +51,7 @@ export default class Info extends Component { ...@@ -41,7 +51,7 @@ export default class Info extends Component {
static getDerivedStateFromProps(props, state) { static getDerivedStateFromProps(props, state) {
const { match, location } = props; const { match, location } = props;
let selectKey = location.pathname.replace(`${match.path}/`, ''); let selectKey = location.pathname.replace(`${match.path}/`, '');
selectKey = menuMap[selectKey] ? selectKey : 'base'; selectKey = state.menuMap[selectKey] ? selectKey : 'base';
if (selectKey !== state.selectKey) { if (selectKey !== state.selectKey) {
return { selectKey }; return { selectKey };
} }
...@@ -49,11 +59,12 @@ export default class Info extends Component { ...@@ -49,11 +59,12 @@ export default class Info extends Component {
} }
getmenu = () => { getmenu = () => {
const { menuMap } = this.state;
return Object.keys(menuMap).map(item => <Item key={item}>{menuMap[item]}</Item>); return Object.keys(menuMap).map(item => <Item key={item}>{menuMap[item]}</Item>);
}; };
getRightTitle = () => { getRightTitle = () => {
const { selectKey } = this.state; const { selectKey, menuMap } = this.state;
return menuMap[selectKey]; return menuMap[selectKey];
}; };
......
import React, { Component, Fragment } from 'react'; import React, { Component, Fragment } from 'react';
import { FormattedMessage } from 'react-intl';
import { List } from 'antd'; import { List } from 'antd';
const passwordStrength = { const passwordStrength = {
strong: <font className="strong"></font>, strong: (
medium: <font className="medium">中文</font>, <font className="strong">
weak: <font className="weak"></font>, <FormattedMessage id="app.settings.security.strong" defaultMessage="Strong" />
</font>
),
medium: (
<font className="medium">
<FormattedMessage id="app.settings.security.medium" defaultMessage="Medium" />
</font>
),
weak: (
<font className="weak">
<FormattedMessage id="app.settings.security.weak" defaultMessage="Weak" />Weak
</font>
),
}; };
export default class SecurityView extends Component { export default class SecurityView extends Component {
getData = () => { getData = () => {
return [ return [
{ {
title: '账户密码', title: 'account password',
description: <Fragment> 当前密码强度{passwordStrength.strong}</Fragment>, description: <Fragment> Current password strength{passwordStrength.strong}</Fragment>,
actions: [<a>修改</a>], actions: [<a>Modify</a>],
}, },
{ {
title: '密保手机', title: 'Security phone',
description: '已绑定手机:138****8293', description: 'Bound phone:138****8293',
actions: [<a>修改</a>], actions: [<a>Modify</a>],
}, },
{ {
title: '密保问题', title: 'Security Question',
description: '未设置密保问题,密保问题可有效保护账户安全', description:
actions: [<a>设置</a>], 'The security question is not set, and the security policy can effectively protect the account security',
actions: [<a>Set</a>],
}, },
{ {
title: '备用邮箱', title: 'Backup Email',
description: '已绑定邮箱:ant***sign.com', description: 'Bound Email:ant***sign.com',
actions: [<a>修改</a>], actions: [<a>Modify</a>],
}, },
{ {
title: 'MFA 设备', title: 'MFA Device',
description: '未绑定 MFA 设备,绑定后,可以进行二次确认', description: 'Unbound MFA device, after binding, can be confirmed twice',
actions: [<a>绑定</a>], actions: [<a>Bind</a>],
}, },
]; ];
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment