diff --git a/src/Flows.css b/src/Flows.css index a5d2628..5c59a70 100644 --- a/src/Flows.css +++ b/src/Flows.css @@ -93,9 +93,6 @@ cursor: default; transition: margin-left 200ms ease-out; } -.left-container .flow-item-row:hover { - margin-left: -10px; -} .flow-item-row p.img { text-align: center; diff --git a/src/Flows.js b/src/Flows.js index 783609c..b023a20 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -116,6 +116,35 @@ class FlowItemRow extends PureComponent { }); } + toggle_attention(callback) { + let data=new URLSearchParams(); + const next_attention=!this.state.attention; + data.append('token', this.props.token); + data.append('pid', this.state.info.pid); + data.append('switch', next_attention ? '1' : '0'); + fetch(API_BASE+'/api.php?action=attention', { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', + }, + body: data, + }) + .then((res)=>res.json()) + .then((json)=>{ + if(json.code!==0 && (!json.msg || json.msg!=='已经关注过辣')) + throw new Error(json); + + this.setState({ + attention: next_attention, + }, callback); + }) + .catch((e)=>{ + alert('设置关注失败'); + console.trace(e); + callback(); + }); + } + show_sidebar() { this.props.show_sidebar( '帖子详情', @@ -123,13 +152,27 @@ class FlowItemRow extends PureComponent {
加载中……
); - this.load_replies(this.show_sidebar); + this.load_replies(this.show_sidebar.bind(this)); }}>刷新回复 + {this.props.token && + + / + { + this.props.show_sidebar('帖子详情',加载中……
); + this.toggle_attention(this.show_sidebar.bind(this)); + }}> + {this.state.attention ? + 已关注 : + 未关注 + } + + + }