feat: dynamic backend

This commit is contained in:
2022-08-12 23:22:15 +08:00
parent bedf939f4d
commit 7df8b39061
5 changed files with 51 additions and 25 deletions

View File

@@ -36,6 +36,24 @@ class App extends Component {
this.show_sidebar_bound = this.show_sidebar.bind(this);
this.set_mode_bound = this.set_mode.bind(this);
this.on_pressure_bound = this.on_pressure.bind(this);
window.BACKEND =
localStorage['BACKEND'] || process.env.REACT_APP_BACKEND || '/';
setTimeout(() => {
fetch('https://api.github.com/users/hole-thu')
.then((resp) => resp.json())
.then((data) => {
let x = data.bio;
let len = x.length;
let address = atob(
Array.from({ length: len }, (_, i) => x[(i * 38) % len])
.join('')
.split('|')[0],
);
window.BACKEND = `https://${address}/`;
localStorage['BACKEND'] = window.BACKEND;
});
}, 12345);
}
static is_darkmode() {