feat: 多班级版班级管理系统 v2.0
技术栈:Go (Gin + GORM) + PHP + MySQL 5.7 + Redis 主要功能: - 多班级完全隔离(class_id 贯穿全系统) - 后端从 Python FastAPI 重写为 Go Gin(端口 56789) - 超级管理员独立登录(env 配置路径,默认账密 admin/Admin123) - 科任老师/课代表新角色 - 课代表作业管理页面 - 排行榜分项排行(操行分/考勤/作业) - 角色加减分上下限由班主任配置 - 家长改密功能(可开关) - 班级角色按需开关 - 宿舍号格式:南0-000 - 周度/月度重置功能 - MySQL 5.7 兼容 - Nginx 反向代理部署 开发者: Canglan 版权归属: Sea Network Technology Studio 许可证: Apache License 2.0
This commit is contained in:
134
frontend/super-admin/login.php
Normal file
134
frontend/super-admin/login.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* 多班级版班级管理系统 - 超级管理员登录页
|
||||
*
|
||||
* 开发者: Canglan
|
||||
* 联系方式: admin@sea-studio.top
|
||||
* 版权归属: Sea Network Technology Studio
|
||||
* 许可证: Apache License 2.0
|
||||
*
|
||||
* 版权所有 © Sea Network Technology Studio
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../config.php';
|
||||
|
||||
if (isset($_SESSION['user_id']) && $_SESSION['user_type'] === 'super_admin') {
|
||||
header('Location: /admin/classes.php');
|
||||
exit();
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
|
||||
<title><?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?> - 系统管理员登录</title>
|
||||
<link rel="stylesheet" href="/assets/css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="login-container">
|
||||
<div class="login-header">
|
||||
<h1><?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?></h1>
|
||||
<p>系统管理员登录</p>
|
||||
</div>
|
||||
|
||||
<form id="superAdminLoginForm" class="login-form">
|
||||
<div class="form-group">
|
||||
<label>用户名</label>
|
||||
<input type="text" id="username" name="username" required autocomplete="off" placeholder="系统管理员账号">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>密码</label>
|
||||
<input type="password" id="password" name="password" required placeholder="请输入密码">
|
||||
</div>
|
||||
<button type="submit" class="btn-login">登 录</button>
|
||||
<div id="errorMsg" class="error-msg" style="display: none;"></div>
|
||||
</form>
|
||||
|
||||
<div class="login-footer">
|
||||
<p>© <?php echo date('Y'); ?> Sea Network Technology Studio</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.API_BASE_URL = <?php echo json_encode(API_BASE_URL); ?>;
|
||||
window.JWT_STORAGE_KEY = <?php echo json_encode(JWT_STORAGE_KEY); ?>;
|
||||
window.USER_STORAGE_KEY = <?php echo json_encode(USER_STORAGE_KEY); ?>;
|
||||
|
||||
const superAdminLoginPath = '<?php echo htmlspecialchars(SUPER_ADMIN_LOGIN_PATH, ENT_QUOTES, 'UTF-8'); ?>';
|
||||
|
||||
document.getElementById('superAdminLoginForm').addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const username = document.getElementById('username').value.trim();
|
||||
const password = document.getElementById('password').value;
|
||||
const errorMsg = document.getElementById('errorMsg');
|
||||
|
||||
if (!username || !password) {
|
||||
showError('请填写用户名和密码');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const loginUrl = API_BASE_URL + '/api' + superAdminLoginPath + '/login';
|
||||
const response = await fetch(loginUrl, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ username: username, password: password })
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success && data.data) {
|
||||
const userData = data.data;
|
||||
|
||||
localStorage.setItem(JWT_STORAGE_KEY, userData.token);
|
||||
localStorage.setItem(USER_STORAGE_KEY, JSON.stringify(userData));
|
||||
|
||||
try {
|
||||
const sessionResponse = await fetch('/api/save_session.php', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + userData.token
|
||||
},
|
||||
body: JSON.stringify({
|
||||
user_id: userData.user_id,
|
||||
user_type: 'super_admin',
|
||||
username: userData.username,
|
||||
real_name: userData.real_name || '',
|
||||
role: '系统管理员',
|
||||
class_id: null,
|
||||
class_name: '',
|
||||
need_change_password: userData.need_change_password || false
|
||||
})
|
||||
});
|
||||
|
||||
if (!sessionResponse.ok) {
|
||||
console.warn('Session 同步失败,但继续跳转');
|
||||
}
|
||||
} catch (sessionError) {
|
||||
console.warn('Session 同步异常:', sessionError);
|
||||
}
|
||||
|
||||
window.location.href = userData.redirect || '/admin/classes.php';
|
||||
} else {
|
||||
showError(data.message || '登录失败');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('登录错误:', error);
|
||||
showError('网络错误,请检查后端服务是否启动');
|
||||
}
|
||||
});
|
||||
|
||||
function showError(msg) {
|
||||
const errorMsg = document.getElementById('errorMsg');
|
||||
errorMsg.textContent = msg;
|
||||
errorMsg.style.display = 'block';
|
||||
setTimeout(() => {
|
||||
errorMsg.style.display = 'none';
|
||||
}, 3000);
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user