退出修复

This commit is contained in:
2026-04-13 20:25:24 +08:00
parent 0fa95e661b
commit 77b348eb48
4 changed files with 85 additions and 3 deletions

View File

@@ -145,8 +145,27 @@ function getStatusBadge(status, type = 'homework') {
}
async function logout() {
await apiPost('/api/auth/logout');
// 清除 PHP Session
try {
await fetch('/api/clear_session.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' }
});
} catch (e) {
console.warn('清除Session失败', e);
}
// 清除后端 Token
try {
await apiPost('/api/auth/logout');
} catch (e) {
console.warn('后端登出失败', e);
}
// 清除 localStorage
clearAuth();
// 跳转回登录页
window.location.href = '/index.php';
}