- 使用 Flask context_processor 自动注入 site_config - 所有页面标题使用 site_name 配置 - 所有页面导航栏品牌使用 site_name 配置 - 所有页面底部使用 site_footer 配置 - 文件上传时使用 max_file_size 配置验证文件大小 - 显示最大文件限制提示
88 lines
3.0 KiB
HTML
88 lines
3.0 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>登录 - {{ site_config.site_name }}</title>
|
|
<link rel="icon" href="/static/img/favicon.svg" type="image/svg+xml">
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link href="/static/css/style.css" rel="stylesheet">
|
|
</head>
|
|
<body class="bg-light">
|
|
<nav class="navbar navbar-dark bg-primary">
|
|
<div class="container">
|
|
<a class="navbar-brand" href="/">📄 {{ site_config.site_name }}</a>
|
|
</div>
|
|
</nav>
|
|
|
|
<div class="auth-form">
|
|
<h3 class="text-center mb-4">登录</h3>
|
|
|
|
<form id="loginForm">
|
|
<div class="mb-3">
|
|
<label class="form-label">用户名</label>
|
|
<input type="text" class="form-control" id="username" name="username" required>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label">密码</label>
|
|
<input type="password" class="form-control" id="password" name="password" required>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary w-100">登录</button>
|
|
</form>
|
|
|
|
<hr>
|
|
|
|
<p class="text-center text-muted">
|
|
还没有账号? <a href="/register">立即注册</a>
|
|
</p>
|
|
|
|
<div class="alert alert-info mt-3">
|
|
<strong>注册福利:</strong>
|
|
<ul class="mb-0">
|
|
<li>每日翻译次数提升至10次</li>
|
|
<li>单文件最大50页</li>
|
|
<li>翻译历史记录</li>
|
|
<li>支持重新翻译</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.getElementById('loginForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const username = document.getElementById('username').value;
|
|
const password = document.getElementById('password').value;
|
|
|
|
try {
|
|
const response = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json'},
|
|
body: JSON.stringify({username, password})
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (!response.ok) {
|
|
throw new Error(result.error || '登录失败');
|
|
}
|
|
|
|
// 登录成功,跳转首页
|
|
window.location.href = '/';
|
|
|
|
} catch (error) {
|
|
alert('登录失败: ' + error.message);
|
|
}
|
|
});
|
|
</script>
|
|
|
|
<!-- 页脚 -->
|
|
<footer class="bg-light py-4 mt-5">
|
|
<div class="container text-center">
|
|
{{ site_config.site_footer | safe }}
|
|
</div>
|
|
</footer>
|
|
</body>
|
|
</html> |