Files
EXAM-MASTER/templates/base.html
Echo-Whale f856c310a6 feat: 增强题目处理和用户界面,优化用户体验
- 增加题库管理功能,可以导入管理、切换使用多个题库
- 更新题目页面,添加答题进度条和题目类型标识
- 实现题目答案的动态验证,确保用户输入有效
- 优化移动端导航菜单,增加分组和标题,提升可用性
- 更新统计页面,显示当前题库信息和题目总数
- 改进样式,增强视觉效果和响应式设计

这些改进旨在提升用户在答题过程中的体验和操作便捷性。
2025-06-15 14:58:56 +08:00

364 lines
16 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>{% block title %}ExamMaster{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
<!-- Font Awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<!-- Favicon -->
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📚</text></svg>">
<!-- 额外样式 -->
{% block styles %}{% endblock %}
</head>
<body>
<!-- 导航栏 -->
<nav>
<div class="nav-left">
<a href="{{ url_for('index') }}" class="nav-logo">
<i class="fas fa-book-open"></i> ExamMaster
</a>
</div>
<!-- 移动端菜单按钮 -->
<button class="menu-toggle" id="menuToggle">
<i class="fas fa-bars"></i>
</button>
<!-- 导航链接 -->
<div class="nav-links" id="navLinks">
<!-- 移动端菜单标题 -->
<div class="mobile-menu-header">
<h3 class="mobile-menu-title">
<i class="fas fa-compass"></i>
导航菜单
</h3>
</div>
<!-- 答题功能组 -->
<div class="mobile-menu-group">
<div class="mobile-menu-group-label">
<i class="fas fa-play-circle"></i>
答题练习
</div>
</div>
<a href="{{ url_for('sequential_start') }}" class="nav-link{% if request.path == url_for('sequential_start') %} active{% endif %}">
<i class="fas fa-list-ol"></i> 顺序答题
</a>
<a href="{{ url_for('random_question') }}" class="nav-link{% if request.path == url_for('random_question') %} active{% endif %}">
<i class="fas fa-random"></i> 随机答题
</a>
<!-- 搜索功能组 -->
<div class="mobile-menu-group">
<div class="mobile-menu-group-label">
<i class="fas fa-search"></i>
题目查找
</div>
</div>
<a href="{{ url_for('search') }}" class="nav-link{% if request.path == url_for('search') %} active{% endif %}">
<i class="fas fa-search"></i> 搜索题目
</a>
<a href="{{ url_for('filter_questions') }}" class="nav-link{% if request.path == url_for('filter_questions') %} active{% endif %}">
<i class="fas fa-filter"></i> 筛选题目
</a>
<!-- 个人功能组 -->
<div class="mobile-menu-group">
<div class="mobile-menu-group-label">
<i class="fas fa-user"></i>
个人中心
</div>
</div>
<a href="{{ url_for('wrong_questions') }}" class="nav-link{% if request.path == url_for('wrong_questions') %} active{% endif %}">
<i class="fas fa-times-circle"></i> 错题本
</a>
<a href="{{ url_for('show_favorites') }}" class="nav-link{% if request.path == url_for('show_favorites') %} active{% endif %}">
<i class="fas fa-star"></i> 我的收藏
</a>
<a href="{{ url_for('show_history') }}" class="nav-link{% if request.path == url_for('show_history') %} active{% endif %}">
<i class="fas fa-history"></i> 答题历史
</a>
<!-- 管理功能组 -->
<div class="mobile-menu-group">
<div class="mobile-menu-group-label">
<i class="fas fa-cog"></i>
系统管理
</div>
</div>
<a href="{{ url_for('question_bank_list') }}" class="nav-link{% if request.path == url_for('question_bank_list') %} active{% endif %}">
<i class="fas fa-database"></i> 题库管理
</a>
<a href="{{ url_for('statistics') }}" class="nav-link{% if request.path == url_for('statistics') %} active{% endif %}">
<i class="fas fa-chart-bar"></i> 统计分析
</a>
</div>
<!-- 用户操作 -->
<div class="nav-right">
<!-- 移除退出按钮,已移到错题练习页面下方 -->
</div>
</nav>
<!-- Flash消息 -->
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="container">
{% for category, message in messages %}
<div class="alert {% if category == 'error' %}alert-danger{% elif category == 'success' %}alert-success{% else %}alert-info{% endif %}">
{% if category == 'error' %}
<i class="fas fa-exclamation-circle"></i>
{% elif category == 'success' %}
<i class="fas fa-check-circle"></i>
{% else %}
<i class="fas fa-info-circle"></i>
{% endif %}
{{ message }}
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
<!-- 主要内容 -->
<main class="container">
{% block content %}{% endblock %}
</main>
<!-- 页脚 -->
<footer class="footer">
<div class="container">
<p class="footer-text">
&copy; {{ current_year|default(2023) }} ExamMaster |
<a href="https://github.com/CiE-XinYuChen/EXAM-MASTER" class="footer-link" target="_blank">
<i class="fab fa-github"></i> GitHub
</a> |
<a href="mailto:xinyu-c@outlook.com" class="footer-link">
<i class="fas fa-envelope"></i> 联系我们
</a>
</p>
<p class="footer-text mt-1">
<a href="https://beian.miit.gov.cn/" target="_blank" class="footer-link">吉ICP备2023007431h号-2</a>
</p>
</div>
</footer>
<!-- JavaScript -->
<script>
// 移动端菜单切换和优化
document.addEventListener('DOMContentLoaded', function() {
const menuToggle = document.getElementById('menuToggle');
const navLinks = document.getElementById('navLinks');
const navLinksItems = document.querySelectorAll('.nav-link');
const body = document.body;
// 移动端菜单切换
if (menuToggle && navLinks) {
menuToggle.addEventListener('click', function(e) {
e.stopPropagation();
toggleMenu();
});
// 点击菜单项关闭菜单(仅在移动端)
navLinksItems.forEach(item => {
item.addEventListener('click', function() {
if (window.innerWidth <= 768) {
closeMenu();
}
});
});
// 点击其他区域关闭菜单
document.addEventListener('click', function(e) {
if (navLinks.classList.contains('active') &&
!navLinks.contains(e.target) &&
e.target !== menuToggle) {
closeMenu();
}
});
// 监听窗口大小变化,调整菜单显示
window.addEventListener('resize', function() {
if (window.innerWidth > 768 && navLinks.classList.contains('active')) {
navLinks.classList.remove('active');
updateMenuIcon(false);
body.style.overflow = '';
}
});
}
// 创建背景遮罩元素
let menuBackdrop;
// 初始化遮罩
function initBackdrop() {
if (!document.querySelector('.menu-backdrop')) {
menuBackdrop = document.createElement('div');
menuBackdrop.className = 'menu-backdrop';
document.body.appendChild(menuBackdrop);
// 点击遮罩关闭菜单
menuBackdrop.addEventListener('click', closeMenu);
} else {
menuBackdrop = document.querySelector('.menu-backdrop');
}
}
// 初始化
initBackdrop();
// 菜单切换功能
function toggleMenu() {
const isActive = navLinks.classList.toggle('active');
updateMenuIcon(isActive);
// 切换背景遮罩
if (isActive) {
menuBackdrop.classList.add('active');
} else {
menuBackdrop.classList.remove('active');
}
// 当菜单打开时禁止背景滚动(仅移动端)
if (window.innerWidth <= 768) {
body.style.overflow = isActive ? 'hidden' : '';
}
}
// 关闭菜单
function closeMenu() {
navLinks.classList.remove('active');
menuBackdrop.classList.remove('active');
updateMenuIcon(false);
body.style.overflow = '';
}
// 更新菜单图标
function updateMenuIcon(isActive) {
const icon = menuToggle.querySelector('i');
if (isActive) {
icon.classList.remove('fa-bars');
icon.classList.add('fa-times');
} else {
icon.classList.remove('fa-times');
icon.classList.add('fa-bars');
}
}
// 添加移动端swipe手势支持
let touchStartX = 0;
let touchEndX = 0;
document.addEventListener('touchstart', function(e) {
touchStartX = e.changedTouches[0].screenX;
}, false);
document.addEventListener('touchend', function(e) {
touchEndX = e.changedTouches[0].screenX;
handleSwipe();
}, false);
function handleSwipe() {
const swipeThreshold = 100; // 最小滑动距离
// 从左往右滑动,打开菜单
if (touchEndX - touchStartX > swipeThreshold && window.innerWidth <= 768) {
if (!navLinks.classList.contains('active')) {
toggleMenu();
}
}
// 从右往左滑动,关闭菜单
if (touchStartX - touchEndX > swipeThreshold && window.innerWidth <= 768) {
if (navLinks.classList.contains('active')) {
closeMenu();
}
}
}
// Flash消息自动消失
const alerts = document.querySelectorAll('.alert');
alerts.forEach(alert => {
setTimeout(() => {
alert.style.opacity = '0';
setTimeout(() => {
alert.style.display = 'none';
}, 500);
}, 5000);
});
// 检测是否为移动设备,添加相应的类
const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
if (isMobile) {
document.body.classList.add('mobile-device');
}
// 处理表格滚动指示器
const tableContainers = document.querySelectorAll('.table-container');
tableContainers.forEach(container => {
// 添加滚动提示文本(仅在移动端)
if (window.innerWidth <= 768) {
const hint = document.createElement('div');
hint.className = 'table-scroll-hint';
hint.innerHTML = '<i class="fas fa-arrows-left-right"></i> 左右滑动查看更多';
container.insertBefore(hint, container.firstChild);
}
// 检查表格是否可滚动
function checkScrollable() {
if (container.scrollWidth > container.clientWidth) {
container.classList.add('is-scrollable');
} else {
container.classList.remove('is-scrollable');
}
}
// 初始检查
checkScrollable();
// 监听窗口大小变化
window.addEventListener('resize', checkScrollable);
// 监听滚动事件,处理滚动指示器
container.addEventListener('scroll', function() {
const scrollLeft = container.scrollLeft;
const maxScroll = container.scrollWidth - container.clientWidth;
// 如果滚动到最右侧,隐藏右侧指示器
if (scrollLeft >= maxScroll - 5) {
container.classList.add('scrolled-end');
} else {
container.classList.remove('scrolled-end');
}
});
});
// 处理卡片式移动表格
const cardTables = document.querySelectorAll('.table.table-card-mobile');
cardTables.forEach(table => {
// 获取表头内容,用于生成移动端标签
const headerCells = table.querySelectorAll('thead th');
const headerTexts = Array.from(headerCells).map(cell => cell.textContent.trim());
// 为每个数据单元格添加data-label属性
const rows = table.querySelectorAll('tbody tr');
rows.forEach(row => {
const cells = row.querySelectorAll('td');
cells.forEach((cell, index) => {
if (index < headerTexts.length) {
cell.setAttribute('data-label', headerTexts[index]);
}
});
});
});
});
</script>
<!-- 额外脚本 -->
{% block scripts %}{% endblock %}
</body>
</html>