From 80f8342c0b4a3489f46fbfe04c8bf1467cbf32d6 Mon Sep 17 00:00:00 2001 From: canglan Date: Wed, 15 Jul 2026 03:49:50 +0800 Subject: [PATCH] debug: add window.onerror to display JS errors in sidebar --- public/js/app.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/public/js/app.js b/public/js/app.js index caedc7b..925edf9 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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', '
Error: ' + String(msg).substring(0,80) + '
'); + }; document.getElementById('modal-close').onclick = () => this.closeModal(); document.addEventListener('click', (e) => { const action = e.target.closest('[data-action]');