mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 15:15:44 -03:00
feat: Update showToast function to support options object and improve notification handling
fix: Adjust modal max-height for better responsiveness
This commit is contained in:
@@ -23,7 +23,7 @@ body.modal-open {
|
|||||||
position: relative;
|
position: relative;
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
height: auto;
|
height: auto;
|
||||||
/* max-height: calc(90vh - 48px); */
|
max-height: calc(90vh);
|
||||||
margin: 1rem auto; /* Keep reduced top margin */
|
margin: 1rem auto; /* Keep reduced top margin */
|
||||||
background: var(--lora-surface);
|
background: var(--lora-surface);
|
||||||
border-radius: var(--border-radius-base);
|
border-radius: var(--border-radius-base);
|
||||||
|
|||||||
@@ -171,10 +171,20 @@ app.registerExtension({
|
|||||||
|
|
||||||
if (foundPaths.length === 1) {
|
if (foundPaths.length === 1) {
|
||||||
// Single match found - success
|
// 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 {
|
} else {
|
||||||
// Multiple matches found - warning
|
// 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
|
// Mark node as modified
|
||||||
|
|||||||
@@ -25,21 +25,53 @@ export function getComfyUIFrontendVersion() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Show a toast notification
|
* Show a toast notification
|
||||||
* @param {string} message - The message to display
|
* @param {Object|string} options - Toast options object or message string for backward compatibility
|
||||||
* @param {string} type - The type of toast (success, error, info, warning)
|
* @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) {
|
if (app && app.extensionManager && app.extensionManager.toast) {
|
||||||
app.extensionManager.toast.add({
|
app.extensionManager.toast.add(toastOptions);
|
||||||
severity: type,
|
|
||||||
summary: type.charAt(0).toUpperCase() + type.slice(1),
|
|
||||||
detail: message,
|
|
||||||
life: 3000
|
|
||||||
});
|
|
||||||
} else {
|
} 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
|
// Fallback alert for critical errors only
|
||||||
if (type === 'error') {
|
if (toastOptions.severity === 'error') {
|
||||||
alert(message);
|
alert(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user