Add defaultLocation

This commit is contained in:
2021-05-08 21:15:20 +02:00
parent fedd45b83c
commit f710430f53

View File

@ -1,6 +1,7 @@
"use strict";
let main, windows;
let defaultLocation = '/welcome';
function createWelcomeWindow() {
let win = document.createElement("div");
@ -32,7 +33,8 @@ function createLoginWindow() {
function handleHash(hash) {
if (hash[0] === '#') hash = hash.substr(1);
if (hash === '') hash = '/welcome';
if (hash === '') hash = defaultLocation;
switch (hash) {
case "/welcome": createWelcomeWindow(); break;
case "/login": createLoginWindow(); break;
@ -41,13 +43,19 @@ function handleHash(hash) {
hash = "/welcome";
break;
}
let url = new URL(document.URL);
url.hash = hash;
location.href = url.toString();
}
function handleUrl(url) {
handleHash(new URL(url).hash)
let hash = new URL(url).hash;
if (hash === '') {
history.replaceState(null, null, `#${defaultLocation}`);
} else {
handleHash(hash);
}
}
window.addEventListener("load", function () {