v0.3测试

This commit is contained in:
2026-04-10 17:59:28 +08:00
parent 916b0bac4a
commit 81153806ed
4 changed files with 21 additions and 127 deletions

View File

@@ -12,15 +12,13 @@
require_once __DIR__ . '/config.php';
// 如果已登录,跳转到对应页面
if (isset($_SESSION['user_id']) && isset($_SESSION['user_type'])) {
$redirect = [
'student' => '/student/dashboard.php',
'parent' => '/parent/dashboard.php',
'admin' => '/admin/dashboard.php'
];
$target = $redirect[$_SESSION['user_type']] ?? '/index.php';
header("Location: $target");
header("Location: " . ($redirect[$_SESSION['user_type']] ?? '/index.php'));
exit();
}
?>
@@ -42,7 +40,7 @@ if (isset($_SESSION['user_id']) && isset($_SESSION['user_type'])) {
<form id="loginForm" class="login-form">
<div class="form-group">
<label>用户名</label>
<input type="text" id="username" name="username" required autocomplete="off" placeholder="请输入用户名">
<input type="text" id="username" name="username" required autocomplete="off" placeholder="学号/手机号/管理员账号">
</div>
<div class="form-group">
<label>密码</label>
@@ -84,11 +82,8 @@ if (isset($_SESSION['user_id']) && isset($_SESSION['user_type'])) {
const data = await response.json();
if (data.success && data.data) {
// 存储Token和用户信息
localStorage.setItem(JWT_STORAGE_KEY, data.data.token);
localStorage.setItem(USER_STORAGE_KEY, JSON.stringify(data.data));
// 跳转
window.location.href = data.data.redirect;
} else {
showError(data.message || '登录失败');