mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-24 14:42:11 -03:00
Merge pull request #469 from willmiao/codex/add-download-example-images-to-global-context-menu
feat: add download example images to global context menu
This commit is contained in:
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -123,6 +123,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"globalContextMenu": {
|
"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": {
|
"cleanupExampleImages": {
|
||||||
"label": "Clean up example image folders",
|
"label": "Clean up example image folders",
|
||||||
"success": "Moved {count} folder(s) to the deleted folder",
|
"success": "Moved {count} folder(s) to the deleted folder",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { BaseContextMenu } from './BaseContextMenu.js';
|
import { BaseContextMenu } from './BaseContextMenu.js';
|
||||||
import { showToast } from '../../utils/uiHelpers.js';
|
import { showToast } from '../../utils/uiHelpers.js';
|
||||||
|
import { state } from '../../state/index.js';
|
||||||
|
|
||||||
export class GlobalContextMenu extends BaseContextMenu {
|
export class GlobalContextMenu extends BaseContextMenu {
|
||||||
constructor() {
|
constructor() {
|
||||||
@@ -19,12 +20,40 @@ export class GlobalContextMenu extends BaseContextMenu {
|
|||||||
console.error('Failed to trigger example images cleanup:', error);
|
console.error('Failed to trigger example images cleanup:', error);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case 'download-example-images':
|
||||||
|
this.downloadExampleImages(menuItem).catch((error) => {
|
||||||
|
console.error('Failed to trigger example images download:', error);
|
||||||
|
});
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
console.warn(`Unhandled global context menu action: ${action}`);
|
console.warn(`Unhandled global context menu action: ${action}`);
|
||||||
break;
|
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) {
|
async cleanupExampleImagesFolders(menuItem) {
|
||||||
if (this._cleanupInProgress) {
|
if (this._cleanupInProgress) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -85,6 +85,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="globalContextMenu" class="context-menu">
|
<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">
|
<div class="context-menu-item" data-action="cleanup-example-images-folders">
|
||||||
<i class="fas fa-trash-restore"></i> <span>{{ t('globalContextMenu.cleanupExampleImages.label') }}</span>
|
<i class="fas fa-trash-restore"></i> <span>{{ t('globalContextMenu.cleanupExampleImages.label') }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user