🔥删除:暂时注释不必要节点

This commit is contained in:
arlozen
2025-11-20 19:48:39 +08:00
parent 356fc953e7
commit 604dc6ea61
7 changed files with 1048 additions and 1048 deletions
+79 -79
View File
@@ -1,89 +1,89 @@
import { app } from "../../../scripts/app.js";
import { api } from "../../../scripts/api.js";
import {
showInfo,
showSuccess,
showWarning,
showError,
showConfirmDialog,
showMessage
} from "../box_utils.js";
// import { app } from "../../../scripts/app.js";
// import { api } from "../../../scripts/api.js";
// import {
// showInfo,
// showSuccess,
// showWarning,
// showError,
// showConfirmDialog,
// showMessage
// } from "../box_utils.js";
/**
* Extension for DialogBox node
* Displays dialog boxes during workflow execution and captures user responses
*/
app.registerExtension({
name: "EasyToolkit.DialogBox",
// /**
// * Extension for DialogBox node
// * Displays dialog boxes during workflow execution and captures user responses
// */
// app.registerExtension({
// name: "EasyToolkit.DialogBox",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name === "DialogBox") {
// Add custom node behavior
const originalOnExecuted = nodeType.prototype.onExecuted;
// async beforeRegisterNodeDef(nodeType, nodeData) {
// if (nodeData.name === "DialogBox") {
// // Add custom node behavior
// const originalOnExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(output) {
// Call original method if it exists
if (originalOnExecuted) {
originalOnExecuted.call(this, output);
}
// nodeType.prototype.onExecuted = function(output) {
// // Call original method if it exists
// if (originalOnExecuted) {
// originalOnExecuted.call(this, output);
// }
const dialogs = output?.dialogs;
if (dialogs && dialogs.length > 0) {
const dialog = dialogs[0];
// Show dialog and capture user response
this.showDialog(dialog.type, dialog.message);
}
};
// const dialogs = output?.dialogs;
// if (dialogs && dialogs.length > 0) {
// const dialog = dialogs[0];
// // Show dialog and capture user response
// this.showDialog(dialog.type, dialog.message);
// }
// };
// Add method to show dialog and capture response
nodeType.prototype.showDialog = async function(type, message) {
try {
// Validate inputs
if (!message || message.trim() === "") {
console.warn("[DialogBox] Empty message");
return;
}
// // Add method to show dialog and capture response
// nodeType.prototype.showDialog = async function(type, message) {
// try {
// // Validate inputs
// if (!message || message.trim() === "") {
// console.warn("[DialogBox] Empty message");
// return;
// }
const trimmedMessage = message.trim();
console.log(`[DialogBox] Showing ${type} dialog: ${trimmedMessage}`);
// const trimmedMessage = message.trim();
// console.log(`[DialogBox] Showing ${type} dialog: ${trimmedMessage}`);
let userResponse = "";
// let userResponse = "";
// Use appropriate dialog function based on type
switch (type) {
case "info":
showMessage(trimmedMessage);
userResponse = "ok";
break;
case "success":
showSuccess(trimmedMessage);
userResponse = "ok";
break;
case "warn":
showWarning(trimmedMessage);
userResponse = "ok";
break;
case "error":
showError(trimmedMessage);
userResponse = "ok";
break;
case "confirm":
const confirmed = await showConfirmDialog(trimmedMessage);
userResponse = confirmed ? "ok" : "cancel";
break;
default:
console.warn(`[DialogBox] Unknown type: ${type}, defaulting to info`);
showMessage(trimmedMessage);
userResponse = "ok";
}
// // Use appropriate dialog function based on type
// switch (type) {
// case "info":
// showMessage(trimmedMessage);
// userResponse = "ok";
// break;
// case "success":
// showSuccess(trimmedMessage);
// userResponse = "ok";
// break;
// case "warn":
// showWarning(trimmedMessage);
// userResponse = "ok";
// break;
// case "error":
// showError(trimmedMessage);
// userResponse = "ok";
// break;
// case "confirm":
// const confirmed = await showConfirmDialog(trimmedMessage);
// userResponse = confirmed ? "ok" : "cancel";
// break;
// default:
// console.warn(`[DialogBox] Unknown type: ${type}, defaulting to info`);
// showMessage(trimmedMessage);
// userResponse = "ok";
// }
console.log(`[DialogBox] User response: ${userResponse}`);
// console.log(`[DialogBox] User response: ${userResponse}`);
} catch (error) {
console.error("[DialogBox] Error showing dialog:", error);
showError("DialogBox Error", "Failed to display dialog");
}
};
}
}
});
// } catch (error) {
// console.error("[DialogBox] Error showing dialog:", error);
// showError("DialogBox Error", "Failed to display dialog");
// }
// };
// }
// }
// });
+110 -110
View File
@@ -1,123 +1,123 @@
import { app } from "../../../scripts/app.js";
import { api } from "../../../scripts/api.js";
import {
showToastInfo,
showToastSuccess,
showToastWarning,
showToastError,
showSystemNotification,
showWindowsNotification
} from "../box_utils.js";
// import { app } from "../../../scripts/app.js";
// import { api } from "../../../scripts/api.js";
// import {
// showToastInfo,
// showToastSuccess,
// showToastWarning,
// showToastError,
// showSystemNotification,
// showWindowsNotification
// } from "../box_utils.js";
/**
* Extension for ToastBox node
* Displays toast notifications during workflow execution
*/
app.registerExtension({
name: "EasyToolkit.ToastBox",
// /**
// * Extension for ToastBox node
// * Displays toast notifications during workflow execution
// */
// app.registerExtension({
// name: "EasyToolkit.ToastBox",
async beforeRegisterNodeDef(nodeType, nodeData) {
if (nodeData.name === "ToastBox") {
// Add custom node behavior
const originalOnExecuted = nodeType.prototype.onExecuted;
// async beforeRegisterNodeDef(nodeType, nodeData) {
// if (nodeData.name === "ToastBox") {
// // Add custom node behavior
// const originalOnExecuted = nodeType.prototype.onExecuted;
nodeType.prototype.onExecuted = function(output) {
// Call original method if it exists
if (originalOnExecuted) {
originalOnExecuted.call(this, output);
}
// nodeType.prototype.onExecuted = function(output) {
// // Call original method if it exists
// if (originalOnExecuted) {
// originalOnExecuted.call(this, output);
// }
const notifications = output?.notifications;
if (notifications && notifications.length > 0) {
const notification = notifications[0];
// Show notification based on node parameters
this.showNotification(
notification.type,
notification.message,
notification.duration,
notification.mode
);
}
};
// const notifications = output?.notifications;
// if (notifications && notifications.length > 0) {
// const notification = notifications[0];
// // Show notification based on node parameters
// this.showNotification(
// notification.type,
// notification.message,
// notification.duration,
// notification.mode
// );
// }
// };
// Add method to show notification (toast or system)
nodeType.prototype.showNotification = function(type, message, duration, mode = "comfyui") {
try {
// Validate inputs
if (!message || message.trim() === "") {
console.warn("[ToastBox] Empty message");
return;
}
// // Add method to show notification (toast or system)
// nodeType.prototype.showNotification = function(type, message, duration, mode = "comfyui") {
// try {
// // Validate inputs
// if (!message || message.trim() === "") {
// console.warn("[ToastBox] Empty message");
// return;
// }
const trimmedMessage = message.trim();
const clampedDuration = Math.max(1000, Math.min(10000, duration)); // Clamp duration between 1-10 seconds
// const trimmedMessage = message.trim();
// const clampedDuration = Math.max(1000, Math.min(10000, duration)); // Clamp duration between 1-10 seconds
console.log(`[ToastBox] Showing ${type} notification (${mode}): ${trimmedMessage}`);
// console.log(`[ToastBox] Showing ${type} notification (${mode}): ${trimmedMessage}`);
// Choose notification method based on mode
if (mode === "system") {
// Use system notifications
// this.showSystemNotification(type, trimmedMessage, clampedDuration);
} else {
// Use ComfyUI toast notifications (default)
this.showComfyUIToast(type, trimmedMessage, clampedDuration);
}
} catch (error) {
console.error("[ToastBox] Error showing notification:", error);
// Fallback to error toast
showToastError("ToastBox Error", "Failed to display notification", 5000);
}
};
// // Choose notification method based on mode
// if (mode === "system") {
// // Use system notifications
// // this.showSystemNotification(type, trimmedMessage, clampedDuration);
// } else {
// // Use ComfyUI toast notifications (default)
// this.showComfyUIToast(type, trimmedMessage, clampedDuration);
// }
// } catch (error) {
// console.error("[ToastBox] Error showing notification:", error);
// // Fallback to error toast
// showToastError("ToastBox Error", "Failed to display notification", 5000);
// }
// };
// Method to show ComfyUI toast notifications
nodeType.prototype.showComfyUIToast = function(type, message, duration) {
const toastOptions = {
summary: "ToastBox Notification",
detail: message,
life: duration
};
// // Method to show ComfyUI toast notifications
// nodeType.prototype.showComfyUIToast = function(type, message, duration) {
// const toastOptions = {
// summary: "ToastBox Notification",
// detail: message,
// life: duration
// };
// Use appropriate toast function based on type
switch (type) {
case "info":
showToastInfo(toastOptions.summary, toastOptions.detail, toastOptions.life);
break;
case "success":
showToastSuccess(toastOptions.summary, toastOptions.detail, toastOptions.life);
break;
case "warn":
showToastWarning(toastOptions.summary, toastOptions.detail, toastOptions.life);
break;
case "error":
showToastError(toastOptions.summary, toastOptions.detail, toastOptions.life);
break;
default:
console.warn(`[ToastBox] Unknown type: ${type}, defaulting to info`);
showToastInfo(toastOptions.summary, toastOptions.detail, toastOptions.life);
}
};
// // Use appropriate toast function based on type
// switch (type) {
// case "info":
// showToastInfo(toastOptions.summary, toastOptions.detail, toastOptions.life);
// break;
// case "success":
// showToastSuccess(toastOptions.summary, toastOptions.detail, toastOptions.life);
// break;
// case "warn":
// showToastWarning(toastOptions.summary, toastOptions.detail, toastOptions.life);
// break;
// case "error":
// showToastError(toastOptions.summary, toastOptions.detail, toastOptions.life);
// break;
// default:
// console.warn(`[ToastBox] Unknown type: ${type}, defaulting to info`);
// showToastInfo(toastOptions.summary, toastOptions.detail, toastOptions.life);
// }
// };
// // Method to show system notifications
// nodeType.prototype.showSystemNotification = function(type, message, duration) {
// const titleMap = {
// "info": "Info",
// "success": "Success",
// "warn": "Warning",
// "error": "Error"
// };
// // // Method to show system notifications
// // nodeType.prototype.showSystemNotification = function(type, message, duration) {
// // const titleMap = {
// // "info": "Info",
// // "success": "Success",
// // "warn": "Warning",
// // "error": "Error"
// // };
// const title = titleMap[type] || titleMap.info;
// // const title = titleMap[type] || titleMap.info;
// // Use Windows-style system notification
// showWindowsNotification(title, message, type, {
// timeout: duration,
// requireInteraction: type === "error"
// }).catch(error => {
// console.warn("[ToastBox] System notification failed, falling back to toast:", error);
// // Fallback to ComfyUI toast
// this.showComfyUIToast(type, message, duration);
// });
// };
}
}
});
// // // Use Windows-style system notification
// // showWindowsNotification(title, message, type, {
// // timeout: duration,
// // requireInteraction: type === "error"
// // }).catch(error => {
// // console.warn("[ToastBox] System notification failed, falling back to toast:", error);
// // // Fallback to ComfyUI toast
// // this.showComfyUIToast(type, message, duration);
// // });
// // };
// }
// }
// });