后台管理重塑 + 主题 / 皮肤双轴 + a11y 与编辑器增强
Backend
- Post 加 cover_url,Tag 加 color;老库 ALTER 兼容
- admin API: GET /api/admin/dashboard,POST /bulk,POST /tags/:id/merge,
PUT /tags/:id 接 {name,color},Settings 加 light_skin_id(兼容老 theme_id)
- 白名单兜底(非法 light_skin_id 落 paper)
- 新增合并 / Dashboard / Theme 测试覆盖
Frontend
- AdminLayout 改为侧边栏布局;新增 Dashboard 总览页
- PostsView 卡片化预览 + 筛选 chip + 批量操作 + 排序
- EditorView 增强:封面图 / WYSIWYG↔MD 双模式 / 实时大纲 / 字数统计 /
自动保存条 / ⌘S / unsaved 守卫(beforeunload + beforeRouteLeave)
- TagsView 加色板 + 合并到目标
- SettingsView 主题外观改为「亮色皮肤」三选一 + 「暗色皮肤」固定墨色说明
- 新增 CommandPalette(⌘K)+ ShortcutsPanel(?)
- api.js 接新接口;router.js 拆 /admin → /admin/posts
主题 / 皮肤双轴
- site.js: themeMode(light/dark/auto)+ light_skin_id;data-theme 前台,
data-admin-theme 后台(仅跟随 mode 切明暗)
- styles.css: :root[data-theme] 四套皮肤 + :root[data-admin-theme=dark] 后台墨感
- 修 sticky head / ThemeSwitcher / 表单 / 批量条 等 token 引用
- 后台用独立 --admin-* 系列,与前台主题解耦
- 左栏底部放 inline 形态 ThemeSwitcher(图标按钮 36×36),mobile 保留浮窗
a11y
- 全局 :focus-visible 描边(前后台跟随 token)
- prefers-reduced-motion 全局降级
- color-scheme 随主题切
- meta theme-color 双套(light/dark)
- 命令面板 / 快捷键面板:role=dialog aria-modal aria-label + 搜索框 aria-label
- icon-only 按钮加 aria-label(tag × / 清除选择 / 移除封面等)
- 输入框 aria-label + spellcheck=false
- PostsView 筛选同步 URL(可分享、可刷新保留)
- img width/height + loading=lazy
- utils.js 用 Intl.DateTimeFormat(zh-CN / sv-SE)
This commit is contained in:
@@ -18,6 +18,7 @@ type Post struct {
|
||||
Title string `json:"title"`
|
||||
Slug string `json:"slug"`
|
||||
Summary string `json:"summary"`
|
||||
CoverURL string `json:"cover_url"`
|
||||
ContentMd string `json:"content_md,omitempty"`
|
||||
ContentHTML string `json:"content_html"`
|
||||
Status string `json:"status"`
|
||||
@@ -33,6 +34,7 @@ type PostInput struct {
|
||||
Title string `json:"title"`
|
||||
Slug string `json:"slug"`
|
||||
Summary string `json:"summary"`
|
||||
CoverURL string `json:"cover_url"`
|
||||
ContentMd string `json:"content_md"`
|
||||
Status string `json:"status"`
|
||||
PublishedAt string `json:"published_at"`
|
||||
@@ -44,6 +46,7 @@ type Tag struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Slug string `json:"slug"`
|
||||
Color string `json:"color"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
@@ -65,6 +68,26 @@ type Page struct {
|
||||
Size int `json:"size"`
|
||||
}
|
||||
|
||||
// Dashboard is the snapshot rendered on /admin (homepage).
|
||||
type Dashboard struct {
|
||||
TotalPosts int `json:"total_posts"`
|
||||
PublishedPosts int `json:"published_posts"`
|
||||
DraftPosts int `json:"draft_posts"`
|
||||
ShortPosts int `json:"short_posts"`
|
||||
LongPosts int `json:"long_posts"`
|
||||
TotalTags int `json:"total_tags"`
|
||||
TotalWords int `json:"total_words"`
|
||||
RecentPosts []Post `json:"recent_posts"`
|
||||
RecentDrafts []Post `json:"recent_drafts"`
|
||||
TopTags []Tag `json:"top_tags"`
|
||||
PublishedByMonth []MonthBucket `json:"published_by_month"`
|
||||
}
|
||||
|
||||
type MonthBucket struct {
|
||||
Month string `json:"month"` // "YYYY-MM"
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type Settings struct {
|
||||
SiteTitle string `json:"site_title"`
|
||||
SiteDesc string `json:"site_desc"`
|
||||
@@ -73,4 +96,13 @@ type Settings struct {
|
||||
FooterNote string `json:"footer_note"`
|
||||
ICPLicense string `json:"icp"`
|
||||
PostsPerPage int `json:"posts_per_page"`
|
||||
// LightSkinID is the front-end skin used when the client (or system)
|
||||
// prefers light. Valid values: paper / sage / rose.
|
||||
// Dark side is fixed to ink for now — kept implicit so we can add
|
||||
// dark variants later without breaking clients.
|
||||
LightSkinID string `json:"light_skin_id"`
|
||||
// ThemeID is kept for backward compatibility with older clients that
|
||||
// only know about a single skin. settingsFromMap falls back to it
|
||||
// when LightSkinID is empty.
|
||||
ThemeID string `json:"theme_id,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user