Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Moecube Accounts Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Moecube Accounts Web
Commits
d1e78c3d
Commit
d1e78c3d
authored
Apr 06, 2017
by
2breakegg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reformat code
parent
26b58b53
Changes
22
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
765 additions
and
700 deletions
+765
-700
.idea/workspace.xml
.idea/workspace.xml
+270
-186
src/components/EmailForm.js
src/components/EmailForm.js
+39
-37
src/components/PasswordForm.js
src/components/PasswordForm.js
+43
-39
src/components/SendEmail.js
src/components/SendEmail.js
+21
-40
src/components/SubmitButton.js
src/components/SubmitButton.js
+2
-2
src/components/UserNameForm.js
src/components/UserNameForm.js
+9
-6
src/index.js
src/index.js
+4
-7
src/models/auth.js
src/models/auth.js
+18
-18
src/models/common.js
src/models/common.js
+11
-11
src/models/upload.js
src/models/upload.js
+32
-31
src/models/user.js
src/models/user.js
+17
-25
src/router.js
src/router.js
+6
-7
src/routes/Activate.js
src/routes/Activate.js
+3
-4
src/routes/Forgot.js
src/routes/Forgot.js
+11
-24
src/routes/Index.js
src/routes/Index.js
+123
-114
src/routes/Login.js
src/routes/Login.js
+9
-10
src/routes/Profiles.js
src/routes/Profiles.js
+55
-51
src/routes/Register.js
src/routes/Register.js
+24
-17
src/routes/Verify.js
src/routes/Verify.js
+54
-53
src/services/auth.js
src/services/auth.js
+4
-4
src/services/upload.js
src/services/upload.js
+4
-5
src/services/user.js
src/services/user.js
+6
-9
No files found.
.idea/workspace.xml
View file @
d1e78c3d
This diff is collapsed.
Click to expand it.
src/components/EmailForm.js
View file @
d1e78c3d
import
{
Form
,
Input
}
from
'
antd
'
;
import
React
,
{
PropTypes
}
from
'
react
'
;
import
styles
from
'
./EmailForm.css
'
;
import
{
connect
}
from
'
react-redux
'
import
{
Form
,
Input
,
Icon
,
Button
}
from
'
antd
'
const
FormItem
=
Form
.
Item
;
import
SubmitButton
from
'
./SubmitButton
'
import
{
connect
}
from
'
react-redux
'
;
import
SubmitButton
from
'
./SubmitButton
'
;
const
FormItem
=
Form
.
Item
;
const
formItemLayout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
15
},
}
}
;
class
EmailForm
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Received values of form:
'
,
values
);
const
{
email
,
password
}
=
values
const
{
email
,
password
}
=
values
;
dispatch
({
type
:
"
user/updateEmail
"
,
payload
:
{
email
,
password
,
user_id
:
id
}})
dispatch
({
type
:
'
user/updateEmail
'
,
payload
:
{
email
,
password
,
user_id
:
id
}
});
}
});
}
render
(){
};
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
}
=
this
.
props
const
{
getFieldDecorator
}
=
form
const
{
id
,
email
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
render
()
{
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
id
,
email
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
emailProps
=
{
...
...
@@ -45,45 +43,50 @@ class EmailForm extends React.Component {
hasFeedback
:
true
,
validateStatus
:
checkEmail
,
help
:
isEmailExists
?
'
email exists
'
:
''
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
initialValue
:
email
initialValue
:
email
,
},
input
:
{
placeholder
:
messages
.
email
}
}
placeholder
:
messages
.
email
,
}
,
}
;
const
passwordProps
=
{
fromItem
:
{
label
:
messages
.
password
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
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}
$/
,
},
],
},
input
:
{
placeholder
:
messages
.
password
,
type
:
'
password
'
}
}
type
:
'
password
'
,
}
,
}
;
return
(
<
Form
onSubmit
=
{
this
.
onSubmit
}
>
<
FormItem
{...
emailProps
.
fromItem
}
>
{
getFieldDecorator
(
`email`
,
{...
emailProps
.
decorator
})(
{
getFieldDecorator
(
'
email
'
,
{
...
emailProps
.
decorator
})(
<
Input
{...
emailProps
.
input
}
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/
>
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/>
,
)}
<
/FormItem
>
<
FormItem
{...
passwordProps
.
fromItem
}
>
{
getFieldDecorator
(
'
password
'
)(
<
Input
{...
passwordProps
.
input
}
/
>
<
Input
{...
passwordProps
.
input
}
/>
,
)}
<
/FormItem
>
...
...
@@ -96,20 +99,19 @@ class EmailForm extends React.Component {
}
function
mapStateToProps
(
state
,
props
)
{
const
{
user
:
{
user
},
auth
:
{
isEmailExists
,
checkEmail
}
}
=
state
user
:
{
user
},
auth
:
{
isEmailExists
,
checkEmail
},
}
=
state
;
return
{
user
,
checkEmail
,
isEmailExists
isEmailExists
,
};
}
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
;
export
default
connect
(
mapStateToProps
)(
WrapperEmailForm
);
src/components/PasswordForm.js
View file @
d1e78c3d
import
{
Form
,
Input
}
from
'
antd
'
;
import
React
,
{
PropTypes
}
from
'
react
'
;
import
styles
from
'
./EmailForm.css
'
;
import
{
connect
}
from
'
react-redux
'
import
{
Form
,
Input
,
Icon
,
Button
}
from
'
antd
'
;
import
{
connect
}
from
'
react-redux
'
;
import
SubmitButton
from
'
./SubmitButton
'
;
...
...
@@ -11,14 +10,14 @@ const FormItem = Form.Item;
const
formItemLayout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
15
},
}
}
;
class
EmailForm
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
checkPassword
=
(
rule
,
value
,
callback
)
=>
{
const
form
=
this
.
props
.
form
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
...
...
@@ -27,7 +26,7 @@ class EmailForm extends React.Component {
}
else
{
callback
();
}
}
}
;
checkConfirm
=
(
rule
,
value
,
callback
)
=>
{
const
form
=
this
.
props
.
form
;
...
...
@@ -35,84 +34,91 @@ class EmailForm extends React.Component {
form
.
validateFields
([
'
confirm
'
],
{
force
:
true
});
}
callback
();
}
}
;
onSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Received values of form:
'
,
values
);
const
{
new_password
,
password
}
=
values
const
{
new_password
,
password
}
=
values
;
dispatch
({
type
:
"
user/updateAccount
"
,
payload
:
{
new_password
,
password
,
user_id
:
id
}})
dispatch
({
type
:
'
user/updateAccount
'
,
payload
:
{
new_password
,
password
,
user_id
:
id
}
});
}
});
}
render
(){
};
const
{
form
}
=
this
.
props
const
{
getFieldDecorator
}
=
form
;
const
{
intl
:
{
messages
}
}
=
this
.
context
render
()
{
const
{
form
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
passwordProps
=
{
fromItem
:
{
label
:
'
old passwrod
'
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
rules
:
[
{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
},
{
validator
:
this
.
checkConfirm
}
{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
,
},
{
validator
:
this
.
checkConfirm
},
],
},
input
:
{
placeholder
:
messages
[
'
old-password
'
],
type
:
'
password
'
type
:
'
password
'
,
},
input2
:
{
placeholder
:
messages
[
'
new-password
'
],
type
:
'
password
'
}
}
type
:
'
password
'
,
}
,
}
;
const
confirmProps
=
{
fromItem
:
{
label
:
messages
[
'
password-again
'
],
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
rules
:
[
{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
},
{
validator
:
this
.
checkPassword
}
{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
,
},
{
validator
:
this
.
checkPassword
},
],
},
input
:
{
placeholder
:
messages
[
'
password-again
'
],
type
:
'
password
'
}
}
type
:
'
password
'
,
}
,
}
;
return
(
<
Form
onSubmit
=
{
this
.
onSubmit
}
>
<
FormItem
{...
passwordProps
.
fromItem
}
label
=
{
messages
[
'
old-password
'
]}
>
{
getFieldDecorator
(
'
password
'
)(
<
Input
{...
passwordProps
.
input
}
/
>
<
Input
{...
passwordProps
.
input
}
/>
,
)}
<
/FormItem
>
<
FormItem
{...
passwordProps
.
fromItem
}
label
=
{
messages
[
'
new-password
'
]}
>
{
getFieldDecorator
(
'
new_password
'
,
{
...
passwordProps
.
decorator
})(
<
Input
{...
passwordProps
.
input2
}
/
>
{
getFieldDecorator
(
'
new_password
'
,
{
...
passwordProps
.
decorator
})(
<
Input
{...
passwordProps
.
input2
}
/>
,
)}
<
/FormItem
>
<
FormItem
{...
confirmProps
.
fromItem
}
>
{
getFieldDecorator
(
`confirm`
,
{...
confirmProps
.
decorator
})(
<
Input
{...
confirmProps
.
input
}
/
>
{
getFieldDecorator
(
'
confirm
'
,
{
...
confirmProps
.
decorator
})(
<
Input
{...
confirmProps
.
input
}
/>
,
)}
<
/FormItem
>
...
...
@@ -125,18 +131,16 @@ class EmailForm extends React.Component {
}
function
mapStateToProps
(
state
,
props
)
{
const
{
user
:
{
user
}
}
=
state
user
:
{
user
},
}
=
state
;
return
{
user
,
};
}
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
;
export
default
connect
(
mapStateToProps
)(
WrapperEmailForm
);
src/components/SendEmail.js
View file @
d1e78c3d
import
{
Form
,
Input
}
from
'
antd
'
;
import
React
,
{
PropTypes
}
from
'
react
'
;
import
styles
from
'
./EmailForm.css
'
;
import
{
connect
}
from
'
react-redux
'
import
{
Form
,
Input
,
Icon
,
Button
,
Modal
}
from
'
antd
'
;
const
FormItem
=
Form
.
Item
;
import
{
connect
}
from
'
react-redux
'
;
import
SubmitButton
from
'
./SubmitButton
'
;
const
FormItem
=
Form
.
Item
;
const
formItemLayout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
15
},
}
}
;
class
EmailForm
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Received values of form:
'
,
values
);
const
{
email
,
password
}
=
values
const
{
email
,
password
}
=
values
;
dispatch
({
type
:
"
user/updateEmail
"
,
payload
:
{
email
,
password
,
user_id
:
id
}
})
dispatch
({
type
:
'
user/updateEmail
'
,
payload
:
{
email
,
password
,
user_id
:
id
}
});
}
});
}
}
;
render
()
{
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
,
isSendEmailActive
}
=
this
.
props
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
id
,
email
}
=
data
;
const
{
id
,
email
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
emailProps
=
{
...
...
@@ -45,31 +42,16 @@ class EmailForm extends React.Component {
hasFeedback
:
true
,
validateStatus
:
checkEmail
,
help
:
isEmailExists
?
'
email exists
'
:
''
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
initialValue
:
email
initialValue
:
email
,
},
input
:
{
placeholder
:
messages
.
email
}
}
const
passwordProps
=
{
fromItem
:
{
label
:
messages
.
passwrod
,
...
formItemLayout
},
decorator
:
{
rules
:
[
{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
}
]
placeholder
:
messages
.
email
,
},
input
:
{
placeholder
:
messages
.
password
,
type
:
'
password
'
}
}
};
return
(
<
Form
onSubmit
=
{
this
.
onSubmit
}
>
...
...
@@ -77,7 +59,7 @@ class EmailForm extends React.Component {
{
getFieldDecorator
(
'
email
'
,
{
...
emailProps
.
decorator
})(
<
Input
{...
emailProps
.
input
}
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/
>
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/>
,
)}
<
/FormItem
>
...
...
@@ -90,21 +72,20 @@ class EmailForm extends React.Component {
}
function
mapStateToProps
(
state
,
props
)
{
const
{
user
:
{
user
},
auth
:
{
isEmailExists
,
checkEmail
,
isSendEmailActive
}
}
=
state
auth
:
{
isEmailExists
,
checkEmail
,
isSendEmailActive
}
,
}
=
state
;
return
{
user
,
checkEmail
,
isEmailExists
,
isSendEmailActive
isSendEmailActive
,
};
}
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
const
WrapperEmailForm
=
Form
.
create
()(
EmailForm
)
;
export
default
connect
(
mapStateToProps
)(
WrapperEmailForm
);
src/components/SubmitButton.js
View file @
d1e78c3d
import
{
Button
}
from
'
antd
'
;
import
React
from
'
react
'
;
import
styles
from
'
./SubmitButton.css
'
;
import
{
FormattedMessage
as
Format
}
from
'
react-intl
'
;
import
styles
from
'
./SubmitButton.css
'
;
function
SubmitButton
(
props
)
{
return
(
<
div
className
=
{
styles
.
wrapSubmit
}
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
size
=
"
large
"
{...
props
}
><
Format
id
=
"
save
"
/><
/Button
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
size
=
"
large
"
{...
props
}
><
Format
id
=
"
save
"
/><
/Button
>
<
/div
>
);
}
...
...
src/components/UserNameForm.js
View file @
d1e78c3d
...
...
@@ -14,7 +14,7 @@ class EmailForm extends React.Component {
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
user
:
{
id
}
}
=
this
.
props
;
...
...
@@ -31,7 +31,6 @@ class EmailForm extends React.Component {
};
render
()
{
const
{
form
,
dispatch
,
user
,
checkUsername
,
isUserNameExists
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
id
,
username
}
=
user
;
...
...
@@ -43,7 +42,7 @@ class EmailForm extends React.Component {
hasFeedback
:
true
,
validateStatus
:
checkUsername
,
help
:
isUserNameExists
?
'
username exists
'
:
''
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
initialValue
:
username
,
...
...
@@ -57,11 +56,15 @@ class EmailForm extends React.Component {
const
passwordProps
=
{
fromItem
:
{
label
:
messages
.
password
,
...
formItemLayout
...
formItemLayout
,
},
decorator
:
{
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}
$/
,
},
],
},
input
:
{
...
...
@@ -93,7 +96,7 @@ class EmailForm extends React.Component {
}
function
mapStateToProps
(
state
,
props
)
{
function
mapStateToProps
(
state
)
{
const
{
user
:
{
user
},
auth
:
{
isUserNameExists
,
checkUsername
},
...
...
src/index.js
View file @
d1e78c3d
import
{
message
}
from
'
antd
'
;
import
dva
from
'
dva
'
;
import
createLoading
from
'
dva-loading
'
;
import
{
browserHistory
}
from
'
dva/router
'
;
import
ReactDOM
from
'
react-dom
'
;
import
createLoading
from
'
dva-loading
'
;
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
const
app
=
dva
({
onError
:
(
error
,
dispatch
)
=>
{
...
...
@@ -20,12 +18,12 @@ const app = dva({
history
:
browserHistory
,
});
app
.
use
(
createLoading
())
app
.
use
(
createLoading
())
;
app
.
model
(
require
(
'
./models/user
'
));
app
.
model
(
require
(
"
./models/upload
"
));
app
.
model
(
require
(
'
./models/upload
'
));
app
.
model
(
require
(
'
./models/auth
'
));
...
...
@@ -48,10 +46,9 @@ app.router(require('./router'));
// 5. Start
addLocaleData
([...
en
,
...
zh
]);
/*eslint-disable */
let
language
=
localStorage
.
getItem
(
'
locale
'
)
||
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 */
const
languageWithoutRegionCode
=
language
.
toLowerCase
().
split
(
/
[
_-
]
+/
)[
0
];
...
...
src/models/auth.js
View file @
d1e78c3d
...
...
@@ -23,10 +23,10 @@ export default {
reducers
:
{
change
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
...
state
,
...
action
.
payload
,
};
},
checkEmail
(
state
,
action
)
{
checkEmail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -34,7 +34,7 @@ export default {
},
};
},
checkUsername
(
state
,
action
)
{
checkUsername
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -42,7 +42,7 @@ export default {
},
};
},
activate
(
state
,
action
)
{
activate
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -52,18 +52,18 @@ export default {
},
check
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
...
state
,
...
action
.
payload
,
};
},
register
(
state
,
action
)
{
register
(
state
)
{
return
{
...
state
,
...{
isRegisterSubmit
:
true
,
}
}
,
};
},
registerSuccess
(
state
,
action
)
{
registerSuccess
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -71,7 +71,7 @@ export default {
},
};
},
registerFail
(
state
,
action
)
{
registerFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -79,7 +79,7 @@ export default {
},
};
},
login
(
state
,
action
)
{
login
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -96,7 +96,7 @@ export default {
},
};
},
loginFail
(
state
,
action
)
{
loginFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -104,7 +104,7 @@ export default {
},
};
},
forgot
(
state
,
action
)
{
forgot
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -112,7 +112,7 @@ export default {
},
};
},
forgotSuccess
(
state
,
action
)
{
forgotSuccess
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -120,7 +120,7 @@ export default {
},
};
},
forgotFail
(
state
,
action
)
{
forgotFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -128,7 +128,7 @@ export default {
},
};
},
reset
(
state
,
action
)
{
reset
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -136,7 +136,7 @@ export default {
},
};
},
resetSuccess
(
state
,
action
)
{
resetSuccess
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -144,7 +144,7 @@ export default {
},
};
},
resetFail
(
state
,
action
)
{
resetFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -154,7 +154,7 @@ export default {
},
},
effects
:
{
*
activate
({
payload
},
{
call
,
put
,
select
})
{
*
activate
({
payload
},
{
call
,
select
})
{
const
{
messages
}
=
yield
select
(
state
=>
state
.
common
);
try
{
const
{
data
}
=
yield
call
(
activate
,
payload
);
...
...
src/models/common.js
View file @
d1e78c3d
import
i18n
from
'
../../i18n.json
'
import
i18n
from
'
../../i18n.json
'
;
export
default
{
namespace
:
'
common
'
,
state
:
{
language
:
'
zh-CN
'
,
messages
:
{}
messages
:
{}
,
},
reducers
:
{
init
(
state
,
action
){
init
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
}
}
...
state
,
...
action
.
payload
,
}
;
}
,
},
effects
:
{},
subscriptions
:
{
setup
({
dispatch
,
history
})
{
let
language
=
localStorage
.
getItem
(
'
locale
'
)
||
navigator
.
language
||
(
navigator
.
languages
&&
navigator
.
languages
[
0
])
||
navigator
.
userLanguage
;
setup
({
dispatch
})
{
let
language
=
localStorage
.
getItem
(
'
locale
'
)
||
navigator
.
language
||
(
navigator
.
languages
&&
navigator
.
languages
[
0
])
||
navigator
.
userLanguage
;
const
languageWithoutRegionCode
=
language
.
toLowerCase
().
split
(
/
[
_-
]
+/
)[
0
];
const
messages
=
i18n
[
languageWithoutRegionCode
]
const
messages
=
i18n
[
languageWithoutRegionCode
]
;
dispatch
({
type
:
"
init
"
,
payload
:
{
language
:
languageWithoutRegionCode
,
messages
}})
}
dispatch
({
type
:
'
init
'
,
payload
:
{
language
:
languageWithoutRegionCode
,
messages
}
});
}
,
},
};
src/models/upload.js
View file @
d1e78c3d
import
{
uploadImage
}
from
'
../services/upload
'
import
{
message
}
from
'
antd
'
import
{
message
}
from
'
antd
'
;
import
{
uploadImage
}
from
'
../services/upload
'
;
export
default
{
namespace
:
'
upload
'
,
state
:
{
imageUrl
:
""
,
imageUrl
:
''
,
isUpload
:
false
,
uploadedImage
:
{}
uploadedImage
:
{}
,
},
reducers
:
{
start
(
state
,
action
)
{
start
(
state
)
{
return
{
...
state
,
...{
isUpload
:
true
}
}
...
state
,
...{
isUpload
:
true
,
},
};
},
getfile
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
}
},
...
state
,
...
action
.
payload
,
}
;
},
uploadSuccess
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
,
...{
isUpload
:
false
}
}
}
...
state
,
...
action
.
payload
,
...{
isUpload
:
false
,
},
};
},
},
effects
:
{
*
upload
({
payload
},
{
call
,
put
})
{
try
{
const
{
data
}
=
yield
call
(
uploadImage
,
payload
)
try
{
const
{
data
}
=
yield
call
(
uploadImage
,
payload
);
if
(
data
)
{
const
[
image
]
=
data
yield
put
({
type
:
'
uploadSuccess
'
,
payload
:
{
uploadedImage
:
image
}
})
if
(
data
)
{
const
[
image
]
=
data
;
yield
put
({
type
:
'
uploadSuccess
'
,
payload
:
{
uploadedImage
:
image
}
});
const
{
user_id
}
=
payload
const
{
user_id
}
=
payload
;
yield
put
({
type
:
'
user/updateProfile
'
,
payload
:
{
avatar
:
image
[
"
Key
"
],
user_id
}})
}
}
catch
(
error
)
{
yield
put
({
type
:
'
uploadFail
'
})
message
.
error
(
error
.
message
)
yield
put
({
type
:
'
user/updateProfile
'
,
payload
:
{
avatar
:
image
.
Key
,
user_id
}
});
}
}
catch
(
error
)
{
yield
put
({
type
:
'
uploadFail
'
});
message
.
error
(
error
.
message
);
}
},
},
subscriptions
:
{
},
subscriptions
:
{},
};
src/models/user.js
View file @
d1e78c3d
...
...
@@ -15,15 +15,15 @@ export default {
reducers
:
{
loginFromStorage
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
...
state
,
...
action
.
payload
,
};
},
loginSuccess
(
state
,
action
)
{
return
{
...
state
,
...
action
.
payload
.
data
...
state
,
...
action
.
payload
.
data
,
};
},
updateProfile
(
state
,
action
)
{
updateProfile
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -40,7 +40,7 @@ export default {
},
};
},
updateProfileFail
(
state
,
action
)
{
updateProfileFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -48,7 +48,7 @@ export default {
},
};
},
updateAccount
(
state
,
action
)
{
updateAccount
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -65,7 +65,7 @@ export default {
},
};
},
updateAccountFail
(
state
,
action
)
{
updateAccountFail
(
state
)
{
return
{
...
state
,
...{
...
...
@@ -90,10 +90,8 @@ export default {
},
},
effects
:
{
*
loginSuccess
({
payload
},
{
call
,
put
})
{
*
loginSuccess
({
payload
},
{
put
})
{
const
{
data
:
{
user
,
token
}
}
=
payload
;
if
(
!
payload
.
data
)
{
message
.
error
(
'
error
'
);
}
...
...
@@ -116,20 +114,20 @@ export default {
}
}
},
*
getAuthUser
({
payload
},
{
call
,
put
,
select
})
{
*
getAuthUser
({
payload
},
{
call
,
put
})
{
const
{
token
}
=
payload
;
try
{
let
{
data
}
=
yield
call
(
getAuthUser
,
{
token
})
if
(
data
)
{
yield
put
({
type
:
'
getAuthUserSuccess
'
,
payload
:
{
user
:
data
,
token
}
})
let
{
data
}
=
yield
call
(
getAuthUser
,
{
token
});
if
(
data
)
{
yield
put
({
type
:
'
getAuthUserSuccess
'
,
payload
:
{
user
:
data
,
token
}
});
}
}
catch
(
error
)
{
yield
put
({
type
:
'
getAuthUserFail
'
})
}
catch
(
error
)
{
yield
put
({
type
:
'
getAuthUserFail
'
});
// message.error(error.message)
}
},
*
preLogin
({
payload
},
{
call
,
put
,
select
})
{
*
preLogin
({
payload
},
{
call
,
put
})
{
const
{
token
}
=
payload
;
if
(
!
token
)
{
...
...
@@ -150,8 +148,8 @@ export default {
}
}
}
catch
(
error
)
{
yield
put
(
routerRedux
.
replace
(
"
/signin
"
))
// message.error(error.message)
yield
put
(
routerRedux
.
replace
(
'
/signin
'
));
// message.error(error.message)
}
},
*
updateProfile
({
payload
},
{
call
,
put
,
select
})
{
...
...
@@ -160,12 +158,10 @@ export default {
let
token
=
yield
select
(
state
=>
state
.
user
.
token
);
let
{
messages
}
=
yield
select
(
state
=>
state
.
common
);
try
{
let
{
data
}
=
yield
call
(
updateProfile
,
{
...
payload
,
token
});
if
(
data
)
{
yield
put
({
type
:
'
updateProfileSuccess
'
,
payload
:
{
user
:
data
,
token
}
});
message
.
info
(
messages
.
update_success
);
}
}
catch
(
error
)
{
...
...
@@ -178,7 +174,6 @@ export default {
try
{
let
token
=
yield
select
(
state
=>
state
.
user
.
token
);
let
{
data
}
=
yield
call
(
updateAccount
,
{
...
payload
,
token
});
if
(
data
)
{
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.
'
]);
...
...
@@ -194,7 +189,6 @@ export default {
try
{
let
token
=
yield
select
(
state
=>
state
.
user
.
token
);
let
{
data
}
=
yield
call
(
updateAccount
,
{
...
payload
,
token
});
if
(
data
)
{
yield
put
({
type
:
'
updateAccountSuccess
'
,
payload
:
{
user
:
data
,
token
}
});
message
.
info
(
messages
.
update_success
);
...
...
@@ -208,12 +202,10 @@ export default {
subscriptions
:
{
setup
({
dispatch
,
history
})
{
let
token
=
localStorage
.
getItem
(
'
token
'
);
if
(
token
)
{
dispatch
({
type
:
'
getAuthUser
'
,
payload
:
{
token
}
});
}
history
.
listen
(({
pathname
,
query
})
=>
{
history
.
listen
(({
pathname
})
=>
{
if
(
pathname
==
'
/
'
)
{
dispatch
({
type
:
'
preLogin
'
,
payload
:
{
token
}
});
}
...
...
src/router.js
View file @
d1e78c3d
import
{
Redirect
,
Route
,
Router
}
from
'
dva/router
'
;
import
QueueAnim
from
'
rc-queue-anim
'
import
{
Route
,
Router
}
from
'
dva/router
'
;
import
React
from
'
react
'
;
import
Active
from
'
./routes/Activate.js
'
;
import
Forgot
from
'
./routes/Forgot.js
'
;
import
Index
from
'
./routes/Index.js
'
;
import
Login
from
'
./routes/Login.js
'
;
import
Profiles
from
'
./routes/Profiles.js
'
;
...
...
@@ -14,21 +15,19 @@ import Register from './routes/Register.js';
import
Reset
from
'
./routes/Reset.js
'
;
import
Verify
from
"
./routes/Verify.js
"
;
import
Index
from
"
./routes/Index.js
"
;
import
Verify
from
'
./routes/Verify.js
'
;
function
RouterConfig
({
history
})
{
return
(
<
Router
history
=
{
history
}
>
<
Route
path
=
"
/
"
component
=
{
Index
}
>
<
Route
path
=
"
/
"
component
=
{
Index
}
>
<
Route
path
=
"
/signin
"
component
=
{
Login
}
/
>
<
Route
path
=
"
/forgot
"
component
=
{
Forgot
}
/
>
<
Route
path
=
"
/signup
"
component
=
{
Register
}
/
>
<
Route
path
=
"
/reset
"
component
=
{
Reset
}
/
>
<
Route
path
=
"
/profiles
"
component
=
{
Profiles
}
/
>
<
Route
path
=
"
/activate
"
component
=
{
Active
}
/
>
<
Route
path
=
"
/verify
"
component
=
{
Verify
}
/
>
<
Route
path
=
"
/verify
"
component
=
{
Verify
}
/
>
<
/Route
>
<
/Router
>
);
...
...
src/routes/Activate.js
View file @
d1e78c3d
...
...
@@ -16,7 +16,7 @@ class Active extends React.Component {
return
(
<
div
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
,
flex
:
1
}}
>
<
Button
type
=
"
primary
"
icon
=
"
poweroff
"
loading
=
{
loading
}
onClick
=
{
this
.
handleClick
}
>
<
Format
id
=
{
'
verify-email
'
}
/
>
<
Format
id
=
{
'
verify-email
'
}
/
>
<
/Button
>
<
/div
>
);
...
...
@@ -24,10 +24,9 @@ class Active extends React.Component {
}
function
mapStateToProps
(
state
)
{
const
{
}
=
state
;
const
{}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
loading
,
...
...
src/routes/Forgot.js
View file @
d1e78c3d
...
...
@@ -5,26 +5,13 @@ import React, { PropTypes } from 'react';
import
{
FormattedMessage
as
Format
}
from
'
react-intl
'
;
const
FormItem
=
Form
.
Item
;
const
Option
=
Select
.
Option
;
const
Step
=
Steps
.
Step
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
6
},
},
wrapperCol
:
{
xs
:
{
span
:
24
},
sm
:
{
span
:
14
},
},
};
const
Step
=
Steps
.
Step
;
class
Login
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmitLogin
=
(
e
)
=>
{
const
{
form
,
dispatch
,
params
:
{
id
}
}
=
this
.
props
;
...
...
@@ -42,35 +29,35 @@ class Login extends React.Component {
};
render
()
{
const
{
getFieldDecorator
,
dispatch
}
=
this
.
props
.
form
;
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
loading
}
=
this
.
props
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
return
(
<
div
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
,
flex
:
1
}}
>
<
div
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
,
flex
:
1
}}
>
<
Spin
spinning
=
{
loading
}
delay
=
{
100
}
>
<
Form
onSubmit
=
{
this
.
onSubmitLogin
}
className
=
"
login-form
"
>
<
Steps
size
=
"
large
"
current
=
{
0
}
>
<
Step
title
=
{
messages
[
'
send-email
'
]}
icon
=
{
<
Icon
type
=
"
solution
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
verify-email
'
]}
icon
=
{
<
Icon
type
=
"
mail
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
send-email
'
]}
icon
=
{
<
Icon
type
=
"
solution
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
verify-email
'
]}
icon
=
{
<
Icon
type
=
"
mail
"
/>
}
/
>
<
/Steps
>
<
FormItem
style
=
{{
marginTop
:
'
28px
'
}}
>
{
getFieldDecorator
(
'
email
'
,
{
rules
:
[{
required
:
true
,
message
:
'
Please input your username or email!
'
}],
})(
<
Input
prefix
=
{
<
Icon
type
=
"
user
"
style
=
{{
fontSize
:
13
}}
/>} placeholder={messages
[
'email-address-or-username'
]
}
/
>
,
<
Input
prefix
=
{
<
Icon
type
=
"
user
"
style
=
{{
fontSize
:
13
}}
/>} placeholder={messages
[
'email-address-or-username'
]
}
/
>
,
)}
<
/FormItem
>
<
FormItem
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
className
=
"
login-form-button
"
>
<
Format
id
=
{
'
send-email
'
}
/
>
<
Format
id
=
{
'
send-email
'
}
/
>
<
/Button
>
<
/FormItem
>
<
div
>
<
Link
to
=
"
/signin
"
><
Format
id
=
{
'
sign-in
'
}
/></
Link
>
<
Link
to
=
"
/signin
"
><
Format
id
=
{
'
sign-in
'
}
/></
Link
>
<
/div
>
<
/Form
>
<
/Spin
>
...
...
@@ -79,12 +66,12 @@ class Login extends React.Component {
}
}
function
mapStateToProps
(
state
,
props
)
{
function
mapStateToProps
(
state
)
{
const
{
auth
:
{
isForgotSubmit
},
}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
loading
,
...
...
src/routes/Index.js
View file @
d1e78c3d
import
React
from
'
react
'
;
import
{
Layout
,
Menu
}
from
'
antd
'
;
import
{
connect
}
from
'
dva
'
;
import
styles
from
'
./Index.less
'
;
import
Particles
from
'
react-particles-js
'
import
DocumentTitle
from
'
react-document-title
'
import
{
Link
}
from
'
dva/router
'
;
import
React
from
'
react
'
;
import
DocumentTitle
from
'
react-document-title
'
;
import
{
FormattedMessage
as
Format
}
from
'
react-intl
'
;
import
{
Layout
,
Button
,
Menu
}
from
'
antd
'
;
import
{
Link
}
from
'
dva/router
'
import
logo
from
'
../assets/MoeCube.png
'
import
Particles
from
'
react-particles-js
'
;
import
logo
from
'
../assets/MoeCube.png
'
;
const
{
Header
,
Footer
,
Sider
,
Content
}
=
Layout
;
const
particleConfig
=
{
'
particles
'
:
{
'
number
'
:
{
'
value
'
:
20
,
'
density
'
:
{
'
enable
'
:
true
,
'
value_area
'
:
1000
}
particles
:
{
number
:
{
value
:
20
,
density
:
{
enable
:
true
,
value_area
:
1000
,
}
,
},
'
color
'
:
{
'
value
'
:
'
#888
'
,
'
opacity
'
:
0.4
color
:
{
value
:
'
#888
'
,
opacity
:
0.4
,
},
'
shape
'
:
{
'
type
'
:
'
circle
'
,
'
stroke
'
:
{
'
width
'
:
4
,
'
color
'
:
'
#888
'
,
'
opacity
'
:
0.4
shape
:
{
type
:
'
circle
'
,
stroke
:
{
width
:
4
,
color
:
'
#888
'
,
opacity
:
0.4
,
},
polygon
:
{
nb_sides
:
5
,
},
'
polygon
'
:
{
'
nb_sides
'
:
5
image
:
{
src
:
'
img/github.svg
'
,
width
:
100
,
height
:
100
,
},
'
image
'
:
{
'
src
'
:
'
img/github.svg
'
,
'
width
'
:
100
,
'
height
'
:
100
}
},
'
opacity
'
:
{
'
value
'
:
0.5
,
'
random
'
:
false
,
'
anim
'
:
{
'
enable
'
:
false
,
'
speed
'
:
1
,
'
opacity_min
'
:
0.1
,
'
sync
'
:
false
}
opacity
:
{
value
:
0.5
,
random
:
false
,
anim
:
{
enable
:
false
,
speed
:
1
,
opacity_min
:
0.1
,
sync
:
false
,
}
,
},
'
size
'
:
{
'
value
'
:
3
,
'
random
'
:
true
,
'
anim
'
:
{
'
enable
'
:
false
,
'
speed
'
:
1
,
'
size_min
'
:
0.1
,
'
sync
'
:
false
}
size
:
{
value
:
3
,
random
:
true
,
anim
:
{
enable
:
false
,
speed
:
1
,
size_min
:
0.1
,
sync
:
false
,
}
,
},
'
line_linked
'
:
{
'
enable
'
:
true
,
'
distance
'
:
150
,
'
color
'
:
'
#888
'
,
'
opacity
'
:
0.4
,
'
width
'
:
1
line_linked
:
{
enable
:
true
,
distance
:
150
,
color
:
'
#888
'
,
opacity
:
0.4
,
width
:
1
,
},
move
:
{
enable
:
true
,
speed
:
1
,
direction
:
'
none
'
,
random
:
false
,
straight
:
false
,
out_mode
:
'
out
'
,
bounce
:
false
,
attract
:
{
enable
:
false
,
rotateX
:
600
,
rotateY
:
1200
,
},
},
'
move
'
:
{
'
enable
'
:
true
,
'
speed
'
:
1
,
'
direction
'
:
'
none
'
,
'
random
'
:
false
,
'
straight
'
:
false
,
'
out_mode
'
:
'
out
'
,
'
bounce
'
:
false
,
'
attract
'
:
{
'
enable
'
:
false
,
'
rotateX
'
:
600
,
'
rotateY
'
:
1200
}
}
},
'
interactivity
'
:
{
'
detect_on
'
:
'
canvas
'
,
'
events
'
:
{
'
onhover
'
:
{
'
enable
'
:
true
,
'
mode
'
:
'
grab
'
,
'
nb
'
:
2
interactivity
:
{
detect_on
:
'
canvas
'
,
events
:
{
onhover
:
{
enable
:
true
,
mode
:
'
grab
'
,
nb
:
2
,
},
'
onclick
'
:
{
'
enable
'
:
true
,
'
mode
'
:
'
push
'
onclick
:
{
enable
:
true
,
mode
:
'
push
'
,
},
'
resize
'
:
true
resize
:
true
,
},
'
modes
'
:
{
'
grab
'
:
{
'
distance
'
:
400
,
'
line_linked
'
:
{
'
opacity
'
:
0.4
}
modes
:
{
grab
:
{
distance
:
400
,
line_linked
:
{
opacity
:
0.4
,
},
},
bubble
:
{
distance
:
400
,
size
:
20
,
duration
:
2
,
opacity
:
8
,
speed
:
1
,
},
'
bubble
'
:
{
'
distance
'
:
400
,
'
size
'
:
20
,
'
duration
'
:
2
,
'
opacity
'
:
8
,
'
speed
'
:
1
repulse
:
{
distance
:
200
,
duration
:
0.4
,
},
'
repulse
'
:
{
'
distance
'
:
200
,
'
duration
'
:
0.4
push
:
{
particles_nb
:
4
,
},
'
push
'
:
{
'
particles_nb
'
:
4
remove
:
{
particles_nb
:
2
,
},
'
remove
'
:
{
'
particles_nb
'
:
2
}
}
},
},
'
retina_detect
'
:
true
}
retina_detect
:
true
,
}
;
function
Index
({
dispatch
,
children
,
messages
})
{
function
Index
({
children
,
messages
})
{
return
(
<
div
style
=
{{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
flex
:
1
,
height
:
'
100vh
'
}}
>
<
DocumentTitle
title
=
{
messages
[
'
title
'
]
||
'
Moe Cube
'
}
/
>
<
DocumentTitle
title
=
{
messages
.
title
||
'
Moe Cube
'
}
/
>
<
Header
style
=
{{
display
:
'
flex
'
,
alignItems
:
'
center
'
}}
>
<
Link
to
=
"
/
"
style
=
{{
marginTop
:
'
20px
'
}}
>
<
img
src
=
{
logo
}
style
=
{{
width
:
'
140px
'
,
height
:
'
44px
'
}}
/
>
<
Header
style
=
{{
display
:
'
flex
'
,
alignItems
:
'
center
'
}}
>
<
Link
to
=
"
/
"
style
=
{{
marginTop
:
'
20px
'
}}
>
<
img
src
=
{
logo
}
style
=
{{
width
:
'
140px
'
,
height
:
'
44px
'
}}
/
>
<
/Link
>
<
Menu
<
Menu
theme
=
"
dark
"
mode
=
"
horizontal
"
defaultSelectedKeys
=
{[
'
1
'
]}
style
=
{{
lineHeight
:
'
64px
'
}}
>
style
=
{{
lineHeight
:
'
64px
'
}}
>
<
Menu
.
Item
key
=
"
1
"
>
<
Link
to
=
"
/
"
>
<
Format
id
=
"
Home
"
/>
...
...
@@ -150,12 +150,21 @@ function Index({ dispatch, children, messages }) {
<
Particles
params
=
{
particleConfig
}
style
=
{{
position
:
"
fixed
"
position
:
'
fixed
'
,
}}
/
>
{
children
}
<
Footer
style
=
{{
position
:
'
absolute
'
,
width
:
'
100%
'
,
bottom
:
0
,
left
:
0
,
display
:
'
flex
'
,
justifyContent
:
'
space-between
'
}}
>
<
Footer
style
=
{{
position
:
'
absolute
'
,
width
:
'
100%
'
,
bottom
:
0
,
left
:
0
,
display
:
'
flex
'
,
justifyContent
:
'
space-between
'
,
}}
>
<
div
>
©
MoeCube
2017
all
right
reserved
.
<
/div
>
<
/Footer
>
<
/div
>
...
...
@@ -164,10 +173,10 @@ function Index({ dispatch, children, messages }) {
function
mapStateToProps
(
state
)
{
const
{
common
:
{
messages
}
}
=
state
common
:
{
messages
}
,
}
=
state
;
return
{
messages
messages
,
};
}
...
...
src/routes/Login.js
View file @
d1e78c3d
import
{
Button
,
Checkbox
,
Form
,
Icon
,
Input
,
Spin
}
from
'
antd
'
;
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
logo
from
'
../assets/MoeCube.png
'
import
'
./Login.less
'
;
const
FormItem
=
Form
.
Item
;
...
...
@@ -13,7 +12,7 @@ class Login extends React.Component {
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmitLogin
=
(
e
)
=>
{
const
{
form
,
dispatch
}
=
this
.
props
;
...
...
@@ -33,7 +32,7 @@ class Login extends React.Component {
render
()
{
const
{
getFieldDecorator
}
=
this
.
props
.
form
;
const
{
loading
}
=
this
.
props
;
const
{
intl
:
{
messages
}
}
=
this
.
context
const
{
intl
:
{
messages
}
}
=
this
.
context
;
return
(
<
div
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
,
alignItems
:
'
center
'
,
height
:
'
100%
'
}}
>
...
...
@@ -44,26 +43,26 @@ class Login extends React.Component {
{
getFieldDecorator
(
'
account
'
,
{
rules
:
[{
required
:
true
,
message
:
messages
[
'
Please input your account!
'
]
}],
})(
<
Input
prefix
=
{
<
Icon
type
=
"
user
"
style
=
{{
fontSize
:
13
}}
/>} placeholder={messages
[
'email-address-or-username'
]
}
/
>
,
<
Input
prefix
=
{
<
Icon
type
=
"
user
"
style
=
{{
fontSize
:
13
}}
/>} placeholder={messages
[
'email-address-or-username'
]
}
/
>
,
)}
<
/FormItem
>
<
FormItem
>
{
getFieldDecorator
(
'
password
'
,
{
rules
:
[{
required
:
true
,
message
:
messages
[
'
Please-input-your-Password!
'
]
}],
})(
<
Input
prefix
=
{
<
Icon
type
=
"
lock
"
style
=
{{
fontSize
:
13
}}
/>} type="password" placeholder={messages.password}
/
>
,
<
Input
prefix
=
{
<
Icon
type
=
"
lock
"
style
=
{{
fontSize
:
13
}}
/>} type="password" placeholder={messages.password}
/
>
,
)}
<
/FormItem
>
<
FormItem
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
className
=
"
login-form-button
"
>
<
Format
id
=
{
'
sign-in
'
}
/
>
<
Format
id
=
{
'
sign-in
'
}
/
>
<
/Button
>
<
/FormItem
>
<
div
>
<
Link
to
=
"
/signup
"
><
Format
id
=
{
'
sign-up
'
}
/></
Link
>
<
Link
to
=
"
/forgot
"
className
=
"
login-form-forgot
"
><
Format
id
=
{
'
forgot-password
'
}
/></
Link
>
<
Link
to
=
"
/signup
"
><
Format
id
=
{
'
sign-up
'
}
/></
Link
>
<
Link
to
=
"
/forgot
"
className
=
"
login-form-forgot
"
><
Format
id
=
{
'
forgot-password
'
}
/></
Link
>
<
/div
>
<
/Form
>
<
/Spin
>
...
...
@@ -77,7 +76,7 @@ function mapStateToProps(state) {
common
:
{
language
},
}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
loading
,
...
...
src/routes/Profiles.js
View file @
d1e78c3d
import
{
Button
,
Form
,
Icon
,
Input
,
Spin
,
Tabs
,
Upload
,
message
}
from
'
antd
'
;
import
{
connect
}
from
'
dva
'
;
import
Cropper
from
'
react-cropper
'
import
{
Button
,
Form
,
Icon
,
Input
,
Spin
,
Tabs
}
from
'
antd
'
;
import
'
cropperjs/dist/cropper.css
'
;
import
{
connect
}
from
'
dva
'
;
import
React
,
{
PropTypes
}
from
'
react
'
;
import
Cropper
from
'
react-cropper
'
;
import
{
FormattedMessage
as
Format
}
from
'
react-intl
'
;
import
EmailForm
from
'
../components/EmailForm
'
;
import
PasswordForm
from
'
../components/PasswordForm
'
;
import
UserNameForm
from
'
../components/UserNameForm
'
;
import
styles
from
'
./Profiles.less
'
;
import
config
from
'
../config
'
const
FormItem
=
Form
.
Item
;
const
TabPane
=
Tabs
.
TabPane
;
const
defaultAvatar
=
require
(
"
../../public/default_avatar.jpg
"
)
const
defaultAvatar
=
require
(
'
../../public/default_avatar.jpg
'
);
const
formItemLayout
=
{
labelCol
:
{
span
:
4
},
...
...
@@ -30,20 +29,20 @@ class Profiles extends React.Component {
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
handleUpload
=
()
=>
{
if
(
typeof
this
.
cropper
.
getCroppedCanvas
()
===
'
undefined
'
)
{
return
;
}
const
{
user
:
{
id
}
}
=
this
.
props
const
{
user
:
{
id
}
}
=
this
.
props
;
this
.
cropper
.
getCroppedCanvas
().
toBlob
(
blob
=>
{
console
.
log
(
blob
)
this
.
props
.
dispatch
({
type
:
'
upload/upload
'
,
payload
:
{
image
:
blob
,
user_id
:
id
}})
})
}
console
.
log
(
blob
)
;
this
.
props
.
dispatch
({
type
:
'
upload/upload
'
,
payload
:
{
image
:
blob
,
user_id
:
id
}
});
})
;
}
;
onGetFile
=
(
e
)
=>
{
...
...
@@ -57,11 +56,11 @@ class Profiles extends React.Component {
reader
.
onload
=
()
=>
{
this
.
props
.
dispatch
({
type
:
'
upload/getfile
'
,
payload
:
{
imageUrl
:
reader
.
result
}
});
};
reader
.
readAsDataURL
(
files
[
0
])
}
reader
.
readAsDataURL
(
files
[
0
])
;
}
;
onUpdateSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
user
:
{
id
},
}
=
this
.
props
;
const
{
form
,
dispatch
,
user
:
{
id
},
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
...
...
@@ -70,85 +69,90 @@ class Profiles extends React.Component {
const
{
username
,
name
,
password
}
=
values
;
dispatch
({
type
:
"
user/updateProfile
"
,
payload
:
{
username
,
name
,
password
,
user_id
:
id
}
})
dispatch
({
type
:
'
user/updateProfile
'
,
payload
:
{
username
,
name
,
password
,
user_id
:
id
}
});
}
});
};
render
()
{
const
{
dispatch
,
form
,
user
,
loading
,
progress
,
status
,
imageUrl
,
isUpload
,
uploadedImage
}
=
this
.
props
const
{
dispatch
,
form
,
user
,
loading
,
progress
,
status
,
imageUrl
,
isUpload
,
uploadedImage
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
username
,
name
,
id
,
avatar
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
nameProps
=
{
fromItem
:
{
label
:
messages
[
'
nickname
'
]
,
...
formItemLayout
label
:
messages
.
nickname
,
...
formItemLayout
,
},
decorator
:
{
initialValue
:
name
initialValue
:
name
,
},
input
:
{
placeholder
:
messages
[
'
nickname
'
]
,
}
}
placeholder
:
messages
.
nickname
,
}
,
}
;
const
crop
=
{
maxHeight
:
80
,
width
:
30
,
aspect
:
16
/
16
}
aspect
:
16
/
16
,
}
;
return
(
<
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
"
>
<
TabPane
tab
=
{
<
span
><
Icon
type
=
"
user
"
/><
Format
id
=
{
'
user-info
'
}
/> </
span
>
}
key
=
"
1
"
>
<
Form
onSubmit
=
{
this
.
onUpdateSubmit
}
>
<
FormItem
style
=
{{
display
:
'
flex
'
,
justifyContent
:
'
center
'
}}
>
{
isUpload
?
{
isUpload
?
<
div
>
<
Cropper
ref
=
{
cropper
=>
{
this
.
cropper
=
cropper
}}
ref
=
{
cropper
=>
{
this
.
cropper
=
cropper
;
}}
src
=
{
imageUrl
||
defaultAvatar
}
style
=
{{
height
:
'
20vw
'
,
width
:
'
20vw
'
}}
style
=
{{
height
:
'
20vw
'
,
width
:
'
20vw
'
}}
aspectRatio
=
{
1
/
1
}
guides
=
{
true
}
/
>
<
Button
>
<
label
>
<
Icon
type
=
"
plus
"
/>
add
file
<
input
type
=
"
file
"
onChange
=
{
this
.
onGetFile
}
ref
=
{
file
=>
{
this
.
file
=
file
}}
style
=
{{
display
:
"
none
"
}}
/>
<
/label>
<
/Button
>
<
Button
type
=
"
primary
"
onClick
=
{
this
.
handleUpload
}
>
<
Icon
type
=
"
upload
"
/>
upload
<
/Button>
/
>
<
Button
>
<
label
>
<
Icon
type
=
"
plus
"
/>
add
file
<
input
type
=
"
file
"
onChange
=
{
this
.
onGetFile
}
ref
=
{
file
=>
{
this
.
file
=
file
;
}}
style
=
{{
display
:
'
none
'
}}
/
>
<
/label
>
<
/Button
>
<
Button
type
=
"
primary
"
onClick
=
{
this
.
handleUpload
}
>
<
Icon
type
=
"
upload
"
/>
upload
<
/Button
>
<
/div
>
:
<
img
src
=
{
avatar
||
imageUrl
||
defaultAvatar
}
onClick
=
{()
=>
dispatch
({
type
:
"
upload/start
"
})}
/
>
}
:
<
img
src
=
{
avatar
||
imageUrl
||
defaultAvatar
}
onClick
=
{()
=>
dispatch
({
type
:
'
upload/start
'
})}
/
>
}
<
/FormItem
>
<
FormItem
{...
nameProps
.
fromItem
}
>
{
getFieldDecorator
(
`name`
,
{
...
nameProps
.
decorator
})(
<
Input
{...
nameProps
.
input
}
/
>
<
Input
{...
nameProps
.
input
}
/>
,
)}
<
/FormItem
>
<
FormItem
>
<
div
className
=
{
styles
.
wrapSubmit
}
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
size
=
"
large
"
><
Format
id
=
{
'
save
'
}
/></
Button
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
size
=
"
large
"
><
Format
id
=
{
'
save
'
}
/></
Button
>
<
/div
>
<
/FormItem
>
<
/Form
>
<
/TabPane
>
<
TabPane
tab
=
{
<
span
><
Icon
type
=
"
setting
"
/><
Format
id
=
{
'
account-info
'
}
/></
span
>
}
key
=
"
2
"
>
<
TabPane
tab
=
{
<
span
><
Icon
type
=
"
setting
"
/><
Format
id
=
{
'
account-info
'
}
/></
span
>
}
key
=
"
2
"
>
<
Tabs
type
=
"
card
"
className
=
"
app-detail-nav
"
>
<
TabPane
tab
=
{
messages
[
'
reset-username
'
]}
key
=
{
0
}
>
...
...
@@ -175,15 +179,15 @@ function mapStateToProps(state) {
const
{
user
:
{
user
,
isUpdateSubmit
},
auth
:
{
checkUsername
,
isEmailExists
,
isUserNameExists
},
upload
:
{
imageUrl
,
isUpload
,
uploadedImage
}
upload
:
{
imageUrl
,
isUpload
,
uploadedImage
},
}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
user
,
loading
,
imageUrl
,
imageUrl
,
isUpload
,
checkUsername
,
uploadedImage
,
...
...
src/routes/Register.js
View file @
d1e78c3d
...
...
@@ -3,17 +3,17 @@ import { connect } from 'dva';
import
{
Link
}
from
'
dva/router
'
;
import
React
,
{
PropTypes
}
from
'
react
'
;
import
{
FormattedMessage
as
Format
}
from
'
react-intl
'
;
import
styles
from
'
./Register.less
'
const
FormItem
=
Form
.
Item
;
const
Option
=
Select
.
Option
;
const
Step
=
Steps
.
Step
const
Step
=
Steps
.
Step
;
class
Register
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
onSubmitLogin
=
(
e
)
=>
{
const
{
form
,
dispatch
,
params
:
{
id
}
}
=
this
.
props
;
...
...
@@ -77,12 +77,13 @@ class Register extends React.Component {
};
return
(
<
div
style
=
{{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
flex
:
1
}}
>
<
div
style
=
{{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
flex
:
1
}}
>
<
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
"
/>
}
/
>
<
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
'
}}
>
...
...
@@ -112,41 +113,47 @@ class Register extends React.Component {
<
FormItem
hasFeedback
>
{
getFieldDecorator
(
'
password
'
,
{
rules
:
[{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
}],
rules
:
[{
required
:
true
,
message
:
messages
[
'
Password-length-must-be-between-8-and-24-characters.
'
],
pattern
:
/^.
{8,24}
$/
,
}],
},
{
validator
:
this
.
checkConfirm
,
})(
validator
:
this
.
checkConfirm
,
})(
<
Input
prefix
=
{
<
Icon
type
=
"
lock
"
style
=
{{
fontSize
:
13
}}
/>
}
prefix
=
{
<
Icon
type
=
"
lock
"
style
=
{{
fontSize
:
13
}}
/>
}
type
=
"
password
"
placeholder
=
{
messages
.
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}
$/
,
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
}}
/>
}
prefix
=
{
<
Icon
type
=
"
lock
"
style
=
{{
fontSize
:
13
}}
/>
}
type
=
"
password
"
onBlur
=
{
this
.
handleConfirmBlur
}
placeholder
=
{
messages
[
'
password-again
'
]}
/>
,
placeholder
=
{
messages
[
'
password-again
'
]}
/>
,
)}
<
/FormItem
>
<
FormItem
>
<
Button
type
=
"
primary
"
htmlType
=
"
submit
"
className
=
"
login-form-button
"
>
<
Format
id
=
{
'
sign-up
'
}
/
>
<
Format
id
=
{
'
sign-up
'
}
/
>
<
/Button
>
<
/FormItem
>
<
div
>
<
Link
to
=
"
/signin
"
><
Format
id
=
{
'
sign-in
'
}
/></
Link
>
<
Link
to
=
"
/signin
"
><
Format
id
=
{
'
sign-in
'
}
/></
Link
>
<
/div
>
<
/Form
>
<
/Spin
>
...
...
@@ -160,7 +167,7 @@ function mapStateToProps(state) {
auth
:
{
register
,
checkEmail
,
checkUsername
,
isEmailExists
,
isUserNameExists
,
isRegisterSubmit
},
}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
loading
,
...
...
src/routes/Verify.js
View file @
d1e78c3d
import
React
,
{
PropTypes
}
from
'
react
'
;
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
styles
from
'
./Verify.css
'
;
import
{
Form
,
Input
,
Steps
,
Icon
,
Spin
,
Alert
,
Tag
}
from
'
antd
'
;
import
{
routerRedux
}
from
'
dva/router
'
const
FormItem
=
Form
.
Item
;
import
SubmitButton
from
'
../components/SubmitButton
'
;
const
FormItem
=
Form
.
Item
;
const
Step
=
Steps
.
Step
const
Step
=
Steps
.
Step
;
class
Verify
extends
React
.
Component
{
static
contextTypes
=
{
intl
:
PropTypes
.
object
.
isRequired
,
}
}
;
state
=
{
isChangeEmail
:
false
}
isChangeEmail
:
false
,
}
;
onSubmit
=
(
e
)
=>
{
const
{
form
,
dispatch
,
input
:
{
password
},
user
:
{
id
}}
=
this
.
props
;
const
{
form
,
dispatch
,
input
:
{
password
},
user
:
{
id
}
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
form
.
validateFieldsAndScroll
((
err
,
values
)
=>
{
if
(
!
err
)
{
console
.
log
(
'
Received values of form:
'
,
values
);
const
{
email
}
=
values
const
{
email
}
=
values
;
dispatch
({
type
:
'
user/updateEmail
'
,
payload
:
{
email
,
password
,
user_id
:
id
}
});
}
...
...
@@ -34,7 +33,7 @@ class Verify extends React.Component {
};
onReSend
=
(
e
)
=>
{
const
{
dispatch
,
input
:
{
password
},
user
:
{
id
,
email
}}
=
this
.
props
;
const
{
dispatch
,
input
:
{
password
},
user
:
{
id
,
email
}
}
=
this
.
props
;
e
&&
e
.
preventDefault
();
...
...
@@ -42,10 +41,10 @@ class Verify extends React.Component {
};
render
(
select
)
{
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
,
loading
,
input
}
=
this
.
props
const
{
form
,
dispatch
,
user
,
checkEmail
,
isEmailExists
,
loading
,
input
}
=
this
.
props
;
const
{
getFieldDecorator
}
=
form
;
const
{
id
,
email
}
=
user
;
const
{
intl
:
{
messages
}
}
=
this
.
context
const
{
intl
:
{
messages
}
}
=
this
.
context
;
const
emailProps
=
{
fromItem
:
{
...
...
@@ -55,50 +54,52 @@ class Verify extends React.Component {
help
:
isEmailExists
?
messages
.
email_exists
:
''
,
},
decorator
:
{
initialValue
:
email
initialValue
:
email
,
},
input
:
{
placeholder
:
messages
.
email
,
}
}
}
,
}
;
return
(
<
div
style
=
{{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
flex
:
1
}}
>
<
div
style
=
{{
display
:
'
flex
'
,
flexDirection
:
'
column
'
,
alignItems
:
'
center
'
,
justifyContent
:
'
center
'
,
flex
:
1
}}
>
<
Spin
spinning
=
{
loading
}
delay
=
{
100
}
>
<
Steps
size
=
"
large
"
current
=
{
1
}
>
<
Step
title
=
{
messages
[
'
sign-up
'
]}
icon
=
{
<
Icon
type
=
"
solution
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
verify-email
'
]}
icon
=
{
<
Icon
type
=
"
mail
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
sign-up
'
]}
icon
=
{
<
Icon
type
=
"
solution
"
/>
}
/
>
<
Step
title
=
{
messages
[
'
verify-email
'
]}
icon
=
{
<
Icon
type
=
"
mail
"
/>
}
/
>
<
/Steps
>
{
id
&&
input
[
"
password
"
]
?
<
Alert
style
=
{{
marginTop
:
'
24px
'
}}
message
=
{
<
div
>
<
span
style
=
{{
marginRight
:
'
10px
'
}}
><
Format
id
=
{
'
Your-account-has-been-created.
'
}
/></
span
>
<
Tag
color
=
"
blue
"
onClick
=
{
this
.
onReSend
}
><
Format
id
=
{
'
send-email2
'
}
/></
Tag
>
<
Tag
color
=
"
orange
"
onClick
=
{()
=>
this
.
setState
({
isChangeEmail
:
true
})}
>
<
Format
id
=
{
'
reset-email
'
}
/
>
<
/Tag
>
<
/div
>
}
type
=
"
warning
"
showIcon
/>
:
<
Alert
style
=
{{
marginTop
:
'
24px
'
}}
message
=
{
<
div
>
<
span
style
=
{{
marginRight
:
'
10px
'
}}
><
Format
id
=
{
'
Please-sign-in
'
}
/></
span
>
<
Tag
color
=
"
blue
"
onClick
=
{
()
=>
dispatch
(
routerRedux
.
replace
(
"
/signin
"
))}
><
Format
id
=
{
'
sign-in
'
}
/></
Tag
>
<
/div
>
}
type
=
"
warning
"
showIcon
/>
{
id
&&
input
[
'
password
'
]
?
<
Alert
style
=
{{
marginTop
:
'
24px
'
}}
message
=
{
<
div
>
<
span
style
=
{{
marginRight
:
'
10px
'
}}
><
Format
id
=
{
'
Your-account-has-been-created.
'
}
/></
span
>
<
Tag
color
=
"
blue
"
onClick
=
{
this
.
onReSend
}
><
Format
id
=
{
'
send-email2
'
}
/></
Tag
>
<
Tag
color
=
"
orange
"
onClick
=
{()
=>
this
.
setState
({
isChangeEmail
:
true
})}
>
<
Format
id
=
{
'
reset-email
'
}
/
>
<
/Tag
>
<
/div
>
}
type
=
"
warning
"
showIcon
/>
:
<
Alert
style
=
{{
marginTop
:
'
24px
'
}}
message
=
{
<
div
>
<
span
style
=
{{
marginRight
:
'
10px
'
}}
><
Format
id
=
{
'
Please-sign-in
'
}
/></
span
>
<
Tag
color
=
"
blue
"
onClick
=
{
()
=>
dispatch
(
routerRedux
.
replace
(
'
/signin
'
))}
><
Format
id
=
{
'
sign-in
'
}
/></
Tag
>
<
/div
>
}
type
=
"
warning
"
showIcon
/>
}
{
...
...
@@ -108,12 +109,12 @@ class Verify extends React.Component {
{
getFieldDecorator
(
'
email
'
,
{
...
emailProps
.
decorator
})(
<
Input
{...
emailProps
.
input
}
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/
>
onBlur
=
{()
=>
dispatch
({
type
:
'
auth/checkEmail
'
,
payload
:
{
...
form
.
getFieldsValue
(),
id
}
})}
/>
,
)}
<
/FormItem
>
<
FormItem
>
<
SubmitButton
disabled
=
{
isEmailExists
}
/
>
<
SubmitButton
disabled
=
{
isEmailExists
}
/
>
<
/FormItem
>
<
/Form
>
}
...
...
@@ -126,11 +127,11 @@ class Verify extends React.Component {
function
mapStateToProps
(
state
,
props
)
{
const
{
user
:
{
user
}
,
auth
:
{
input
,
isEmailExists
,
checkEmail
}
}
=
state
user
:
{
user
},
auth
:
{
input
,
isEmailExists
,
checkEmail
}
,
}
=
state
;
const
loading
=
state
.
loading
.
global
||
false
const
loading
=
state
.
loading
.
global
||
false
;
return
{
input
,
...
...
src/services/auth.js
View file @
d1e78c3d
...
...
@@ -61,7 +61,7 @@ export async function getAuthUser(params) {
return
request
(
`/authUser`
,
{
method
:
'
GET
'
,
headers
:
{
Authorization
:
`Bearer
${
params
.
token
}
`
}
})
}
\ No newline at end of file
Authorization
:
`Bearer
${
params
.
token
}
`
,
},
});
}
src/services/upload.js
View file @
d1e78c3d
...
...
@@ -2,16 +2,15 @@ import request from '../utils/request';
export
async
function
uploadImage
(
params
)
{
console
.
log
(
params
)
console
.
log
(
params
)
;
let
data
=
new
FormData
()
data
.
append
(
"
file
"
,
params
[
"
image
"
])
let
data
=
new
FormData
()
;
data
.
append
(
'
file
'
,
params
[
'
image
'
]);
return
request
(
'
/upload/image
'
,
{
method
:
'
POST
'
,
body
:
data
,
headers
:
{
}
headers
:
{},
});
}
src/services/user.js
View file @
d1e78c3d
import
request
from
'
../utils/request
'
;
export
async
function
updateProfile
(
params
)
{
return
request
(
`/user/profiles`
,
{
return
request
(
'
/user/profiles
'
,
{
method
:
'
PATCH
'
,
body
:
JSON
.
stringify
(
params
),
headers
:
{
Authorization
:
`Bearer
${
params
.
token
}
`
,
"
content-type
"
:
"
application/json
"
}
'
content-type
'
:
'
application/json
'
,
}
,
});
}
export
async
function
updateAccount
(
params
)
{
return
request
(
`/user/account`
,
{
return
request
(
'
/user/account
'
,
{
method
:
'
PATCH
'
,
body
:
JSON
.
stringify
(
params
),
headers
:
{
Authorization
:
`Bearer
${
params
.
token
}
`
,
"
content-type
"
:
"
application/json
"
}
'
content-type
'
:
'
application/json
'
,
}
,
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment