feat: 添加 PWA 安装支持,包括安装横幅和按钮;更新国际化文本;配置 PWA 清单和缓存策略

This commit is contained in:
2026-01-05 15:49:35 +07:00
parent ee997fd612
commit 01e727490c
10 changed files with 332 additions and 4 deletions

View File

@@ -4,10 +4,84 @@ export default defineNuxtConfig({
'@nuxt/ui',
'@nuxtjs/i18n',
'@nuxt/eslint',
'@vite-pwa/nuxt',
],
devtools: { enabled: true },
pwa: {
registerType: 'autoUpdate',
manifest: {
name: 'Riwa App 下载',
short_name: 'Riwa应用商店',
description: 'Riwa App 下载 - iOS, Android, H5',
theme_color: '#3b82f6',
background_color: '#ffffff',
display: 'standalone',
scope: '/',
start_url: '/',
icons: [
{
src: '/favicon.svg',
sizes: '512x512',
type: 'image/svg+xml',
purpose: 'any',
},
{
src: '/favicon.svg',
sizes: '192x192',
type: 'image/svg+xml',
},
],
},
workbox: {
navigateFallback: '/',
globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
cleanupOutdatedCaches: true,
runtimeCaching: [
{
urlPattern: /^https:\/\/fonts\.googleapis\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'google-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
{
urlPattern: /^https:\/\/fonts\.gstatic\.com\/.*/i,
handler: 'CacheFirst',
options: {
cacheName: 'gstatic-fonts-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365, // 1 year
},
cacheableResponse: {
statuses: [0, 200],
},
},
},
],
},
client: {
installPrompt: true,
periodicSyncForUpdates: 3600,
},
devOptions: {
enabled: true,
type: 'module',
},
injectManifest: {
globPatterns: ['**/*.{js,css,html,png,svg,ico}'],
},
},
css: [
'~/assets/css/main.css',
'~/assets/css/animations.css',