|
|
|
self.addEventListener('message', (event) => { |
|
if (event.data && event.data.type === 'CACHE_FILES') { |
|
cachedFiles = ['/index.html', ...event.data.files]; |
|
|
|
|
|
if (event.data.checkboxStates) { |
|
event.waitUntil( |
|
caches.open('settings-cache').then(cache => { |
|
return cache.put( |
|
new Request('checkbox-states'), |
|
new Response(JSON.stringify(event.data.checkboxStates)) |
|
}) |
|
); |
|
} |
|
|
|
|
|
event.waitUntil( |
|
caches.open(CACHE_NAME).then(cache => { |
|
return cache.addAll(cachedFiles).catch(error => { |
|
console.error('キャッシュ追加エラー:', error); |
|
}); |
|
}) |
|
); |
|
} |
|
}); |