改成自己的router,基本完成网络通信

此提交包含在:
2021-07-26 23:51:30 +08:00
父節點 d8c40cfe59
當前提交 41f5239ae6
共有 9 個檔案被更改,包括 294 行新增23 行删除

查看文件

@@ -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();
});
});
}
}