改成自己的router,基本完成网络通信
此提交包含在:
@@ -4,6 +4,7 @@ import Spinner from '../components/Spinner/Spinner';
|
||||
import UploadUnit from '../components/UploadUnit/UploadUnit';
|
||||
import { post } from '../helper/axios';
|
||||
import { apis } from '../helper/apis';
|
||||
import { alert } from '../helper/alert';
|
||||
|
||||
import './upload.css';
|
||||
|
||||
@@ -39,8 +40,13 @@ export class UploadContainer extends Component {
|
||||
if (this.state.submitting && (!this.state.file || this.state.url !== "")) {
|
||||
// upload using axios
|
||||
post(apis.submitMessage, { content: this.state.msg, image: this.state.url })
|
||||
.then(res => {
|
||||
this.setState({ submitting: false, msg: "", url: "" });
|
||||
.then(({ data, status, networkStatus }) => {
|
||||
if (networkStatus !== 200) return;
|
||||
if (!status) return alert('提交内容失败:' + data);
|
||||
this.setState({ submitting: false, msg: "", url: "", file: null });
|
||||
alert('内容提交成功啦').then(({ isConfirmed }) => {
|
||||
if (isConfirmed) window.close();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
新增問題並參考
封鎖使用者