From a71ea7137fb9f545fa190aee35bf7215682e6b27 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Sun, 19 Dec 2021 22:51:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Flows.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Flows.js b/src/Flows.js index ed58d0b..15eb668 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -511,6 +511,10 @@ class FlowSidebar extends PureComponent { } do_vote(vote) { + this.setState({ + loading_status: 'loading', + error_msg: null, + }); API.add_vote(vote, this.state.info.pid, this.props.token) .then((json) => { if (json.code !== 0) return; @@ -518,6 +522,7 @@ class FlowSidebar extends PureComponent { this.setState( (prev, props) => ({ info: Object.assign({}, prev.info, { poll: json.data }), + loading_status: 'done', }), () => { this.syncState({ @@ -525,6 +530,13 @@ class FlowSidebar extends PureComponent { }); }, ); + }) + .catch((e) => { + console.error(e); + this.setState({ + loading_status: 'done', + error_msg: '' + e, + }); }); } @@ -739,7 +751,7 @@ class FlowSidebar extends PureComponent { {!this.state.rev && main_thread_elem} {!!this.state.error_msg && (
-

回复加载失败

+

加载失败

{this.state.error_msg}

)}