feat: 分类系统 + 标签系统 — Phase 4 完成
分类:Model/Repo/Service/Controller + 管理后台树形页面 + 首页导航栏
标签:Model/Repo/Service/Controller + /tags/{slug} 落地页 + 写文章页输入
Post 加 CategoryID,Create/Update 支持分类和标签
SQL 迁移含 categories/tags/post_tags 表及预设未分类
This commit is contained in:
80
templates/admin/html/categories/index.html
Normal file
80
templates/admin/html/categories/index.html
Normal file
@ -0,0 +1,80 @@
|
||||
{{template "admin/layout/base.html" .}}
|
||||
<div class="page-header">
|
||||
<h1>分类管理</h1>
|
||||
<p class="page-desc">两级树形分类,仅叶子节点可被文章选择</p>
|
||||
</div>
|
||||
|
||||
<div class="toolbar">
|
||||
<button class="btn btn-primary" id="btnNewCategory">+ 新建主分类</button>
|
||||
</div>
|
||||
|
||||
<div id="categoryTree" class="category-tree">
|
||||
{{range .Tree}}
|
||||
<div class="cat-node cat-parent">
|
||||
<div class="cat-row">
|
||||
<span class="cat-name">{{.Name}}</span>
|
||||
<span class="cat-slug">/{{.Slug}}</span>
|
||||
<span class="cat-actions">
|
||||
<a href="#" class="cat-btn-edit" data-id="{{.ID}}" data-name="{{.Name}}" data-slug="{{.Slug}}" data-desc="{{.Description}}" data-sort="{{.Sort}}">编辑</a>
|
||||
<a href="#" class="cat-btn-delete" data-id="{{.ID}}">删除</a>
|
||||
<a href="#" class="cat-btn-add-child" data-parent-id="{{.ID}}">+ 子分类</a>
|
||||
</span>
|
||||
</div>
|
||||
{{if .Children}}
|
||||
<div class="cat-children">
|
||||
{{range .Children}}
|
||||
<div class="cat-row cat-child">
|
||||
<span class="cat-name">{{.Name}}</span>
|
||||
<span class="cat-slug">/{{$.Slug}}/{{.Slug}}</span>
|
||||
<span class="cat-actions">
|
||||
<a href="#" class="cat-btn-edit" data-id="{{.ID}}" data-name="{{.Name}}" data-slug="{{.Slug}}" data-desc="{{.Description}}" data-sort="{{.Sort}}" data-parent-id="{{.ParentID}}">编辑</a>
|
||||
<a href="#" class="cat-btn-delete" data-id="{{.ID}}">删除</a>
|
||||
</span>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="cat-empty">暂无分类</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<!-- 编辑弹窗 -->
|
||||
<div class="modal-overlay" id="modalOverlay">
|
||||
<div class="modal">
|
||||
<div class="modal-header">
|
||||
<h3 id="modalTitle">新建分类</h3>
|
||||
<button class="modal-close" id="modalClose">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form id="categoryForm">
|
||||
<input type="hidden" id="catId">
|
||||
<input type="hidden" id="catParentId">
|
||||
<div class="form-group">
|
||||
<label for="catName">名称</label>
|
||||
<input type="text" id="catName" class="form-input" maxlength="50" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="catSlug">Slug(URL 标识)</label>
|
||||
<input type="text" id="catSlug" class="form-input" maxlength="50" pattern="[a-z0-9\-]+">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="catDesc">简介</label>
|
||||
<input type="text" id="catDesc" class="form-input" maxlength="200">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="catSort">排序</label>
|
||||
<input type="number" id="catSort" class="form-input" value="0" min="0" style="width:100px">
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary" id="modalCancel">取消</button>
|
||||
<button class="btn btn-primary" id="modalSave">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="toast" id="toast"></div>
|
||||
{{template "admin/layout/footer.html" .}}
|
||||
@ -55,6 +55,10 @@
|
||||
<span class="sidebar-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 1v4M12 19v4M4.22 4.22l2.83 2.83M16.95 16.95l2.83 2.83M1 12h4M19 12h4M4.22 19.78l2.83-2.83M16.95 7.05l2.83-2.83"/></svg></span>
|
||||
公户流水
|
||||
</a>
|
||||
<a href="/admin/categories" class="sidebar-item {{if eq .CurrentPath "/admin/categories"}}active{{end}}">
|
||||
<span class="sidebar-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 3h7v7H3V3z"/><path d="M14 3h7v7h-7V3z"/><path d="M3 14h7v7H3v-7z"/><path d="M14 14h7v7h-7v-7z"/></svg></span>
|
||||
分类管理
|
||||
</a>
|
||||
<a href="/admin/announcements" class="sidebar-item {{if eq .CurrentPath "/admin/announcements"}}active{{end}}">
|
||||
<span class="sidebar-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"/><path d="M13.73 21a2 2 0 0 1-3.46 0"/></svg></span>
|
||||
公告管理
|
||||
|
||||
Reference in New Issue
Block a user