Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jun 29, 2024
1 parent c0e6698 commit b512c94
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
13 changes: 7 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,10 @@ <h2>选择服务器</h2>
loginButton.addEventListener("click", () => {
loginButton.setAttribute("loading", "")
loginDialog.setAttribute("disabled", "")
// loginDialog.open = false
let host = localStorage.getItem("server");
let encrypted = localStorage.getItem("encrypted")
let protocol;
if (encrypted.value === "true") {
if (encrypted === "true") {
protocol = "https://"
} else {
protocol = "http://"
Expand All @@ -71,6 +70,7 @@ <h2>选择服务器</h2>
let json = JSON.parse(httpRequest.responseText);
let token = json.data.token;
sessionStorage.setItem("token", token);
loginDialog.open = false; // close dialog
window.location.reload();
} else {
loginButton.removeAttribute("loading")
Expand All @@ -89,21 +89,22 @@ <h2>选择服务器</h2>
let host = localStorage.getItem("server");
let encrypted = localStorage.getItem("encrypted")
let protocol;
if (encrypted.value === "true") {
if (encrypted === "true") {
protocol = "https://"
} else {
protocol = "http://"
}
fetch(protocol + host).catch(() => {
fetch(protocol + host).catch((reason) => {
localStorage.clear(); // remove everything
console.error(reason)
window.location.reload();
});
let token = sessionStorage.getItem("token");
if (token === null) {
console.log("Call login");
loginDialog.open = true;
} else {
processMessenger(token, encrypted.value === "true", host)
processMessenger(token, encrypted === "true", host)
}
}

Expand All @@ -122,7 +123,7 @@ <h2>选择服务器</h2>
} catch (e) {
localStorage.clear();
sessionStorage.clear();
window.location.reload();
// window.location.reload();
}
}
</script>
Expand Down
3 changes: 3 additions & 0 deletions select-server.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@
protocol = "http://"
}
fetch(protocol + value).then(() => {
localStorage.clear();
sessionStorage.clear();
localStorage.setItem("server", value);
localStorage.setItem("encrypted", encrypted.selected.toString());
console.log("OK");
window.open("index.html", "_self");
}).catch(() => {
dialog.open = true
Expand Down

0 comments on commit b512c94

Please sign in to comment.