From 689411c19a267630855251f7d54999250faabbf7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Wed, 21 Dec 2022 16:00:00 +0900 Subject: [PATCH] refactor(client): refacotr MkMediaCaption --- locales/ja-JP.yml | 1 + .../client/src/components/MkDrive.file.vue | 18 +- .../components/MkFileCaptionEditWindow.vue | 175 ++++++++++++ .../client/src/components/MkMediaCaption.vue | 263 ------------------ .../src/components/MkPostFormAttaches.vue | 17 +- 5 files changed, 188 insertions(+), 286 deletions(-) create mode 100644 packages/client/src/components/MkFileCaptionEditWindow.vue delete mode 100644 packages/client/src/components/MkMediaCaption.vue diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 0e8e22752f..7737e6044e 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -908,6 +908,7 @@ sendPushNotificationReadMessage: "通知やメッセージが既読になった sendPushNotificationReadMessageCaption: "「{emptyPushNotificationMessage}」という通知が一瞬表示されるようになります。端末の電池消費量が増加する可能性があります。" windowMaximize: "最大化" windowRestore: "元に戻す" +caption: "キャプション" _sensitiveMediaDetection: description: "機械学習を使って自動でセンシティブなメディアを検出し、モデレーションに役立てることができます。サーバーの負荷が少し増えます。" diff --git a/packages/client/src/components/MkDrive.file.vue b/packages/client/src/components/MkDrive.file.vue index 11bd9e9e3b..8c17c0530a 100644 --- a/packages/client/src/components/MkDrive.file.vue +++ b/packages/client/src/components/MkDrive.file.vue @@ -71,7 +71,7 @@ function getMenu() { action: toggleSensitive, }, { text: i18n.ts.describeFile, - icon: 'ti ti-forms', + icon: 'ti ti-text-caption', action: describe, }, null, { text: i18n.ts.copyUrl, @@ -134,20 +134,14 @@ function rename() { } function describe() { - os.popup(defineAsyncComponent(() => import('@/components/MkMediaCaption.vue')), { - title: i18n.ts.describeFile, - input: { - placeholder: i18n.ts.inputNewDescription, - default: props.file.comment != null ? props.file.comment : '', - }, - image: props.file, + os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), { + default: props.file.comment != null ? props.file.comment : '', + file: props.file, }, { - done: result => { - if (!result || result.canceled) return; - let comment = result.result; + done: caption => { os.api('drive/files/update', { fileId: props.file.id, - comment: comment.length === 0 ? null : comment, + comment: caption.length === 0 ? null : caption, }); }, }, 'closed'); diff --git a/packages/client/src/components/MkFileCaptionEditWindow.vue b/packages/client/src/components/MkFileCaptionEditWindow.vue new file mode 100644 index 0000000000..73875251f0 --- /dev/null +++ b/packages/client/src/components/MkFileCaptionEditWindow.vue @@ -0,0 +1,175 @@ + + + + + diff --git a/packages/client/src/components/MkMediaCaption.vue b/packages/client/src/components/MkMediaCaption.vue deleted file mode 100644 index c25755d762..0000000000 --- a/packages/client/src/components/MkMediaCaption.vue +++ /dev/null @@ -1,263 +0,0 @@ - - - - - diff --git a/packages/client/src/components/MkPostFormAttaches.vue b/packages/client/src/components/MkPostFormAttaches.vue index 955d835f25..2e16cc52a7 100644 --- a/packages/client/src/components/MkPostFormAttaches.vue +++ b/packages/client/src/components/MkPostFormAttaches.vue @@ -70,17 +70,12 @@ async function rename(file) { } async function describe(file) { - os.popup(defineAsyncComponent(() => import('@/components/MkMediaCaption.vue')), { - title: i18n.ts.describeFile, - input: { - placeholder: i18n.ts.inputNewDescription, - default: file.comment !== null ? file.comment : '', - }, - image: file, + os.popup(defineAsyncComponent(() => import('@/components/MkFileCaptionEditWindow.vue')), { + default: file.comment !== null ? file.comment : '', + file: file, }, { - done: result => { - if (!result || result.canceled) return; - let comment = result.result.length === 0 ? null : result.result; + done: caption => { + let comment = caption.length === 0 ? null : caption; os.api('drive/files/update', { fileId: file.id, comment: comment, @@ -103,7 +98,7 @@ function showFileMenu(file, ev: MouseEvent) { action: () => { toggleSensitive(file); }, }, { text: i18n.ts.describeFile, - icon: 'ti ti-forms', + icon: 'ti ti-text-caption', action: () => { describe(file); }, }, { text: i18n.ts.attachCancel,