- 添加 Service Worker 支持后台定时检查提醒 - 实现浏览器通知 API 集成 - 添加设置页面通知开关和测试功能 - 创建同步服务自动将提醒同步到 SW - 优化提醒检查逻辑(30秒间隔,10分钟宽限期) 文件变更: - public/sw.js: Service Worker 主文件 - public/sw-register.ts: SW 注册脚本 - public/manifest.json: PWA 清单文件 - src/services/notification.ts: 通知权限管理 - src/services/swSync.ts: 提醒同步服务 - src/stores/index.ts: 添加同步调用 - src/pages/SettingsPage.tsx: 添加通知开关和测试按钮 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
47 lines
1.1 KiB
TypeScript
47 lines
1.1 KiB
TypeScript
import { defineConfig } from 'vite'
|
|
import react from '@vitejs/plugin-react'
|
|
import { VitePWA } from 'vite-plugin-pwa'
|
|
|
|
// https://vite.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
react(),
|
|
VitePWA({
|
|
registerType: 'autoUpdate',
|
|
includeAssets: ['favicon.png'],
|
|
manifest: {
|
|
name: '掐日子 - AI 纪念日提醒',
|
|
short_name: '掐日子',
|
|
description: '智能纪念日和提醒管理应用',
|
|
theme_color: '#faf9f7',
|
|
background_color: '#faf9f7',
|
|
display: 'standalone',
|
|
orientation: 'portrait-primary',
|
|
scope: '/',
|
|
start_url: '/',
|
|
icons: [
|
|
{
|
|
src: '/favicon.png',
|
|
sizes: '192x192',
|
|
type: 'image/png',
|
|
},
|
|
{
|
|
src: '/favicon.png',
|
|
sizes: '512x512',
|
|
type: 'image/png',
|
|
purpose: 'any maskable',
|
|
},
|
|
],
|
|
},
|
|
workbox: {
|
|
// 只缓存静态资源,不缓存 API 请求
|
|
globPatterns: ['**/*.{js,css,html,ico,png,svg,woff2}'],
|
|
},
|
|
}),
|
|
],
|
|
build: {
|
|
outDir: 'dist',
|
|
emptyOutDir: true,
|
|
},
|
|
})
|