PWA注册改为异步避免影响加载速度

This commit is contained in:
eoao
2025-09-05 17:26:08 +08:00
parent 25a27ec038
commit 2c6803475b
3 changed files with 6 additions and 13 deletions

View File

@@ -17,8 +17,7 @@ export default defineConfig(({mode}) => {
base: env.VITE_STATIC_URL || '/',
plugins: [vue(),
VitePWA({
registerType: 'autoUpdate', // 配置 service worker 的注册方式
includeAssets: ['favicon.svg', 'robots.txt'], // 指定需要包含的静态资源
injectRegister: 'script-defer',
manifest: {
name: env.VITE_PWA_NAME,
short_name: env.VITE_PWA_NAME,
@@ -26,19 +25,13 @@ export default defineConfig(({mode}) => {
theme_color: '#FFFFFF',
icons: [
{
src: 'mail-pwa.png',//像素尺寸一定要对应
src: 'mail-pwa.png',
sizes: '192x192',
type: 'image/png',
}
],
},
workbox: {
disableDevLogs: true,
globPatterns: [],
runtimeCaching: [],
navigateFallback: null,
cleanupOutdatedCaches: true,
}
workbox: false
}),
AutoImport({
resolvers: [ElementPlusResolver()],