Browse Source

新自动拉黑机制,阈值可配置

pull/16/head
hole-thu 3 years ago
parent
commit
f7fc9a98e4
  1. 2
      src/Config.js
  2. 3
      src/Flows.js
  3. 78
      src/UserAction.js

2
src/Config.js

@ -428,7 +428,7 @@ export class ConfigUI extends PureComponent {
<p>
新功能建议或问题反馈请在&nbsp;
<a
href="https://git.thu.monster/newthuhole/hole_thu_backend/issues"
href="https://git.thu.monster/newthuhole/hole-backend-rust/issues"
target="_blank"
>
Gitea

3
src/Flows.js

@ -566,7 +566,7 @@ class FlowSidebar extends PureComponent {
API.block(type, id, this.props.token)
.then((json) => {
let data = json.data;
alert(`操作成功,其成为危险用户进度 ${data.curr}/${data.threshold}`);
alert(`操作成功,当前拉黑数 ${data.curr}`);
!!on_complete && on_complete();
})
.catch((e) => {
@ -1355,6 +1355,7 @@ class SubFlow extends PureComponent {
localStorage['_LATEST_POST_ID'] = '' + max_id;
}
window.TITLE = json.custom_title;
window.AUTO_BLCOK = json.auto_block_rank;
json.data.forEach((x) => {
if (x.comments) {
let comment_json = {

78
src/UserAction.js

@ -12,7 +12,7 @@ import { ColorPicker } from './color_picker';
import { ConfigUI } from './Config';
import copy from 'copy-to-clipboard';
import { cache } from './cache';
import { API, get_json } from './flows_api';
import { get_json } from './flows_api';
import { save_attentions } from './Attention';
import './UserAction.css';
@ -42,7 +42,7 @@ export function InfoSidebar(props) {
}}
>
<span className="icon icon-settings" />
<label>设置</label>
<label>本地设置</label>
</a>
&nbsp;&nbsp;
<a href="/policy.html" target="_blank">
@ -150,6 +150,7 @@ export class LoginForm extends Component {
super(props);
this.state = {
custom_title: window.TITLE || '',
auto_block_rank: window.AUTO_BLCOK || 2,
};
}
@ -158,16 +159,43 @@ export class LoginForm extends Component {
alert('无变化');
return;
}
API.set_title(title, token)
.then((json) => {
if (json.code === 0) {
window.TITLE = title;
alert('专属头衔设置成功');
let data = new FormData();
data.append('title', title);
fetch(API_BASE + '/title', {
method: 'POST',
headers: { 'User-Token': token },
body: data,
})
.then(get_json)
.then((j) => {
if (j.code !== 0) {
throw new Error(j.msg);
}
window.TITLE = title;
alert('专属头衔设置成功');
})
.catch((err) => alert('设置头衔出错了:\n' + err));
}
update_auto_block(rank, token) {
let data = new FormData();
data.append('rank', rank);
fetch(API_BASE + '/auto_block', {
method: 'POST',
headers: { 'User-Token': token },
body: data,
})
.then(get_json)
.then((j) => {
if (j.code !== 0) {
throw new Error(j.msg);
}
window.AUTO_BLCOK = rank;
alert('设置自动拉黑阈值成功');
})
.catch((err) => alert('设置自动拉黑出错了:\n' + err));
}
copy_token(token) {
if (copy(token)) alert('复制成功!\n请一定不要泄露哦');
}
@ -232,12 +260,48 @@ export class LoginForm extends Component {
onClick={(e) => {
this.update_title(this.state.custom_title, token.value);
}}
disabled={!this.state.custom_title}
>
提交
</button>
<br />
设置专属头衔后可在发言时选择使用重置后需重新设置临时用户如需保持头衔请使用相同后缀
</p>
<p>
自动拉黑阈值:
<span style={{ display: 'inline-block', width: '3rem' }}>
<b>{this.state.auto_block_rank * 5}</b>
</span>
<input
value={this.state.auto_block_rank}
type="range"
min="1"
max="10"
list="autoBlock"
onChange={(e) => {
this.setState({ auto_block_rank: e.target.value });
}}
/>
<button
className="update-title-btn"
type="button"
onClick={(e) => {
this.update_auto_block(
this.state.auto_block_rank,
token.value,
);
}}
>
提交
</button>
<datalist id="autoBlock">
<option>1</option>
<option>2</option>
<option>3</option>
</datalist>
<br />
自动不展示被拉黑次数较多用户发布的内容包括自己对每个洞及其评论的可见性会有1小时缓存频繁修改无效
</p>
</div>
) : (
<LoginPopup token_callback={token.set_value}>

Loading…
Cancel
Save