fix: 修复后台登录API路径(改为/admin/api/login)
This commit is contained in:
@@ -18,7 +18,7 @@
|
|||||||
<i class="ri-shield-keyhole-line text-3xl text-white"></i>
|
<i class="ri-shield-keyhole-line text-3xl text-white"></i>
|
||||||
</div>
|
</div>
|
||||||
<h1 class="text-2xl font-bold text-gray-800">后台管理系统</h1>
|
<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>
|
</div>
|
||||||
|
|
||||||
<form id="loginForm" class="space-y-6">
|
<form id="loginForm" class="space-y-6">
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
<label class="block text-sm font-medium text-gray-700 mb-2">用户名</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">用户名</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<i class="ri-user-line absolute left-3 top-3 text-gray-400"></i>
|
<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"
|
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="请输入用户名">
|
placeholder="请输入用户名">
|
||||||
</div>
|
</div>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<label class="block text-sm font-medium text-gray-700 mb-2">密码</label>
|
<label class="block text-sm font-medium text-gray-700 mb-2">密码</label>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<i class="ri-lock-line absolute left-3 top-3 text-gray-400"></i>
|
<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"
|
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="请输入密码">
|
placeholder="请输入密码">
|
||||||
</div>
|
</div>
|
||||||
@@ -63,10 +63,10 @@
|
|||||||
// 检查是否已登录
|
// 检查是否已登录
|
||||||
async function checkAuth() {
|
async function checkAuth() {
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/check-auth');
|
const res = await fetch('/admin/api/check-auth');
|
||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
if (data.logged_in) {
|
if (data.logged_in) {
|
||||||
window.location.href = '/';
|
window.location.href = '/admin';
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// 未登录,继续显示登录页面
|
// 未登录,继续显示登录页面
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
btn.innerHTML = '<i class="ri-loader-4-line animate-spin"></i> 登录中...';
|
btn.innerHTML = '<i class="ri-loader-4-line animate-spin"></i> 登录中...';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch('/api/login', {
|
const res = await fetch('/admin/api/login', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ username, password })
|
body: JSON.stringify({ username, password })
|
||||||
@@ -113,6 +113,4 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>> </script>
|
</html>
|
||||||
</body>
|
|
||||||
</html>>
|
|
||||||
Reference in New Issue
Block a user