diff --git a/src/App.js b/src/App.js index b762d92..ebab031 100644 --- a/src/App.js +++ b/src/App.js @@ -24,6 +24,7 @@ class App extends Component { window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false; window.ANN = localStorage['ANN']; window.LAST_ANN = localStorage['LAST_ANN']; + window.TITLE_SECRET = localStorage['TITLE_SECRET'] || ''; listen_darkmode( { default: undefined, light: false, dark: true }[ window.config.color_scheme diff --git a/src/Flows.js b/src/Flows.js index dd684bd..b2ea2da 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1475,6 +1475,13 @@ class SubFlow extends PureComponent { } 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/UserAction.js b/src/UserAction.js index 05f3fbb..3770dd4 100644 --- a/src/UserAction.js +++ b/src/UserAction.js @@ -151,7 +151,8 @@ export class LoginForm extends Component { } let data = new FormData(); data.append('title', title); - fetch(get_api_base() + '/title', { + data.append('secret', window.TITLE_SECRET); + fetch(get_api_base_2() + '/set-title', { method: 'POST', headers: { 'User-Token': token }, body: data, @@ -162,6 +163,8 @@ export class LoginForm extends Component { throw new Error(j.msg); } window.TITLE = title; + window.TITLE_SECRET = j.data; + localStorage['TITLE_SECRET'] = j.data; alert('专属头衔设置成功'); }) .catch((err) => alert('设置头衔出错了:\n' + err));