diff --git a/src/Flows.js b/src/Flows.js
index a95c255..bfd1c4d 100644
--- a/src/Flows.js
+++ b/src/Flows.js
@@ -42,7 +42,7 @@ function load_single_meta(show_sidebar,token) {
)
})
.catch((e)=>{
- console.trace(e);
+ console.error(e);
show_sidebar(
'帖子详情',
@@ -136,7 +136,7 @@ class FlowSidebar extends PureComponent {
});
})
.catch((e)=>{
- console.trace(e);
+ console.error(e);
this.setState({
replies: [],
loading_status: 'done',
@@ -164,23 +164,43 @@ class FlowSidebar extends PureComponent {
loading_status: 'done'
});
alert('设置关注失败');
- console.trace(e);
+ console.error(e);
});
}
+ report() {
+ let reason=prompt(`举报 #${this.state.info.pid} 的理由:`);
+ if(reason!==null) {
+ API.report(this.state.info.pid,reason,this.props.token)
+ .then((json)=>{
+ alert('举报成功');
+ })
+ .catch((e)=>{
+ alert('举报失败');
+ console.error(e);
+ })
+ }
+ }
+
render() {
if(this.state.loading_status==='loading')
return (
加载中……
);
return (
+ {this.props.token &&
+
+ 举报
+ /
+
+ }
刷新回复
{this.props.token &&
/
- {
- this.toggle_attention();
- }}>
+ {
+ this.toggle_attention();
+ }}>
{this.state.attention ?
已关注 :
未关注
@@ -239,7 +259,7 @@ class FlowItemRow extends PureComponent {
}),callback);
})
.catch((e)=>{
- console.trace(e);
+ console.error(e);
this.setState({
replies: [],
reply_status: 'failed',
@@ -312,7 +332,7 @@ export class Flow extends PureComponent {
load_page(page) {
const failed=(err)=>{
- console.trace(err);
+ console.error(err);
this.setState((prev,props)=>({
loaded_pages: prev.loaded_pages-1,
loading_status: 'failed',
diff --git a/src/UserAction.js b/src/UserAction.js
index 12b74d3..1f2512c 100644
--- a/src/UserAction.js
+++ b/src/UserAction.js
@@ -60,7 +60,7 @@ export class LoginForm extends Component {
this.setState({
loading_status: 'done',
});
- console.trace(e);
+ console.error(e);
});
}
@@ -162,7 +162,7 @@ export class ReplyForm extends Component {
this.props.on_complete();
})
.catch((e)=>{
- console.trace(e);
+ console.error(e);
alert('回复失败\n(树洞服务器经常抽风,其实有可能已经回复上了,不妨点“刷新回复”看一看)');
this.setState({
loading_status: 'done',
@@ -236,7 +236,7 @@ export class PostForm extends Component {
this.props.on_complete();
})
.catch((e)=>{
- console.trace(e);
+ console.error(e);
alert('发表失败');
this.setState({
loading_status: 'done',
diff --git a/src/flows_api.js b/src/flows_api.js
index c33061b..2d85ddd 100644
--- a/src/flows_api.js
+++ b/src/flows_api.js
@@ -54,6 +54,29 @@ export const API={
});
},
+ report: (pid,reason,token)=>{
+ let data=new URLSearchParams();
+ data.append('token',token);
+ data.append('action','report');
+ data.append('pid',pid);
+ data.append('reason',reason);
+ return fetch(API_BASE+'/api.php', {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ body: data,
+ })
+ .then((res)=>res.json())
+ .then((json)=>{
+ if(json.code!==0) {
+ if(json.msg) alert(json.msg);
+ throw new Error(json);
+ }
+ return json;
+ });
+ },
+
get_list: (page,token)=>{
return fetch(
API_BASE+'/api.php?action=getlist'+