feat: overhaul UI styling, improve templates, enhance services and tests

This commit is contained in:
2026-06-06 00:38:56 +08:00
parent f7f1a4c0cb
commit 904eec392e
38 changed files with 1471 additions and 795 deletions
+97 -58
View File
@@ -1,26 +1,53 @@
{% extends "base.html" %}
{% block title %}{{ page_title }} — HF Daily Papers{% endblock %}
{% block content %}
{% extends "base.html" %} {% block title %}{{ page_title }} — HF Daily Papers{%
endblock %} {% block content %}
<section class="search-page">
{# 搜索表单 #}
<form class="search-form" method="get" action="/search">
<input type="text" name="q" value="{{ query }}" placeholder="搜索标题、摘要、作者、标签..."
class="search-input" autofocus>
<input
type="text"
name="q"
value="{{ query }}"
placeholder="搜索标题、摘要、作者、标签..."
class="search-input"
autofocus
/>
{% if tag %}
<input type="hidden" name="tag" value="{{ tag }}">
{% endif %}
{# 模式切换 #}
{% if chroma_enabled %}
<input type="hidden" name="tag" value="{{ tag }}" />
{% endif %} {# 模式切换 #} {% if chroma_enabled %}
<div class="search-mode-toggle">
<label class="mode-option {% if mode == 'keyword' or not mode %}active{% endif %}">
<input type="radio" name="mode" value="keyword" {% if mode == 'keyword' or not mode %}checked{% endif %}>
<label
class="mode-option {% if mode == 'keyword' or not mode %}active{% endif %}"
>
<input
type="radio"
name="mode"
value="keyword"
{%
if
mode=""
="keyword"
or
not
mode
%}checked{%
endif
%}
/>
关键词
</label>
<label class="mode-option {% if mode == 'semantic' %}active{% endif %}">
<input type="radio" name="mode" value="semantic" {% if mode == 'semantic' %}checked{% endif %}>
<input
type="radio"
name="mode"
value="semantic"
{%
if
mode=""
="semantic"
%}checked{%
endif
%}
/>
语义搜索
</label>
</div>
@@ -29,29 +56,40 @@
<button type="submit" class="search-btn">搜索</button>
</form>
{# 标签筛选 #}
{% if all_tags %}
{# 标签筛选 #} {% if all_tags %}
<div class="tag-filter">
<span class="tag-filter-label">标签:</span>
<a href="/search?q={{ query }}&mode={{ mode }}{% if tag %}&tag={{ tag }}{% endif %}"
class="tag-chip {% if not tag %}active{% endif %}">全部</a>
<a
href="/search?q={{ query }}&mode={{ mode }}{% if tag %}&tag={{ tag }}{% endif %}"
class="tag-chip {% if not tag %}active{% endif %}"
>全部</a
>
{% for t in all_tags %}
<a href="/search?q={{ query }}&tag={{ t }}&mode={{ mode }}"
class="tag-chip {% if t == tag %}active{% endif %}">{{ t }}</a>
<a
href="/search?q={{ query }}&tag={{ t }}&mode={{ mode }}"
class="tag-chip {% if t == tag %}active{% endif %}"
>{{ t }}</a
>
{% endfor %}
</div>
{% endif %}
{% if query or tag %}
{# 搜索结果元信息 #}
{% endif %} {% if query or tag %} {# 搜索结果元信息 #}
<div class="search-meta">
<span>找到 {{ total }} 条结果{% if mode == 'semantic' %}(语义模式){% endif %}</span>
<span
>找到 {{ total }} 条结果{% if mode == 'semantic' %}(语义模式){% endif
%}</span
>
<div class="sort-toggle">
<a href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=relevance"
class="{% if sort == 'relevance' %}active{% endif %}">相关性</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=relevance"
class="{% if sort == 'relevance' %}active{% endif %}"
>相关性</a
>
<span class="sort-divider">|</span>
<a href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=date"
class="{% if sort == 'date' %}active{% endif %}">日期</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&mode={{ mode }}&sort=date"
class="{% if sort == 'date' %}active{% endif %}"
>日期</a
>
</div>
</div>
@@ -62,14 +100,10 @@
<div class="paper-card-header">
<h2 class="paper-title">
<a href="/paper/{{ paper.arxiv_id }}">
{% set snippet = snippets.get(paper.id, {}) %}
{% if snippet and snippet.title_zh %}
{{ snippet.title_zh | safe }}
{% elif paper.title_zh %}
{{ paper.title_zh }}
{% else %}
{{ paper.title_en }}
{% endif %}
{% set snippet = snippets.get(paper.id, {}) %} {% if snippet and
snippet.title_zh %} {{ snippet.title_zh | safe }} {% elif
paper.title_zh %} {{ paper.title_zh }} {% else %} {{ paper.title_en
}} {% endif %}
</a>
</h2>
<span class="paper-upvotes">👍 {{ paper.upvotes }}</span>
@@ -85,7 +119,10 @@
{% elif paper.summary and paper.summary.one_line %}
<p class="paper-one-line">{{ paper.summary.one_line }}</p>
{% elif paper.abstract %}
<p class="paper-abstract-preview">{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif %}</p>
<p class="paper-abstract-preview">
{{ paper.abstract[:200] }}{% if paper.abstract|length > 200 %}…{% endif
%}
</p>
{% endif %}
<div class="paper-meta">
@@ -102,16 +139,14 @@
</div>
<div class="paper-footer">
<span class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}">
{% if not paper.summary_status or paper.summary_status.status == 'pending' %}
未总结
{% elif paper.summary_status.status == 'processing' %}
🔄 总结中
{% elif paper.summary_status.status in ('failed', 'permanent_failure') %}
❌ 总结失败
{% elif paper.summary_status.status == 'done' %}
✅ 已总结
{% endif %}
<span
class="summary-badge summary-{{ paper.summary_status.status if paper.summary_status else 'none' }}"
>
{% if not paper.summary_status or paper.summary_status.status ==
'pending' %} 未总结 {% elif paper.summary_status.status ==
'processing' %} 🔄 总结中 {% elif paper.summary_status.status in
('failed', 'permanent_failure') %} ❌ 总结失败 {% elif
paper.summary_status.status == 'done' %} ✅ 已总结 {% endif %}
</span>
<a href="/paper/{{ paper.arxiv_id }}" class="btn-detail">详情 →</a>
</div>
@@ -119,25 +154,29 @@
{% endfor %}
</div>
{# 分页 #}
{% if total_pages > 1 %}
{# 分页 #} {% if total_pages > 1 %}
<nav class="pagination">
{% if page > 1 %}
<a href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page - 1 }}" class="page-btn">← 上一页</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page - 1 }}"
class="page-btn"
>← 上一页</a
>
{% endif %}
<span class="page-info">{{ page }} / {{ total_pages }}</span>
{% if page < total_pages %}
<a href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page + 1 }}" class="page-btn">下一页 →</a>
<a
href="/search?q={{ query }}&tag={{ tag }}&sort={{ sort }}&mode={{ mode }}&page={{ page + 1 }}"
class="page-btn"
>下一页 →</a
>
{% endif %}
</nav>
{% endif %}
{% else %}
{% endif %} {% else %}
<div class="empty-state">
<p>没有找到匹配的论文</p>
<p class="hint">试试其他关键词或标签</p>
</div>
{% endif %}
{% endif %}
{% endif %} {% endif %}
</section>
{% endblock %}