187 lines
5.6 KiB
HTML
187 lines
5.6 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>登录 - 职位信息爬虫工具</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 20px;
|
|
}
|
|
|
|
.login-container {
|
|
background: #fff;
|
|
border-radius: 10px;
|
|
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
|
padding: 40px;
|
|
width: 100%;
|
|
max-width: 400px;
|
|
}
|
|
|
|
h1 {
|
|
color: #333;
|
|
margin-bottom: 30px;
|
|
text-align: center;
|
|
font-size: 24px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.form-group label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
color: #333;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.form-group input {
|
|
width: 100%;
|
|
padding: 12px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 6px;
|
|
font-size: 14px;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
outline: none;
|
|
border-color: #667eea;
|
|
}
|
|
|
|
.btn {
|
|
width: 100%;
|
|
padding: 12px;
|
|
background: #667eea;
|
|
color: #fff;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
font-weight: 500;
|
|
transition: background 0.3s;
|
|
}
|
|
|
|
.btn:hover {
|
|
background: #5568d3;
|
|
}
|
|
|
|
.btn:disabled {
|
|
background: #ccc;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.message {
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
margin-bottom: 20px;
|
|
text-align: center;
|
|
}
|
|
|
|
.message.success {
|
|
background: #d4edda;
|
|
color: #155724;
|
|
border: 1px solid #c3e6cb;
|
|
}
|
|
|
|
.message.error {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
border: 1px solid #f5c6cb;
|
|
}
|
|
|
|
.message.info {
|
|
background: #d1ecf1;
|
|
color: #0c5460;
|
|
border: 1px solid #bee5eb;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<h1>职位信息爬虫工具</h1>
|
|
<div id="message"></div>
|
|
<form id="loginForm">
|
|
<div class="form-group">
|
|
<label for="username">用户名:</label>
|
|
<input type="text" id="username" name="username" required autofocus>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="password">密码:</label>
|
|
<input type="password" id="password" name="password" required>
|
|
</div>
|
|
<button type="submit" class="btn" id="loginBtn">登录</button>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
const API_BASE_URL = '';
|
|
|
|
document.getElementById('loginForm').addEventListener('submit', function(e) {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value.trim();
|
|
const password = document.getElementById('password').value.trim();
|
|
const loginBtn = document.getElementById('loginBtn');
|
|
|
|
if (!username || !password) {
|
|
showMessage('请输入用户名和密码', 'error');
|
|
return;
|
|
}
|
|
|
|
loginBtn.disabled = true;
|
|
loginBtn.textContent = '登录中...';
|
|
|
|
fetch(API_BASE_URL + '/auth/doLogin', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
body: `username=${encodeURIComponent(username)}&password=${encodeURIComponent(password)}`
|
|
})
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
if (data.code === 1) {
|
|
showMessage('登录成功,正在跳转...', 'success');
|
|
setTimeout(() => {
|
|
// 根据账号类型跳转到不同页面
|
|
if (data.data && data.data.is_admin) {
|
|
window.location.href = '/admin';
|
|
} else {
|
|
window.location.href = '/crawler';
|
|
}
|
|
}, 500);
|
|
} else {
|
|
showMessage(data.msg || '登录失败', 'error');
|
|
loginBtn.disabled = false;
|
|
loginBtn.textContent = '登录';
|
|
}
|
|
})
|
|
.catch(error => {
|
|
showMessage('请求失败: ' + error.message, 'error');
|
|
loginBtn.disabled = false;
|
|
loginBtn.textContent = '登录';
|
|
});
|
|
});
|
|
|
|
function showMessage(message, type) {
|
|
const messageDiv = document.getElementById('message');
|
|
messageDiv.innerHTML = `<div class="message ${type}">${message}</div>`;
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|