diff --git a/frontend/src/views/MediaList.vue b/frontend/src/views/MediaList.vue
index a0bc1e6..133b8f2 100644
--- a/frontend/src/views/MediaList.vue
+++ b/frontend/src/views/MediaList.vue
@@ -89,6 +89,15 @@
-
+
+
+
+
+
-
@@ -157,7 +166,7 @@ export default {
formatOptions: [],
query: {
page: 1,
- pageSize: 20,
+ pageSize: 10,
mediaType: '',
orientation: '',
resolution: '',
@@ -240,6 +249,15 @@ export default {
d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) +
' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds())
)
+ },
+ async handleManualNsfwChange(row) {
+ const newValue = row.manualNsfw === 'Y' ? 'N' : 'Y'
+ try {
+ await request.put(`/api/media/${row.id}/manual-nsfw`, { value: newValue })
+ row.manualNsfw = newValue
+ } catch (e) {
+ // 拦截器已提示
+ }
}
}
}
diff --git a/internal/api/media_controller.go b/internal/api/media_controller.go
index f4669cb..734da8d 100644
--- a/internal/api/media_controller.go
+++ b/internal/api/media_controller.go
@@ -137,6 +137,34 @@ func (c *MediaController) Preview(ctx *gin.Context) {
ctx.File(path)
}
+// UpdateManualNsfw 处理 PUT /api/media/:id/manual-nsfw:更新手动色情标记。
+func (c *MediaController) UpdateManualNsfw(ctx *gin.Context) {
+ idStr := ctx.Param("id")
+ var id int64
+ if _, err := fmt.Sscanf(idStr, "%d", &id); err != nil || id <= 0 {
+ Error(ctx, http.StatusBadRequest, "无效的 ID")
+ return
+ }
+
+ var req struct {
+ Value string `json:"value"`
+ }
+ if err := ctx.ShouldBindJSON(&req); err != nil {
+ Error(ctx, http.StatusBadRequest, "请求参数错误:"+err.Error())
+ return
+ }
+ if req.Value != "Y" && req.Value != "N" {
+ Error(ctx, http.StatusBadRequest, "值必须是 Y 或 N")
+ return
+ }
+
+ if err := c.store.UpdateManualNsfw(id, req.Value); err != nil {
+ Error(ctx, http.StatusInternalServerError, "更新失败:"+err.Error())
+ return
+ }
+ Success(ctx, nil)
+}
+
// toMediaView 给一条数据库记录补上展示用的派生字段。
func toMediaView(m store.MediaInfo) mediaView {
v := mediaView{MediaInfo: m}
diff --git a/internal/api/router.go b/internal/api/router.go
index f141b46..00a5475 100644
--- a/internal/api/router.go
+++ b/internal/api/router.go
@@ -33,6 +33,7 @@ func NewRouter(st *store.Store) *gin.Engine {
apiGroup.POST("/media/list", mc.List)
apiGroup.POST("/media/stats", mc.Stats)
apiGroup.GET("/media/preview", mc.Preview)
+ apiGroup.PUT("/media/:id/manual-nsfw", mc.UpdateManualNsfw)
// 扫描整理(开始 / 中止 / 移动 / 查进度 / 实时进度)
sc := NewScanController(service.NewScanService(st))
diff --git a/internal/store/store.go b/internal/store/store.go
index 15d836c..6e43183 100644
--- a/internal/store/store.go
+++ b/internal/store/store.go
@@ -49,6 +49,7 @@ type MediaInfo struct {
TailMd5 string `xorm:"char(32) index('idx_fp') 'tail_md5'" json:"tailMd5"` // 文件尾 256KB 的 MD5(指纹用)
NsfwScore float64 `xorm:"real 'nsfw_score'" json:"nsfwScore"` // NSFW 检测分 0~1(0 表示未检测或非图片)
NsfwThreshold float64 `xorm:"real 'nsfw_threshold'" json:"nsfwThreshold"` // NSFW 判定阈值
+ ManualNsfw string `xorm:"varchar(1) 'manual_nsfw'" json:"manualNsfw"` // 手动标记是否色情:Y/N,默认 N
CreatedAt time.Time `xorm:"created 'created_at'" json:"createdAt"` // 首次入库时间
UpdatedAt time.Time `xorm:"updated 'updated_at'" json:"updatedAt"` // 最近更新时间
}
@@ -219,6 +220,15 @@ func (s *Store) UpdateMediaFilePaths(moved map[string]string) error {
return sess.Commit()
}
+// UpdateManualNsfw 更新单条记录的手动色情标记。
+func (s *Store) UpdateManualNsfw(id int64, value string) error {
+ if s == nil || s.engine == nil {
+ return nil
+ }
+ _, err := s.engine.ID(id).Update(&MediaInfo{ManualNsfw: value})
+ return err
+}
+
// ============================ 媒体记录的新增/更新 ============================
// SaveMedia 保存/更新一条媒体记录:按 MD5 找,有就更新,没有就新增。