/** * ShowcaseView.js * 处理LoRA模型展示内容(图片、视频)的功能模块 */ import { showToast, copyToClipboard } from '../../utils/uiHelpers.js'; import { state } from '../../state/index.js'; import { NSFW_LEVELS } from '../../utils/constants.js'; /** * Get the local URL for an example image if available * @param {Object} img - Image object * @param {number} index - Image index * @param {string} modelHash - Model hash * @returns {string|null} - Local URL or null if not available */ function getLocalExampleImageUrl(img, index, modelHash) { if (!modelHash) return null; // Get remote extension const remoteExt = (img.url || '').split('?')[0].split('.').pop().toLowerCase(); // If it's a video (mp4), use that extension if (remoteExt === 'mp4') { return `/example_images_static/${modelHash}/image_${index + 1}.mp4`; } // For images, check if optimization is enabled (defaults to true) const optimizeImages = state.settings.optimizeExampleImages !== false; // Use .webp for images if optimization enabled, otherwise use original extension const extension = optimizeImages ? 'webp' : remoteExt; return `/example_images_static/${modelHash}/image_${index + 1}.${extension}`; } /** * 渲染展示内容 * @param {Array} images - 要展示的图片/视频数组 * @param {string} modelHash - Model hash for identifying local files * @returns {string} HTML内容 */ export function renderShowcaseContent(images, modelHash) { if (!images?.length) return '
All example images are filtered due to NSFW content settings
Your settings are currently set to show only safe-for-work content
You can change this in Settings