Files
aitsc/src/flask_prompt_master/templates/base.html

322 lines
10 KiB
HTML
Raw Normal View History

2025-02-23 09:07:52 +08:00
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>提示词大师 - {% block title %}{% endblock %}</title>
<!-- 添加 Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
2025-08-29 00:34:40 +08:00
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Bootstrap JS -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
2025-02-23 09:07:52 +08:00
<style>
/* 全局样式 */
:root {
--primary-color: #2196f3;
--primary-dark: #1976d2;
--secondary-color: #6c757d;
--success-color: #28a745;
--background-color: #f8f9fa;
--border-color: #e0e0e0;
--text-color: #2c3e50;
--text-light: #666;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
line-height: 1.5;
color: var(--text-color);
background-color: var(--background-color);
}
/* 导航栏样式 */
header {
background: white;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
position: sticky;
top: 0;
z-index: 100;
}
nav {
max-width: 1200px;
margin: 0 auto;
padding: 1rem;
display: flex;
justify-content: space-between;
align-items: center;
}
.nav-brand {
font-size: 1.25rem;
font-weight: 600;
color: var(--primary-color);
text-decoration: none;
display: flex;
align-items: center;
gap: 0.5rem;
}
.nav-brand i {
font-size: 1.5rem;
}
2025-08-29 00:34:40 +08:00
.nav-links {
display: flex;
gap: 1rem;
align-items: center;
}
.nav-link {
color: var(--text-color);
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 4px;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 0.5rem;
}
.nav-link:hover {
background: var(--background-color);
color: var(--primary-color);
}
.nav-link i {
font-size: 1rem;
}
.user-menu {
display: flex;
align-items: center;
}
.user-menu .dropdown-toggle {
color: var(--text-color);
text-decoration: none;
padding: 0.5rem 1rem;
border-radius: 4px;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 0.5rem;
}
.user-menu .dropdown-toggle:hover {
background: var(--background-color);
color: var(--primary-color);
}
.user-menu .dropdown-menu {
min-width: 200px;
}
2025-02-23 09:07:52 +08:00
/* 主要内容区域 */
main {
min-height: calc(100vh - 120px);
}
/* 闪现消息样式 */
.flash-messages {
position: fixed;
top: 1rem;
right: 1rem;
z-index: 1000;
}
.flash-message {
background: white;
padding: 1rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
margin-bottom: 0.5rem;
animation: slideIn 0.3s ease-out;
}
@keyframes slideIn {
from {
transform: translateX(100%);
opacity: 0;
}
to {
transform: translateX(0);
opacity: 1;
}
}
/* 页脚样式 */
footer {
background: white;
padding: 2rem 1rem;
text-align: center;
color: var(--text-light);
margin-top: 3rem;
}
/* 响应式设计 */
@media (max-width: 768px) {
nav {
padding: 1rem;
}
}
</style>
{% block extra_css %}{% endblock %}
2025-08-29 00:34:40 +08:00
<script>
// 检查登录状态并更新用户菜单
function updateUserMenu() {
fetch('/api/check-login')
.then(response => response.json())
.then(data => {
const userMenu = document.getElementById('userMenu');
if (data.logged_in) {
userMenu.innerHTML = `
<div class="dropdown">
<a class="dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown">
<i class="fas fa-user"></i>
${data.user.nickname}
</a>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="/profile">个人资料</a></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#" onclick="logout()">退出登录</a></li>
</ul>
</div>
`;
} else {
userMenu.innerHTML = `
<a href="/login" class="nav-link">
<i class="fas fa-sign-in-alt"></i>
登录
</a>
<a href="/register" class="nav-link">
<i class="fas fa-user-plus"></i>
注册
</a>
`;
}
})
.catch(error => {
console.error('检查登录状态失败:', error);
});
}
function logout() {
fetch('/api/logout', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
alert('退出登录成功');
window.location.reload();
} else {
alert(data.message || '退出登录失败');
}
})
.catch(error => {
console.error('退出登录失败:', error);
alert('退出登录失败,请稍后重试');
});
}
// 页面加载时更新用户菜单
document.addEventListener('DOMContentLoaded', function() {
updateUserMenu();
});
</script>
2025-02-23 09:07:52 +08:00
</head>
<body>
<header>
<nav>
<a href="{{ url_for('main.index') }}" class="nav-brand">
<i class="fas fa-magic"></i>
提示词大师
</a>
2025-08-29 00:34:40 +08:00
<div class="nav-links">
<a href="{{ url_for('main.index') }}" class="nav-link">
<i class="fas fa-plus"></i>
生成提示词
</a>
2025-09-08 08:07:04 +08:00
<a href="{{ url_for('meal_planning.meal_planning_page') }}" class="nav-link">
<i class="fas fa-utensils"></i>
饭菜规划
</a>
2025-09-19 00:14:29 +08:00
<a href="{{ url_for('poetry.poetry_page') }}" class="nav-link">
<i class="fas fa-scroll"></i>
古诗词解析
</a>
<a href="{{ url_for('poetry.poetry_favorites') }}" class="nav-link">
<i class="fas fa-heart"></i>
古诗词收藏
</a>
2025-09-08 08:07:04 +08:00
<a href="{{ url_for('meal_planning.meal_planning_history') }}" class="nav-link">
<i class="fas fa-history"></i>
我的规划
</a>
2025-08-29 00:34:40 +08:00
<a href="{{ url_for('favorites.favorites_page') }}" class="nav-link">
<i class="fas fa-heart"></i>
我的收藏
</a>
2025-08-29 20:32:52 +08:00
<a href="{{ url_for('auth.profile_page') }}" class="nav-link">
<i class="fas fa-user"></i>
个人资料
</a>
2025-08-29 00:34:40 +08:00
<div class="user-menu" id="userMenu">
<!-- 用户菜单将通过JavaScript动态加载 -->
</div>
</div>
2025-02-23 09:07:52 +08:00
</nav>
</header>
<main>
{% with messages = get_flashed_messages() %}
{% if messages %}
<div class="flash-messages">
{% for message in messages %}
<div class="flash-message">{{ message }}</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</main>
<footer>
<p>&copy; 2025 提示词大师 - 让AI更好地理解您的需求</p>
</footer>
2025-08-29 00:34:40 +08:00
{% block scripts %}{% endblock %}
2025-02-23 09:07:52 +08:00
{% block extra_js %}{% endblock %}
<script>
// 自动隐藏闪现消息
document.addEventListener('DOMContentLoaded', function() {
const messages = document.querySelectorAll('.flash-message');
messages.forEach(message => {
setTimeout(() => {
message.style.opacity = '0';
message.style.transform = 'translateX(100%)';
setTimeout(() => message.remove(), 300);
}, 3000);
});
});
</script>
</body>
</html>