mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
feat(context-menu): add example image download entry
This commit is contained in:
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "Download example images",
|
||||
"missingPath": "Set a download location before downloading example images.",
|
||||
"unavailable": "Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -123,6 +123,11 @@
|
||||
}
|
||||
},
|
||||
"globalContextMenu": {
|
||||
"downloadExampleImages": {
|
||||
"label": "[TODO: Translate] Download example images",
|
||||
"missingPath": "[TODO: Translate] Set a download location before downloading example images.",
|
||||
"unavailable": "[TODO: Translate] Example image downloads aren't available yet. Try again after the page finishes loading."
|
||||
},
|
||||
"cleanupExampleImages": {
|
||||
"label": "Clean up example image folders",
|
||||
"success": "Moved {count} folder(s) to the deleted folder",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { BaseContextMenu } from './BaseContextMenu.js';
|
||||
import { showToast } from '../../utils/uiHelpers.js';
|
||||
import { state } from '../../state/index.js';
|
||||
|
||||
export class GlobalContextMenu extends BaseContextMenu {
|
||||
constructor() {
|
||||
@@ -19,12 +20,40 @@ export class GlobalContextMenu extends BaseContextMenu {
|
||||
console.error('Failed to trigger example images cleanup:', error);
|
||||
});
|
||||
break;
|
||||
case 'download-example-images':
|
||||
this.downloadExampleImages(menuItem).catch((error) => {
|
||||
console.error('Failed to trigger example images download:', error);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.warn(`Unhandled global context menu action: ${action}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async downloadExampleImages(menuItem) {
|
||||
const exampleImagesManager = window.exampleImagesManager;
|
||||
|
||||
if (!exampleImagesManager) {
|
||||
showToast('globalContextMenu.downloadExampleImages.unavailable', {}, 'error');
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadPath = state?.global?.settings?.example_images_path;
|
||||
if (!downloadPath) {
|
||||
showToast('globalContextMenu.downloadExampleImages.missingPath', {}, 'warning');
|
||||
return;
|
||||
}
|
||||
|
||||
menuItem?.classList.add('disabled');
|
||||
|
||||
try {
|
||||
await exampleImagesManager.handleDownloadButton();
|
||||
} finally {
|
||||
menuItem?.classList.remove('disabled');
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupExampleImagesFolders(menuItem) {
|
||||
if (this._cleanupInProgress) {
|
||||
return;
|
||||
|
||||
@@ -85,6 +85,9 @@
|
||||
</div>
|
||||
|
||||
<div id="globalContextMenu" class="context-menu">
|
||||
<div class="context-menu-item" data-action="download-example-images">
|
||||
<i class="fas fa-download"></i> <span>{{ t('globalContextMenu.downloadExampleImages.label') }}</span>
|
||||
</div>
|
||||
<div class="context-menu-item" data-action="cleanup-example-images-folders">
|
||||
<i class="fas fa-trash-restore"></i> <span>{{ t('globalContextMenu.cleanupExampleImages.label') }}</span>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user