diff --git a/internal/web/ui.go b/internal/web/ui.go index 7e97d5f..63056b7 100644 --- a/internal/web/ui.go +++ b/internal/web/ui.go @@ -4184,5 +4184,6 @@ func (u *UI) actionFaceGalleryDeletePhoto(w http.ResponseWriter, r *http.Request if id > 0 && strings.TrimSpace(u.dbPath) != "" { storage.NewFaceGalleryRepo(u.dbPath).DeletePhoto(id) } - http.Redirect(w, r, "/ui/face-gallery", http.StatusFound) + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(map[string]any{"ok": true}) } diff --git a/internal/web/ui/templates/face_gallery.html b/internal/web/ui/templates/face_gallery.html index 605d2f2..dce1ecc 100644 --- a/internal/web/ui/templates/face_gallery.html +++ b/internal/web/ui/templates/face_gallery.html @@ -92,10 +92,7 @@ function showEdit(id,name,photos){ } function delPhoto(id){ if(!confirm('确认删除这张照片?'))return; - var f=document.createElement('form'); - f.method='post';f.action='/ui/face-gallery/delete-photo'; - var i=document.createElement('input');i.type='hidden';i.name='id';i.value=id;f.appendChild(i); - document.body.appendChild(f);f.submit(); + fetch('/ui/face-gallery/delete-photo',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'id='+id}).then(function(){window.location.reload();}); } function closeModal(){document.getElementById('modal').style.display='none';} document.addEventListener('click',function(e){var b=e.target.closest('.edit-btn');if(b){showEdit(b.dataset.id,b.dataset.name,JSON.parse(b.dataset.photos));}}); diff --git a/resources/standard_resources/face_gallery/face_gallery.db b/resources/standard_resources/face_gallery/face_gallery.db deleted file mode 100644 index afedcea..0000000 Binary files a/resources/standard_resources/face_gallery/face_gallery.db and /dev/null differ