diff --git a/src/App.css b/src/App.css
index 593f7a0..984044e 100644
--- a/src/App.css
+++ b/src/App.css
@@ -74,3 +74,16 @@ button.btn {
height: 30px;
margin-left: 10px;
}
+
+.content {
+ width: 1000px;
+ margin: 0 auto;
+ padding-top: 30px;
+}
+
+@media (max-width: 1080px) {
+ .content {
+ width: calc(100% - 80px);
+ margin: 0 40px;
+ }
+}
\ No newline at end of file
diff --git a/src/components/UploadUnit/UploadUnit.js b/src/components/UploadUnit/UploadUnit.js
index f786a88..bd5f0eb 100644
--- a/src/components/UploadUnit/UploadUnit.js
+++ b/src/components/UploadUnit/UploadUnit.js
@@ -162,15 +162,18 @@ export default class UploadUnit extends Component {
return (
- {this.state.src
+ {
+ this.state.src
?

: null
}
- {this.state.status >= 0
+ {
+ this.state.status >= 0
? (
- {this.state.status === 3
+ {
+ this.state.status === 3
? (
@@ -184,9 +187,11 @@ export default class UploadUnit extends Component {
上传中
- ) : null
+ )
+ : null
}
- {this.state.status <= 1
+ {
+ this.state.status <= 1
? (
@@ -194,34 +199,43 @@ export default class UploadUnit extends Component {
{this.state.status === 0 ? '加载中' : '压缩中'}
- ) : null
+ )
+ : null
}
- {this.state.status === 4
+ {
+ this.state.status === 4
? (
上传成功
- ) : null}
+ )
+ : null
+ }
- {this.state.status === 2
+ {
+ this.state.status === 2
? (
- ) : null
+ )
+ : null
}
- {this.state.status === 2 || this.state.status === 4
+ {
+ this.state.status === 2 || this.state.status === 4
? (
- ) : null
+ )
+ : null
}
- ) : null
+ )
+ : null
}
diff --git a/src/helper/apis.js b/src/helper/apis.js
index 1370c5f..d445380 100644
--- a/src/helper/apis.js
+++ b/src/helper/apis.js
@@ -6,7 +6,7 @@ export const apis = {
getProfile: backEndBaseURL + "/user/me",
submitMessage: backEndBaseURL + "/post/submit",
- listEssence: backEndBaseURL + "/post/listPublished",
+ listEssence: backEndBaseURL + "/post/listPublished?page=1",
listAll: backEndBaseURL + "/admin/list",
setStatus: backEndBaseURL + "/admin/setStatus"
diff --git a/src/index/index.css b/src/index/index.css
index 7696544..6fcdf0f 100644
--- a/src/index/index.css
+++ b/src/index/index.css
@@ -15,24 +15,36 @@
right: 40px;
bottom: 20px;
}
-.message {
- width: calc(50% - 60px);
- margin-top: 30px;
+/* 这里的卡片和分栏结构就比较接近bootstrap了,可惜视觉做的太古板,如果愿意的话改成Material Design就更好了 */
+.split-lg > .card {
+ width: 440px;
+ flex-shrink: 0;
+ margin: 0 5px;
}
-
-.container {
- display: flex;
- width: 1000px;
- margin: 0 auto;
- justify-content: space-between;
-}
-.cut-line {
- display: flex;
- height: 1px;
- width: 100%;
- background-color: #e6e6e6;
-}
-.little-title {
+.card-header {
padding: .75em .5em;
font-size: 18px;
+ border-bottom: 1px solid #e6e6e6;
+}
+.card-center {
+ width: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+}
+.card-body {
+ padding: 10px;
+}
+
+.split-lg {
+ display: flex;
+ justify-content: space-between;
+ flex-wrap: wrap;
+}
+
+@media (max-width: 980px) {
+ .split-lg > .card {
+ width: 100%;
+ margin-bottom: 20px;
+ }
}
\ No newline at end of file
diff --git a/src/index/index.js b/src/index/index.js
index 569e7a2..2d181bf 100644
--- a/src/index/index.js
+++ b/src/index/index.js
@@ -1,19 +1,84 @@
import { Component } from 'react';
import { Link } from '../components/SingleRouter/SingleRouter';
+import Spinner from '../components/Spinner/Spinner';
+import { alert } from '../helper/alert';
+import { apis } from '../helper/apis';
+import { get } from '../helper/axios';
import { images } from '../resources.json';
import './index.css';
export class AppContainer extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ essentialMessages: [],
+ essentialImages: [],
+ fetchingEssential: false,
+ };
+ }
+
+ componentDidMount() {
+ if (this.state.fetchingEssential) return;
+ this.setState({ fetchingEssential: true });
+ get(apis.listEssence).then(({ data, status, networkStatus }) => {
+ this.setState({ fetchingEssential: false });
+ if (networkStatus !== 200) return;
+ if (!status) return alert('获取精选列表失败:' + data + ',请刷新重试');
+ let messages = [], images = [];
+ data.forEach(post => {
+ if (post.content) messages.push(post.content);
+ if (post.image) images.push(post.image);
+ });
+ this.setState({ essentialMessages: messages, essentialImages: images });
+ });
+ }
+
render() {
return (
-
+
点击参加
-
-
-
+
+
+
+ 精选留言
+
+
+ {
+ this.state.fetchingEssential
+ ?
+ : (this.state.essentialMessages.length === 0
+ ? (
暂时没有精选留言
)
+ : (
+
+ {this.state.essentialMessages.map(msg => (
+
+ ))}
+
+ )
+ )
+ }
+
+
+
+
+ 精选图片
+
+
+ {
+ this.state.fetchingEssential
+ ?
+ : (this.state.essentialImages.length === 0
+ ? (
暂时没有精选图片
)
+ : this.state.essentialImages.map(src => (
+

+ ))
+ )
+ }
+
+
);
diff --git a/src/upload/upload.css b/src/upload/upload.css
index e4c367c..ef37a15 100644
--- a/src/upload/upload.css
+++ b/src/upload/upload.css
@@ -8,10 +8,6 @@
background-color: #9D0004;
}
-.content {
- width: 800px;
- margin: 0 auto;
-}
.message-box {
width: 100%;
height: 300px;
diff --git a/src/upload/upload.js b/src/upload/upload.js
index 2c7f36e..8225d6f 100644
--- a/src/upload/upload.js
+++ b/src/upload/upload.js
@@ -77,27 +77,37 @@ export class UploadContainer extends Component {
/>
- {this.state.file ? (
-
this.setState({ url })}
- onUploadError={this.handleUploadError}
- onCancel={() => this.setState({ file: null, url: "" })}
- upload={this.state.submitting}
- />
- ) : (
-
- )}
+ {
+ this.state.file
+ ? (
+ this.setState({ url })}
+ onUploadError={this.handleUploadError}
+ onCancel={() => this.setState({ file: null, url: "" })}
+ upload={this.state.submitting}
+ />
+ )
+ : (
+
+ )
+ }
+ >
+ {
+ this.state.submitting
+ ? (
)
+ : '提交'
+ }
+
);