退出修复

This commit is contained in:
canglan committed 2026-04-13 20:25:24 +08:00
1 parent 0fa95e661b
commit 77b348eb48
4 files changed
+85 -3

No files matched your search

+20 -1
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';
}