File size: 18,480 Bytes
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 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
<!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;
}
/* 验证容器样式 */
.verification-container {
width: 100%;
max-width: 500px;
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;
}
.verification-container:hover {
box-shadow: var(--card-shadow-hover);
}
.verification-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;
}
.verification-header {
text-align: center;
margin-bottom: 2rem;
}
.verification-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;
}
.verification-header p {
color: var(--neutral-600);
margin-bottom: 0;
font-size: 0.95rem;
}
/* 加载状态 */
.loading-container {
text-align: center;
margin-bottom: 1.5rem;
}
.spinner-border {
width: 3rem;
height: 3rem;
color: var(--secondary-color);
margin-bottom: 1.5rem;
}
.loading-container h2 {
margin-bottom: 0.75rem;
font-size: 1.4rem;
color: var(--primary-color);
}
.loading-container p {
color: var(--neutral-600);
font-size: 0.95rem;
}
/* Agent信息卡片 */
.agent-info {
padding: 1.5rem;
background-color: var(--neutral-50);
border-radius: var(--border-radius-lg);
margin-bottom: 1.75rem;
border: 1px solid var(--neutral-200);
position: relative;
overflow: hidden;
transition: var(--transition-base);
}
.agent-info:hover {
border-color: var(--secondary-color);
box-shadow: 0 4px 10px rgba(74, 108, 253, 0.1);
}
.agent-info::before {
content: '';
position: absolute;
top: 0;
bottom: 0;
left: 0;
width: 4px;
background: linear-gradient(to bottom, var(--secondary-color), var(--secondary-light));
border-radius: 4px 0 0 4px;
}
.agent-title {
font-size: 1.25rem;
font-weight: 600;
margin-bottom: 0.75rem;
color: var(--primary-color);
display: flex;
align-items: center;
}
.agent-title i {
margin-right: 0.75rem;
font-size: 1.1rem;
color: var(--secondary-color);
}
.agent-description {
color: var(--neutral-700);
margin-bottom: 1rem;
font-size: 0.95rem;
line-height: 1.5;
}
.agent-meta {
display: flex;
flex-wrap: wrap;
gap: 1rem;
font-size: 0.9rem;
color: var(--neutral-600);
}
.agent-meta-item {
display: flex;
align-items: center;
}
.agent-meta-item i {
margin-right: 0.5rem;
font-size: 0.95rem;
color: var(--secondary-color);
}
/* 验证操作按钮 */
.verification-actions {
margin-bottom: 1.5rem;
}
.btn {
font-weight: 500;
padding: 0.75rem 1.25rem;
border-radius: var(--border-radius-lg);
transition: var(--transition-base);
}
.btn-primary {
background: linear-gradient(to right, var(--secondary-color), var(--secondary-light));
border: none;
color: white;
}
.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(-2px);
}
.btn-outline-secondary {
color: var(--neutral-700);
border-color: var(--neutral-300);
background-color: white;
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
background-color: var(--neutral-100);
border-color: var(--neutral-400);
color: var(--neutral-900);
}
/* 过期/错误状态 */
.expired-container {
text-align: center;
color: var(--danger-color);
margin-bottom: 1.5rem;
}
.expired-container i {
font-size: 3rem;
margin-bottom: 1rem;
display: block;
}
.expired-container h2 {
margin-bottom: 0.75rem;
font-size: 1.5rem;
color: var(--danger-color);
}
.expired-container p {
color: var(--neutral-700);
margin-bottom: 1.5rem;
}
/* 页脚样式 */
.verification-footer {
text-align: center;
margin-top: 2rem;
color: var(--neutral-500);
font-size: 0.85rem;
}
.verification-footer a {
color: var(--secondary-color);
text-decoration: none;
transition: var(--transition-base);
}
.verification-footer a:hover {
text-decoration: underline;
color: var(--secondary-light);
}
/* 动画效果 */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
opacity: 0;
animation: fadeIn 0.4s ease-out forwards;
}
/* 响应式样式 */
@media (max-width: 576px) {
.verification-container {
padding: 1.5rem;
margin: 0 1rem;
}
.verification-header h1 {
font-size: 1.5rem;
}
.agent-title {
font-size: 1.15rem;
}
.agent-meta {
flex-direction: column;
gap: 0.5rem;
}
}
</style>
</head>
<body>
<div class="verification-container fade-in" id="main-container">
<div class="loading-container" id="loading-container">
<div class="spinner-border" role="status">
<span class="visually-hidden">验证中...</span>
</div>
<h2>正在验证访问权限</h2>
<p class="text-muted">请稍候,我们正在验证您的访问令牌...</p>
</div>
<div class="verification-header" id="verification-header" style="display: none;">
<h1>访问 AI 助手</h1>
<p>您正在使用访问令牌访问以下 AI 助手</p>
</div>
<div class="agent-info" id="agent-info" style="display: none;">
<!-- 将由JavaScript填充 -->
</div>
<div class="verification-actions" id="verification-actions" style="display: none;">
<div class="row g-3">
<div class="col-12">
<button class="btn btn-primary w-100" id="access-btn">
<i class="bi bi-robot me-2"></i>开始对话
</button>
</div>
<div class="col-12">
<button class="btn btn-outline-secondary w-100" id="back-btn">
<i class="bi bi-arrow-left me-2"></i>返回
</button>
</div>
</div>
</div>
<div class="expired-container" id="expired-container" style="display: none;">
<i class="bi bi-exclamation-triangle"></i>
<h2>访问令牌无效</h2>
<p>您使用的访问令牌无效或已过期,请联系教师获取新的访问令牌。</p>
<button class="btn btn-outline-secondary mt-3" id="back-btn-expired">
<i class="bi bi-arrow-left me-2"></i>返回
</button>
</div>
<div class="verification-footer" id="verification-footer" style="display: none;">
<p>教育 AI 助手平台 | <a href="/login.html">登录</a></p>
</div>
</div>
<script>
// 解析URL参数
function getUrlParams() {
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const pathParts = window.location.pathname.split('/');
return {
agentId: pathParts[pathParts.length - 1] || '',
token: urlParams.get('token') || ''
};
}
// 页面加载函数
document.addEventListener('DOMContentLoaded', async function() {
const { agentId, token } = getUrlParams();
if (!token) {
showExpiredState('未提供访问令牌');
return;
}
try {
// 验证令牌
const response = await fetch('/api/verify_token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
token: token,
agent_id: agentId
})
});
const result = await response.json();
if (result.success) {
// 显示Agent信息
showAgentInfo(result.agent);
} else {
showExpiredState(result.message);
}
} catch (error) {
console.error('验证出错:', error);
showExpiredState('验证过程中出错');
}
});
// 显示Agent信息
function showAgentInfo(agent) {
// 隐藏加载区域
document.getElementById('loading-container').style.display = 'none';
// 显示验证内容
document.getElementById('verification-header').style.display = 'block';
document.getElementById('agent-info').style.display = 'block';
document.getElementById('verification-actions').style.display = 'block';
document.getElementById('verification-footer').style.display = 'block';
// 填充Agent信息
const agentInfoElement = document.getElementById('agent-info');
// 构建主题和教师信息
let metaHtml = '<div class="agent-meta">';
if (agent.subject) {
metaHtml += `
<div class="agent-meta-item">
<i class="bi bi-book"></i>
${agent.subject}
</div>
`;
}
if (agent.instructor) {
metaHtml += `
<div class="agent-meta-item">
<i class="bi bi-person"></i>
${agent.instructor}
</div>
`;
}
metaHtml += '</div>';
agentInfoElement.innerHTML = `
<div class="agent-title">
<i class="bi bi-robot"></i>${agent.name}
</div>
<div class="agent-description">
${agent.description || '暂无描述'}
</div>
${metaHtml}
`;
// 设置按钮链接
document.getElementById('access-btn').addEventListener('click', function() {
const { token } = getUrlParams();
window.location.href = `/student/${agent.id}?token=${token}`;
});
document.getElementById('back-btn').addEventListener('click', function() {
// 检查是否从学生门户进入
const hasHistory = document.referrer.includes('student_portal.html');
if (hasHistory) {
window.history.back();
} else {
window.location.href = '/student_portal.html';
}
});
}
// 显示过期状态
function showExpiredState(message) {
// 隐藏加载区域
document.getElementById('loading-container').style.display = 'none';
// 显示过期内容
document.getElementById('expired-container').style.display = 'block';
document.getElementById('verification-footer').style.display = 'block';
// 更新过期消息
const expiredContainer = document.getElementById('expired-container');
expiredContainer.querySelector('p').textContent = message || '您使用的访问令牌无效或已过期,请联系教师获取新的访问令牌。';
// 设置返回按钮
document.getElementById('back-btn-expired').addEventListener('click', function() {
// 检查是否从学生门户进入
const hasHistory = document.referrer.includes('student_portal.html');
if (hasHistory) {
window.history.back();
} else {
window.location.href = '/login.html';
}
});
}
</script>
</body>
</html> |