feat: 首页素材画廊增加分类筛选标签

- 后端 SQL 增加 json_extract 提取素材 metaType (frame/spritesheet/preview)
- 前端 AssetGallery 新增分类标签栏:全部/精灵表/帧/场景瓦片/背景/UI
- 按 metaType + assetType 组合过滤展示
This commit is contained in:
2026-05-25 21:07:15 +08:00
parent b88f9aaf03
commit 1a78744766
3 changed files with 131 additions and 68 deletions
+5 -1
View File
@@ -313,13 +313,14 @@ type RecentAssetItem struct {
Format string `json:"format"`
Prompt string `json:"prompt"`
AssetType string `json:"assetType"`
MetaType string `json:"metaType"` // frame / spritesheet / preview
TaskID string `json:"taskId"`
CreatedAt string `json:"createdAt"`
}
// GetRecentAssets 获取最近生成的素材列表(已完成任务的全部素材)。
func GetRecentAssets(c *gin.Context) {
limit := 20
limit := 60
var dbRows []struct {
Key string
@@ -327,6 +328,7 @@ func GetRecentAssets(c *gin.Context) {
Format string
Prompt string
AssetType string
MetaType string
TaskID string
ProjectID uint
CreatedAt string
@@ -334,6 +336,7 @@ func GetRecentAssets(c *gin.Context) {
db.GetDB().WithContext(c.Request.Context()).
Raw(`SELECT a.key, a.url, a.format, t.prompt, t.asset_type as asset_type,
COALESCE(json_extract(a.metadata, '$.type'), 'frame') as meta_type,
t.external_id as task_id, t.project_id, t.created_at as created_at
FROM assets a
INNER JOIN tasks t ON a.task_id = t.id
@@ -350,6 +353,7 @@ func GetRecentAssets(c *gin.Context) {
Format: r.Format,
Prompt: r.Prompt,
AssetType: r.AssetType,
MetaType: r.MetaType,
TaskID: r.TaskID,
CreatedAt: r.CreatedAt,
}