add report
This commit is contained in:
30
src/Flows.js
30
src/Flows.js
@@ -42,7 +42,7 @@ function load_single_meta(show_sidebar,token) {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
show_sidebar(
|
show_sidebar(
|
||||||
'帖子详情',
|
'帖子详情',
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
@@ -136,7 +136,7 @@ class FlowSidebar extends PureComponent {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
this.setState({
|
this.setState({
|
||||||
replies: [],
|
replies: [],
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
@@ -164,16 +164,36 @@ class FlowSidebar extends PureComponent {
|
|||||||
loading_status: 'done'
|
loading_status: 'done'
|
||||||
});
|
});
|
||||||
alert('设置关注失败');
|
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() {
|
render() {
|
||||||
if(this.state.loading_status==='loading')
|
if(this.state.loading_status==='loading')
|
||||||
return (<p className="box box-tip">加载中……</p>);
|
return (<p className="box box-tip">加载中……</p>);
|
||||||
return (
|
return (
|
||||||
<div className="flow-item-row sidebar-flow-item">
|
<div className="flow-item-row sidebar-flow-item">
|
||||||
<div className="box box-tip">
|
<div className="box box-tip">
|
||||||
|
{this.props.token &&
|
||||||
|
<span>
|
||||||
|
<a onClick={this.report.bind(this)}>举报</a>
|
||||||
|
/
|
||||||
|
</span>
|
||||||
|
}
|
||||||
<a onClick={this.load_replies.bind(this)}>刷新回复</a>
|
<a onClick={this.load_replies.bind(this)}>刷新回复</a>
|
||||||
{this.props.token &&
|
{this.props.token &&
|
||||||
<span>
|
<span>
|
||||||
@@ -239,7 +259,7 @@ class FlowItemRow extends PureComponent {
|
|||||||
}),callback);
|
}),callback);
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
this.setState({
|
this.setState({
|
||||||
replies: [],
|
replies: [],
|
||||||
reply_status: 'failed',
|
reply_status: 'failed',
|
||||||
@@ -312,7 +332,7 @@ export class Flow extends PureComponent {
|
|||||||
|
|
||||||
load_page(page) {
|
load_page(page) {
|
||||||
const failed=(err)=>{
|
const failed=(err)=>{
|
||||||
console.trace(err);
|
console.error(err);
|
||||||
this.setState((prev,props)=>({
|
this.setState((prev,props)=>({
|
||||||
loaded_pages: prev.loaded_pages-1,
|
loaded_pages: prev.loaded_pages-1,
|
||||||
loading_status: 'failed',
|
loading_status: 'failed',
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ export class LoginForm extends Component {
|
|||||||
this.setState({
|
this.setState({
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
});
|
});
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ export class ReplyForm extends Component {
|
|||||||
this.props.on_complete();
|
this.props.on_complete();
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
alert('回复失败\n(树洞服务器经常抽风,其实有可能已经回复上了,不妨点“刷新回复”看一看)');
|
alert('回复失败\n(树洞服务器经常抽风,其实有可能已经回复上了,不妨点“刷新回复”看一看)');
|
||||||
this.setState({
|
this.setState({
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
@@ -236,7 +236,7 @@ export class PostForm extends Component {
|
|||||||
this.props.on_complete();
|
this.props.on_complete();
|
||||||
})
|
})
|
||||||
.catch((e)=>{
|
.catch((e)=>{
|
||||||
console.trace(e);
|
console.error(e);
|
||||||
alert('发表失败');
|
alert('发表失败');
|
||||||
this.setState({
|
this.setState({
|
||||||
loading_status: 'done',
|
loading_status: 'done',
|
||||||
|
|||||||
@@ -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)=>{
|
get_list: (page,token)=>{
|
||||||
return fetch(
|
return fetch(
|
||||||
API_BASE+'/api.php?action=getlist'+
|
API_BASE+'/api.php?action=getlist'+
|
||||||
|
|||||||
Reference in New Issue
Block a user