293 lines
7.3 KiB
HTML
293 lines
7.3 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>邮箱验证 - 玩玩云</title>
|
||
<link rel="stylesheet" href="libs/fontawesome/css/all.min.css">
|
||
<style>
|
||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||
|
||
/* 暗色主题(默认) */
|
||
:root {
|
||
--bg-primary: #0a0a0f;
|
||
--bg-secondary: #12121a;
|
||
--bg-card: rgba(255, 255, 255, 0.03);
|
||
--glass-border: rgba(255, 255, 255, 0.08);
|
||
--text-primary: #ffffff;
|
||
--text-secondary: rgba(255, 255, 255, 0.6);
|
||
--accent-1: #667eea;
|
||
--accent-2: #764ba2;
|
||
--glow: rgba(102, 126, 234, 0.4);
|
||
}
|
||
|
||
/* 亮色主题 */
|
||
.light-theme {
|
||
--bg-primary: #f0f4f8;
|
||
--bg-secondary: #ffffff;
|
||
--bg-card: rgba(255, 255, 255, 0.8);
|
||
--glass-border: rgba(102, 126, 234, 0.15);
|
||
--text-primary: #1a1a2e;
|
||
--text-secondary: rgba(26, 26, 46, 0.7);
|
||
--accent-1: #5a67d8;
|
||
--accent-2: #6b46c1;
|
||
--glow: rgba(90, 103, 216, 0.3);
|
||
}
|
||
|
||
body {
|
||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
||
background: var(--bg-primary);
|
||
color: var(--text-primary);
|
||
min-height: 100vh;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
padding: 20px;
|
||
}
|
||
|
||
/* 动态背景 */
|
||
body::before {
|
||
content: '';
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
z-index: -1;
|
||
background:
|
||
radial-gradient(ellipse at top right, rgba(102, 126, 234, 0.15) 0%, transparent 50%),
|
||
radial-gradient(ellipse at bottom left, rgba(118, 75, 162, 0.15) 0%, transparent 50%),
|
||
var(--bg-primary);
|
||
}
|
||
|
||
body.light-theme::before {
|
||
background:
|
||
radial-gradient(ellipse at top right, rgba(102, 126, 234, 0.12) 0%, transparent 50%),
|
||
radial-gradient(ellipse at bottom left, rgba(118, 75, 162, 0.12) 0%, transparent 50%),
|
||
linear-gradient(135deg, #e0e7ff 0%, #f0f4f8 50%, #fdf2f8 100%);
|
||
}
|
||
|
||
.container {
|
||
max-width: 450px;
|
||
width: 100%;
|
||
}
|
||
|
||
.card {
|
||
background: var(--bg-card);
|
||
backdrop-filter: blur(20px);
|
||
border: 1px solid var(--glass-border);
|
||
border-radius: 20px;
|
||
padding: 40px;
|
||
text-align: center;
|
||
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
||
}
|
||
|
||
body.light-theme .card {
|
||
background: rgba(255, 255, 255, 0.8);
|
||
box-shadow: 0 8px 32px rgba(102, 126, 234, 0.1);
|
||
}
|
||
|
||
.logo {
|
||
font-size: 48px;
|
||
margin-bottom: 20px;
|
||
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
|
||
-webkit-background-clip: text;
|
||
-webkit-text-fill-color: transparent;
|
||
}
|
||
|
||
.title {
|
||
font-size: 24px;
|
||
font-weight: 700;
|
||
margin-bottom: 10px;
|
||
color: var(--text-primary);
|
||
}
|
||
|
||
.subtitle {
|
||
color: var(--text-secondary);
|
||
margin-bottom: 30px;
|
||
font-size: 14px;
|
||
}
|
||
|
||
.status-icon {
|
||
font-size: 64px;
|
||
margin-bottom: 20px;
|
||
}
|
||
|
||
.status-icon.loading {
|
||
color: var(--accent-1);
|
||
animation: spin 1s linear infinite;
|
||
}
|
||
|
||
.status-icon.success {
|
||
color: #10b981;
|
||
}
|
||
|
||
.status-icon.error {
|
||
color: #ef4444;
|
||
}
|
||
|
||
@keyframes spin {
|
||
from { transform: rotate(0deg); }
|
||
to { transform: rotate(360deg); }
|
||
}
|
||
|
||
.message {
|
||
font-size: 16px;
|
||
margin-bottom: 30px;
|
||
line-height: 1.6;
|
||
}
|
||
|
||
.btn {
|
||
display: inline-flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
gap: 8px;
|
||
padding: 14px 32px;
|
||
border-radius: 12px;
|
||
font-size: 15px;
|
||
font-weight: 600;
|
||
cursor: pointer;
|
||
transition: all 0.3s;
|
||
text-decoration: none;
|
||
border: none;
|
||
}
|
||
|
||
.btn-primary {
|
||
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
|
||
color: white;
|
||
box-shadow: 0 4px 15px var(--glow);
|
||
}
|
||
|
||
.btn-primary:hover {
|
||
transform: translateY(-2px);
|
||
box-shadow: 0 8px 25px var(--glow);
|
||
}
|
||
|
||
.footer {
|
||
margin-top: 20px;
|
||
color: var(--text-secondary);
|
||
font-size: 13px;
|
||
}
|
||
|
||
.footer a {
|
||
color: var(--accent-1);
|
||
text-decoration: none;
|
||
}
|
||
|
||
.footer a:hover {
|
||
text-decoration: underline;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<div class="card">
|
||
<div class="logo">
|
||
<i class="fas fa-cloud"></i>
|
||
</div>
|
||
<h1 class="title">邮箱验证</h1>
|
||
<p class="subtitle">玩玩云账号激活</p>
|
||
|
||
<div id="content">
|
||
<div class="status-icon loading">
|
||
<i class="fas fa-spinner"></i>
|
||
</div>
|
||
<p class="message">正在验证您的邮箱...</p>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="footer">
|
||
<a href="index.html"><i class="fas fa-arrow-left"></i> 返回首页</a>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
// 加载全局主题
|
||
async function loadTheme() {
|
||
try {
|
||
const res = await fetch('/api/public/theme');
|
||
const data = await res.json();
|
||
if (data.success && data.theme === 'light') {
|
||
document.body.classList.add('light-theme');
|
||
}
|
||
} catch (e) {
|
||
console.warn('[主题加载] 失败,使用默认主题:', e.message);
|
||
}
|
||
}
|
||
|
||
// 获取URL参数
|
||
function getParam(name) {
|
||
const url = new URL(window.location.href);
|
||
return url.searchParams.get(name);
|
||
}
|
||
|
||
// HTML 转义函数(防御 XSS)
|
||
function escapeHtml(text) {
|
||
const div = document.createElement('div');
|
||
div.textContent = text;
|
||
return div.innerHTML;
|
||
}
|
||
|
||
// 显示结果
|
||
function showResult(success, message, showButton = true) {
|
||
const content = document.getElementById('content');
|
||
const iconClass = success ? 'success' : 'error';
|
||
const iconName = success ? 'fa-check-circle' : 'fa-times-circle';
|
||
|
||
// 转义用户消息(但允许安全的 HTML 标签如 <br>)
|
||
const safeMessage = message.replace(/</g, '<').replace(/>/g, '>')
|
||
.replace(/<br>/g, '<br>'); // 允许 <br> 标签
|
||
|
||
let html = `
|
||
<div class="status-icon ${iconClass}">
|
||
<i class="fas ${iconName}"></i>
|
||
</div>
|
||
<p class="message">${safeMessage}</p>
|
||
`;
|
||
|
||
if (showButton) {
|
||
html += `
|
||
<a href="app.html" class="btn btn-primary">
|
||
<i class="fas fa-right-to-bracket"></i> 前往登录
|
||
</a>
|
||
`;
|
||
}
|
||
|
||
content.innerHTML = html;
|
||
}
|
||
|
||
// 验证邮箱
|
||
async function verifyEmail() {
|
||
const token = getParam('verifyToken') || getParam('token');
|
||
|
||
if (!token) {
|
||
showResult(false, '无效的验证链接,缺少验证令牌');
|
||
return;
|
||
}
|
||
|
||
try {
|
||
const res = await fetch('/api/auth/verify-email', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ token })
|
||
});
|
||
|
||
const data = await res.json();
|
||
|
||
if (data.success) {
|
||
showResult(true, '邮箱验证成功!<br>您的账号已激活,现在可以登录了。');
|
||
} else {
|
||
showResult(false, data.message || '验证失败,请重试或联系管理员');
|
||
}
|
||
} catch (error) {
|
||
showResult(false, '网络错误,请检查网络连接后重试');
|
||
}
|
||
}
|
||
|
||
// 初始化
|
||
loadTheme();
|
||
verifyEmail();
|
||
</script>
|
||
</body>
|
||
</html>
|