fix: logout no longer reloads page, shows message instead

This commit is contained in:
Accusys
2026-05-18 12:08:33 +08:00
parent d4f68c40e5
commit e0a6fdf143

View File

@@ -148,8 +148,13 @@ async function init() {
listEl.appendChild(a);
});
document.getElementById('logout-btn').onclick = async function(e) {
await fetch('/api/v1/auth/logout', {method:'POST'});
window.location.reload();
e.preventDefault();
e.stopPropagation();
try {
await fetch('/api/v1/auth/logout', {method:'POST'});
} catch(_) {}
el.innerHTML = '<p style="color:#060">Logged out. Session cleared.</p>';
document.getElementById('logout-btn').style.display = 'none';
};
var hash = location.hash.slice(1);
await loadDoc(hash || '01_auth');
@@ -158,11 +163,6 @@ async function init() {
}
}
window.onpopstate = function() {
var hash = location.hash.slice(1);
if (hash) loadDoc(hash);
};
init();
</script>
</body>