Files
ai_baijiahao/templates/login.html

383 lines
12 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>登录 - 百家号文章导出工具</title>
<!-- Bootstrap Icons - 使用本地CSS + CDN字体 -->
<link rel="stylesheet" href="/static/css/icons-local.css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary-color: #0052D9;
--primary-hover: #003DA6;
--bg-gradient-start: #f5f7fa;
--bg-gradient-end: #e8eef5;
--card-bg: #ffffff;
--text-primary: #1f2937;
--text-secondary: #6b7280;
--border-color: #e5e7eb;
--success-color: #10b981;
--error-color: #ef4444;
--shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 20px;
}
.login-container {
width: 100%;
max-width: 420px;
}
.login-card {
background: var(--card-bg);
border-radius: 16px;
box-shadow: var(--shadow);
padding: 40px;
animation: fadeInUp 0.5s ease-out;
}
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.login-header {
text-align: center;
margin-bottom: 32px;
}
.login-icon {
width: 64px;
height: 64px;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin: 0 auto 16px;
font-size: 32px;
color: white;
}
.login-title {
font-size: 24px;
font-weight: 600;
color: var(--text-primary);
margin-bottom: 8px;
}
.login-subtitle {
font-size: 14px;
color: var(--text-secondary);
}
.form-group {
margin-bottom: 20px;
}
.form-label {
display: block;
font-size: 14px;
font-weight: 500;
color: var(--text-primary);
margin-bottom: 8px;
}
.input-wrapper {
position: relative;
}
.input-icon {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
color: var(--text-secondary);
font-size: 18px;
}
.form-input {
width: 100%;
padding: 12px 12px 12px 40px;
font-size: 14px;
border: 1px solid var(--border-color);
border-radius: 8px;
outline: none;
transition: all 0.3s;
}
.form-input:focus {
border-color: var(--primary-color);
box-shadow: 0 0 0 3px rgba(0, 82, 217, 0.1);
}
.btn-login {
width: 100%;
padding: 14px;
font-size: 16px;
font-weight: 500;
color: white;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
border: none;
border-radius: 8px;
cursor: pointer;
transition: all 0.3s;
margin-top: 24px;
}
.btn-login:hover {
transform: translateY(-2px);
box-shadow: 0 10px 15px -3px rgba(0, 82, 217, 0.3);
}
.btn-login:active {
transform: translateY(0);
}
.btn-login:disabled {
opacity: 0.6;
cursor: not-allowed;
transform: none;
}
.alert {
padding: 12px 16px;
border-radius: 8px;
font-size: 14px;
margin-bottom: 20px;
display: none;
animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.alert-success {
background: #d1fae5;
color: #065f46;
border: 1px solid #6ee7b7;
}
.alert-error {
background: #fee2e2;
color: #991b1b;
border: 1px solid #fca5a5;
}
.divider {
text-align: center;
margin: 24px 0;
position: relative;
}
.divider::before {
content: '';
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 1px;
background: var(--border-color);
}
.divider-text {
display: inline-block;
background: var(--card-bg);
padding: 0 16px;
color: var(--text-secondary);
font-size: 14px;
position: relative;
}
.info-box {
background: #eff6ff;
border: 1px solid #bfdbfe;
border-radius: 8px;
padding: 12px 16px;
margin-top: 20px;
}
.info-box p {
margin: 4px 0;
font-size: 13px;
color: #1e40af;
}
.info-box strong {
font-weight: 600;
}
.footer {
text-align: center;
margin-top: 24px;
color: var(--text-secondary);
font-size: 14px;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-card">
<div class="login-header">
<div class="login-icon">
<i class="bi bi-shield-lock-fill"></i>
</div>
<h1 class="login-title">欢迎登录</h1>
<p class="login-subtitle">百家号文章导出工具</p>
</div>
<div id="alertBox" class="alert"></div>
<form id="loginForm">
<div class="form-group">
<label class="form-label">用户名</label>
<div class="input-wrapper">
<i class="bi bi-person-fill input-icon"></i>
<input
type="text"
id="username"
class="form-input"
placeholder="请输入用户名"
autocomplete="username"
required
>
</div>
</div>
<div class="form-group">
<label class="form-label">密码</label>
<div class="input-wrapper">
<i class="bi bi-key-fill input-icon"></i>
<input
type="password"
id="password"
class="form-input"
placeholder="请输入密码"
autocomplete="current-password"
required
>
</div>
</div>
<button type="submit" id="loginBtn" class="btn-login">
<i class="bi bi-box-arrow-in-right"></i>
登录
</button>
</form>
</div>
<div class="footer">
<p>© 2025 百家号文章导出工具 | 仅供学习交流使用</p>
</div>
</div>
<script src="/static/js/jquery.min.js"></script>
<script>
// 检查jQuery是否加载
if (typeof jQuery === 'undefined') {
console.error('jQuery未加载请检查网络连接');
alert('jQuery加载失败请刷新页面或检查网络连接');
} else {
$(document).ready(function() {
// 登录表单提交
$('#loginForm').submit(function(e) {
e.preventDefault();
const username = $('#username').val().trim();
const password = $('#password').val().trim();
if (!username || !password) {
showAlert('请输入用户名和密码', 'error');
return;
}
// 禁用按钮
$('#loginBtn').prop('disabled', true).html('<i class="bi bi-hourglass-split"></i> 登录中...');
// 发送登录请求
$.ajax({
url: '/api/login',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({
username: username,
password: password
}),
success: function(response) {
if (response.success) {
showAlert('登录成功,正在跳转...', 'success');
setTimeout(function() {
window.location.href = '/';
}, 1000);
} else {
showAlert(response.message || '登录失败', 'error');
$('#loginBtn').prop('disabled', false).html('<i class="bi bi-box-arrow-in-right"></i> 登录');
}
},
error: function(xhr, status, error) {
let errorMessage = '登录失败,请稍后重试';
if (xhr.responseJSON && xhr.responseJSON.message) {
errorMessage = xhr.responseJSON.message;
}
showAlert(errorMessage, 'error');
$('#loginBtn').prop('disabled', false).html('<i class="bi bi-box-arrow-in-right"></i> 登录');
}
});
});
// 显示提示信息
function showAlert(message, type) {
const alertBox = $('#alertBox');
alertBox.removeClass('alert-success alert-error');
alertBox.addClass('alert-' + type);
alertBox.text(message);
alertBox.show();
// 3秒后自动隐藏
if (type === 'error') {
setTimeout(function() {
alertBox.fadeOut();
}, 3000);
}
}
// 回车登录
$('#username, #password').keypress(function(e) {
if (e.which === 13) {
$('#loginForm').submit();
}
});
});
}
</script>
</body>
</html>