Commit 7ae37291 authored by 2breakegg's avatar 2breakegg

i18n + 修改账户信息 无密码长度约束

parent 871ea484
This diff is collapsed.
...@@ -48,7 +48,6 @@ ...@@ -48,7 +48,6 @@
"You can use this E-mail address.": "You can use this E-mail address.", "You can use this E-mail address.": "You can use this E-mail address.",
"This user name has been token.": "This user name has been token.", "This user name has been token.": "This user name has been token.",
"You can use this user name.": "You can use this user name.", "You can use this user name.": "You can use this user name.",
"Password is not correct.": "Password is not correct.",
"User does not exisit.": "User does not exisit.", "User does not exisit.": "User does not exisit.",
"Incorrect password.": "Incorrect password.", "Incorrect password.": "Incorrect password.",
"Please check your registration info again.": "Please check your registration info again.", "Please check your registration info again.": "Please check your registration info again.",
...@@ -128,7 +127,6 @@ ...@@ -128,7 +127,6 @@
"You can use this E-mail address.": "邮箱可以使用", "You can use this E-mail address.": "邮箱可以使用",
"This user name has been token.": "该用户名已被注册", "This user name has been token.": "该用户名已被注册",
"You can use this user name.": "用户名可以使用", "You can use this user name.": "用户名可以使用",
"Password is not correct.": "密码不一致",
"User does not exisit.": "用户不存在", "User does not exisit.": "用户不存在",
"Incorrect password.": "密码不正确", "Incorrect password.": "密码不正确",
"Please check your registration info again.": "请填写正确的注册信息。", "Please check your registration info again.": "请填写正确的注册信息。",
...@@ -156,6 +154,7 @@ ...@@ -156,6 +154,7 @@
"old-password":"原密码", "old-password":"原密码",
"new-password":"新密码", "new-password":"新密码",
"Password length must be between 8 and 24 characters":"密码必须为8-24位", "Password length must be between 8 and 24 characters":"密码必须为8-24位",
"Please confirm your password":"",
"密码至少为8-24位":"密码至少为8-24位", "密码至少为8-24位":"密码至少为8-24位",
......
...@@ -82,7 +82,7 @@ class EmailForm extends React.Component { ...@@ -82,7 +82,7 @@ class EmailForm extends React.Component {
</FormItem> </FormItem>
<FormItem {...passwordProps.fromItem}> <FormItem {...passwordProps.fromItem}>
{getFieldDecorator(`password`, {...passwordProps.decorator})( {getFieldDecorator('password')(
<Input {...passwordProps.input} /> <Input {...passwordProps.input} />
)} )}
</FormItem> </FormItem>
......
...@@ -66,7 +66,7 @@ class EmailForm extends React.Component { ...@@ -66,7 +66,7 @@ class EmailForm extends React.Component {
rules: [ rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ }, { required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/ },
{ validator: this.checkConfirm } { validator: this.checkConfirm }
] ],
}, },
input: { input: {
placeholder: messages['old-password'], placeholder: messages['old-password'],
...@@ -87,7 +87,7 @@ class EmailForm extends React.Component { ...@@ -87,7 +87,7 @@ class EmailForm extends React.Component {
rules: [ rules: [
{ required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/}, { required: true, message: messages['Password length must be between 8 and 24 characters'], pattern: /^.{8,24}$/},
{ validator: this.checkPassword} { validator: this.checkPassword}
] ],
}, },
input: { input: {
placeholder: messages['password-again'], placeholder: messages['password-again'],
...@@ -98,13 +98,13 @@ class EmailForm extends React.Component { ...@@ -98,13 +98,13 @@ class EmailForm extends React.Component {
return ( return (
<Form onSubmit={this.onSubmit}> <Form onSubmit={this.onSubmit}>
<FormItem {...passwordProps.fromItem} label={messages['old-password']}> <FormItem {...passwordProps.fromItem} label={messages['old-password']}>
{getFieldDecorator(`password`, {...passwordProps.decorator})( {getFieldDecorator('password')(
<Input {...passwordProps.input} /> <Input {...passwordProps.input} />
)} )}
</FormItem> </FormItem>
<FormItem {...passwordProps.fromItem} label={messages['new-password']}> <FormItem {...passwordProps.fromItem} label={messages['new-password']}>
{getFieldDecorator(`new_password`, {...passwordProps.decorator})( {getFieldDecorator('new_password', {...passwordProps.decorator})(
<Input {...passwordProps.input2} /> <Input {...passwordProps.input2} />
)} )}
</FormItem> </FormItem>
......
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import styles from './EmailForm.css'; import styles from './EmailForm.css';
import { connect } from 'react-redux' import { connect } from 'react-redux'
import { Form, Input, Icon, Button, Modal } from 'antd' import { Form, Input, Icon, Button, Modal } from 'antd';
const FormItem = Form.Item; const FormItem = Form.Item;
import SubmitButton from './SubmitButton' import SubmitButton from './SubmitButton';
const formItemLayout = { const formItemLayout = {
labelCol: { span: 4 }, labelCol: { span: 4 },
......
...@@ -2,8 +2,8 @@ import { Form, Input } from 'antd'; ...@@ -2,8 +2,8 @@ import { Form, Input } from 'antd';
import React, { PropTypes } from 'react'; import React, { PropTypes } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import SubmitButton from './SubmitButton'; import SubmitButton from './SubmitButton';
const FormItem = Form.Item;
const FormItem = Form.Item;
const formItemLayout = { const formItemLayout = {
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 15 }, wrapperCol: { span: 15 },
...@@ -35,7 +35,7 @@ class EmailForm extends React.Component { ...@@ -35,7 +35,7 @@ class EmailForm extends React.Component {
const { form, dispatch, data, checkUsername, isUserNameExists } = this.props; const { form, dispatch, data, checkUsername, isUserNameExists } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { id, username } = data; const { id, username } = data;
const { intl: {messages} } = this.context; const { intl: { messages } } = this.context;
const usernameProps = { const usernameProps = {
fromItem: { fromItem: {
...@@ -73,13 +73,13 @@ class EmailForm extends React.Component { ...@@ -73,13 +73,13 @@ class EmailForm extends React.Component {
return ( return (
<Form onSubmit={this.onSubmit}> <Form onSubmit={this.onSubmit}>
<FormItem {...usernameProps.fromItem}> <FormItem {...usernameProps.fromItem}>
{getFieldDecorator(`username`, { ...usernameProps.decorator })( {getFieldDecorator('username', { ...usernameProps.decorator })(
<Input {...usernameProps.input}/>, <Input {...usernameProps.input}/>,
)} )}
</FormItem> </FormItem>
<FormItem {...passwordProps.fromItem}> <FormItem {...passwordProps.fromItem}>
{getFieldDecorator(`password`, { ...passwordProps.decorator })( {getFieldDecorator('password')(
<Input {...passwordProps.input} />, <Input {...passwordProps.input} />,
)} )}
</FormItem> </FormItem>
......
...@@ -49,12 +49,11 @@ app.router(require('./router')); ...@@ -49,12 +49,11 @@ app.router(require('./router'));
addLocaleData([...en, ...zh]); addLocaleData([...en, ...zh]);
/*eslint-disable */ /*eslint-disable */
let language = navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage; let language =localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
/*eslint-enable */ /*eslint-enable */
if(localStorage.getItem('locale')){
language = localStorage.getItem('locale');
}
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0]; const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
language = (localeData[languageWithoutRegionCode] || localeData[language]) ? language : 'zh-CN';
const messages = localeData[languageWithoutRegionCode] || localeData[language] || localeData.zh; const messages = localeData[languageWithoutRegionCode] || localeData[language] || localeData.zh;
const App = app.start(); const App = app.start();
...@@ -65,5 +64,3 @@ ReactDOM.render( ...@@ -65,5 +64,3 @@ ReactDOM.render(
document.getElementById('root'), document.getElementById('root'),
); );
console.log(language);
import { Button, Form, Icon, Input, Select, Spin } from 'antd'; import { Button, Form, Icon, Input, Select, Spin } from 'antd';
import { connect } from 'dva'; import { connect } from 'dva';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl'; import { FormattedMessage as Format } from 'react-intl';
import React from 'react';
const FormItem = Form.Item; const FormItem = Form.Item;
const Option = Select.Option; const Option = Select.Option;
class Reset extends React.Component { class Reset extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmitReset = (e) => { onSubmitReset = (e) => {
const { form, dispatch, location: { query: { key, user_id } } } = this.props; const { form, dispatch, location: { query: { key, user_id } } } = this.props;
...@@ -43,35 +48,40 @@ class Reset extends React.Component { ...@@ -43,35 +48,40 @@ class Reset extends React.Component {
render() { render() {
const { getFieldDecorator } = this.props.form; const { getFieldDecorator } = this.props.form;
const { isResetSubmit = false } = this.props; const { isResetSubmit = false } = this.props;
const { intl: { messages } } = this.context;
return ( return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}> <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={isResetSubmit} delay={100}> <Spin spinning={isResetSubmit} delay={100}>
<Form onSubmit={this.onSubmitReset} className="login-form"> <Form onSubmit={this.onSubmitReset} className="login-form">
<FormItem>
<h1><Format id='reset-password'/></h1>
</FormItem>
<FormItem> <FormItem>
{getFieldDecorator('password', { {getFieldDecorator('password', {
rules: [{ required: true, message: 'Please input your Password!' }], rules: [{ required: true, message: messages['Password can not be blank'] }],
}, { }, {
validator: this.checkConfirm, validator: this.checkConfirm,
})( })(
<Input prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} type="password" placeholder="Password"/>, <Input prefix={<Icon type="lock" style={{ fontSize: 13 }}/>} type="password"
placeholder={messages.password}/>,
)} )}
</FormItem> </FormItem>
<FormItem> <FormItem>
{getFieldDecorator('confirm', { {getFieldDecorator('confirm', {
rules: [{ rules: [{
required: true, message: 'Please confirm your password!', required: true, message: messages['Incorrect password.2'],
}, { }, {
validator: this.checkPassword, validator: this.checkPassword,
}], }],
})( })(
<Input type="password" onBlur={this.handleConfirmBlur} placeholder="Password Again"/>, <Input type="password" onBlur={this.handleConfirmBlur} placeholder={messages['password-again']}/>,
)} )}
</FormItem> </FormItem>
<Button type="primary" htmlType="submit" className="login-form-button"> <Button type="primary" htmlType="submit" className="login-form-button">
Submit <Format id='reset-password'/>
</Button> </Button>
</Form> </Form>
</Spin> </Spin>
......
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