举报时手动选择是否隐藏

This commit is contained in:
2022-07-21 14:06:18 +08:00
parent efa94e45f9
commit d842a5205b
3 changed files with 11 additions and 6 deletions

View File

@@ -26,7 +26,7 @@
<title>新T树洞</title> <title>新T树洞</title>
</head> </head>
<script> <script>
function force_reload() { function force_reload() {
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {
navigator.serviceWorker navigator.serviceWorker
.getRegistrations() .getRegistrations()

View File

@@ -550,8 +550,9 @@ class FlowSidebar extends PureComponent {
report(event, text = '') { report(event, text = '') {
console.log(text); console.log(text);
let reason = prompt(`举报 #${this.state.info.pid} 的理由:`, text); let reason = prompt(`举报 #${this.state.info.pid} 的理由:`, text);
let should_hide = confirm('是否认为此洞应该被删除或隐藏?');
if (reason !== null) { if (reason !== null) {
API.report(this.state.info.pid, reason, this.props.token) API.report(this.state.info.pid, reason, should_hide, this.props.token)
.then((json) => { .then((json) => {
alert('举报成功'); alert('举报成功');
}) })

View File

@@ -80,10 +80,14 @@ export const API = {
return handle_response(response, false); return handle_response(response, false);
}, },
report: async (pid, reason, token) => { report: async (pid, reason, should_hide, token) => {
let data = new URLSearchParams(); let data = new URLSearchParams([
data.append('pid', pid); ['pid', pid],
data.append('reason', reason); ['reason', reason],
]);
if (should_hide) {
data.append('should_hide', 1);
}
let response = await fetch(API_BASE + '/report', { let response = await fetch(API_BASE + '/report', {
method: 'POST', method: 'POST',
headers: { headers: {