refactor(import): Implement DownloadManager, FolderBrowser, ImageProcessor, and RecipeDataManager for enhanced recipe import functionality

- Added DownloadManager to handle saving recipes and downloading missing LoRAs.
- Introduced FolderBrowser for selecting LoRA root directories and managing folder navigation.
- Created ImageProcessor for handling image uploads and URL inputs for recipe analysis.
- Developed RecipeDataManager to manage recipe details, including metadata and LoRA information.
- Implemented ImportStepManager to control the flow of the import process and manage UI steps.
- Added utility function for formatting file sizes for better user experience.
This commit is contained in:
Will Miao
2025-05-08 15:41:13 +08:00
parent 59aefdff77
commit 23fa2995c8
7 changed files with 1168 additions and 1123 deletions

View File

@@ -0,0 +1,12 @@
/**
* Format a file size in bytes to a human-readable string
* @param {number} bytes - The size in bytes
* @returns {string} Formatted size string (e.g., "1.5 MB")
*/
export function formatFileSize(bytes) {
if (!bytes || isNaN(bytes)) return '';
const sizes = ['B', 'KB', 'MB', 'GB'];
const i = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, i)).toFixed(2) + ' ' + sizes[i];
}