完善了首页和关于前端页面,以及解决了图片存储方案问题
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}郭安的小站{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div style="margin-bottom: 2rem;">
|
||||
<h2 style="
|
||||
font-size: 1.1rem;
|
||||
font-weight: 600;
|
||||
color: var(--text);
|
||||
margin-bottom: 1.5rem;
|
||||
padding-bottom: 0.8rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
">分类</h2>
|
||||
|
||||
{% for category in categories %}
|
||||
<div class="post-item">
|
||||
<h2>
|
||||
<a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
|
||||
</h2>
|
||||
<div style="
|
||||
font-size: 0.85rem;
|
||||
color: var(--text-muted);
|
||||
font-family: -apple-system, 'Noto Sans SC', sans-serif;
|
||||
margin-top: 0.3rem;
|
||||
">
|
||||
{{ category.posts.count }} 篇文章
|
||||
{% if category.description %} · {{ category.description }}{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% empty %}
|
||||
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
|
||||
<p style="margin-bottom: 0.5rem;">还没有分类</p>
|
||||
<p style="font-size: 0.9rem;">
|
||||
<a href="/admin/" style="color: var(--text-light); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;">去管理后台创建一个</a>
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- ✅ 分页 -->
|
||||
{% if categories.paginator.num_pages > 1 %}
|
||||
<nav style="
|
||||
margin-top: 3rem;
|
||||
text-align: center;
|
||||
font-family: -apple-system, 'Noto Sans SC', sans-serif;
|
||||
font-size: 0.9rem;
|
||||
">
|
||||
{% if categories.has_previous %}
|
||||
<a href="?page=1" style="margin-right: 0.6rem; color: var(--text-light); text-decoration: none;">« 首页</a>
|
||||
<a href="?page={{ categories.previous_page_number }}" style="margin-right: 1rem; color: var(--text-light); text-decoration: none;">‹ 上一页</a>
|
||||
{% else %}
|
||||
<span style="margin-right: 0.6rem; color: var(--text-muted);">« 首页</span>
|
||||
<span style="margin-right: 1rem; color: var(--text-muted);">‹ 上一页</span>
|
||||
{% endif %}
|
||||
|
||||
{% for num in categories.paginator.page_range %}
|
||||
{% if categories.paginator.num_pages <= 9 %}
|
||||
{% if num == categories.number %}
|
||||
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
|
||||
{% else %}
|
||||
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
{% if num == 1 or num == categories.paginator.num_pages %}
|
||||
{% if num == categories.number %}
|
||||
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
|
||||
{% else %}
|
||||
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
|
||||
{% endif %}
|
||||
{% elif num >= categories.number|add:'-2' and num <= categories.number|add:'2' %}
|
||||
{% if num == categories.number %}
|
||||
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
|
||||
{% else %}
|
||||
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
|
||||
{% endif %}
|
||||
{% elif num == categories.number|add:'-3' or num == categories.number|add:'3' %}
|
||||
<span style="margin: 0 0.2rem; color: var(--text-muted);">…</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if categories.has_next %}
|
||||
<a href="?page={{ categories.next_page_number }}" style="margin-left: 1rem; color: var(--text-light); text-decoration: none;">下一页 ›</a>
|
||||
<a href="?page={{ categories.paginator.num_pages }}" style="margin-left: 0.6rem; color: var(--text-light); text-decoration: none;">末页 »</a>
|
||||
{% else %}
|
||||
<span style="margin-left: 1rem; color: var(--text-muted);">下一页 ›</span>
|
||||
<span style="margin-left: 0.6rem; color: var(--text-muted);">末页 »</span>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user