Commit 20311474 authored by 2breakegg's avatar 2breakegg
parents 5238444e eecf89f3
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
"react/forbid-prop-types": [0], "react/forbid-prop-types": [0],
"react/jsx-filename-extension": [1, { "extensions": [".js"] }], "react/jsx-filename-extension": [1, { "extensions": [".js"] }],
"global-require": [1], "global-require": [1],
"react/jsx-closing-bracket-location":[0],
"import/prefer-default-export": [0], "import/prefer-default-export": [0],
"react/jsx-no-bind": [0], "react/jsx-no-bind": [0],
"react/prop-types": [0], "react/prop-types": [0],
......
...@@ -81,7 +81,7 @@ class EmailForm extends React.Component { ...@@ -81,7 +81,7 @@ class EmailForm extends React.Component {
{getFieldDecorator('email', { ...emailProps.decorator })( {getFieldDecorator('email', { ...emailProps.decorator })(
<Input <Input
{...emailProps.input} {...emailProps.input}
onBlur={() => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue(), id } })} onBlur={() => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue(), user_id: id } })}
/>, />,
)} )}
</FormItem> </FormItem>
......
...@@ -61,7 +61,7 @@ class EmailForm extends React.Component { ...@@ -61,7 +61,7 @@ class EmailForm extends React.Component {
{getFieldDecorator('email', { ...emailProps.decorator })( {getFieldDecorator('email', { ...emailProps.decorator })(
<Input <Input
{...emailProps.input} {...emailProps.input}
onBlur={() => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue(), id } })} onBlur={() => dispatch({ type: 'auth/checkEmail', payload: { ...form.getFieldsValue(), user_id: id } })}
/>, />,
)} )}
</FormItem> </FormItem>
......
...@@ -6,19 +6,19 @@ import { FormattedMessage as Format } from 'react-intl'; ...@@ -6,19 +6,19 @@ import { FormattedMessage as Format } from 'react-intl';
const defaultAvatar = require('../../public/default_avatar.jpg'); const defaultAvatar = require('../../public/default_avatar.jpg');
function UserPanel({ dispatch, user, token }) { function UserPanel({ dispatch, user }) {
const { avatar } = user; const { avatar } = user;
const menu = ( const menu = (
<Menu trigger={['click']}> <Menu trigger={['click']}>
<Menu.Item> <Menu.Item>
{ {
token ? <Link to="/profiles"><Format id="User-Center"/></Link> : <Link to="/signin"><Format id="sign-in"/></Link> user.active ? <Link to="/profiles"><Format id="User-Center"/></Link> : <Link to="/signin"><Format id="sign-in"/></Link>
} }
</Menu.Item> </Menu.Item>
<Menu.Divider/> <Menu.Divider/>
{ {
token && user.active &&
<Menu.Item > <Menu.Item >
<div <div
onClick={() => { onClick={() => {
...@@ -37,8 +37,10 @@ function UserPanel({ dispatch, user, token }) { ...@@ -37,8 +37,10 @@ function UserPanel({ dispatch, user, token }) {
<div className="ant-dropdown-link" style={{ display: 'flex', alignItems: 'center' }}> <div className="ant-dropdown-link" style={{ display: 'flex', alignItems: 'center' }}>
<img <img
alt="avatar" src={avatar || defaultAvatar} alt="avatar" src={avatar || defaultAvatar}
style={{ borderRadius: '40px', height: '40px', weight: 'auto' }} style={{ borderRadius: '45px',
/> height: '45px',
weight: '45px',
border: '2px solid rgba(255,255,255,0.2' }} />
</div> </div>
</Dropdown> </Dropdown>
); );
......
...@@ -4,6 +4,9 @@ html, body, :global(#root) { ...@@ -4,6 +4,9 @@ html, body, :global(#root) {
} }
:global { :global {
.ant-layout-header, .ant-menu-item{
background: #001933 !important
}
.example-enter { .example-enter {
opacity: 0.01; opacity: 0.01;
} }
......
...@@ -165,10 +165,10 @@ export default { ...@@ -165,10 +165,10 @@ export default {
try { try {
const { data } = yield call(activate, payload); const { data } = yield call(activate, payload);
if (data) { if (data) {
message.success(messages['Your-account-has-been-successfully-activated!'], 5); message.success(messages['Your-account-has-been-successfully-activated!'], 3);
} }
} catch (error) { } catch (error) {
message.error(error.message); message.error(error.message, 3);
} }
}, },
*checkEmail({ payload }, { call, put }) { *checkEmail({ payload }, { call, put }) {
...@@ -178,7 +178,10 @@ export default { ...@@ -178,7 +178,10 @@ export default {
} }
try { try {
const { data } = yield call(checkUserExists, { email: payload.email }); const { data } = yield call(checkUserExists, {
email: payload.email,
user_id: payload.user_id,
});
if (data) { if (data) {
yield put({ type: 'check', payload: { isEmailExists: true, checkEmail: 'warning' } }); yield put({ type: 'check', payload: { isEmailExists: true, checkEmail: 'warning' } });
} }
...@@ -193,7 +196,10 @@ export default { ...@@ -193,7 +196,10 @@ export default {
} }
try { try {
const { data } = yield call(checkUserExists, { username: payload.username }); const { data } = yield call(checkUserExists, {
username: payload.username,
user_id: payload.user_id,
});
if (data) { if (data) {
yield put({ type: 'check', payload: { isUserNameExists: true, checkUsername: 'warning' } }); yield put({ type: 'check', payload: { isUserNameExists: true, checkUsername: 'warning' } });
} }
...@@ -212,7 +218,7 @@ export default { ...@@ -212,7 +218,7 @@ export default {
} }
} catch (error) { } catch (error) {
yield put({ type: 'loginFail' }); yield put({ type: 'loginFail' });
message.error(messages[error.message] || error.message); message.error(messages[error.message] || error.message, 3);
} }
}, },
*forgot({ payload }, { call, put, select }) { *forgot({ payload }, { call, put, select }) {
...@@ -221,7 +227,7 @@ export default { ...@@ -221,7 +227,7 @@ export default {
const { data } = yield call(forgot, payload); const { data } = yield call(forgot, payload);
if (data) { if (data) {
yield put({ type: 'forgotSuccess' }); yield put({ type: 'forgotSuccess' });
message.info(messages['A-password-reset-email-has-been-sent-to-you.'], 5); message.info(messages['A-password-reset-email-has-been-sent-to-you.'], 3);
} }
} catch (error) { } catch (error) {
yield put({ type: 'forgotFail' }); yield put({ type: 'forgotFail' });
...@@ -237,7 +243,7 @@ export default { ...@@ -237,7 +243,7 @@ export default {
yield put({ type: 'user/loginSuccess', payload: { data } }); yield put({ type: 'user/loginSuccess', payload: { data } });
yield put({ type: 'loginSuccess', payload: { input: payload } }); yield put({ type: 'loginSuccess', payload: { input: payload } });
message.info(messages['Your-account-has-been-created.'], 5); message.info(messages['Your-account-has-been-created.'], 3);
yield put(routerRedux.replace('/verify')); yield put(routerRedux.replace('/verify'));
} }
} catch (error) { } catch (error) {
......
...@@ -17,6 +17,14 @@ export default { ...@@ -17,6 +17,14 @@ export default {
}, },
}; };
}, },
abort(state) {
return {
...state,
...{
isUpload: false,
},
};
},
getfile(state, action) { getfile(state, action) {
return { return {
...state, ...action.payload, ...state, ...action.payload,
......
...@@ -93,7 +93,7 @@ export default { ...@@ -93,7 +93,7 @@ export default {
*loginSuccess({ payload }, { put }) { *loginSuccess({ payload }, { put }) {
const { data: { user, token } } = payload; const { data: { user, token } } = payload;
if (!payload.data) { if (!payload.data) {
message.error('error '); message.error('error ', 3);
} }
if (token) { if (token) {
yield put({ type: 'storeToken', payload: { token } }); yield put({ type: 'storeToken', payload: { token } });
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
if (user.active) { if (user.active) {
yield put(routerRedux.replace('/profiles')); yield put(routerRedux.replace('/profiles'));
// message.info("登录成功") // message.info("登录成功, 3")
} else { } else {
yield put(routerRedux.replace('/verify')); yield put(routerRedux.replace('/verify'));
} }
...@@ -124,7 +124,7 @@ export default { ...@@ -124,7 +124,7 @@ export default {
} }
} catch (error) { } catch (error) {
yield put({ type: 'getAuthUserFail' }); yield put({ type: 'getAuthUserFail' });
// message.error(error.message) // message.error(error.messag, 3e)
} }
}, },
*preLogin({ payload }, { call, put }) { *preLogin({ payload }, { call, put }) {
...@@ -149,7 +149,7 @@ export default { ...@@ -149,7 +149,7 @@ export default {
} }
} catch (error) { } catch (error) {
yield put(routerRedux.replace('/signin')); yield put(routerRedux.replace('/signin'));
// message.error(error.message) // message.error(error.messag, 3e)
} }
}, },
*updateProfile({ payload }, { call, put, select }) { *updateProfile({ payload }, { call, put, select }) {
...@@ -162,11 +162,11 @@ export default { ...@@ -162,11 +162,11 @@ export default {
if (data) { if (data) {
yield put({ type: 'updateProfileSuccess', payload: { user: data, token } }); yield put({ type: 'updateProfileSuccess', payload: { user: data, token } });
message.info(messages.update_success); message.info(messages.update_success, 3);
} }
} catch (error) { } catch (error) {
yield put({ type: 'updateProfileFail' }); yield put({ type: 'updateProfileFail' });
message.error(error.message); message.error(error.message, 3);
} }
}, },
*updateEmail({ payload }, { call, put, select }) { *updateEmail({ payload }, { call, put, select }) {
...@@ -176,11 +176,11 @@ export default { ...@@ -176,11 +176,11 @@ export default {
const { data } = yield call(updateAccount, { ...payload, token }); const { data } = yield call(updateAccount, { ...payload, token });
if (data) { if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } }); yield put({ type: 'updateAccountSuccess', payload: { user: data, token } });
message.info(messages['A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.']); message.info(messages['A-verification-email-has-been-sent-to-you,please-check-the-mail-to-complete.'], 3);
} }
} catch (error) { } catch (error) {
yield put({ type: 'updateAccountFail' }); yield put({ type: 'updateAccountFail' });
message.error(messages[error.message] || error.message); message.error(messages[error.message] || error.message, 3);
} }
}, },
...@@ -191,11 +191,11 @@ export default { ...@@ -191,11 +191,11 @@ export default {
const { data } = yield call(updateAccount, { ...payload, token }); const { data } = yield call(updateAccount, { ...payload, token });
if (data) { if (data) {
yield put({ type: 'updateAccountSuccess', payload: { user: data, token } }); yield put({ type: 'updateAccountSuccess', payload: { user: data, token } });
message.info(messages.update_success); message.info(messages.update_success, 3);
} }
} catch (error) { } catch (error) {
yield put({ type: 'updateAccountFail' }); yield put({ type: 'updateAccountFail' });
message.error(messages[error.message] || error.message); message.error(messages[error.message] || error.message, 3);
} }
}, },
}, },
......
...@@ -49,14 +49,21 @@ class Profiles extends React.Component { ...@@ -49,14 +49,21 @@ class Profiles extends React.Component {
}; };
onGetFile = (e) => { onGetFile = (e) => {
let files; let files = [];
if (e.dataTransfer) { if (e.dataTransfer) {
files = e.dataTransfer.files; files = e.dataTransfer.files;
} else if (e.target) { } else if (e.target) {
files = e.target.files; files = e.target.files;
} }
if (files.length <= 0) {
this.props.dispatch({ type: 'upload/abort' })
return
}
const reader = new FileReader(); const reader = new FileReader();
reader.onload = () => { reader.onload = () => {
this.props.dispatch({ type: 'upload/start' })
this.props.dispatch({ type: 'upload/getfile', payload: { imageUrl: reader.result } }); this.props.dispatch({ type: 'upload/getfile', payload: { imageUrl: reader.result } });
}; };
reader.readAsDataURL(files[0]); reader.readAsDataURL(files[0]);
...@@ -69,13 +76,12 @@ class Profiles extends React.Component { ...@@ -69,13 +76,12 @@ class Profiles extends React.Component {
const { user: { id } } = this.props; const { user: { id } } = this.props;
this.cropper.getCroppedCanvas().toBlob((blob) => { this.cropper.getCroppedCanvas().toBlob((blob) => {
console.log(blob);
this.props.dispatch({ type: 'upload/upload', payload: { image: blob, user_id: id } }); this.props.dispatch({ type: 'upload/upload', payload: { image: blob, user_id: id } });
}); });
}; };
render() { render() {
const { dispatch, form, user, loading, imageUrl, isUpload } = this.props; const { form, user, loading, imageUrl, isUpload } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { name, avatar } = user; const { name, avatar } = user;
const { intl: { messages } } = this.context; const { intl: { messages } } = this.context;
...@@ -119,8 +125,8 @@ class Profiles extends React.Component { ...@@ -119,8 +125,8 @@ class Profiles extends React.Component {
<div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column' }}> <div style={{ display: !isUpload ? 'flex' : 'none', flexDirection: 'column' }}>
<img alt="avatar" src={avatar || imageUrl || defaultAvatar}/> <img alt="avatar" src={avatar || imageUrl || defaultAvatar}/>
<Button onClick={() => { dispatch({ type: 'upload/start' }); }}> <Button style={{ padding: '4px 0' }}>
<label> <label style={{ display: 'flex', flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Icon type="plus"/><Format id="Change-Avatar"/> <Icon type="plus"/><Format id="Change-Avatar"/>
<input <input
type="file" onChange={this.onGetFile} ref={(file) => { type="file" onChange={this.onGetFile} ref={(file) => {
......
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