soiz1 commited on
Commit
40b87bd
·
verified ·
1 Parent(s): 76f2fc4

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +16 -13
templates/index.html CHANGED
@@ -166,19 +166,22 @@
166
  let currentFiles = [];
167
  let currentDirs = [];
168
 
169
- // Service Workerの登録
170
- if ('serviceWorker' in navigator) {
171
- window.addEventListener('load', () => {
172
- navigator.serviceWorker.register('/sw.js')
173
- .then(registration => {
174
- console.log('ServiceWorker registration successful with scope: ', registration.scope);
175
- })
176
- .catch(err => {
177
- console.log('ServiceWorker registration failed: ', err);
178
- });
179
- });
180
- }
181
-
 
 
 
182
  // ディレクトリを読み込む関数
183
  function loadDirectory(dir = '') {
184
  fetch(`/get_file_json?dir=${encodeURIComponent(dir)}`)
 
166
  let currentFiles = [];
167
  let currentDirs = [];
168
 
169
+ if ('serviceWorker' in navigator) {
170
+ window.addEventListener('load', function() {
171
+ navigator.serviceWorker.register('/sw.js')
172
+ .then(function(registration) {
173
+ console.log('ServiceWorker registration successful with scope: ', registration.scope);
174
+
175
+ // 定期的にキャッシュを更新
176
+ setInterval(() => {
177
+ registration.update();
178
+ }, 60 * 60 * 1000); // 1時間ごとに更新
179
+ })
180
+ .catch(function(err) {
181
+ console.log('ServiceWorker registration failed: ', err);
182
+ });
183
+ });
184
+ }
185
  // ディレクトリを読み込む関数
186
  function loadDirectory(dir = '') {
187
  fetch(`/get_file_json?dir=${encodeURIComponent(dir)}`)