Commit 4fdee9cc authored by 2breakegg's avatar 2breakegg

change language 按钮位置

parent 323eb459
......@@ -4,6 +4,8 @@
"rules": {
"react/jsx-space-before-closing":[0],
"generator-star-spacing": [0],
"semi":[0],
"no-console":[0],
"consistent-return": [0],
"react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }],
......
This diff is collapsed.
let publicPath = 'https://cdn01.moecube.com/accounts/'
const API_ROOT = {
test: 'http://192.168.1.9:3000',
dev: 'http://114.215.243.95:8082',
prod: 'https://api.moeube.com/accounts'
}
let defineConf = {
apiRoot: process.env["API_ROOT"]
apiRoot: API_ROOT[process.env["ENV"]],
}
export default {
......
{
"private": true,
"scripts": {
"start": "cross-env API_ROOT=http://192.168.1.9:3000 roadhog server",
"build:dev": "cross-env API_ROOT=http://114.215.243.95:8082 roadhog build",
"build": "cross-env API_ROOT=https://api.moeube.com/accounts roadhog build",
"start": "cross-env ENV=test roadhog server",
"build:dev": "cross-env ENV=dev roadhog build",
"build": "cross-env ENV=prod roadhog build",
"lint": "eslint --ext .js src test",
"precommit": "npm run lint"
},
......
import i18n from '../../i18n.json';
export default {
namespace: 'common',
state: {
language: 'zh-CN',
messages: {},
},
reducers: {
init(state, action) {
return {
...state, ...action.payload,
};
},
changeLanguage(state, { payload: id }) {
localStorage.setItem('locale', id.id);
history.go(0);
return state;
},
},
effects: {},
subscriptions: {
setup({ dispatch }) {
const language = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const languageWithoutRegionCode = language.toLowerCase().split(/[_-]+/)[0];
const messages = i18n[languageWithoutRegionCode];
dispatch({ type: 'init', payload: { language: languageWithoutRegionCode, messages } });
},
},
};
import { Route, Router } from 'dva/router';
import { Route, Router, Redirect } from 'dva/router';
import React from 'react';
import Active from './routes/Activate.js';
......
......@@ -95,6 +95,7 @@ class Profiles extends React.Component {
/* eslint-disable jsx-a11y/label-has-for */
return (
<div style={{ flex: 1, height: '100%' }}>
<Spin spinning={loading} delay={100}>
<Tabs defaultActiveKey="1" className="app-detail-nav">
<TabPane tab={<span><Icon type="user"/><Format id={'user-info'}/> </span>} key="1">
......@@ -107,7 +108,7 @@ class Profiles extends React.Component {
this.cropper = cropper;
}}
src={imageUrl || defaultAvatar}
style={{ height: '20vw', width: '20vw' }}
style={{ maxHeight: '20vw', maxWidth: '20vw' }}
aspectRatio={1 / 1}
guides
/>
......@@ -164,6 +165,7 @@ class Profiles extends React.Component {
</TabPane>
</Tabs>
</Spin>
</div>
);
}
}
......
import { Button, Form, Icon, Input, Spin, Steps } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
const FormItem = Form.Item;
const Step = Steps.Step;
class Register extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmitLogin = (e) => {
const { form, dispatch } = this.props;
if (e) {
e.preventDefault();
}
form.validateFieldsAndScroll((err, values) => {
if (!err) {
console.log('Received values of form: ', values);
const { email, username, password } = values;
dispatch({ type: 'auth/register', payload: { email, username, password } });
}
});
};
checkPassword = (rule, value, callback) => {
const form = this.props.form;
if (value && value !== form.getFieldValue('password')) {
callback(this.context.intl.messages['Incorrect-password.2']);
} else {
callback();
}
};
checkConfirm = (rule, value, callback) => {
const form = this.props.form;
if (value) {
form.validateFields(['confirm'], { force: true });
}
callback();
};
render() {
const {
dispatch, form, checkEmail, checkUsername,
isEmailExists, isUserNameExists, loading,
} = this.props;
const { getFieldDecorator } = form;
const { intl: { messages } } = this.context;
const emailProps = {
hasFeedback: true,
validateStatus: checkEmail,
extra: isEmailExists ? messages.i_email_exists : '',
};
const emailInputProps = {
onBlur: () => !form.getFieldError('email') && dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue() } }),
placeholder: messages.email,
};
const usernameProps = {
hasFeedback: true,
validateStatus: checkUsername,
extra: isUserNameExists ? 'username exists' : '',
};
const usernameInputProps = {
onBlur: () => !form.getFieldError('username') && dispatch({ type: 'auth/checkUsername', payload: { ...form.getFieldsValue() } }),
placeholder: messages.username,
};
return (
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}>
<Steps size="large" current={0}>
<Step title={messages['sign-up']} icon={<Icon type="solution"/>}/>
<Step title={messages['verify-email']} icon={<Icon type="mail"/>}/>
</Steps>
<Form onSubmit={this.onSubmitLogin} className="login-form" style={{ marginTop: '24px' }}>
<FormItem {...emailProps} >
{getFieldDecorator('email', {
rules: [{
required: true,
message: messages['Please-use-a-correct-E-Mail-address.'],
pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
}],
}, {})(
<Input {...emailInputProps} />,
)}
</FormItem>
<FormItem {...usernameProps}>
{getFieldDecorator('username', {
rules: [{
required: true,
message: messages['You-can-not-use-this-username.'],
pattern: /^[A-Za-z0-9_\u4E00-\u9FD5\u3400-\u4DBF\u{20000}-\u{2A6DF}\u{2A700}-\u{2CEAF}\uF900–\uFAFF\u{2F800}-\u{2FA1D}\uAC00–\uD7AF\u3040-\u30FF\u31F0–\u31FF\u{1B000}–\u{1B0FF}\u3005]+$/u,
}],
}, {})(
<Input {...usernameInputProps} />,
)}
</FormItem>
<FormItem hasFeedback>
{getFieldDecorator('password', {
rules: [{
required: true,
message: messages['Password-length-must-be-between-8-and-24-characters.'],
pattern: /^.{8,24}$/,
}],
}, {
validator: this.checkConfirm,
})(
<Input
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password"
placeholder={messages.password}
/>,
)}
</FormItem>
<FormItem hasFeedback>
{getFieldDecorator('confirm', {
rules: [{
required: true,
message: messages['Password-length-must-be-between-8-and-24-characters.'],
pattern: /^.{8,24}$/,
}, {
validator: this.checkPassword,
}],
})(
<Input
prefix={<Icon type="lock" style={{ fontSize: 13 }}/>}
type="password"
onBlur={this.handleConfirmBlur}
placeholder={messages['password-again']}
/>,
)}
</FormItem>
<FormItem>
<Button type="primary" htmlType="submit" className="login-form-button">
<Format id={'sign-up'}/>
</Button>
</FormItem>
<div>
<Link to="/signin"><Format id={'sign-in'}/></Link>
</div>
</Form>
</Spin>
</div>
);
}
}
function mapStateToProps(state) {
const {
auth: {
register, checkEmail, checkUsername, isEmailExists,
isUserNameExists, isRegisterSubmit,
},
} = state;
const loading = state.loading.global || false;
return {
loading,
register,
checkEmail,
checkUsername,
isEmailExists,
isUserNameExists,
isRegisterSubmit,
};
}
const WrapperRegister = Form.create()(Register);
export default connect(mapStateToProps)(WrapperRegister);
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