feat(context-menu): add example image download entry

This commit is contained in:
pixelpaws
2025-09-23 20:49:44 +08:00
parent 656f1755fd
commit cd3e32bf4b
11 changed files with 77 additions and 0 deletions

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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",

View File

@@ -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;

View File

@@ -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>