static: make site-shell not rely on hash
This commit is contained in:
parent
c9712facf3
commit
ffea308480
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -50,7 +50,7 @@ export class SidebarUser extends LitElement {
|
||||||
}
|
}
|
||||||
return html`
|
return html`
|
||||||
<a
|
<a
|
||||||
href="/-/user/"
|
href="#/-/user/"
|
||||||
class="pf-c-nav__link user-avatar"
|
class="pf-c-nav__link user-avatar"
|
||||||
id="user-settings"
|
id="user-settings"
|
||||||
>
|
>
|
||||||
|
|
|
@ -10,11 +10,12 @@ import BackdropStyle from "@patternfly/patternfly/components/Backdrop/backdrop.c
|
||||||
export class SiteShell extends LitElement {
|
export class SiteShell extends LitElement {
|
||||||
@property()
|
@property()
|
||||||
set url(value: string) {
|
set url(value: string) {
|
||||||
if (window.location.hash === "" && value !== undefined) {
|
this._url = value;
|
||||||
window.location.hash = `#${value}`;
|
this.loadContent();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_url?: string;
|
||||||
|
|
||||||
@property()
|
@property()
|
||||||
loading: boolean = false;
|
loading: boolean = false;
|
||||||
|
|
||||||
|
@ -39,19 +40,12 @@ export class SiteShell extends LitElement {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.loadContent();
|
|
||||||
window.addEventListener("hashchange", (e) => this.loadContent());
|
|
||||||
}
|
|
||||||
|
|
||||||
loadContent() {
|
loadContent() {
|
||||||
let url = window.location.hash.slice(1, Infinity);
|
if (!this._url) {
|
||||||
if (url === "") {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
fetch(url)
|
fetch(this._url)
|
||||||
.then((r) => r.text())
|
.then((r) => r.text())
|
||||||
.then((t) => {
|
.then((t) => {
|
||||||
this.querySelector("[slot=body]")!.innerHTML = t;
|
this.querySelector("[slot=body]")!.innerHTML = t;
|
||||||
|
@ -86,7 +80,7 @@ export class SiteShell extends LitElement {
|
||||||
const qs = new URLSearchParams(
|
const qs = new URLSearchParams(
|
||||||
<any>(<unknown>formData)
|
<any>(<unknown>formData)
|
||||||
).toString();
|
).toString();
|
||||||
window.location.hash = `#${url}?${qs}`;
|
window.location.hash = `#${this._url}?${qs}`;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
Reference in New Issue