| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- {% extends "base.html" %}
- {% block title %}时间线 - 满意错题本{% endblock %}
- {% block page_title %}时间线{% endblock %}
- {% block content %}
- <!-- Date nav -->
- <div class="bg-white rounded-2xl border border-gray-100 p-4 mb-6 flex items-center gap-3">
- {% if prev_date %}
- <a href="?date={{ prev_date }}" class="flex-shrink-0 w-9 h-9 rounded-xl bg-gray-50 hover:bg-gray-100 flex items-center justify-center text-gray-500 transition" title="前一天">
- <i class="fa-solid fa-chevron-left text-sm"></i>
- </a>
- {% else %}
- <span class="flex-shrink-0 w-9 h-9 rounded-xl bg-gray-50 flex items-center justify-center text-gray-200">
- <i class="fa-solid fa-chevron-left text-sm"></i>
- </span>
- {% endif %}
- <div class="flex items-center gap-2 overflow-x-auto flex-1 pb-1">
- {% for d in all_dates %}
- <a href="?date={{ d }}" class="date-chip flex-shrink-0 px-3 py-1.5 rounded-xl text-xs font-medium transition {% if d == current_date %}bg-primary text-white shadow-sm{% else %}bg-gray-50 text-gray-500 hover:bg-gray-100{% endif %}">
- {{ d }}
- </a>
- {% endfor %}
- </div>
- {% if next_date %}
- <a href="?date={{ next_date }}" class="flex-shrink-0 w-9 h-9 rounded-xl bg-gray-50 hover:bg-gray-100 flex items-center justify-center text-gray-500 transition" title="后一天">
- <i class="fa-solid fa-chevron-right text-sm"></i>
- </a>
- {% else %}
- <span class="flex-shrink-0 w-9 h-9 rounded-xl bg-gray-50 flex items-center justify-center text-gray-200">
- <i class="fa-solid fa-chevron-right text-sm"></i>
- </span>
- {% endif %}
- <input type="date" value="{{ current_date }}" onchange="location.href='/timeline?date='+this.value"
- class="border border-gray-200 rounded-xl px-3 py-1.5 text-xs focus:outline-none focus:ring-2 focus:ring-primary/30 text-gray-500 flex-shrink-0">
- </div>
- {% if timeline_data %}
- <div class="space-y-5">
- {% for item in timeline_data %}
- <div class="bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden" data-subject="{{ item.subject.id }}">
- <div class="px-5 py-3.5 flex items-center gap-3 border-b border-gray-50">
- <span class="w-3 h-3 rounded-full flex-shrink-0" style="background-color:{{ item.subject.color }};box-shadow:0 0 0 3px {{ item.subject.color }}20"></span>
- <span class="font-bold text-gray-800 text-sm">{{ item.subject.name }}</span>
- <span class="text-xs text-gray-400 ml-auto" id="count-{{ item.subject.id }}">加载中...</span>
- <a href="/subject/{{ item.subject.id }}?date={{ current_date }}" class="text-xs text-primary hover:underline ml-2 flex items-center gap-1"><i class="fa-solid fa-arrow-right"></i>进入科目</a>
- </div>
- {% set txt_list = [] %}
- {% set img_list = [] %}
- {% for img in item.images %}{% if img.filename %}{% set x = img_list.append(img) %}{% else %}{% set x = txt_list.append(img) %}{% endif %}{% endfor %}
- <div class="p-4">
- {% if img_list %}
- <div class="grid grid-cols-5 gap-3 mb-3">
- {% for img in img_list %}
- <div class="group relative aspect-[3/4] rounded-xl overflow-hidden bg-gray-100 cursor-pointer" onclick="openLightbox('/static/uploads/{{ img.filename }}','{{ img.original_name }}',lbImg{{ item.subject.id }},{{ loop.index0 }})">
- <img src="/static/uploads/{{ img.filename }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-300" loading="lazy">
- <div class="absolute inset-0 bg-black/0 group-hover:bg-black/20 transition"></div>
- <div class="absolute bottom-1.5 left-1.5 right-1.5">
- <p class="text-[10px] text-white/80 truncate px-1 py-0.5 bg-black/30 rounded">{{ img.original_name }}</p>
- </div>
- </div>
- {% endfor %}
- </div>
- {% endif %}
- {% if txt_list %}
- <div class="border-t border-gray-50 pt-3 mt-1">
- <div class="text-xs text-gray-400 mb-2 flex items-center gap-1"><i class="fa-solid fa-keyboard"></i>{{ txt_list|length }} 条文字记录</div>
- <div class="grid grid-cols-5 gap-3">
- {% for txt in txt_list %}
- <div class="rounded-xl overflow-hidden bg-violet-50 border border-violet-100 cursor-pointer hover:shadow-sm transition" onclick="toggleTimelineAnswer(this)">
- <div class="p-3">
- <p class="text-xs font-medium text-gray-700 line-clamp-2 leading-relaxed">{{ txt.question[:40] }}</p>
- </div>
- <div class="timeline-answer hidden px-3 pb-3">
- <p class="text-[11px] text-gray-500 leading-relaxed">{{ txt.answer }}</p>
- </div>
- </div>
- {% endfor %}
- </div>
- </div>
- {% endif %}
- </div>
- <div class="px-5 py-2 bg-gray-50 border-t border-gray-50 flex items-center gap-3">
- <span class="text-xs text-gray-400">{{ img_list|length }} 张错题{% if txt_list %} · {{ txt_list|length }} 条文字{% endif %}</span>
- </div>
- </div>
- {% endfor %}
- </div>
- {% else %}
- <div class="bg-white rounded-2xl border border-gray-100 p-16 text-center">
- <div class="text-6xl text-gray-200 mb-4"><i class="fa-regular fa-calendar-xmark"></i></div>
- <p class="text-gray-400 mb-2">该日期暂无错题记录</p>
- <p class="text-sm text-gray-300">请选择其他日期或前往科目页上传错题</p>
- </div>
- {% endif %}
- {% endblock %}
- {% block extra_js %}
- <script>
- {% for item in timeline_data %}
- const lbImg{{ item.subject.id }} = [
- {% for img in item.images %}{% if img.filename %}" /static/uploads/{{ img.filename }}",{% endif %}
- {% endfor %}
- ];
- {% endfor %}
- document.querySelectorAll('[id^="count-"]').forEach(function(el) {
- var id = el.id.replace('count-', '');
- var items = document.querySelectorAll('#timeline-subject-' + id + ' .timeline-entry');
- var imgCount = document.querySelectorAll('#timeline-subject-' + id + ' .img-entry').length;
- var txtCount = document.querySelectorAll('#timeline-subject-' + id + ' .txt-entry').length;
- if (txtCount > 0 && imgCount > 0) el.textContent = imgCount + ' 张错题 · ' + txtCount + ' 条文字';
- else if (txtCount > 0) el.textContent = txtCount + ' 条文字';
- else el.textContent = imgCount + ' 张错题';
- });
- function toggleTimelineAnswer(el) {
- var answer = el.querySelector('.timeline-answer');
- if (answer) answer.classList.toggle('hidden');
- }
- </script>
- {% endblock %}
|