Files
vps_web/templates/forum/index.html
ddrwode d29515598d 哈哈
2026-02-10 11:49:01 +08:00

192 lines
9.6 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>论坛 - 云价眼</title>
<link rel="stylesheet" href="/static/css/style.css">
<link rel="stylesheet" href="/static/css/forum.css">
</head>
<body class="forum-page">
{% set cards = post_cards if post_cards is defined else [] %}
{% set sb = sidebar if sidebar is defined else {'total_users': 0, 'total_posts': 0, 'total_comments': 0, 'category_counts': [], 'active_users': []} %}
<header class="forum-header">
<div class="forum-header-inner">
<div class="forum-header-left">
<a href="{{ url_for('forum_index') }}" class="forum-logo">VPS 论坛</a>
<nav class="forum-primary-nav">
{% for item in tab_links %}
<a href="{{ item.url }}" class="{{ 'active' if item.active else '' }}">{{ item.label }}</a>
{% endfor %}
<a href="{{ category_nav_url }}" class="{{ 'active' if selected_category else '' }}">分类</a>
<a href="{{ url_for('index') }}">价格表</a>
</nav>
</div>
<div class="forum-header-right">
{% if current_user %}
<span class="forum-user-chip">{{ current_user.username }}{% if current_user.is_banned %}(封禁){% endif %}</span>
<a href="{{ url_for('user_profile') }}" class="forum-link">个人中心</a>
<a href="{{ url_for('user_notifications') }}" class="forum-link nav-link-with-badge">通知{% if notifications_unread_count %}<span class="nav-badge">{{ notifications_unread_count }}</span>{% endif %}</a>
<a href="{{ url_for('user_logout') }}" class="forum-link">退出</a>
{% else %}
<a href="{{ url_for('user_login') }}" class="forum-link">登录</a>
<a href="{{ url_for('user_register') }}" class="forum-link">注册</a>
{% endif %}
</div>
</div>
</header>
<main class="forum-shell">
<section class="forum-topline">
<div class="forum-tabs">
{% for item in tab_links %}
<a class="{{ 'active' if item.active else '' }}" href="{{ item.url }}">{{ item.label }}</a>
{% endfor %}
<a class="{{ 'active' if selected_category else '' }}" href="{{ category_nav_url }}">分类</a>
</div>
<div class="forum-actions">
{% if current_user and not current_user.is_banned %}
<a href="{{ url_for('forum_post_new') }}" class="forum-btn-primary">+ 发布主题</a>
{% elif current_user and current_user.is_banned %}
<span class="forum-btn-muted">账号封禁中</span>
{% else %}
<a href="{{ url_for('user_login', next='/forum/post/new') }}" class="forum-btn-primary">登录后发帖</a>
{% endif %}
</div>
</section>
{% if message %}
<p class="form-success">{{ message }}</p>
{% endif %}
{% if error %}
<p class="form-error">{{ error }}</p>
{% endif %}
<section class="forum-tools">
<form method="get" action="{{ url_for('forum_index') }}" class="forum-search-form">
<input type="hidden" name="tab" value="{{ active_tab }}">
{% if selected_category %}
<input type="hidden" name="category" value="{{ selected_category }}">
{% endif %}
<input type="text" name="q" value="{{ search_query or '' }}" placeholder="搜索标题、正文、作者" maxlength="80">
<button type="submit" class="forum-btn-primary">搜索</button>
{% if search_query %}
<a href="{{ clear_search_url }}" class="forum-btn-muted">清空搜索</a>
{% endif %}
{% if has_filters %}
<a href="{{ clear_all_url }}" class="forum-btn-muted">重置全部</a>
{% endif %}
</form>
<div class="category-bar">
{% for item in category_links %}
<a href="{{ item.url }}" class="category-chip {{ 'active' if item.active else '' }}">
<span>{{ item.name }}</span>
{% if item.count is not none %}
<strong>{{ item.count }}</strong>
{% endif %}
</a>
{% endfor %}
</div>
</section>
<section class="forum-layout">
<div class="topic-stream">
<div class="topic-head">
<div class="topic-col-main">主题</div>
<div class="topic-col-mini">回复</div>
<div class="topic-col-mini">浏览</div>
<div class="topic-col-mini">活动</div>
</div>
{% if total_posts %}
<div class="topic-result">显示 {{ result_start }} - {{ result_end }} / 共 {{ total_posts }} 条</div>
{% endif %}
{% if cards %}
<ul class="topic-list">
{% for item in cards %}
{% set post = item.post %}
<li class="topic-row">
<div class="topic-main">
<div class="topic-avatar">{{ item.author_initial }}</div>
<div class="topic-content">
<a href="{{ url_for('forum_post_detail', post_id=post.id) }}" class="topic-title">
{% if post.is_pinned %}<span class="topic-flag flag-pinned">置顶</span>{% endif %}
{% if post.is_featured %}<span class="topic-flag flag-featured">精华</span>{% endif %}
{% if post.is_locked %}<span class="topic-flag flag-locked">锁帖</span>{% endif %}
{{ post.title }}
</a>
<div class="topic-meta">
<span class="topic-category">{{ post.category or '综合讨论' }}</span>
<span>{{ item.author_name }}</span>
<span>{{ post.created_at.strftime('%Y-%m-%d %H:%M') if post.created_at else '' }}</span>
<span>点赞 {{ item.like_count }}</span>
<span>收藏 {{ item.bookmark_count }}</span>
</div>
</div>
</div>
<div class="topic-stat">{{ item.reply_count }}</div>
<div class="topic-stat">{{ item.view_count }}</div>
<div class="topic-stat topic-activity">{{ item.latest_activity_text }}</div>
</li>
{% endfor %}
</ul>
{% if total_pages > 1 %}
<nav class="forum-pagination" aria-label="帖子分页">
{% if has_prev %}
<a href="{{ prev_page_url }}" class="page-link">上一页</a>
{% else %}
<span class="page-link disabled">上一页</span>
{% endif %}
{% for item in page_links %}
<a href="{{ item.url }}" class="page-link {{ 'active' if item.active else '' }}">{{ item.num }}</a>
{% endfor %}
{% if has_next %}
<a href="{{ next_page_url }}" class="page-link">下一页</a>
{% else %}
<span class="page-link disabled">下一页</span>
{% endif %}
</nav>
{% endif %}
{% else %}
<div class="topic-empty">{{ empty_hint }}</div>
{% endif %}
</div>
<aside class="forum-sidebar">
<div class="side-card">
<h3>社区统计</h3>
<div class="side-stats">
<div><span>用户</span><strong>{{ sb.total_users }}</strong></div>
<div><span>帖子</span><strong>{{ sb.total_posts }}</strong></div>
<div><span>评论</span><strong>{{ sb.total_comments }}</strong></div>
</div>
</div>
<div class="side-card">
<h3>分类热度</h3>
{% if sb.category_counts %}
<ul class="side-list">
{% for name, count in sb.category_counts %}
<li><span>{{ name }}</span><strong>{{ count }}</strong></li>
{% endfor %}
</ul>
{% else %}
<p class="side-empty">暂无分类数据</p>
{% endif %}
</div>
<div class="side-card">
<h3>活跃作者</h3>
{% if sb.active_users %}
<ul class="side-list">
{% for username, post_count in sb.active_users %}
<li><span>{{ username }}</span><strong>{{ post_count }}</strong></li>
{% endfor %}
</ul>
{% else %}
<p class="side-empty">暂无活跃作者</p>
{% endif %}
</div>
</aside>
</section>
</main>
</body>
</html>