后端: - ORDER BY 白名单(sanitizeOrder)堵住 ?order= SQL 注入,补回归测试 - 登录限速(每 IP 10 次失败/10 分钟 429)、TLS/反代下 Secure cookie、NewAPI 构造器 - Delete/setTags/MergeTags/DeleteTag 包事务;Archive 去 500 篇上限 - 列表接口裁剪:不传 content_md,长文 content_html 截 600,新增 content_len;health 探 DB 前端: - EditorView 路由复用串写修复(RouterView :key + sync watch 回写原文章) - v-html 出口统一过 DOMPurify(sanitizeHtml),stripTags 改 DOMParser - 列表竞态防护(Home/Tag/Posts 请求序号)、TagView 分页修复 - 侧栏接口 30s 缓存去重;one:unauthorized 监听器泄漏修复 - 删 styles.css 498 行重复块;移除 tailwind/marked/vue-tsc 死依赖;CommandPalette a11y 语义
111 lines
3.5 KiB
Go
111 lines
3.5 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"`
|
|
}
|
|
|
|
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"`
|
|
}
|