mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-01-11 14:50:49 +08:00
Add a delete images button on main floating menu
This commit is contained in:
parent
1474c0f420
commit
4e5c0f4fa0
@ -40,9 +40,7 @@ class Note:
|
||||
class SaveImageList:
|
||||
def __init__(self):
|
||||
current_dir = os.path.abspath(os.getcwd())
|
||||
print(current_dir)
|
||||
self.output_dir = os.path.join(current_dir, "output")
|
||||
print(self.output_dir)
|
||||
self.type = "output"
|
||||
|
||||
@classmethod
|
||||
|
||||
16
server.py
16
server.py
@ -138,6 +138,22 @@ class PromptServer():
|
||||
|
||||
return web.Response(status=404)
|
||||
|
||||
@routes.post("/delete")
|
||||
async def delete(request):
|
||||
current_dir = os.path.abspath(os.getcwd())
|
||||
output_dir = os.path.join(current_dir, "output")
|
||||
if not os.path.exists(output_dir):
|
||||
return web.json_response({"message": "Output directory does not exist."}, status=404)
|
||||
try:
|
||||
for file_name in os.listdir(output_dir):
|
||||
file_path = os.path.join(output_dir, file_name)
|
||||
if os.path.isfile(file_path):
|
||||
os.remove(file_path)
|
||||
return web.json_response({"message": "All content deleted from Output folder."}, status=200)
|
||||
|
||||
except Exception as e:
|
||||
return web.json_response({"message": f"An error occurred: {str(e)}"}, status=500)
|
||||
|
||||
@routes.get("/prompt")
|
||||
async def get_prompt(request):
|
||||
return web.json_response(self.get_queue_info())
|
||||
|
||||
@ -106,6 +106,10 @@ class ComfyApi extends EventTarget {
|
||||
return await resp.json();
|
||||
}
|
||||
|
||||
async deleteAllImages() {
|
||||
await this.#postItem("delete", { delete: "all" })
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of embedding names
|
||||
* @returns An array of script urls to import
|
||||
|
||||
@ -329,6 +329,7 @@ export class ComfyUI {
|
||||
$el("button", { textContent: "Load", onclick: () => fileInput.click() }),
|
||||
$el("button", { textContent: "Clear", onclick: () => app.graph.clear() }),
|
||||
$el("button", { textContent: "Load Default", onclick: () => app.loadGraphData() }),
|
||||
$el("button", { textContent: "Delete Images", onclick: () => api.deleteAllImages() }),
|
||||
]);
|
||||
|
||||
this.setStatus({ exec_info: { queue_remaining: "X" } });
|
||||
|
||||
Loading…
Reference in New Issue
Block a user