fix: 修复后台登录API路径(改为/admin/api/login)

This commit is contained in:
2026-04-12 17:15:22 +08:00
parent 9e25623cf6
commit e6805d0b75

View File

@@ -18,7 +18,7 @@
<i class="ri-shield-keyhole-line text-3xl text-white"></i>
</div>
<h1 class="text-2xl font-bold text-gray-800">后台管理系统</h1>
<p class="text-gray-500 text-sm mt-2">请输入管理员账号登录</p>
<p class="text-gray-500 text-sm mt-2">管理员账号: admin / admin123</p>
</div>
<form id="loginForm" class="space-y-6">
@@ -26,7 +26,7 @@
<label class="block text-sm font-medium text-gray-700 mb-2">用户名</label>
<div class="relative">
<i class="ri-user-line absolute left-3 top-3 text-gray-400"></i>
<input type="text" id="username" name="username" required
<input type="text" id="username" name="username" required value="admin"
class="w-full pl-10 pr-4 py-2.5 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="请输入用户名">
</div>
@@ -36,7 +36,7 @@
<label class="block text-sm font-medium text-gray-700 mb-2">密码</label>
<div class="relative">
<i class="ri-lock-line absolute left-3 top-3 text-gray-400"></i>
<input type="password" id="password" name="password" required
<input type="password" id="password" name="password" required value="admin123"
class="w-full pl-10 pr-4 py-2.5 border border-gray-200 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"
placeholder="请输入密码">
</div>
@@ -63,10 +63,10 @@
// 检查是否已登录
async function checkAuth() {
try {
const res = await fetch('/api/check-auth');
const res = await fetch('/admin/api/check-auth');
const data = await res.json();
if (data.logged_in) {
window.location.href = '/';
window.location.href = '/admin';
}
} catch (e) {
// 未登录,继续显示登录页面
@@ -89,7 +89,7 @@
btn.innerHTML = '<i class="ri-loader-4-line animate-spin"></i> 登录中...';
try {
const res = await fetch('/api/login', {
const res = await fetch('/admin/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password })
@@ -113,6 +113,4 @@
});
</script>
</body>
</html>> </script>
</body>
</html>>
</html>