mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
feat: Add Lora recipes retrieval and filtering functionality
- Implemented a new API endpoint to fetch recipes associated with a specific Lora by its hash. - Enhanced the recipe scanning logic to support filtering by Lora hash and bypassing other filters. - Added a new method to retrieve a recipe by its ID with formatted metadata. - Created a new RecipeTab component to display recipes in the Lora modal. - Introduced session storage utilities for managing custom filter states. - Updated the UI to include a custom filter indicator and loading/error states for recipes. - Refactored existing recipe management logic to accommodate new features and improve maintainability.
This commit is contained in:
@@ -69,6 +69,53 @@ export function removeStorageItem(key) {
|
||||
localStorage.removeItem(key); // Also remove legacy key
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item from sessionStorage with namespace support
|
||||
* @param {string} key - The key without prefix
|
||||
* @param {any} defaultValue - Default value if key doesn't exist
|
||||
* @returns {any} The stored value or defaultValue
|
||||
*/
|
||||
export function getSessionItem(key, defaultValue = null) {
|
||||
// Try with prefix
|
||||
const prefixedValue = sessionStorage.getItem(STORAGE_PREFIX + key);
|
||||
|
||||
if (prefixedValue !== null) {
|
||||
// If it's a JSON string, parse it
|
||||
try {
|
||||
return JSON.parse(prefixedValue);
|
||||
} catch (e) {
|
||||
return prefixedValue;
|
||||
}
|
||||
}
|
||||
|
||||
// Return default value if key doesn't exist
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an item in sessionStorage with namespace prefix
|
||||
* @param {string} key - The key without prefix
|
||||
* @param {any} value - The value to store
|
||||
*/
|
||||
export function setSessionItem(key, value) {
|
||||
const prefixedKey = STORAGE_PREFIX + key;
|
||||
|
||||
// Convert objects and arrays to JSON strings
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
sessionStorage.setItem(prefixedKey, JSON.stringify(value));
|
||||
} else {
|
||||
sessionStorage.setItem(prefixedKey, value);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an item from sessionStorage with namespace prefix
|
||||
* @param {string} key - The key without prefix
|
||||
*/
|
||||
export function removeSessionItem(key) {
|
||||
sessionStorage.removeItem(STORAGE_PREFIX + key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Migrate all existing localStorage items to use the prefix
|
||||
* This should be called once during application initialization
|
||||
|
||||
Reference in New Issue
Block a user