feat(nav): 新增前台公开导航页与后台导航管理
新增模块
- Nav 模型(applications/models/admin_nav.py):公开导航表,与 admin_power 解耦
- NavOutSchema / NavManageSchema(applications/schemas/admin_nav.py)
- 前台公开视图 applications/view/public/nav.py:/site/、/site/category/<name>、/site/api/navs,无需登录
- 后台管理视图 applications/view/system/nav.py:CRUD + 启用/禁用,挂入 system_bp
- 前台模板 templates/public/{base,index,category}.html(独立配色,无需登录即可访问)
- 后台模板 templates/system/nav/{main,add,edit}.html(Layui table + form)
调整
- applications/view/__init__.py:注册前台蓝图到根
- applications/view/system/__init__.py:注册后台 nav 子蓝图
- applications/common/script/admin.py:admin init/export 支持 navs 数组
- applications/common/script/app_data/init.json:新增 10 条导航种子 + 4 条 system:nav 权限
数据库
- 新增 public_nav 表(含 category 索引)
- migration: 38751d88d42c_add_public_nav_table.py
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>{% block title %}{{ site_name|default('BWStudio · 导航') }}{% endblock %}</title>
|
||||
<meta name="description" content="BWStudio 公开导航聚合页:精选开发工具、AI、设计资源、效率工具等优质站点。">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/layui@2.9.7/dist/css/layui.css">
|
||||
<style>
|
||||
:root {
|
||||
--brand: #16baaa;
|
||||
--bg: #f5f7fa;
|
||||
--card-bg: #ffffff;
|
||||
--text: #2c3e50;
|
||||
--text-muted: #6c7a89;
|
||||
--border: #e8eef0;
|
||||
--shadow: 0 2px 12px rgba(0,0,0,0.06);
|
||||
--shadow-hover: 0 8px 24px rgba(22, 186, 170, 0.18);
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
|
||||
}
|
||||
.topbar {
|
||||
background: linear-gradient(135deg, #16baaa 0%, #2e8de8 100%);
|
||||
color: #fff;
|
||||
padding: 56px 0 48px;
|
||||
}
|
||||
.topbar .container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.topbar h1 { font-size: 36px; margin: 0 0 8px; font-weight: 600; }
|
||||
.topbar .sub { font-size: 15px; opacity: 0.92; }
|
||||
.topbar .actions { margin-top: 18px; }
|
||||
.topbar .actions a {
|
||||
display: inline-block;
|
||||
padding: 6px 14px;
|
||||
margin-right: 8px;
|
||||
background: rgba(255,255,255,0.18);
|
||||
border: 1px solid rgba(255,255,255,0.35);
|
||||
color: #fff;
|
||||
border-radius: 999px;
|
||||
font-size: 13px;
|
||||
text-decoration: none;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
.topbar .actions a:hover { background: rgba(255,255,255,0.32); }
|
||||
|
||||
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
|
||||
.section { margin: 32px 0; }
|
||||
.section-header {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 16px;
|
||||
border-left: 4px solid var(--brand);
|
||||
padding-left: 12px;
|
||||
}
|
||||
.section-header h2 {
|
||||
font-size: 20px;
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
}
|
||||
.section-header .meta { font-size: 13px; color: var(--text-muted); }
|
||||
|
||||
.grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
|
||||
gap: 16px;
|
||||
}
|
||||
.card {
|
||||
background: var(--card-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
padding: 18px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
box-shadow: var(--shadow);
|
||||
transition: all 0.25s ease;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.card:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: var(--shadow-hover);
|
||||
border-color: var(--brand);
|
||||
}
|
||||
.card .title-row {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
}
|
||||
.card .icon-wrap {
|
||||
width: 36px; height: 36px;
|
||||
background: rgba(22, 186, 170, 0.1);
|
||||
color: var(--brand);
|
||||
border-radius: 8px;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
font-size: 18px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.card .title {
|
||||
font-size: 15px; font-weight: 600; color: var(--text);
|
||||
flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.card .desc {
|
||||
font-size: 13px; color: var(--text-muted);
|
||||
line-height: 1.5;
|
||||
overflow: hidden;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
min-height: 38px;
|
||||
}
|
||||
.card .url {
|
||||
font-size: 12px; color: #b0bac3;
|
||||
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
||||
}
|
||||
.empty {
|
||||
text-align: center; padding: 48px 0; color: var(--text-muted);
|
||||
}
|
||||
|
||||
footer.site-footer {
|
||||
margin-top: 48px; padding: 24px 0;
|
||||
text-align: center; color: var(--text-muted); font-size: 13px;
|
||||
border-top: 1px solid var(--border);
|
||||
}
|
||||
</style>
|
||||
{% block extra_head %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<header class="topbar">
|
||||
<div class="container">
|
||||
<h1>{{ site_name|default('BWStudio · 导航') }}</h1>
|
||||
<div class="sub">{% block subtitle %}精选优质站点,按分类聚合展示 · 共 {{ total|default(0) }} 个链接{% endblock %}</div>
|
||||
<div class="actions">
|
||||
<a href="{{ url_for('public_nav.index') }}">🏠 首页</a>
|
||||
<a href="/admin/login">🔐 登录后台</a>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main class="container">
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
|
||||
<footer class="site-footer">
|
||||
© 2026 BWStudio · 基于 <a href="https://gitea.bwhome.top/bwadmin/pear-admin-flask" style="color:var(--brand);">Pear Admin Flask</a> 构建
|
||||
</footer>
|
||||
|
||||
{% block extra_js %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,36 @@
|
||||
{% extends 'public/base.html' %}
|
||||
|
||||
{% block title %}{{ category }} - {{ site_name }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="section">
|
||||
<div class="section-header">
|
||||
<h2>{{ category }}</h2>
|
||||
<div class="meta">
|
||||
共 {{ items|length }} 个 ·
|
||||
<a href="{{ url_for('public_nav.index') }}">← 返回首页</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if not items %}
|
||||
<div class="empty">该分类下暂无导航。</div>
|
||||
{% else %}
|
||||
<div class="grid">
|
||||
{% for item in items %}
|
||||
<a class="card"
|
||||
href="{{ item.url }}"
|
||||
{% if item.is_external %}target="_blank" rel="noopener noreferrer"{% endif %}>
|
||||
<div class="title-row">
|
||||
<div class="icon-wrap">
|
||||
<i class="layui-icon {{ item.icon }}"></i>
|
||||
</div>
|
||||
<div class="title">{{ item.title }}</div>
|
||||
</div>
|
||||
<div class="desc">{{ item.description or '暂无描述' }}</div>
|
||||
<div class="url">{{ item.url }}</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,38 @@
|
||||
{% extends 'public/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
{% if not groups %}
|
||||
<div class="empty">
|
||||
<i class="layui-icon layui-icon-face-surprised" style="font-size:48px;color:#ccc;"></i>
|
||||
<p>暂无导航数据,请先在后台【系统管理 → 导航管理】添加。</p>
|
||||
</div>
|
||||
{% else %}
|
||||
{% for category, items in groups.items() %}
|
||||
<section class="section">
|
||||
<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 }}"
|
||||
{% if item.is_external %}target="_blank" rel="noopener noreferrer"{% endif %}>
|
||||
<div class="title-row">
|
||||
<div class="icon-wrap">
|
||||
<i class="layui-icon {{ item.icon }}"></i>
|
||||
</div>
|
||||
<div class="title">{{ item.title }}</div>
|
||||
</div>
|
||||
<div class="desc">{{ item.description or '暂无描述' }}</div>
|
||||
<div class="url">{{ item.url }}</div>
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</section>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user