mirror of
https://github.com/CzBiX/qb-web.git
synced 2026-03-31 09:30:15 +08:00
Add PWA
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
>
|
||||
<img
|
||||
class="icon"
|
||||
src="favicon.ico"
|
||||
src="img/icons/favicon-192x192.png"
|
||||
>
|
||||
<span class="title hidden-sm-and-down ml-3 mr-5">
|
||||
qBittorrent Web UI
|
||||
|
||||
@@ -15,6 +15,7 @@ import App from './App.vue';
|
||||
|
||||
import 'roboto-fontface/css/roboto/roboto-fontface.css';
|
||||
import '@mdi/font/css/materialdesignicons.css';
|
||||
import './registerServiceWorker';
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
|
||||
|
||||
32
src/registerServiceWorker.ts
Normal file
32
src/registerServiceWorker.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
import { register } from 'register-service-worker'
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
register(`${process.env.BASE_URL}service-worker.js`, {
|
||||
ready () {
|
||||
console.log(
|
||||
'App is being served from cache by a service worker.\n' +
|
||||
'For more details, visit https://goo.gl/AFskqB'
|
||||
)
|
||||
},
|
||||
registered () {
|
||||
console.log('Service worker has been registered.')
|
||||
},
|
||||
cached () {
|
||||
console.log('Content has been cached for offline use.')
|
||||
},
|
||||
updatefound () {
|
||||
console.log('New content is downloading.')
|
||||
},
|
||||
updated () {
|
||||
console.log('New content is available; please refresh.')
|
||||
},
|
||||
offline () {
|
||||
console.log('No internet connection found. App is running in offline mode.')
|
||||
},
|
||||
error (error) {
|
||||
console.error('Error during service worker registration:', error)
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user