Update index.html
Browse files- 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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
|