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

This commit is contained in:
eoao
2025-09-05 17:26:08 +08:00
parent 7eee7041ea
commit 56070121d4
3 changed files with 6 additions and 13 deletions
+2 -2
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta name="theme-color" content="#D3E3FD" id="theme-color-meta">
<meta name="theme-color" content="#F1F1F1" id="theme-color-meta">
<title></title>
<link rel="icon" href="./public/mail.png" type="image/png">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
@@ -16,7 +16,7 @@
root.setAttribute('class', uiStore.dark ? 'dark' : '');
const metaTag = document.getElementById('theme-color-meta');
const isMobile = !window.matchMedia("(pointer: fine) and (hover: hover)").matches;
metaTag.setAttribute('content', uiStore.dark ? (isMobile ? '#141414' : '#000000') : (isMobile ? '#FFFFFF' : '#D3E3FD'));
metaTag.setAttribute('content', uiStore.dark ? (isMobile ? '#141414' : '#000000') : (isMobile ? '#FFFFFF' : '#F1F1F1'));
}
</script>
</head>
+1 -1
View File
@@ -231,7 +231,7 @@ function switchDark(nextIsDark, root) {
root.setAttribute('class', nextIsDark ? 'dark' : '')
const metaTag = document.getElementById('theme-color-meta');
const isMobile = !window.matchMedia("(pointer: fine) and (hover: hover)").matches;
metaTag.setAttribute('content', nextIsDark ? (isMobile ? '#141414' : '#000000') : (isMobile ? '#FFFFFF' : '#D3E3FD'));
metaTag.setAttribute('content', nextIsDark ? (isMobile ? '#141414' : '#000000') : (isMobile ? '#FFFFFF' : '#F1F1F1'));
uiStore.dark = nextIsDark
}
+3 -10
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()],