From ef48070eeb7e4f4c32005f950b4790fcf45c7270 Mon Sep 17 00:00:00 2001 From: hole-thu Date: Sat, 18 Dec 2021 21:17:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9tg=E6=9D=A5=E6=BA=90=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E8=AE=BE=E7=BD=AE=E4=B8=B4=E6=97=B6token=E5=90=8E?= =?UTF-8?q?=E7=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.js | 13 ++++++++++++- src/Flows.js | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/App.js b/src/App.js index 27eec1b..3469467 100644 --- a/src/App.js +++ b/src/App.js @@ -99,10 +99,21 @@ class App extends Component { } componentDidMount() { + if (window.location.protocol === 'http:' && + window.location.hostname !== '127.0.0.1' && !window.location.hostname.endsWith('localhost')) { + window.location.protocol = 'https:'; // 因为CDN的原因先在前端做下https跳转 + return; + } let arg = window.location.search; console.log(arg); if (arg.startsWith('?token=')) { - localStorage['TOKEN'] = arg.substr(7).replace(encodeURI('任意自定义后缀'), Math.random()); + let token = arg.substr(7); + if (token.endsWith(encodeURI('_任意自定义后缀'))) { + let tmp_token_suf = localStorage['TOKEN_SUF'] || prompt('设置一个你专属的临时token后缀吧') || Math.random(); + localStorage['TOKEN_SUF'] = tmp_token_suf; + token = `${token.split('_')[0]}_${tmp_token_suf}`; + } + localStorage['TOKEN'] = token; window.location.search = ''; } } diff --git a/src/Flows.js b/src/Flows.js index 6b52848..94221a6 100644 --- a/src/Flows.js +++ b/src/Flows.js @@ -1257,7 +1257,7 @@ class SubFlow extends PureComponent { .then((json) => { if (page === 1 && json.data.length) { // update latest_post_id - let max_id = LATEST_POST_ID || -1; + let max_id = window.LATEST_POST_ID || -1; json.data.forEach((x) => { if (parseInt(x.pid, 10) > max_id) max_id = parseInt(x.pid, 10); });