|
|
|
|
@ -19,18 +19,28 @@ customElements.define(
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
class Setup {
|
|
|
|
|
async run() {
|
|
|
|
|
const sw = navigator.serviceWorker
|
|
|
|
|
|
|
|
|
|
sw.addEventListener('controllerchange', () => {
|
|
|
|
|
if (this.registration.active) {
|
|
|
|
|
window.location.reload(true)
|
|
|
|
|
async runWithSw() {
|
|
|
|
|
navigator.serviceWorker.addEventListener(
|
|
|
|
|
'controllerchange',
|
|
|
|
|
() => {
|
|
|
|
|
if (this.registration.active) {
|
|
|
|
|
window.location.reload(true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
)
|
|
|
|
|
await this.register()
|
|
|
|
|
this.load()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async runWithoutSw() {
|
|
|
|
|
const layout = document.createElement(
|
|
|
|
|
'm-layout'
|
|
|
|
|
)
|
|
|
|
|
layout.csp = undefined
|
|
|
|
|
layout.header.menu.handleLinks = true
|
|
|
|
|
document.body.appendChild(layout)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async register() {
|
|
|
|
|
try {
|
|
|
|
|
this.registration =
|
|
|
|
|
@ -54,4 +64,4 @@ class Setup {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new Setup().run()
|
|
|
|
|
new Setup().runWithSw()
|