refactor(frontend): refactor uploader image editing features and menu

Replaces separate 'effect' and 'crop' features with a unified 'imageEditing' feature in the uploader. Groups crop and effect actions under a new parent 'editImage' menu item, adds localization for 'editImage', and updates supported types accordingly.
This commit is contained in:
syuilo 2025-06-26 12:10:15 +09:00
parent 8fda4fefaf
commit bf57557ba3
3 changed files with 56 additions and 61 deletions

4
locales/index.d.ts vendored
View File

@ -11991,6 +11991,10 @@ export interface Locale extends ILocale {
}; };
}; };
"_uploader": { "_uploader": {
/**
*
*/
"editImage": string;
/** /**
* {x} * {x}
*/ */

View File

@ -3208,6 +3208,7 @@ _serverSetupWizard:
text3: "支援者向け特典もあります!" text3: "支援者向け特典もあります!"
_uploader: _uploader:
editImage: "画像の編集"
compressedToX: "{x}に圧縮" compressedToX: "{x}に圧縮"
savedXPercent: "{x}%節約" savedXPercent: "{x}%節約"
abortConfirm: "アップロードされていないファイルがありますが、中止しますか?" abortConfirm: "アップロードされていないファイルがありますが、中止しますか?"

View File

@ -19,9 +19,8 @@ import { ensureSignin } from '@/i.js';
import { WatermarkRenderer } from '@/utility/watermark.js'; import { WatermarkRenderer } from '@/utility/watermark.js';
export type UploaderFeatures = { export type UploaderFeatures = {
effect?: boolean; imageEditing?: boolean;
watermark?: boolean; watermark?: boolean;
crop?: boolean;
}; };
const THUMBNAIL_SUPPORTED_TYPES = [ const THUMBNAIL_SUPPORTED_TYPES = [
@ -38,12 +37,6 @@ const IMAGE_COMPRESSION_SUPPORTED_TYPES = [
'image/svg+xml', 'image/svg+xml',
]; ];
const CROPPING_SUPPORTED_TYPES = [
'image/jpeg',
'image/png',
'image/webp',
];
const IMAGE_EDITING_SUPPORTED_TYPES = [ const IMAGE_EDITING_SUPPORTED_TYPES = [
'image/jpeg', 'image/jpeg',
'image/png', 'image/png',
@ -55,7 +48,6 @@ const WATERMARK_SUPPORTED_TYPES = IMAGE_EDITING_SUPPORTED_TYPES;
const IMAGE_PREPROCESS_NEEDED_TYPES = [ const IMAGE_PREPROCESS_NEEDED_TYPES = [
...WATERMARK_SUPPORTED_TYPES, ...WATERMARK_SUPPORTED_TYPES,
...IMAGE_COMPRESSION_SUPPORTED_TYPES, ...IMAGE_COMPRESSION_SUPPORTED_TYPES,
...CROPPING_SUPPORTED_TYPES,
...IMAGE_EDITING_SUPPORTED_TYPES, ...IMAGE_EDITING_SUPPORTED_TYPES,
]; ];
@ -112,17 +104,14 @@ export function useUploader(options: {
multiple?: boolean; multiple?: boolean;
features?: UploaderFeatures; features?: UploaderFeatures;
} = {}) { } = {}) {
const $i = ensureSignin();
const events = new EventEmitter<{ const events = new EventEmitter<{
'itemUploaded': (ctx: { item: UploaderItem; }) => void; 'itemUploaded': (ctx: { item: UploaderItem; }) => void;
}>(); }>();
const uploaderFeatures = computed<Required<UploaderFeatures>>(() => { const uploaderFeatures = computed<Required<UploaderFeatures>>(() => {
return { return {
effect: options.features?.effect ?? true, imageEditing: options.features?.imageEditing ?? true,
watermark: options.features?.watermark ?? true, watermark: options.features?.watermark ?? true,
crop: options.features?.crop ?? true,
}; };
}); });
@ -215,13 +204,17 @@ export function useUploader(options: {
} }
if ( if (
uploaderFeatures.value.crop && uploaderFeatures.value.imageEditing &&
CROPPING_SUPPORTED_TYPES.includes(item.file.type) && IMAGE_EDITING_SUPPORTED_TYPES.includes(item.file.type) &&
!item.preprocessing && !item.preprocessing &&
!item.uploading && !item.uploading &&
!item.uploaded !item.uploaded
) { ) {
menu.push({ menu.push({
type: 'parent',
icon: 'ti ti-photo-edit',
text: i18n.ts._uploader.editImage,
children: [{
icon: 'ti ti-crop', icon: 'ti ti-crop',
text: i18n.ts.cropImage, text: i18n.ts.cropImage,
action: async () => { action: async () => {
@ -237,17 +230,13 @@ export function useUploader(options: {
triggerRef(items); triggerRef(items);
}); });
}, },
}); }, /*{
} icon: 'ti ti-resize',
text: i18n.ts.resize,
if ( action: async () => {
uploaderFeatures.value.effect && // TODO
IMAGE_EDITING_SUPPORTED_TYPES.includes(item.file.type) && },
!item.preprocessing && },*/ {
!item.uploading &&
!item.uploaded
) {
menu.push({
icon: 'ti ti-sparkles', icon: 'ti ti-sparkles',
text: i18n.ts._imageEffector.title + ' (BETA)', text: i18n.ts._imageEffector.title + ' (BETA)',
action: async () => { action: async () => {
@ -269,6 +258,7 @@ export function useUploader(options: {
closed: () => dispose(), closed: () => dispose(),
}); });
}, },
}],
}); });
} }