debug: add window.onerror to display JS errors in sidebar

This commit is contained in:
2026-07-15 03:49:50 +08:00
parent 0f64af42a1
commit 80f8342c0b

View File

@@ -17,6 +17,11 @@ const App = {
try { const s = await API.get('/install/status'); if (!s.installed) { location.hash = '#/install'; return; } } catch { location.hash = '#/install'; return; }
this._footerLoaded = false;
window.addEventListener('hashchange', () => this.route());
window.onerror = (msg, url, line, col, err) => {
console.error('JS Error:', msg, url, line, col);
const el = document.getElementById('sidebar-nav');
if (el) el.insertAdjacentHTML('beforeend', '<div style="color:red;font-size:10px;padding:8px">Error: ' + String(msg).substring(0,80) + '</div>');
};
document.getElementById('modal-close').onclick = () => this.closeModal();
document.addEventListener('click', (e) => {
const action = e.target.closest('[data-action]');