new
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user