From 331ad8f644248c5c44f411c378bc0d84492b2d16 Mon Sep 17 00:00:00 2001 From: Will Miao <13051207myq@gmail.com> Date: Fri, 22 Aug 2025 08:18:43 +0800 Subject: [PATCH] feat: Update showToast function to support options object and improve notification handling fix: Adjust modal max-height for better responsiveness --- static/css/components/modal/_base.css | 2 +- web/comfyui/usage_stats.js | 14 ++++++- web/comfyui/utils.js | 54 +++++++++++++++++++++------ 3 files changed, 56 insertions(+), 14 deletions(-) diff --git a/static/css/components/modal/_base.css b/static/css/components/modal/_base.css index 073692b2..71172e6d 100644 --- a/static/css/components/modal/_base.css +++ b/static/css/components/modal/_base.css @@ -23,7 +23,7 @@ body.modal-open { position: relative; max-width: 800px; height: auto; - /* max-height: calc(90vh - 48px); */ + max-height: calc(90vh); margin: 1rem auto; /* Keep reduced top margin */ background: var(--lora-surface); border-radius: var(--border-radius-base); diff --git a/web/comfyui/usage_stats.js b/web/comfyui/usage_stats.js index a6b157bc..e772c985 100644 --- a/web/comfyui/usage_stats.js +++ b/web/comfyui/usage_stats.js @@ -171,10 +171,20 @@ app.registerExtension({ if (foundPaths.length === 1) { // Single match found - success - showToast(`Updated path for ${fileName}: ${firstPath}`, 'info'); + showToast({ + severity: 'info', + summary: 'LoRA Manager Path Correction', + detail: `Updated path for ${fileName}: ${firstPath}`, + life: 5000 + }); } else { // Multiple matches found - warning - showToast(`Multiple paths found for ${fileName}, using: ${firstPath}`, 'warning'); + showToast({ + severity: 'warn', + summary: 'LoRA Manager Path Correction', + detail: `Multiple paths found for ${fileName}, using: ${firstPath}`, + life: 5000 + }); } // Mark node as modified diff --git a/web/comfyui/utils.js b/web/comfyui/utils.js index dda3814a..c136853f 100644 --- a/web/comfyui/utils.js +++ b/web/comfyui/utils.js @@ -25,21 +25,53 @@ export function getComfyUIFrontendVersion() { /** * Show a toast notification - * @param {string} message - The message to display - * @param {string} type - The type of toast (success, error, info, warning) + * @param {Object|string} options - Toast options object or message string for backward compatibility + * @param {string} [options.severity] - Message severity level (success, info, warn, error, secondary, contrast) + * @param {string} [options.summary] - Short title for the toast + * @param {any} [options.detail] - Detailed message content + * @param {boolean} [options.closable] - Whether user can close the toast (default: true) + * @param {number} [options.life] - Duration in milliseconds before auto-closing + * @param {string} [options.group] - Group identifier for managing related toasts + * @param {any} [options.styleClass] - Style class of the message + * @param {any} [options.contentStyleClass] - Style class of the content + * @param {string} [type] - Deprecated: severity type for backward compatibility */ -export function showToast(message, type = 'info') { +export function showToast(options, type = 'info') { + // Handle backward compatibility: showToast(message, type) + if (typeof options === 'string') { + options = { + detail: options, + severity: type + }; + } + + // Set defaults + const toastOptions = { + severity: options.severity || 'info', + summary: options.summary, + detail: options.detail, + closable: options.closable !== false, // default to true + life: options.life, + group: options.group, + styleClass: options.styleClass, + contentStyleClass: options.contentStyleClass + }; + + // Remove undefined properties + Object.keys(toastOptions).forEach(key => { + if (toastOptions[key] === undefined) { + delete toastOptions[key]; + } + }); + if (app && app.extensionManager && app.extensionManager.toast) { - app.extensionManager.toast.add({ - severity: type, - summary: type.charAt(0).toUpperCase() + type.slice(1), - detail: message, - life: 3000 - }); + app.extensionManager.toast.add(toastOptions); } else { - console.log(`${type.toUpperCase()}: ${message}`); + const message = toastOptions.detail || toastOptions.summary || 'No message'; + const severity = toastOptions.severity.toUpperCase(); + console.log(`${severity}: ${message}`); // Fallback alert for critical errors only - if (type === 'error') { + if (toastOptions.severity === 'error') { alert(message); } }