diff --git a/src/Config.js b/src/Config.js index 6ddbbc3..48945f7 100644 --- a/src/Config.js +++ b/src/Config.js @@ -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 ( +
+

+ 分区编号: + +  #room_id +

+

+ 选择分区编号,会作为发言时的分区和影响查看到的内容 +

+
+ ); + } +} + class ConfigTextArea extends PureComponent { constructor(props) { super(props); @@ -364,6 +416,8 @@ export class ConfigUI extends PureComponent { callback={this.save_changes_bound} />
+ +

info.text.includes(word)) || (info.cw && window.config.block_words_v4 @@ -294,7 +295,7 @@ class FlowItem extends PureComponent { #{info.pid} - {info.room_id !== parseInt(process.env.REACT_APP_ROOM_ID) && ( + {info.room_id !== parseInt(window.config.room_id) && ( <> @{info.room_id} )} diff --git a/src/Title.js b/src/Title.js index 5558cac..906e028 100644 --- a/src/Title.js +++ b/src/Title.js @@ -206,7 +206,7 @@ export function Title(props) { } > 新T树洞 - {process.env.REACT_APP_ROOM_ID || '?'} + {window.config.room_id || '?'}

diff --git a/src/UserAction.js b/src/UserAction.js index 32a39cf..791de57 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -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 { 树洞管理规范(试行) - ,文明发言。 + 和所在分区的规定,文明发言。

diff --git a/src/flows_api.js b/src/flows_api.js index e2d4856..359213a 100644 --- a/src/flows_api.js +++ b/src/flows_api.js @@ -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 },