Commit 2f7b551a authored by nano's avatar nano

remove react intl

parent c984d162
{
"plugins": ["babel-plugin-transform-decorators-legacy"]
}
\ No newline at end of file
......@@ -19,11 +19,13 @@ export default {
'extraBabelPlugins': [
'dva-hmr',
'transform-runtime',
'babel-plugin-transform-decorators-legacy',
['import', { 'libraryName': 'antd', 'style': 'css' }]
]
},
'production': {
'extraBabelPlugins': [
'babel-plugin-transform-decorators-legacy',
'transform-runtime',
['import', { 'libraryName': 'antd', 'style': 'css' }]
]
......
import { Form, Input } from 'antd';
import React, { PropTypes } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import SubmitButton from './SubmitButton';
......@@ -7,14 +7,14 @@ const FormItem = Form.Item;
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 15 },
};
}
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
// static contextTypes = {
// intl: PropTypes.object.isRequired,
// };
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
......@@ -33,10 +33,10 @@ class EmailForm extends React.Component {
};
render() {
const { form, dispatch, user, checkEmail, isEmailExists } = this.props;
const { form, dispatch, user, checkEmail, isEmailExists, messages } = this.props;
const { getFieldDecorator } = form;
const { id, email } = user;
const { intl: { messages } } = this.context;
// const { intl: { messages } } = this.context;
const emailProps = {
......@@ -105,9 +105,11 @@ function mapStateToProps(state) {
const {
user: { user },
auth: { isEmailExists, checkEmail },
common: { messages },
} = state;
return {
user,
messages,
checkEmail,
isEmailExists,
};
......
import React from 'react';
import { connect } from 'react-redux';
class Format extends React.Component {
render() {
const { id, messages } = this.props
return (
<span>{messages[id] || id}</span>
);
}
}
function mapStateToProps(state) {
const {
common: { messages },
} = state;
return {
messages,
};
}
export default connect(mapStateToProps)(Format);
import { Form, Input } from 'antd';
import React, { PropTypes } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import SubmitButton from './SubmitButton';
......@@ -15,10 +15,6 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
......@@ -56,9 +52,8 @@ class EmailForm extends React.Component {
render() {
const { form } = this.props;
const { form, messages } = this.props;
const { getFieldDecorator } = form;
const { intl: { messages } } = this.context;
const passwordProps = {
fromItem: {
......@@ -138,8 +133,10 @@ class EmailForm extends React.Component {
function mapStateToProps(state) {
const {
user: { user },
common: { messages },
} = state;
return {
messages,
user,
};
}
......
import { Form, Input } from 'antd';
import React, { PropTypes } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import SubmitButton from './SubmitButton';
......@@ -12,10 +12,6 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
if (e) {
......@@ -33,10 +29,9 @@ class EmailForm extends React.Component {
};
render() {
const { form, dispatch, user, checkEmail, isEmailExists } = this.props;
const { form, dispatch, user, checkEmail, isEmailExists, messages } = this.props;
const { getFieldDecorator } = form;
const { id, email } = user;
const { intl: { messages } } = this.context;
const emailProps = {
fromItem: {
......@@ -79,9 +74,11 @@ function mapStateToProps(state) {
const {
user: { user },
auth: { isEmailExists, checkEmail, isSendEmailActive },
common: { messages },
} = state;
return {
user,
messages,
checkEmail,
isEmailExists,
isSendEmailActive,
......
import { Button } from 'antd';
import React from 'react';
import { FormattedMessage as Format } from 'react-intl';
// import { FormattedMessage as Format } from 'react-intl';
import styles from './SubmitButton.css';
import Format from '../components/Format'
function SubmitButton(props) {
return (
......
import { Form, Input } from 'antd';
import React, { PropTypes } from 'react';
import React from 'react';
import { connect } from 'react-redux';
import SubmitButton from './SubmitButton';
......@@ -12,9 +12,6 @@ const formItemLayout = {
class EmailForm extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
......@@ -33,10 +30,9 @@ class EmailForm extends React.Component {
};
render() {
const { form, dispatch, user, checkUsername, isUserNameExists } = this.props;
const { form, dispatch, user, checkUsername, isUserNameExists, messages } = this.props;
const { getFieldDecorator } = form;
const { id, username } = user;
const { intl: { messages } } = this.context;
const usernameProps = {
fromItem: {
......@@ -102,9 +98,11 @@ function mapStateToProps(state) {
const {
user: { user },
auth: { isUserNameExists, checkUsername },
common: { messages },
} = state;
return {
user,
messages,
checkUsername,
isUserNameExists,
};
......
......@@ -2,7 +2,8 @@ import { Dropdown, Menu } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React from 'react';
import { FormattedMessage as Format } from 'react-intl';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
const defaultAvatar = require('../../public/default_avatar.jpg');
......
......@@ -3,10 +3,7 @@ import dva from 'dva';
import createLoading from 'dva-loading';
import { browserHistory } from 'dva/router';
import ReactDOM from 'react-dom';
import { addLocaleData, IntlProvider } from 'react-intl';
import en from 'react-intl/locale-data/en';
import zh from 'react-intl/locale-data/zh';
import localeData from '../i18n.json';
import './index.less';
// 1. Initialize
......@@ -44,21 +41,9 @@ app.model(require('./models/common'));
app.router(require('./router'));
// 5. Start
addLocaleData([...en, ...zh]);
const languageY = localStorage.getItem('locale') || navigator.language || (navigator.languages && navigator.languages[0]) || navigator.userLanguage;
const anguageWithoutRegionCode = languageY.toLowerCase().split(/[_-]+/)[0];
const language = anguageWithoutRegionCode === 'zh' ? 'zh-CN' : 'en-US';
const messages = localeData[language];
const App = app.start();
ReactDOM.render(
<IntlProvider locale={language} messages={messages}>
<App/>
</IntlProvider>,
<App/>,
document.getElementById('root'),
);
import { Button } from 'antd';
import { connect } from 'dva';
import React from 'react';
import { FormattedMessage as Format } from 'react-intl';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
class Active extends React.Component {
......
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';
import React from 'react';
import Format from '../components/Format'
const FormItem = Form.Item;
const Step = Steps.Step;
class Login extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onSubmitLogin = (e) => {
const { form, dispatch } = this.props;
......@@ -32,8 +29,8 @@ class Login extends React.Component {
render() {
const { getFieldDecorator } = this.props.form;
const { loading } = this.props;
const { intl: { messages } } = this.context;
const { loading, messages } = this.props;
return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
<Spin spinning={loading} delay={100}>
......@@ -74,12 +71,14 @@ class Login extends React.Component {
function mapStateToProps(state) {
const {
auth: { isForgotSubmit },
common: { messages },
} = state;
const loading = state.loading.global || false;
return {
loading,
messages,
isForgotSubmit,
};
}
......
......@@ -2,9 +2,10 @@ import { Dropdown, Icon, Layout, Menu } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React from 'react';
import DocumentTitle from 'react-document-title';
import { FormattedMessage as Format } from 'react-intl';
import Particles from 'react-particles-js';
import DocumentTitle from 'react-document-title';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format';
import logo from '../assets/MoeCube.png';
import UserPanel from '../components/UserPanel';
......
import { Button, Form, Icon, Input, Spin } from 'antd';
import { connect } from 'dva';
import { Link } from 'dva/router';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
import React from 'react';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
import './Login.less';
const FormItem = Form.Item;
......@@ -10,9 +12,9 @@ const FormItem = Form.Item;
class Login extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
// static contextTypes = {
// intl: PropTypes.object.isRequired,
// };
onSubmitLogin = (e) => {
const { form, dispatch } = this.props;
......@@ -31,8 +33,8 @@ class Login extends React.Component {
render() {
const { getFieldDecorator } = this.props.form;
const { loading } = this.props;
const { intl: { messages } } = this.context;
const { loading, messages } = this.props;
// const { intl: { messages } } = this.context;
return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
......@@ -79,12 +81,13 @@ class Login extends React.Component {
function mapStateToProps(state) {
const {
common: { language },
common: { language, messages },
} = state;
const loading = state.loading.global || false;
return {
messages,
loading,
language,
};
......
import { Button, Form, Icon, Input, Spin, Tabs } from 'antd';
import 'cropperjs/dist/cropper.css';
import { connect } from 'dva';
import React, { PropTypes } from 'react';
import React from 'react';
import Cropper from 'react-cropper';
import { FormattedMessage as Format } from 'react-intl';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
import EmailForm from '../components/EmailForm';
import PasswordForm from '../components/PasswordForm';
import UserNameForm from '../components/UserNameForm';
......@@ -27,9 +29,6 @@ const formItemLayout = {
class Profiles extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
onUpdateSubmit = (e) => {
const { form, dispatch, user: { id } } = this.props;
......@@ -81,10 +80,10 @@ class Profiles extends React.Component {
};
render() {
const { form, user, loading, imageUrl, isUpload } = this.props;
const { form, user, loading, imageUrl, isUpload, messages } = this.props;
const { getFieldDecorator } = form;
const { name, avatar } = user;
const { intl: { messages } } = this.context;
// const { intl: { messages } } = this.context;
const nameProps = {
fromItem: {
......@@ -182,6 +181,7 @@ function mapStateToProps(state) {
user: { user, isUpdateSubmit },
auth: { checkUsername, isEmailExists, isUserNameExists },
upload: { imageUrl, isUpload, uploadedImage },
common: { messages },
} = state;
const loading = state.loading.global || false;
......@@ -189,6 +189,7 @@ function mapStateToProps(state) {
return {
user,
loading,
messages,
imageUrl,
isUpload,
checkUsername,
......
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';
import React from 'react';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
const FormItem = Form.Item;
const Step = Steps.Step;
......@@ -10,9 +11,9 @@ const Step = Steps.Step;
class Register extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
// static contextTypes = {
// intl: PropTypes.object.isRequired,
// };
onSubmitLogin = (e) => {
const { form, dispatch } = this.props;
......@@ -52,10 +53,10 @@ class Register extends React.Component {
render() {
const {
dispatch, form, checkEmail, checkUsername,
isEmailExists, isUserNameExists, loading,
isEmailExists, isUserNameExists, loading, messages,
} = this.props;
const { getFieldDecorator } = form;
const { intl: { messages } } = this.context;
// const { intl: { messages } } = this.context;
const emailProps = {
hasFeedback: true,
......@@ -173,12 +174,14 @@ function mapStateToProps(state) {
register, checkEmail, checkUsername, isEmailExists,
isUserNameExists, isRegisterSubmit,
},
common: { messages },
} = state;
const loading = state.loading.global || false;
return {
loading,
messages,
register,
checkEmail,
checkUsername,
......
import { Button, Form, Icon, Input, Spin } from 'antd';
import { connect } from 'dva';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
import React from 'react';
// import { FormattedMessage as Format } from 'react-intl';
import Format from '../components/Format'
const FormItem = Form.Item;
class Reset extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
// static contextTypes = {
// intl: PropTypes.object.isRequired,
// };
onSubmitReset = (e) => {
const { form, dispatch, location: { query: { key, user_id } } } = this.props;
......@@ -47,8 +48,8 @@ class Reset extends React.Component {
render() {
const { getFieldDecorator } = this.props.form;
const { isResetSubmit = false } = this.props;
const { intl: { messages } } = this.context;
const { isResetSubmit = false, messages } = this.props;
// const { intl: { messages } } = this.context;
return (
<div style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center', height: '100%' }}>
......@@ -95,8 +96,10 @@ class Reset extends React.Component {
function mapStateToProps(state) {
const {
auth: { isResetSubmit },
common: { messages },
} = state;
return {
messages,
isResetSubmit,
};
}
......
import { Alert, Form, Icon, Input, Spin, Steps, Tag } from 'antd';
import { connect } from 'dva';
import { routerRedux } from 'dva/router';
import React, { PropTypes } from 'react';
import { FormattedMessage as Format } from 'react-intl';
import React from 'react';
// import { FormattedMessage as Format } from 'react-intl';
import SubmitButton from '../components/SubmitButton';
import Format from '../components/Format'
const FormItem = Form.Item;
......@@ -11,9 +13,9 @@ const Step = Steps.Step;
class Verify extends React.Component {
static contextTypes = {
intl: PropTypes.object.isRequired,
};
// static contextTypes = {
// intl: PropTypes.object.isRequired,
// };
state = {
isChangeEmail: false,
};
......@@ -46,10 +48,12 @@ class Verify extends React.Component {
};
render() {
const { form, dispatch, user, checkEmail, isEmailExists, loading, input } = this.props;
const { form, dispatch, user, checkEmail,
isEmailExists, loading, input, messages,
} = this.props;
const { getFieldDecorator } = form;
const { id, email } = user;
const { intl: { messages } } = this.context;
// const { intl: { messages } } = this.context;
const emailProps = {
fromItem: {
......@@ -135,6 +139,7 @@ function mapStateToProps(state) {
const {
user: { user },
auth: { input, isEmailExists, checkEmail },
common: { messages },
} = state;
const loading = state.loading.global || false;
......@@ -143,6 +148,7 @@ function mapStateToProps(state) {
input,
user,
loading,
messages,
checkEmail,
isEmailExists,
};
......
......@@ -522,7 +522,7 @@ babel-plugin-syntax-class-properties@^6.8.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-class-properties/-/babel-plugin-syntax-class-properties-6.13.0.tgz#d7eb23b79a317f8543962c505b827c7d6cac27de"
babel-plugin-syntax-decorators@^6.13.0:
babel-plugin-syntax-decorators@^6.1.18, babel-plugin-syntax-decorators@^6.13.0:
version "6.13.0"
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-decorators/-/babel-plugin-syntax-decorators-6.13.0.tgz#312563b4dbde3cc806cee3e416cceeaddd11ac0b"
......@@ -595,6 +595,14 @@ babel-plugin-transform-class-properties@^6.22.0:
babel-runtime "^6.22.0"
babel-template "^6.23.0"
babel-plugin-transform-decorators-legacy@^1.3.4:
version "1.3.4"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-decorators-legacy/-/babel-plugin-transform-decorators-legacy-1.3.4.tgz#741b58f6c5bce9e6027e0882d9c994f04f366925"
dependencies:
babel-plugin-syntax-decorators "^6.1.18"
babel-runtime "^6.2.0"
babel-template "^6.3.0"
babel-plugin-transform-decorators@^6.22.0:
version "6.22.0"
resolved "https://registry.yarnpkg.com/babel-plugin-transform-decorators/-/babel-plugin-transform-decorators-6.22.0.tgz#c03635b27a23b23b7224f49232c237a73988d27c"
......@@ -964,14 +972,14 @@ babel-register@^6.18.0, babel-register@^6.24.0:
mkdirp "^0.5.1"
source-map-support "^0.4.2"
babel-runtime@6.x, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.9.2:
babel-runtime@6.x, babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.2.0, babel-runtime@^6.22.0, babel-runtime@^6.9.2:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b"
dependencies:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"
babel-template@^6.22.0, babel-template@^6.23.0:
babel-template@^6.22.0, babel-template@^6.23.0, babel-template@^6.3.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638"
dependencies:
......@@ -2757,27 +2765,15 @@ interpret@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.0.1.tgz#d579fb7f693b858004947af39fa0db49f795602c"
intl-format-cache@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/intl-format-cache/-/intl-format-cache-2.0.5.tgz#b484cefcb9353f374f25de389a3ceea1af18d7c9"
intl-messageformat-parser@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/intl-messageformat-parser/-/intl-messageformat-parser-1.2.0.tgz#5906b7f953ab7470e0dc8549097b648b991892ff"
intl-messageformat@1.3.0, intl-messageformat@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/intl-messageformat/-/intl-messageformat-1.3.0.tgz#f7d926aded7a3ab19b2dc601efd54e99a4bd4eae"
dependencies:
intl-messageformat-parser "1.2.0"
intl-locales-supported@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/intl-locales-supported/-/intl-locales-supported-1.0.0.tgz#9a9d94dbf104a87818881952dcb782053f0aeefa"
intl-relativeformat@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/intl-relativeformat/-/intl-relativeformat-1.3.0.tgz#893dc7076fccd380cf091a2300c380fa57ace45b"
dependencies:
intl-messageformat "1.3.0"
intl@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde"
invariant@^2.0.0, invariant@^2.1.1, invariant@^2.2.0, invariant@^2.2.1:
invariant@^2.0.0, invariant@^2.2.0, invariant@^2.2.1:
version "2.2.2"
resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"
dependencies:
......@@ -4543,15 +4539,6 @@ react-hammerjs@~0.5.0:
dependencies:
hammerjs "^2.0.8"
react-intl@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/react-intl/-/react-intl-2.2.3.tgz#8eebb03cddc38b337ed22fab78037ab53a594270"
dependencies:
intl-format-cache "^2.0.5"
intl-messageformat "^1.3.0"
intl-relativeformat "^1.3.0"
invariant "^2.1.1"
react-lazy-load@^3.0.10:
version "3.0.11"
resolved "https://registry.yarnpkg.com/react-lazy-load/-/react-lazy-load-3.0.11.tgz#1d27e4e1f6dc77daaf9236db707aaf2bbbfabafe"
......
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