本轮实现功能: 1. 多用户隔离:每个用户独立 config.json + graph.db 2. TUI 登录页 + 旧版自动迁移(core/migrate.py) 3. Admin/User 角色体系(core/embedded_db.py) 4. Web 后台管理 API(userinfo + admin CRUD) 5. Web 设置页用户管理区(仅 admin 可见) 6. TUI 侧栏配置区权限同步(非 admin 隐藏 Web 服务设置) 7. Web 服务打包为独立二进制(trulymem-web) 8. 双入口 PyInstaller 构建脚本(TUI + Web) 9. 活动记录器(core/activity_recorder.py) 10. 静态页面模板(登录/设置/首次引导)
171 lines
7.3 KiB
HTML
171 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>首次设置 - TrulyMEM</title>
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: 'Courier New', monospace;
|
|
background: #0a0a1a;
|
|
color: #ffffff;
|
|
overflow: hidden;
|
|
width: 100vw; height: 100vh;
|
|
display: flex; align-items: center; justify-content: center;
|
|
position: relative;
|
|
}
|
|
body::before {
|
|
content: '';
|
|
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
|
|
background:
|
|
radial-gradient(2px 2px at 20px 30px, #eee, transparent),
|
|
radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
|
|
radial-gradient(1px 1px at 90px 40px, #fff, transparent),
|
|
radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
|
|
radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
|
|
background-repeat: repeat;
|
|
background-size: 200px 100px;
|
|
animation: twinkle 5s ease-in-out infinite alternate;
|
|
z-index: 0;
|
|
}
|
|
@keyframes twinkle { 0% { opacity: 0.5; } 100% { opacity: 1; } }
|
|
.setup-container {
|
|
position: relative; z-index: 1; width: 420px; padding: 40px;
|
|
background: rgba(10, 10, 26, 0.9);
|
|
border-radius: 12px;
|
|
border: 1px solid rgba(100, 100, 255, 0.3);
|
|
box-shadow: 0 0 20px rgba(68, 136, 255, 0.2), 0 0 60px rgba(68, 136, 255, 0.1), inset 0 0 20px rgba(68, 136, 255, 0.05);
|
|
backdrop-filter: blur(10px);
|
|
}
|
|
.setup-title {
|
|
text-align: center; font-size: 26px; margin-bottom: 8px;
|
|
color: #4488ff; text-shadow: 0 0 10px rgba(68, 136, 255, 0.5);
|
|
letter-spacing: 2px;
|
|
}
|
|
.setup-subtitle {
|
|
text-align: center; font-size: 14px; color: #8888aa; margin-bottom: 8px;
|
|
}
|
|
.setup-hint {
|
|
text-align: center; font-size: 12px; color: #666688; margin-bottom: 25px;
|
|
}
|
|
.form-group { margin-bottom: 18px; }
|
|
.form-group label { display: block; margin-bottom: 6px; color: #aaaacc; font-size: 14px; }
|
|
.form-group input {
|
|
width: 100%; padding: 12px 16px;
|
|
background: rgba(20, 20, 40, 0.8);
|
|
border: 1px solid rgba(100, 100, 255, 0.3);
|
|
border-radius: 6px; color: #ffffff;
|
|
font-family: 'Courier New', monospace; font-size: 14px;
|
|
transition: all 0.3s;
|
|
}
|
|
.form-group input:focus {
|
|
outline: none; border-color: #4488ff; box-shadow: 0 0 10px rgba(68, 136, 255, 0.3);
|
|
}
|
|
.form-group input::placeholder { color: #555577; }
|
|
.setup-btn {
|
|
width: 100%; padding: 14px;
|
|
background: linear-gradient(135deg, rgba(68, 136, 255, 0.3), rgba(68, 136, 255, 0.1));
|
|
border: 1px solid rgba(68, 136, 255, 0.5);
|
|
border-radius: 6px; color: #ffffff;
|
|
font-family: 'Courier New', monospace; font-size: 16px;
|
|
cursor: pointer; transition: all 0.3s;
|
|
letter-spacing: 1px; margin-top: 5px;
|
|
}
|
|
.setup-btn:hover {
|
|
background: linear-gradient(135deg, rgba(68, 136, 255, 0.5), rgba(68, 136, 255, 0.3));
|
|
box-shadow: 0 0 15px rgba(68, 136, 255, 0.4);
|
|
}
|
|
.setup-btn:disabled { opacity: 0.6; cursor: not-allowed; }
|
|
.setup-btn .spinner {
|
|
display: none; width: 16px; height: 16px;
|
|
border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff;
|
|
border-radius: 50%; animation: spin 0.6s linear infinite;
|
|
position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
|
|
}
|
|
.setup-btn.loading .spinner { display: block; }
|
|
.setup-btn.loading span { visibility: hidden; }
|
|
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
|
|
.error-message {
|
|
display: none; margin-top: 12px; padding: 10px;
|
|
background: rgba(255, 68, 68, 0.15);
|
|
border: 1px solid rgba(255, 68, 68, 0.4);
|
|
border-radius: 6px; color: #ff6b6b; font-size: 13px; text-align: center;
|
|
}
|
|
.error-message.show { display: block; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="setup-container">
|
|
<h1 class="setup-title">🚀 首次设置</h1>
|
|
<p class="setup-subtitle">TrulyMEM Web 管理界面</p>
|
|
<p class="setup-hint">创建管理员账户,用于登录 Web 管理界面</p>
|
|
|
|
<form id="setupForm">
|
|
<div class="form-group">
|
|
<label for="username">用户名</label>
|
|
<input type="text" id="username" name="username" placeholder="设置管理员用户名" required>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">密码</label>
|
|
<input type="password" id="password" name="password" placeholder="至少 6 位密码" required minlength="6">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="confirm">确认密码</label>
|
|
<input type="password" id="confirm" name="confirm_password" placeholder="再次输入密码" required>
|
|
</div>
|
|
<button type="submit" class="setup-btn" id="setupBtn">
|
|
<span>创 建 账 户</span>
|
|
<div class="spinner"></div>
|
|
</button>
|
|
</form>
|
|
|
|
<div class="error-message" id="errorMsg"></div>
|
|
</div>
|
|
|
|
<script>
|
|
const setupForm = document.getElementById('setupForm');
|
|
const setupBtn = document.getElementById('setupBtn');
|
|
const errorMsg = document.getElementById('errorMsg');
|
|
|
|
setupForm.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
const confirm = document.getElementById('confirm').value;
|
|
|
|
if (password !== confirm) {
|
|
errorMsg.textContent = '两次密码输入不一致';
|
|
errorMsg.classList.add('show');
|
|
return;
|
|
}
|
|
|
|
errorMsg.classList.remove('show');
|
|
setupBtn.classList.add('loading');
|
|
setupBtn.disabled = true;
|
|
|
|
try {
|
|
const resp = await fetch('/api/setup', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, password, confirm_password: confirm })
|
|
});
|
|
const data = await resp.json();
|
|
if (data.success) {
|
|
window.location.href = '/graph.html';
|
|
} else {
|
|
errorMsg.textContent = data.error || '创建失败';
|
|
errorMsg.classList.add('show');
|
|
}
|
|
} catch (err) {
|
|
errorMsg.textContent = '网络错误,请重试';
|
|
errorMsg.classList.add('show');
|
|
} finally {
|
|
setupBtn.classList.remove('loading');
|
|
setupBtn.disabled = false;
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|