feat: Implement checkpoint modal functionality with metadata editing, showcase display, and utility functions

- Added ModelMetadata.js for handling model metadata editing, including model name, base model, and file name.
- Introduced ShowcaseView.js to manage the display of images and videos in the checkpoint modal, including NSFW filtering and lazy loading.
- Created index.js as the main entry point for the checkpoint modal, integrating various components and functionalities.
- Developed utils.js for utility functions related to file size formatting and tag rendering.
- Enhanced user experience with editable fields, toast notifications, and improved showcase scrolling.
This commit is contained in:
Will Miao
2025-04-10 22:59:09 +08:00
parent cbfb9ac87c
commit 129ca9da81
7 changed files with 1384 additions and 996 deletions

View File

@@ -1,11 +1,8 @@
import { showToast } from '../utils/uiHelpers.js';
import { state } from '../state/index.js';
import { CheckpointModal } from './CheckpointModal.js';
import { showCheckpointModal } from './checkpointModal/index.js';
import { NSFW_LEVELS } from '../utils/constants.js';
// Create an instance of the modal
const checkpointModal = new CheckpointModal();
export function createCheckpointCard(checkpoint) {
const card = document.createElement('div');
card.className = 'lora-card'; // Reuse the same class for styling
@@ -29,6 +26,10 @@ export function createCheckpointCard(checkpoint) {
card.dataset.tags = JSON.stringify(checkpoint.tags);
}
if (checkpoint.modelDescription) {
card.dataset.modelDescription = checkpoint.modelDescription;
}
// Store NSFW level if available
const nsfwLevel = checkpoint.preview_nsfw_level !== undefined ? checkpoint.preview_nsfw_level : 0;
card.dataset.nsfwLevel = nsfwLevel;
@@ -139,9 +140,10 @@ export function createCheckpointCard(checkpoint) {
console.error('Failed to parse tags:', e);
return []; // Return empty array on error
}
})()
})(),
modelDescription: card.dataset.modelDescription || ''
};
checkpointModal.showCheckpointDetails(checkpointMeta);
showCheckpointModal(checkpointMeta);
});
// Toggle blur button functionality