跨分类聚合:按 NavClick 总点击数倒序,取前 12 个有效 nav。 实现要点: - applications/view/public/nav.py: 新增 _top_navs(limit=12), 复用 get_nav_visit_counts() 的 60s 进程内缓存;同点击数按 id asc 稳定排序; 0 点击返回空列表(前端整段不渲染) - _render_index() 注入 top_navs 到模板 - templates/public/index.html: 在 groups 循环前渲染 .section-hot,标题「🔥 热门网址」, meta 显示「近期访问量最大的 N 个」;卡片复用 .card,新增 .card-top 类 - templates/public/base.html: - .card-top:左侧 3px 品牌色边框 + 浅色背景渐变 + hover 增强阴影 - .section-hot h2 图标用 brand-orange #ff6b35 - .cat-nav-inner a.cat-nav-hot 顶部导航热门入口用品牌色 - 抽屉:首页 top_navs 非空时插入「🔥 热门」区段,链接到 #cat-top 边界: - 没有任何点击时整段隐藏(包括抽屉和顶部 nav),不出现「0 个」空标题 - 同一 nav 不会重复(按 nav.id 维度聚合) - Nav.enable=0 的不会进 TOP12 验证: - 15 个 nav 各灌入 20..6 次点击,前 12 个按降序显示访问数 20..9 - 清空所有 NavClick 后首页 section-hot / #cat-top / .cat-drawer-hot 三处全不渲染 - 测试数据已清理
107 lines
5.4 KiB
HTML
107 lines
5.4 KiB
HTML
{% extends 'public/base.html' %}
|
|
|
|
{# 分类目录条(sticky 顶部导航) #}
|
|
{% block cat_nav %}
|
|
{% if groups or top_navs %}
|
|
<nav class="cat-nav" aria-label="分类导航">
|
|
<div class="cat-nav-inner">
|
|
{% if top_navs %}<a href="#cat-top" class="cat-nav-hot">🔥 热门网址</a>{% endif %}
|
|
{% for category in groups.keys() %}
|
|
<a href="#cat-{{ loop.index }}">{{ category }}</a>
|
|
{% endfor %}
|
|
</div>
|
|
</nav>
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if not groups and not top_navs %}
|
|
<div class="empty">
|
|
<i class="layui-icon layui-icon-face-surprised" style="font-size:48px;color:#ccc;"></i>
|
|
<p>暂无导航数据,请先在后台【系统管理 → 导航管理】添加。</p>
|
|
</div>
|
|
{% else %}
|
|
|
|
{# ===== 热门网址:跨分类聚合的 TOP N ===== #}
|
|
{% if top_navs %}
|
|
<section class="section section-hot" id="cat-top">
|
|
<div class="section-header">
|
|
<h2><i class="layui-icon layui-icon-fire"></i> 热门网址</h2>
|
|
<div class="meta">近期访问量最大的 {{ top_navs|length }} 个</div>
|
|
</div>
|
|
<div class="grid">
|
|
{% for item in top_navs %}
|
|
<a class="card card-top"
|
|
href="{{ item.url }}"
|
|
data-nav-id="{{ item.id }}"
|
|
{% if item.is_external %}target="_blank" rel="noopener noreferrer"{% endif %}>
|
|
<div class="icon-wrap">
|
|
<i class="layui-icon {{ item.icon }}"></i>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="title-row">
|
|
<div class="title" title="{{ item.title }}">{{ item.title }}</div>
|
|
{% if item.is_external %}
|
|
<span class="ext-tag" title="外部链接"><i class="layui-icon layui-icon-link"></i></span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="desc">{{ item.description or '暂无描述' }}</div>
|
|
<div class="url" title="{{ item.url }}">{{ item.url }}</div>
|
|
<div class="visit-count" data-nav-visit="{{ item.visit_count or 0 }}">
|
|
{%- set vc = item.visit_count or 0 -%}
|
|
{%- if vc >= 3 -%}访问 {{ '{:,}'.format(vc) }}
|
|
{%- else -%}新
|
|
{%- endif -%}
|
|
</div>
|
|
</div>
|
|
<div class="card-arrow"><i class="layui-icon layui-icon-right"></i></div>
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</section>
|
|
{% endif %}
|
|
|
|
{% for category, items in groups.items() %}
|
|
{% set cat_id = 'cat-' ~ loop.index %}
|
|
<section class="section" id="{{ cat_id }}">
|
|
<div class="section-header">
|
|
<h2>{{ category }}</h2>
|
|
<div class="meta">
|
|
共 {{ items|length }} 个 ·
|
|
<a href="{{ url_for('public_nav.category_detail', name=category) }}">查看全部 →</a>
|
|
</div>
|
|
</div>
|
|
<div class="grid">
|
|
{% for item in items %}
|
|
<a class="card"
|
|
href="{{ item.url }}"
|
|
data-nav-id="{{ item.id }}"
|
|
{% if item.is_external %}target="_blank" rel="noopener noreferrer"{% endif %}>
|
|
<div class="icon-wrap">
|
|
<i class="layui-icon {{ item.icon }}"></i>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="title-row">
|
|
<div class="title" title="{{ item.title }}">{{ item.title }}</div>
|
|
{% if item.is_external %}
|
|
<span class="ext-tag" title="外部链接"><i class="layui-icon layui-icon-link"></i></span>
|
|
{% endif %}
|
|
</div>
|
|
<div class="desc">{{ item.description or '暂无描述' }}</div>
|
|
<div class="url" title="{{ item.url }}">{{ item.url }}</div>
|
|
<div class="visit-count" data-nav-visit="{{ item.visit_count or 0 }}">
|
|
{%- set vc = item.visit_count or 0 -%}
|
|
{%- if vc >= 3 -%}访问 {{ '{:,}'.format(vc) }}
|
|
{%- elif vc > 0 -%}新
|
|
{%- else -%}新
|
|
{%- endif -%}
|
|
</div>
|
|
</div>
|
|
<div class="card-arrow"><i class="layui-icon layui-icon-right"></i></div>
|
|
</a>
|
|
{% endfor %}
|
|
</div>
|
|
</section>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endblock %} |