new set title api with title secret

This commit is contained in:
2022-09-26 00:22:37 +08:00
parent f586337f78
commit 30006ca528
3 changed files with 12 additions and 1 deletions

View File

@@ -24,6 +24,7 @@ class App extends Component {
window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false; window.AS_BACKUP = localStorage['DEFAULT_ALLOW_SEARCH'] ? true : false;
window.ANN = localStorage['ANN']; window.ANN = localStorage['ANN'];
window.LAST_ANN = localStorage['LAST_ANN']; window.LAST_ANN = localStorage['LAST_ANN'];
window.TITLE_SECRET = localStorage['TITLE_SECRET'] || '';
listen_darkmode( listen_darkmode(
{ default: undefined, light: false, dark: true }[ { default: undefined, light: false, dark: true }[
window.config.color_scheme window.config.color_scheme

View File

@@ -1475,6 +1475,13 @@ class SubFlow extends PureComponent {
} }
window.TITLE = json.custom_title; window.TITLE = json.custom_title;
window.AUTO_BLCOK = json.auto_block_rank; 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) => { json.data.forEach((x) => {
if (x.comments) { if (x.comments) {
let comment_json = { let comment_json = {

View File

@@ -151,7 +151,8 @@ export class LoginForm extends Component {
} }
let data = new FormData(); let data = new FormData();
data.append('title', title); data.append('title', title);
fetch(get_api_base() + '/title', { data.append('secret', window.TITLE_SECRET);
fetch(get_api_base_2() + '/set-title', {
method: 'POST', method: 'POST',
headers: { 'User-Token': token }, headers: { 'User-Token': token },
body: data, body: data,
@@ -162,6 +163,8 @@ export class LoginForm extends Component {
throw new Error(j.msg); throw new Error(j.msg);
} }
window.TITLE = title; window.TITLE = title;
window.TITLE_SECRET = j.data;
localStorage['TITLE_SECRET'] = j.data;
alert('专属头衔设置成功'); alert('专属头衔设置成功');
}) })
.catch((err) => alert('设置头衔出错了:\n' + err)); .catch((err) => alert('设置头衔出错了:\n' + err));