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

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

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