fix: simplify face gallery build success message

This commit is contained in:
tian 2026-05-08 10:29:38 +08:00
parent 259f903a11
commit fe2c219db1

View File

@ -3986,11 +3986,22 @@ func (u *UI) actionFaceGalleryBuild(w http.ResponseWriter, r *http.Request) {
}
output, err := builder.Build()
if err != nil {
msg := fmt.Sprintf("生成失败: %v\n%s", err, output)
msg := fmt.Sprintf("生成失败: %v", err)
http.Redirect(w, r, "/ui/face-gallery?msg="+url.QueryEscape(msg), http.StatusFound)
return
}
msg := "人脸库生成成功\n" + output
// Parse key stats from output for a clean message
persons := "0"
photos := "0"
for _, line := range strings.Split(output, "\n") {
if strings.HasPrefix(line, "enrolled_persons:") {
persons = strings.TrimSpace(strings.TrimPrefix(line, "enrolled_persons:"))
}
if strings.HasPrefix(line, "ok_images:") {
photos = strings.TrimSpace(strings.TrimPrefix(line, "ok_images:"))
}
}
msg := fmt.Sprintf("生成成功,共 %s 人,%s 张照片", persons, photos)
http.Redirect(w, r, "/ui/face-gallery?msg="+url.QueryEscape(msg), http.StatusFound)
}