{activity.target.type == "toy" ?
-
+
:null
}
diff --git a/src/scripts/components/Home/index.js b/src/scripts/components/Home/index.js
index 7544d70..540021c 100644
--- a/src/scripts/components/Home/index.js
+++ b/src/scripts/components/Home/index.js
@@ -10,13 +10,13 @@ const mapActionCreators = {
const mapStateToProps = (state) => {
const {
- stats, loaded,
+ stats, loaded,data,
activitiesC,pageC,totalPagesC,
activitiesO,pageO,totalPagesO
} = state.stats.toJS()
return {
- stats, loaded,
+ stats, loaded,data,
activitiesC,pageC,totalPagesC,
activitiesO,pageO,totalPagesO
}
diff --git a/src/scripts/components/PagePanel/PagePanel.jsx b/src/scripts/components/PagePanel/PagePanel.jsx
index a97d607..c4b18aa 100644
--- a/src/scripts/components/PagePanel/PagePanel.jsx
+++ b/src/scripts/components/PagePanel/PagePanel.jsx
@@ -91,13 +91,13 @@ export default class PagePanel extends Component {
{
page.tags.map((tag,index) => {
- return ({tag})
+ return ({tag})
})
}
{
page.toys.map((toy, index) => {
return (
-
+
{ toy.name } this.removeToy(page.id)}>
)
@@ -108,7 +108,7 @@ export default class PagePanel extends Component {
{page.counts.views} views
this.setState({timePageId:page.id})}>
- {Moment.unix(page.created / 1000).fromNow()}
+ {Moment(page.created).fromNow()}
|
diff --git a/src/scripts/reducers/statsReducer.js b/src/scripts/reducers/statsReducer.js
index 89a7f7a..6412be1 100644
--- a/src/scripts/reducers/statsReducer.js
+++ b/src/scripts/reducers/statsReducer.js
@@ -9,10 +9,10 @@ export default (state = Immutable.fromJS({
}),action)=>{
switch (action.type) {
case HOME_RECEIVE_STATS:
- return state.mergeDeep({
- stats: action.res,
- loaded:true
- })
+ return state
+ .set('stats',action.res)
+ .set('data',action.data)
+ .set('loaded',true)
case HOME_RECEIVE_ACTIVITIES_C:
return state
.updateIn(['activitiesC'], (activities) => activities.clear().concat(Immutable.fromJS(action.res)))
diff --git a/src/scripts/widgets/index.js b/src/scripts/widgets/index.js
new file mode 100644
index 0000000..53df311
--- /dev/null
+++ b/src/scripts/widgets/index.js
@@ -0,0 +1,13 @@
+import Moment from 'moment'
+
+
+Moment.locale('zh-cn')
+
+
+export const dateFormat = (time) => {
+ return Moment(time).format("D MMM, H:mm A")
+}
+
+export const dateFromNow = (time) => {
+ return Moment(time).fromNow()
+}
\ No newline at end of file
diff --git a/src/scripts/widgets/upload.js b/src/scripts/widgets/upload.js
index c9a4b2e..0ff3ca1 100644
--- a/src/scripts/widgets/upload.js
+++ b/src/scripts/widgets/upload.js
@@ -22,6 +22,31 @@ export const uploadFiles = async (files,prefix,uploadUrl = 'http://upload.qiniu.
return keys.filter(key => typeof key == 'string')
}
+export const uploadImagesWithWH = async (files,prefix,uploadUrl = 'http://upload.qiniu.com/') => {
+ const uptoken = await Request.get('/api/uptoken').then(res => res.body.uptoken)
+
+ const promises = files.map(async (file) => {
+ const img = new Image()
+ img.src = file.preview
+ await new Promise(resolve => img.onload = resolve)
+ const uploadKey = `${prefix}${Math.round(Date.now() / 1000)}_w_${img.width}_h_${img.height}_${makeId()}.${file.name.split('.').pop()}`
+ return Request
+ .post(uploadUrl)
+ .field('key', uploadKey)
+ .field('token', uptoken)
+ .field('x:filename', file.name)
+ .field('x:size', file.size)
+ .attach('file', file, file.name)
+ .set('Accept', 'application/json')
+ .then(() => uploadKey)
+ .catch(e => e)
+ })
+ const keys = await Promise.all(promises)
+
+ return keys.filter(key => typeof key == 'string')
+}
+
+
export const uploadImageWithWH = async (file,prefix,uploadUrl = 'http://upload.qiniu.com/') => {
const img = new Image()
img.src = file.preview