mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 06:02:11 -03:00
feat: add functionality to open file location from model modal and update translations, fixes #405
This commit is contained in:
@@ -166,10 +166,14 @@ export async function showModelModal(model, modelType) {
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item location-size">
|
||||
<div class="info-item">
|
||||
<div class="location-wrapper">
|
||||
<label>${translate('modals.model.metadata.location', {}, 'Location')}</label>
|
||||
<span class="file-path">${modelWithFullData.file_path.replace(/[^/]+$/, '') || 'N/A'}</span>
|
||||
<span class="file-path" title="${translate('modals.model.actions.openFileLocation', {}, 'Open file location')}"
|
||||
data-action="open-file-location"
|
||||
data-filepath="${modelWithFullData.file_path}">
|
||||
${modelWithFullData.file_path.replace(/[^/]+$/, '') || 'N/A'}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="info-item base-size">
|
||||
@@ -318,6 +322,12 @@ function setupEventHandlers(filePath) {
|
||||
window.open(`https://civitai.com/user/${username}`, '_blank');
|
||||
}
|
||||
break;
|
||||
case 'open-file-location':
|
||||
const filePath = target.dataset.filepath;
|
||||
if (filePath) {
|
||||
openFileLocation(filePath);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -444,6 +454,24 @@ async function saveNotes(filePath) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call backend to open file location and select the file
|
||||
* @param {string} filePath
|
||||
*/
|
||||
async function openFileLocation(filePath) {
|
||||
try {
|
||||
const resp = await fetch('/api/open-file-location', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ 'file_path': filePath })
|
||||
});
|
||||
if (!resp.ok) throw new Error('Failed to open file location');
|
||||
showToast('modals.model.openFileLocation.success', {}, 'success');
|
||||
} catch (err) {
|
||||
showToast('modals.model.openFileLocation.failed', {}, 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// Export the model modal API
|
||||
const modelModal = {
|
||||
show: showModelModal,
|
||||
|
||||
Reference in New Issue
Block a user