Files
ONE/backend/internal/model/model.go
T
Sakurasan fbda293072 余白 UI:按设计稿模块化还原 + 站主自定义 CSS + 详情 neighbors + 静态缓存头
前端(新增 ui/yohaku/,各视图按 ui_id=vivid 分支渲染;classic 与后台不受影响)
- 令牌层:设计稿数值原样落地,28 个 --v-* 为站主接口(自定义 CSS 可覆盖,
  放 @layer 让出优先级);另加防线,中和 styles.css 裸选择器
  (h1 衬线 / body 行高 / 后台 .stat/.toolbar/.chip 卡片)漏进余白元素
- 顶栏(滚动收缩态)/ 阅读进度(顶部 2px + READ n%)/ 页脚
- 首页:hero(统计条)/ 筛选(类型分段 + 标签 chips + 搜索)/
  长文卡片与短文纸条 / 分页 / 作品展示区(3 件 + 查看所有,参照 diygod.cc);
  面板栅格改 1.6fr 1fr 1fr 且高度自适应内容(标签云明显大一圈)
- 文章页:三栏「纸」—— 左时间线(前后各两篇)/ 中纸张 / 右目录与阅读进度;
  短文详情不显示标题(h1 视觉隐藏保留无障碍)
- 全部规则收敛在 html[data-ui='vivid'] 前缀下;无 !important

后端
- GET /api/posts/:slug 增 neighbors(前后各两篇,详情页侧栏时间线用)
- SPA 缓存头:index.html no-cache,assets/ 带 hash 长期 immutable
  (此前无缓存头,浏览器会一直拿旧构建)

其他
- 站主自定义 CSS 管线(customCss.js + ui/sections.js,按分区注入,仅 vivid)
- 删除旧 vivid 覆盖层实现(VividNav/Hero/Footer/Timeline/Toc、ui/vivid.css)
- 设计稿原型附于仓库根 index.html;作品表清掉外链 diygod.cc 的示例封面,
  改用本地占位图(public/covers/)
2026-09-23 15:37:42 +08:00

151 lines
5.1 KiB
Go

package model
// Post kinds. "long" is a normal article; "short" is a Twitter-like note
// with no title shown in the timeline.
const (
KindLong = "long"
KindShort = "short"
)
const (
StatusDraft = "draft"
StatusPublished = "published"
)
type Post struct {
ID int64 `json:"id"`
Kind string `json:"kind"`
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"`
PublishedAt string `json:"published_at"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
ReadingMinutes int `json:"reading_minutes"`
// ContentLen 是正文字符数:列表接口不返回全文,但后台列表要显示字数。
ContentLen int64 `json:"content_len"`
Tags []string `json:"tags"`
}
type PostInput struct {
Kind string `json:"kind"`
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"`
Tags []string `json:"tags"`
ReadingMinutes *int `json:"reading_minutes"`
}
type Tag struct {
ID int64 `json:"id"`
Name string `json:"name"`
Slug string `json:"slug"`
Color string `json:"color"`
Count int `json:"count"`
}
// Project is a showcase entry rendered on the public /projects page. It links
// out to an external homepage and (optionally) a source repository.
type Project struct {
ID int64 `json:"id"`
Title string `json:"title"`
Slug string `json:"slug"`
Summary string `json:"summary"`
CoverURL string `json:"cover_url"`
URL string `json:"url"`
RepoURL string `json:"repo_url"`
Status string `json:"status"`
Position int `json:"position"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
// ProjectInput carries the editable fields for a project. A blank Slug or
// Status is filled in by the store (slug from Title, status defaults to
// published) so the admin UI can omit them.
type ProjectInput struct {
Title string `json:"title"`
Slug string `json:"slug"`
Summary string `json:"summary"`
CoverURL string `json:"cover_url"`
URL string `json:"url"`
RepoURL string `json:"repo_url"`
Status string `json:"status"`
Position int `json:"position"`
}
type ArchiveMonth struct {
Month string `json:"month"`
Posts []Post `json:"posts"`
}
type ArchiveYear struct {
Year string `json:"year"`
Months []ArchiveMonth `json:"months"`
Count int `json:"count"`
}
type Page struct {
Items []Post `json:"items"`
Total int `json:"total"`
Page int `json:"page"`
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"`
AuthorName string `json:"author_name"`
AuthorBio string `json:"author_bio"`
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"`
// UIID selects which front-end UI the whole site renders. Valid values
// are "classic" (the original minimalist layout) and "vivid" (the
// livelier one). The admin UI is unaffected by this — it always uses the
// --admin-* tokens.
UIID string `json:"ui_id"`
// CustomCSS holds owner-authored stylesheets keyed by page section
// ("global", "home", "post", "archive", "tags", "projects", "about").
// Only injected for the vivid UI, and never on /admin. Always non-nil so
// the JSON response is {} rather than null.
CustomCSS map[string]string `json:"custom_css"`
}