Enhance error handling for civitai metadata parsing and update logic; add empty state messages for model descriptions

This commit is contained in:
Will Miao
2025-03-10 17:32:28 +08:00
parent 2bdecf571b
commit cbb76580e4
2 changed files with 47 additions and 22 deletions

View File

@@ -94,7 +94,16 @@ export function createLoraCard(lora) {
base_model: card.dataset.base_model,
usage_tips: card.dataset.usage_tips,
notes: card.dataset.notes,
civitai: JSON.parse(card.dataset.meta || '{}'),
// Parse civitai metadata from the card's dataset
civitai: (() => {
try {
// Attempt to parse the JSON string
return JSON.parse(card.dataset.meta || '{}');
} catch (e) {
console.error('Failed to parse civitai metadata:', e);
return {}; // Return empty object on error
}
})(),
tags: JSON.parse(card.dataset.tags || '[]'),
modelDescription: card.dataset.modelDescription || ''
};