From 22304cb03d6c4aaad9cacde172674afc6c08d6fb Mon Sep 17 00:00:00 2001 From: hole-thu Date: Mon, 26 Sep 2022 01:48:33 +0800 Subject: [PATCH] show admin list & you are admin --- src/Flows.js | 22 ++++++++++++++-------- src/Message.css | 8 ++++++++ src/Message.js | 20 ++++++++++++++++++++ src/UserAction.css | 6 ++++++ src/UserAction.js | 16 ++++++++++++++-- 5 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/Flows.js b/src/Flows.js index b2ea2da..80383a5 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1473,15 +1473,21 @@ class SubFlow extends PureComponent { }); localStorage['_LATEST_POST_ID'] = '' + max_id; } - window.TITLE = json.custom_title; - window.AUTO_BLCOK = json.auto_block_rank; - if ( - json.custom_title && - window.TITLE_SECRET !== json.title_secret - ) { - window.TITLE_SECRET = json.title_secret; - localStorage['TITLE_SECRET'] = json.title_secret; + + if (page === 1) { + window.IS_ADMIN = json.is_admin; + window.IS_CANDIDATE = json.is_candidate; + window.TITLE = json.custom_title; + window.AUTO_BLCOK = json.auto_block_rank; + if ( + json.custom_title && + window.TITLE_SECRET !== json.title_secret + ) { + window.TITLE_SECRET = json.title_secret; + localStorage['TITLE_SECRET'] = json.title_secret; + } } + json.data.forEach((x) => { if (x.comments) { let comment_json = { diff --git a/src/Message.css b/src/Message.css index aaefc14..a7fd2ae 100644 --- a/src/Message.css +++ b/src/Message.css @@ -16,3 +16,11 @@ vertical-align: top; padding: 3px; } + +.admin-card { + display: inline-block; + background: #3332; + margin-left: 7px; + padding: 1px 5px; + border-radius: 5px; +} diff --git a/src/Message.js b/src/Message.js index 601377b..2079b6e 100644 --- a/src/Message.js +++ b/src/Message.js @@ -35,6 +35,8 @@ export class MessageViewer extends PureComponent { msg: json.data, start_time: json.start_time, salt: json.salt, + admin_list: json.admin_list, + candidate_list: json.candidate_list, tmp_token: json.tmp_token, }); }) @@ -107,6 +109,24 @@ export class MessageViewer extends PureComponent { 使用 +
+
+ 当前管理员: + {this.state.admin_list.map((admin) => ( + + {admin} + + ))} +
+
+
+ 当前候选管理员: + {this.state.candidate_list.map((admin) => ( + + {admin} + + ))} +
{this.state.msg.map((msg) => (
diff --git a/src/UserAction.css b/src/UserAction.css index 935465b..6e48e06 100644 --- a/src/UserAction.css +++ b/src/UserAction.css @@ -155,3 +155,9 @@ .update-title-btn { margin-top: 6px; } + +.role-card { + padding: 5px; + background: #d33a; + border-radius: 6px; +} diff --git a/src/UserAction.js b/src/UserAction.js index 3770dd4..2b480c4 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -141,6 +141,7 @@ export class LoginForm extends Component { this.state = { custom_title: window.TITLE || '', auto_block_rank: window.AUTO_BLCOK || 2, + is_admin: window.IS_ADMIN, }; } @@ -166,6 +167,9 @@ export class LoginForm extends Component { window.TITLE_SECRET = j.data; localStorage['TITLE_SECRET'] = j.data; alert('专属头衔设置成功'); + window.IS_ADMIN = false; + window.IS_CANDIDATE = false; + this.setState({ is_admin: false }); }) .catch((err) => alert('设置头衔出错了:\n' + err)); } @@ -243,6 +247,10 @@ export class LoginForm extends Component { Token仅用于开发bot,切勿告知他人。若怀疑被盗号请刷新Token(刷新功能即将上线)。

+ {this.state.is_admin && ( + 你是管理员 + )} +
专属头衔: {' '} 使用头衔 @@ -527,6 +537,7 @@ export class PostForm extends Component { this.on_cw_change_bound = this.on_cw_change.bind(this); this.on_poll_option_change_bound = this.on_poll_option_change.bind(this); this.color_picker = new ColorPicker(); + this.forced_use_title = window.IS_ADMIN || window.IS_CANDIDATE; } componentDidMount() { @@ -784,7 +795,8 @@ export class PostForm extends Component { {' '} 使用头衔