mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-22 13:45:18 +00:00
always show loading
This commit is contained in:
parent
2f329dec26
commit
10fddd223e
@ -1,6 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="prefetch" href="/nuxt.sw.js">
|
<link rel="prefetch" href="/nuxt.sw.js">
|
||||||
@ -9,24 +8,16 @@
|
|||||||
if (!('serviceWorker' in navigator)) {
|
if (!('serviceWorker' in navigator)) {
|
||||||
throw new Error('Browser not supported!')
|
throw new Error('Browser not supported!')
|
||||||
}
|
}
|
||||||
|
|
||||||
let timeout
|
|
||||||
const stopTimer = () => { if (timeout) { clearTimeout(timeout); timeout = undefined } }
|
|
||||||
const startTimer = () => { stopTimer(); timeout = setTimeout(() => { document.write('Loading...') }, 3000) }
|
|
||||||
|
|
||||||
startTimer()
|
|
||||||
navigator.serviceWorker.register('/nuxt.sw.js').then((registration) => {
|
navigator.serviceWorker.register('/nuxt.sw.js').then((registration) => {
|
||||||
stopTimer()
|
|
||||||
console.log('ServiceWorker registration successful with scope:', registration.scope)
|
console.log('ServiceWorker registration successful with scope:', registration.scope)
|
||||||
window.location.reload(false)
|
window.location.reload(false)
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
stopTimer()
|
|
||||||
console.error('ServiceWorker registration failed:', error)
|
console.error('ServiceWorker registration failed:', error)
|
||||||
document.write(error)
|
document.write(error)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
<body>
|
||||||
<body></body>
|
Loading...
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user