fivetech commited on
Commit
efd3ba7
·
verified ·
1 Parent(s): 2a43bf8

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -2
index.html CHANGED
@@ -241,8 +241,25 @@ async function loadModel(repo, file) {
241
  } catch (e) {
242
  console.error(e);
243
  setStatus('Error al cargar el modelo');
244
- addErr('No se pudo cargar el modelo: ' + (e?.message || e) +
245
- '. Prueba a recargar la p\u00e1gina o a cambiar el archivo en Ajustes.');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
  }
248
 
 
241
  } catch (e) {
242
  console.error(e);
243
  setStatus('Error al cargar el modelo');
244
+ addErr('No se pudo cargar el modelo: ' + (e?.message || e));
245
+ const retry = document.createElement('button');
246
+ retry.textContent = 'Limpiar cach\u00e9 y reintentar';
247
+ retry.style.cssText = 'margin-top:6px;background:var(--accent);border:none;color:#fff;border-radius:999px;padding:8px 14px;cursor:pointer;font-weight:700';
248
+ retry.addEventListener('click', async () => {
249
+ retry.disabled = true; retry.textContent = 'Limpiando\u2026';
250
+ try {
251
+ if ('caches' in window) for (const k of await caches.keys()) await caches.delete(k);
252
+ if (indexedDB.databases) for (const db of await indexedDB.databases())
253
+ await new Promise(r => { const q = indexedDB.deleteDatabase(db.name); q.onsuccess = q.onerror = q.onblocked = r; });
254
+ if (navigator.storage?.estimate) {
255
+ const dir = await navigator.storage.getDirectory().catch(() => null);
256
+ if (dir) for await (const k of dir.keys()) await dir.removeEntry(k, { recursive: true }).catch(() => {});
257
+ }
258
+ } catch (_) {}
259
+ loadModel(repo, file);
260
+ });
261
+ const errBox = chatEl.lastElementChild;
262
+ if (errBox) { errBox.appendChild(document.createElement('br')); errBox.appendChild(retry); }
263
  }
264
  }
265