This commit is contained in:
jeremygan2021
2026-03-20 16:18:58 +08:00
parent 3bdb055b83
commit 7caff4d72d
6 changed files with 312 additions and 31 deletions

View File

@@ -329,6 +329,27 @@
</button>
</a>
</div>
<div class="card" style="padding: 20px;">
<h2 style="margin-bottom: 15px;">快捷导航</h2>
<div style="display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;">
<a href="/add-user" style="text-decoration: none;">
<button style="background: linear-gradient(90deg, #28a745 0%, #20c997 100%);">
添加嘉宾
</button>
</a>
<a href="/edit" style="text-decoration: none;">
<button style="background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%);">
✏️ 编辑信息
</button>
</a>
<a href="/data-base" style="text-decoration: none;">
<button style="background: linear-gradient(90deg, #17a2b8 0%, #138496 100%);">
🗄️ 数据库管理
</button>
</a>
</div>
</div>
<div class="card">
<h2>基本信息设置</h2>
@@ -603,26 +624,61 @@
header.parentElement.classList.toggle('collapsed');
});
});
checkAuthStatus();
});
// Use secret from backend
const ACCESS_SECRET = "{{ secret }}";
async function checkAuthStatus() {
try {
const res = await fetch('/api/admin/check-auth');
const data = await res.json();
if (data.authenticated) {
hideOverlay();
} else {
showOverlay();
}
} catch (e) {
showOverlay();
}
}
// Password Check Logic
function checkSecret() {
function showOverlay() {
document.getElementById('password-overlay').style.display = 'flex';
}
function hideOverlay() {
const overlay = document.getElementById('password-overlay');
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
}
async function checkSecret() {
const input = document.getElementById('secret-input');
const error = document.getElementById('secret-error');
const overlay = document.getElementById('password-overlay');
const password = input.value;
if (input.value === ACCESS_SECRET) {
overlay.style.opacity = '0';
setTimeout(() => {
overlay.style.display = 'none';
}, 500);
} else {
try {
const res = await fetch('/api/admin/login', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({password: password})
});
const data = await res.json();
if (data.success) {
error.style.display = 'none';
hideOverlay();
} else {
error.style.display = 'block';
input.value = '';
input.focus();
}
} catch (e) {
error.textContent = '网络错误';
error.style.display = 'block';
input.value = '';
input.focus();
}
}