Update lora modal content

This commit is contained in:
Will Miao
2025-01-29 23:20:43 +08:00
parent 47329f92b6
commit 4abcc75092
2 changed files with 23 additions and 2 deletions

View File

@@ -127,7 +127,19 @@ class LorasEndpoint:
content_type='text/html',
status=500
)
def filter_civitai_data(self, civitai_data):
if not civitai_data:
return {}
required_fields = [
"id", "modelId", "name", "createdAt", "updatedAt",
"publishedAt", "trainedWords", "baseModel", "description",
"model", "images"
]
return {k: civitai_data[k] for k in required_fields if k in civitai_data}
def format_lora(self, lora):
"""格式化前端需要的数据结构"""
return {
@@ -140,7 +152,7 @@ class LorasEndpoint:
"file_path": lora["file_path"],
"modified": lora["modified"],
"from_civitai": lora.get("from_civitai", True),
"civitai": lora.get("civitai", {}) or {} # 确保当 civitai 为 None 时返回空字典
"civitai": self.filter_civitai_data(lora.get("civitai", {}))
}

View File

@@ -178,6 +178,15 @@ function showModal(lora) {
${lora.images.map(img => img.type === 'video' ? `<video controls autoplay muted loop><source src="${img.url}" type="video/mp4">Your browser does not support the video tag.</video>` : `<img src="${img.url}" alt="Preview">`).join('')}
</div>
<div class="description">About this version: ${lora.description ? lora.description : 'N/A'}</div>
<div class="trigger-words">
<strong>Trigger Words:</strong>
<span class="word-list">${lora.trainedWords ? lora.trainedWords.join(', ').toUpperCase() : 'N/A'}</span>
<button class="copy-btn" onclick="navigator.clipboard.writeText('${lora.trainedWords ? lora.trainedWords.join(', ').toUpperCase() : ''}')">
<svg width="16" height="16" viewBox="0 0 24 24">
<path fill="currentColor" d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/>
</svg>
</button>
</div>
<div class="model-link">
<a href="https://civitai.com/models/${lora.modelId}?modelVersionId=${lora.id}" target="_blank">more details on CivitAI</a>
</div>