退出修复
This commit is contained in:
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user