feat: set room by you self
This commit is contained in:
@@ -32,6 +32,7 @@ const DEFAULT_CONFIG = {
|
||||
block_cw: ['xxg', 'zzxg'],
|
||||
block_words_v4: ['🕷️', '[系统自动代发]'],
|
||||
whitelist_cw: [],
|
||||
room_id: process.env.REACT_APP_ROOM_ID,
|
||||
};
|
||||
|
||||
export function load_config() {
|
||||
@@ -217,6 +218,57 @@ class ConfigColorScheme extends PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigRoomId extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
room_id: window.config.room_id,
|
||||
};
|
||||
}
|
||||
|
||||
save_changes() {
|
||||
this.props.callback({
|
||||
room_id: this.state.room_id,
|
||||
});
|
||||
}
|
||||
|
||||
on_select(e) {
|
||||
let value = e.target.value;
|
||||
this.setState(
|
||||
{
|
||||
room_id: value,
|
||||
},
|
||||
this.save_changes.bind(this),
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
<p>
|
||||
<b>分区编号:</b>
|
||||
<select
|
||||
className="config-select"
|
||||
value={this.state.room_id}
|
||||
onChange={this.on_select.bind(this)}
|
||||
>
|
||||
<option value="0">0区(默认分区)</option>
|
||||
<option value="1">1区(友善分区)</option>
|
||||
<option value="2">2区</option>
|
||||
<option value="3">3区</option>
|
||||
<option value="4">4区</option>
|
||||
<option value="5">5区</option>
|
||||
</select>
|
||||
<small>#room_id</small>
|
||||
</p>
|
||||
<p className="config-description">
|
||||
选择分区编号,会作为发言时的分区和影响查看到的内容
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ConfigTextArea extends PureComponent {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
@@ -364,6 +416,8 @@ export class ConfigUI extends PureComponent {
|
||||
callback={this.save_changes_bound}
|
||||
/>
|
||||
<hr />
|
||||
<ConfigRoomId id="room-id" callback={this.save_changes_bound} />
|
||||
<hr />
|
||||
<ConfigSwitch
|
||||
callback={this.save_changes_bound}
|
||||
id="show_all_rooms"
|
||||
@@ -375,7 +429,7 @@ export class ConfigUI extends PureComponent {
|
||||
callback={this.save_changes_bound}
|
||||
id="block_tmp"
|
||||
name="屏蔽临时帐号"
|
||||
description="屏蔽所有临时帐号的发言"
|
||||
description="屏蔽所有临时帐号的发言,不展示其他分区的情况下强制屏蔽"
|
||||
/>
|
||||
<hr />
|
||||
<ConfigTextArea
|
||||
|
||||
@@ -35,7 +35,8 @@ const DZ_NAME = '洞主';
|
||||
|
||||
function check_block(info) {
|
||||
return (
|
||||
((window.config.block_tmp && info.is_tmp) ||
|
||||
(((window.config.block_tmp || !window.config.show_all_rooms) &&
|
||||
info.is_tmp) ||
|
||||
window.config.block_words_v4.some((word) => info.text.includes(word)) ||
|
||||
(info.cw &&
|
||||
window.config.block_words_v4
|
||||
@@ -294,7 +295,7 @@ class FlowItem extends PureComponent {
|
||||
<code className="box-id">
|
||||
<a href={'##' + info.pid} onClick={this.copy_link.bind(this)}>
|
||||
#{info.pid}
|
||||
{info.room_id !== parseInt(process.env.REACT_APP_ROOM_ID) && (
|
||||
{info.room_id !== parseInt(window.config.room_id) && (
|
||||
<> @{info.room_id}</>
|
||||
)}
|
||||
</a>
|
||||
|
||||
@@ -206,7 +206,7 @@ export function Title(props) {
|
||||
}
|
||||
>
|
||||
新T树洞
|
||||
<sup>{process.env.REACT_APP_ROOM_ID || '?'}</sup>
|
||||
<sup>{window.config.room_id || '?'}</sup>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -588,7 +588,7 @@ export class PostForm extends Component {
|
||||
text: text,
|
||||
allow_search: allow_search ? '1' : '',
|
||||
use_title: use_title ? '1' : '',
|
||||
room_id: process.env.REACT_APP_ROOM_ID,
|
||||
room_id: window.config.room_id,
|
||||
});
|
||||
if (has_poll) {
|
||||
poll_options.forEach((opt) => {
|
||||
@@ -881,7 +881,7 @@ export class PostForm extends Component {
|
||||
<a href="/policy.html" target="_blank">
|
||||
树洞管理规范(试行)
|
||||
</a>
|
||||
,文明发言。
|
||||
和所在分区的规定,文明发言。
|
||||
</small>
|
||||
</p>
|
||||
<p>
|
||||
|
||||
@@ -169,7 +169,7 @@ export const API = {
|
||||
get_list: async (page, token, submode) => {
|
||||
let response = await fetch(
|
||||
`${get_api_base()}/getlist?p=${page}&order_mode=${submode}&room_id=${
|
||||
window.config.show_all_rooms ? '' : process.env.REACT_APP_ROOM_ID
|
||||
window.config.show_all_rooms ? '' : window.config.room_id
|
||||
}`,
|
||||
{
|
||||
headers: { 'User-Token': token },
|
||||
@@ -181,7 +181,7 @@ export const API = {
|
||||
get_search: async (page, keyword, token, submode) => {
|
||||
let response = await fetch(
|
||||
`${get_api_base()}/search?search_mode=${submode}&page=${page}&room_id=${
|
||||
window.config.show_all_rooms ? '' : process.env.REACT_APP_ROOM_ID
|
||||
window.config.show_all_rooms ? '' : window.config.room_id
|
||||
}&keywords=${encodeURIComponent(keyword)}&pagesize=${SEARCH_PAGESIZE}`,
|
||||
{
|
||||
headers: { 'User-Token': token },
|
||||
|
||||
Reference in New Issue
Block a user