fix: fetch-based photo delete with JSON response
This commit is contained in:
parent
f14ce9b255
commit
f32fc41be3
@ -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})
|
||||
}
|
||||
|
||||
@ -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));}});
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue
Block a user