mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 22:52:12 -03:00
feat: implement event delegation for checkpoint cards and enhance Civitai link handling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { state, getCurrentPageState } from '../state/index.js';
|
||||
import { VirtualScroller } from './VirtualScroller.js';
|
||||
import { createLoraCard, setupLoraCardEventDelegation } from '../components/LoraCard.js';
|
||||
import { createCheckpointCard } from '../components/CheckpointCard.js';
|
||||
import { createCheckpointCard, setupCheckpointCardEventDelegation } from '../components/CheckpointCard.js';
|
||||
import { fetchLorasPage } from '../api/loraApi.js';
|
||||
import { fetchCheckpointsPage } from '../api/checkpointApi.js';
|
||||
import { showToast } from './uiHelpers.js';
|
||||
@@ -68,6 +68,8 @@ export async function initializeInfiniteScroll(pageType = 'loras') {
|
||||
// Setup event delegation for lora cards if on the loras page
|
||||
if (pageType === 'loras') {
|
||||
setupLoraCardEventDelegation();
|
||||
} else if (pageType === 'checkpoints') {
|
||||
setupCheckpointCardEventDelegation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,16 +196,14 @@ function filterByFolder(folderPath) {
|
||||
});
|
||||
}
|
||||
|
||||
export function openCivitai(modelName) {
|
||||
// 从卡片的data-meta属性中获取civitai ID
|
||||
const loraCard = document.querySelector(`.lora-card[data-name="${modelName}"]`);
|
||||
export function openCivitai(filePath) {
|
||||
const loraCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
|
||||
if (!loraCard) return;
|
||||
|
||||
const metaData = JSON.parse(loraCard.dataset.meta);
|
||||
const civitaiId = metaData.modelId; // 使用modelId作为civitai模型ID
|
||||
const versionId = metaData.id; // 使用id作为版本ID
|
||||
const civitaiId = metaData.modelId;
|
||||
const versionId = metaData.id;
|
||||
|
||||
// 构建URL
|
||||
if (civitaiId) {
|
||||
let url = `https://civitai.com/models/${civitaiId}`;
|
||||
if (versionId) {
|
||||
@@ -214,6 +212,7 @@ export function openCivitai(modelName) {
|
||||
window.open(url, '_blank');
|
||||
} else {
|
||||
// 如果没有ID,尝试使用名称搜索
|
||||
const modelName = loraCard.dataset.name;
|
||||
window.open(`https://civitai.com/models?query=${encodeURIComponent(modelName)}`, '_blank');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user