File size: 18,068 Bytes
ba1c27f 20f7a0a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
<title>教育AI助手平台 - 登录</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css">
<style>
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
:root {
/* 优雅的配色方案 */
--primary-color: #0f2d49;
--primary-light: #234a70;
--secondary-color: #4a6cfd;
--secondary-light: #7b91ff;
--tertiary-color: #f7f9fe;
--success-color: #10b981;
--success-light: rgba(16, 185, 129, 0.1);
--warning-color: #f59e0b;
--warning-light: rgba(245, 158, 11, 0.1);
--info-color: #0ea5e9;
--info-light: rgba(14, 165, 233, 0.1);
--danger-color: #ef4444;
--danger-light: rgba(239, 68, 68, 0.1);
--neutral-50: #f9fafb;
--neutral-100: #f3f4f6;
--neutral-200: #e5e7eb;
--neutral-300: #d1d5db;
--neutral-400: #9ca3af;
--neutral-500: #6b7280;
--neutral-600: #4b5563;
--neutral-700: #374151;
--neutral-800: #1f2937;
--neutral-900: #111827;
/* 样式变量 */
--border-radius-sm: 0.25rem;
--border-radius: 0.375rem;
--border-radius-lg: 0.5rem;
--border-radius-xl: 0.75rem;
--border-radius-2xl: 1rem;
--card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.1);
--card-shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.05), 0 6px 6px rgba(0, 0, 0, 0.1);
--card-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
--transition-base: all 0.2s ease-in-out;
--transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
--font-family: 'Inter', 'PingFang SC', 'Helvetica Neue', 'Microsoft YaHei', sans-serif;
}
/* 基础样式 */
body {
font-family: var(--font-family);
background-color: var(--neutral-50);
color: var(--neutral-800);
margin: 0;
padding: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 600;
color: var(--neutral-900);
}
.text-gradient {
background: linear-gradient(135deg, var(--secondary-color), var(--secondary-light));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
color: transparent;
}
/* 登录容器样式 */
.login-container {
width: 100%;
max-width: 450px;
padding: 2.5rem;
background-color: white;
border-radius: var(--border-radius-xl);
box-shadow: var(--card-shadow-lg);
transition: var(--transition-smooth);
position: relative;
overflow: hidden;
}
.login-container::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 4px;
background: linear-gradient(to right, var(--secondary-color), var(--secondary-light));
border-radius: 4px 4px 0 0;
}
.login-header {
text-align: center;
margin-bottom: 2.5rem;
}
.login-header h1 {
font-size: 1.75rem;
font-weight: 700;
margin-bottom: 0.5rem;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
letter-spacing: -0.01em;
}
.login-header p {
color: var(--neutral-600);
margin-bottom: 0;
font-size: 0.95rem;
}
.user-type-switch {
margin-bottom: 2rem;
}
.user-type-switch .btn-group {
width: 100%;
box-shadow: var(--card-shadow);
border-radius: var(--border-radius-lg);
padding: 0.25rem;
background-color: var(--neutral-100);
}
.user-type-switch .btn {
flex: 1;
background: transparent;
border: none;
padding: 0.75rem 1rem;
font-weight: 500;
color: var(--neutral-700);
border-radius: var(--border-radius);
transition: var(--transition-base);
}
.user-type-switch .btn:hover {
color: var(--primary-color);
}
.user-type-switch .btn.active {
background: white;
color: var(--secondary-color);
box-shadow: var(--card-shadow);
}
/* 表单样式 */
.form-floating {
margin-bottom: 1.25rem;
}
.form-floating > .form-control {
padding: 1rem 1rem;
height: calc(3.5rem + 2px);
border-radius: var(--border-radius-lg);
border: 1px solid var(--neutral-200);
font-size: 0.95rem;
transition: var(--transition-base);
}
.form-floating > .form-control:focus {
border-color: var(--secondary-color);
box-shadow: 0 0 0 3px rgba(74, 108, 253, 0.1);
}
.form-floating > label {
padding: 1rem;
color: var(--neutral-500);
}
.form-check {
display: flex;
align-items: center;
margin-bottom: 1.5rem;
}
.form-check-input {
width: 1.25em;
height: 1.25em;
margin-right: 0.75rem;
background-color: white;
border: 1px solid var(--neutral-300);
border-radius: 0.25em;
transition: all 0.15s ease-in-out;
}
.form-check-input:checked {
background-color: var(--secondary-color);
border-color: var(--secondary-color);
}
.form-check-label {
color: var(--neutral-700);
font-size: 0.95rem;
}
/* 按钮样式 */
.btn-primary {
background: linear-gradient(to right, var(--secondary-color), var(--secondary-light));
border: none;
width: 100%;
padding: 0.85rem;
font-weight: 500;
border-radius: var(--border-radius-lg);
transition: var(--transition-base);
}
.btn-primary:hover, .btn-primary:focus {
background: linear-gradient(to right, var(--secondary-light), var(--secondary-color));
box-shadow: 0 4px 10px rgba(74, 108, 253, 0.3);
transform: translateY(-1px);
}
.btn-outline-primary {
color: var(--secondary-color);
border-color: var(--secondary-color);
background-color: transparent;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
background-color: var(--secondary-color);
border-color: var(--secondary-color);
color: white;
box-shadow: 0 4px 10px rgba(74, 108, 253, 0.2);
}
/* 学生说明部分 */
.student-instructions {
margin-top: 1.5rem;
padding: 1.25rem;
background-color: var(--neutral-50);
border-radius: var(--border-radius-lg);
border: 1px solid var(--neutral-200);
font-size: 0.95rem;
color: var(--neutral-700);
transition: var(--transition-smooth);
}
.student-instructions p {
margin-bottom: 0.75rem;
}
.student-instructions p:last-child {
margin-bottom: 0;
}
.student-instructions strong {
color: var(--neutral-900);
}
/* 页脚样式 */
.login-footer {
text-align: center;
margin-top: 2rem;
color: var(--neutral-500);
font-size: 0.85rem;
}
/* 动画效果 */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(8px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
opacity: 0;
animation: fadeIn 0.4s ease-out forwards;
}
/* 输入组样式 */
.input-group {
position: relative;
}
.input-group .form-control {
padding-right: 3.5rem;
border-radius: var(--border-radius-lg);
}
.input-group .btn {
position: absolute;
right: 0;
top: 0;
bottom: 0;
z-index: 5;
border-radius: 0 var(--border-radius-lg) var(--border-radius-lg) 0;
color: var(--neutral-700);
background-color: var(--neutral-100);
border: 1px solid var(--neutral-200);
border-left: none;
transition: var(--transition-base);
}
.input-group .btn:hover, .input-group .btn:focus {
background-color: var(--neutral-200);
}
</style>
</head>
<body>
<div class="login-container fade-in">
<div class="login-header">
<h1>AI助教开发平台</h1>
<p id="login-subtitle">教师端登录</p>
</div>
<div class="user-type-switch">
<div class="btn-group" role="group" id="user-type-buttons">
<button type="button" class="btn active" id="teacher-button">教师</button>
<button type="button" class="btn" id="student-button">学生</button>
</div>
</div>
<form id="login-form">
<div class="form-floating">
<input type="text" class="form-control" id="username" placeholder="用户名" required>
<label for="username">用户名</label>
</div>
<div class="form-floating">
<input type="password" class="form-control" id="password" placeholder="密码" required>
<label for="password">密码</label>
</div>
<div class="form-check">
<input class="form-check-input" type="checkbox" id="remember-me">
<label class="form-check-label" for="remember-me">
记住我
</label>
</div>
<div id="student-instructions" class="student-instructions" style="display: none;">
<p><strong>学生登录说明:</strong></p>
<p>您也可以直接使用教师分享的链接访问AI助手,无需登录。</p>
<div class="input-group mt-3">
<input type="text" class="form-control" id="access-token" placeholder="输入访问令牌">
<button class="btn" type="button" id="access-button">
<i class="bi bi-arrow-right"></i>
</button>
</div>
</div>
<button type="submit" class="btn btn-primary mt-3">
<i class="bi bi-box-arrow-in-right me-2"></i>登录
</button>
</form>
<div class="login-footer">
© 2025 教育AI助手开发平台 版权所有
</div>
</div>
<script>
// 硬编码用户
const users = {
teachers: [
{ username: 'teacher', password: '123456', name: '李志刚' },
{ username: 'admin', password: 'admin123', name: '管理员' }
],
students: [
{ username: 'student1', password: '123456', name: '张三' },
{ username: 'student2', password: '123456', name: '李四' }
]
};
// DOM元素
const teacherButton = document.getElementById('teacher-button');
const studentButton = document.getElementById('student-button');
const loginSubtitle = document.getElementById('login-subtitle');
const studentInstructions = document.getElementById('student-instructions');
const loginForm = document.getElementById('login-form');
const accessButton = document.getElementById('access-button');
// 切换用户类型
teacherButton.addEventListener('click', function() {
teacherButton.classList.add('active');
studentButton.classList.remove('active');
loginSubtitle.textContent = '教师端登录';
studentInstructions.style.display = 'none';
});
studentButton.addEventListener('click', function() {
studentButton.classList.add('active');
teacherButton.classList.remove('active');
loginSubtitle.textContent = '学生端登录';
studentInstructions.style.display = 'block';
});
// 处理登录表单提交
// 处理登录表单提交
loginForm.addEventListener('submit', async function(e) {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
const isTeacher = teacherButton.classList.contains('active');
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
username: username,
password: password,
type: isTeacher ? 'teacher' : 'student'
})
});
const data = await response.json();
if (data.success) {
// 登录成功,重定向到相应页面
window.location.href = isTeacher ? '/index.html' : '/student_portal.html';
} else {
showAlert('用户名或密码错误', 'danger');
}
} catch (error) {
console.error('登录失败:', error);
showAlert('登录请求失败,请重试', 'danger');
}
});
// 处理访问令牌
accessButton.addEventListener('click', function() {
const token = document.getElementById('access-token').value.trim();
if (token) {
// 简单验证令牌格式
if (token.length >= 32) {
// 这里应该向服务器验证令牌有效性,这里简化处理
// 直接从URL中提取agent_id (假设格式为: [agent_id]?token=[token])
if (token.includes('?token=')) {
window.location.href = '/student/' + token;
} else {
// 假设这是一个纯token,需要输入Agent ID
const agentId = prompt('请输入Agent ID');
if (agentId) {
window.location.href = `/student/${agentId}?token=${token}`;
}
}
} else {
showAlert('无效的访问令牌格式', 'warning');
}
} else {
showAlert('请输入访问令牌', 'warning');
}
});
// 显示提示信息
function showAlert(message, type) {
// 移除现有的提示
const existingAlert = document.querySelector('.alert');
if (existingAlert) {
existingAlert.remove();
}
// 创建新提示
const alert = document.createElement('div');
alert.className = `alert alert-${type} fade-in`;
alert.role = 'alert';
alert.style.marginBottom = '1.5rem';
alert.innerHTML = `
<i class="bi ${type === 'danger' ? 'bi-exclamation-triangle' : 'bi-info-circle'} me-2"></i>
${message}
`;
// 添加到表单上方
loginForm.insertAdjacentElement('beforebegin', alert);
// 3秒后自动移除
setTimeout(() => {
alert.style.opacity = '0';
setTimeout(() => alert.remove(), 300);
}, 3000);
}
// 页面加载时检查是否已经登录
// window.addEventListener('DOMContentLoaded', function() {
// const currentUser = localStorage.getItem('currentUser');
// if (currentUser) {
// const userData = JSON.parse(currentUser);
// if (userData.type === 'teacher') {
// window.location.href = '/index.html';
// } else if (userData.type === 'student') {
// window.location.href = '/student_portal.html';
// }
// }
// });
</script>
</body>
</html> |