mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 06:32:12 -03:00
Implement preview version tracking for LoRA cards
This commit is contained in:
@@ -163,23 +163,28 @@ export async function replacePreview(filePath) {
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const newPreviewPath = `${data.preview_url}?t=${new Date().getTime()}`;
|
||||
|
||||
// 更新预览版本
|
||||
state.previewVersions.set(filePath, Date.now());
|
||||
|
||||
// 更新卡片显示
|
||||
const card = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||
const previewContainer = card.querySelector('.card-preview');
|
||||
const oldPreview = previewContainer.querySelector('img, video');
|
||||
|
||||
const previewUrl = `${data.preview_url}?t=${state.previewVersions.get(filePath)}`;
|
||||
|
||||
if (file.type.startsWith('video/')) {
|
||||
const video = document.createElement('video');
|
||||
video.controls = true;
|
||||
video.autoplay = true;
|
||||
video.muted = true;
|
||||
video.loop = true;
|
||||
video.src = newPreviewPath;
|
||||
video.src = previewUrl;
|
||||
oldPreview.replaceWith(video);
|
||||
} else {
|
||||
const img = document.createElement('img');
|
||||
img.src = newPreviewPath;
|
||||
img.src = previewUrl;
|
||||
oldPreview.replaceWith(img);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user