mirror of
https://github.com/antfu-collective/icones.git
synced 2026-01-09 07:40:49 +08:00
feat: use pwa virtual module (#138)
This commit is contained in:
parent
221f4d8e3e
commit
3371cc4559
15
src/main.ts
15
src/main.ts
@ -10,11 +10,6 @@ import 'uno.css'
|
||||
import { basePath, isElectron } from './env'
|
||||
import routes from '~pages'
|
||||
|
||||
// disable local storage cache when there is PWA:
|
||||
// we need to keep local storage when running dev server without PWA
|
||||
if (!isElectron && PWA)
|
||||
disableCache('all')
|
||||
|
||||
const app = createApp(App)
|
||||
|
||||
const router = createRouter({
|
||||
@ -22,5 +17,15 @@ const router = createRouter({
|
||||
routes,
|
||||
})
|
||||
|
||||
if (!isElectron && PWA) {
|
||||
// disable local storage cache when there is PWA:
|
||||
// we need to keep local storage when running dev server without PWA
|
||||
disableCache('all')
|
||||
router.isReady().then(async () => {
|
||||
const { registerSW } = await import('virtual:pwa-register')
|
||||
registerSW({ immediate: true })
|
||||
})
|
||||
}
|
||||
|
||||
app.use(router)
|
||||
app.mount('#app')
|
||||
|
||||
@ -13,7 +13,8 @@
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"types": [
|
||||
"vite/client",
|
||||
"vite-plugin-pages/client"
|
||||
"vite-plugin-pages/client",
|
||||
"vite-plugin-pwa/client"
|
||||
]
|
||||
},
|
||||
"exclude": [
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user