feat: 更新 Service Worker 版本管理,优化缓存策略,增加未处理更新的提示
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user