feat: add SproutWorkCollect apps
This commit is contained in:
16
SproutWorkCollect-Backend-Golang/internal/model/settings.go
Normal file
16
SproutWorkCollect-Backend-Golang/internal/model/settings.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package model
|
||||
|
||||
// Settings represents the site-wide configuration stored in config/settings.json.
|
||||
type Settings struct {
|
||||
SiteName string `json:"网站名字"`
|
||||
SiteDesc string `json:"网站描述"`
|
||||
Author string `json:"站长"`
|
||||
ContactEmail string `json:"联系邮箱"`
|
||||
ThemeColor string `json:"主题颜色"`
|
||||
PageSize int `json:"每页作品数量"`
|
||||
EnableSearch bool `json:"启用搜索"`
|
||||
EnableCategory bool `json:"启用分类"`
|
||||
Icp string `json:"备案号"`
|
||||
Footer string `json:"网站页尾"`
|
||||
Logo string `json:"网站logo"`
|
||||
}
|
||||
75
SproutWorkCollect-Backend-Golang/internal/model/work.go
Normal file
75
SproutWorkCollect-Backend-Golang/internal/model/work.go
Normal file
@@ -0,0 +1,75 @@
|
||||
package model
|
||||
|
||||
// WorkConfig is the data persisted in each work's work_config.json.
|
||||
// JSON field names are kept in Chinese to maintain backward compatibility
|
||||
// with data files written by the original Python backend.
|
||||
type WorkConfig struct {
|
||||
WorkID string `json:"作品ID"`
|
||||
WorkName string `json:"作品作品"`
|
||||
WorkDesc string `json:"作品描述"`
|
||||
Author string `json:"作者"`
|
||||
Version string `json:"作品版本号"`
|
||||
Category string `json:"作品分类"`
|
||||
Tags []string `json:"作品标签"`
|
||||
UploadTime string `json:"上传时间"`
|
||||
UpdateTime string `json:"更新时间"`
|
||||
Platforms []string `json:"支持平台"`
|
||||
FileNames map[string][]string `json:"文件名称"`
|
||||
// 外部下载:每个平台可以配置多个外链下载(带别名)。
|
||||
ExternalDownloads map[string][]ExternalDownload `json:"外部下载,omitempty"`
|
||||
Screenshots []string `json:"作品截图"`
|
||||
VideoFiles []string `json:"作品视频"`
|
||||
Cover string `json:"作品封面"`
|
||||
Downloads int `json:"作品下载量"`
|
||||
Views int `json:"作品浏览量"`
|
||||
Likes int `json:"作品点赞量"`
|
||||
UpdateCount int `json:"作品更新次数"`
|
||||
OriginalNames map[string]string `json:"原始文件名,omitempty"`
|
||||
}
|
||||
|
||||
type ExternalDownload struct {
|
||||
Alias string `json:"别名"`
|
||||
URL string `json:"链接"`
|
||||
}
|
||||
|
||||
// Normalize replaces nil slices/maps with empty equivalents so JSON
|
||||
// serialization produces [] / {} instead of null, matching Python behaviour.
|
||||
func (w *WorkConfig) Normalize() {
|
||||
if w.Tags == nil {
|
||||
w.Tags = []string{}
|
||||
}
|
||||
if w.Platforms == nil {
|
||||
w.Platforms = []string{}
|
||||
}
|
||||
if w.FileNames == nil {
|
||||
w.FileNames = map[string][]string{}
|
||||
}
|
||||
if w.ExternalDownloads == nil {
|
||||
w.ExternalDownloads = map[string][]ExternalDownload{}
|
||||
}
|
||||
if w.Screenshots == nil {
|
||||
w.Screenshots = []string{}
|
||||
}
|
||||
if w.VideoFiles == nil {
|
||||
w.VideoFiles = []string{}
|
||||
}
|
||||
}
|
||||
|
||||
// WorkResponse is a WorkConfig with dynamically computed link fields appended.
|
||||
// These link fields are NEVER stored in work_config.json; they are built on
|
||||
// the fly at response time.
|
||||
type WorkResponse struct {
|
||||
WorkConfig
|
||||
// 下载链接 is always present (empty map when there are no download files).
|
||||
DownloadLinks map[string][]string `json:"下载链接"`
|
||||
// 下载资源:统一返回“本地下载 + 外部下载”,前端可直接按别名渲染按钮/链接。
|
||||
DownloadResources map[string][]DownloadResource `json:"下载资源"`
|
||||
ImageLinks []string `json:"图片链接,omitempty"`
|
||||
VideoLinks []string `json:"视频链接,omitempty"`
|
||||
}
|
||||
|
||||
type DownloadResource struct {
|
||||
Type string `json:"类型"` // local | external
|
||||
Alias string `json:"别名"`
|
||||
URL string `json:"链接"`
|
||||
}
|
||||
Reference in New Issue
Block a user