feat: 更新 Service Worker 版本管理,优化缓存策略,增加未处理更新的提示
All checks were successful
Docker Build & Deploy / Build Docker Image (push) Successful in 15s
Docker Build & Deploy / Deploy to Production (push) Successful in 9s
Docker Build & Deploy / Cleanup Dangling Images (push) Successful in 1s

This commit is contained in:
孙诚
2026-01-07 16:07:56 +08:00
parent 1bd6b688c1
commit c95aa6b17b
3 changed files with 50 additions and 7 deletions

View File

@@ -20,6 +20,12 @@ export function register() {
swRegistration = registration;
console.log('[SW] Service Worker 注册成功:', registration.scope);
// 如果已经有等待中的更新
if (registration.waiting) {
console.log('[SW] 发现未处理的新版本');
needRefresh.value = true;
}
// 检查更新
registration.addEventListener('updatefound', () => {
const newWorker = registration.installing;