From d1eadbd9080b810f4573cd56d2087b8040b70e42 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Thu, 19 Dec 2024 23:36:47 +0900 Subject: [PATCH] =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=81=8C=E4=B8=8D=E5=8D=81?= =?UTF-8?q?=E5=88=86=E3=81=AA=E5=A0=B4=E5=90=88=E3=81=AF=E3=82=A6=E3=82=A9?= =?UTF-8?q?=E3=83=BC=E3=82=BF=E3=83=BC=E3=83=9E=E3=83=BC=E3=82=AF=E3=82=92?= =?UTF-8?q?=E3=81=8B=E3=81=91=E3=82=89=E3=82=8C=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/frontend/src/components/MkPostForm.vue | 7 ++++++- packages/frontend/src/scripts/select-file.ts | 6 +++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/frontend/src/components/MkPostForm.vue b/packages/frontend/src/components/MkPostForm.vue index 38874ecb21..04efe343ac 100644 --- a/packages/frontend/src/components/MkPostForm.vue +++ b/packages/frontend/src/components/MkPostForm.vue @@ -130,6 +130,7 @@ import { claimAchievement } from '@/scripts/achievements.js'; import { emojiPicker } from '@/scripts/emoji-picker.js'; import { mfmFunctionPicker } from '@/scripts/mfm-function-picker.js'; import type { PostFormProps } from '@/types/post-form.js'; +import { canPreview } from '@/scripts/watermark'; const $i = signinRequired(); @@ -598,7 +599,11 @@ async function onPaste(ev: ClipboardEvent) { const formatted = `${formatTimeString(new Date(file.lastModified), defaultStore.state.pastedFileName).replace(/{{number}}/g, `${i + 1}`)}${ext}`; if (file.type.startsWith('image/')) { - if (shouldApplyWatermark == null && defaultStore.state.clipboardWatermarkBehavior === 'confirm') { + if ( + shouldApplyWatermark == null && + defaultStore.state.clipboardWatermarkBehavior === 'confirm' && + canPreview(defaultStore.reactiveState.watermarkConfig.value) + ) { const { canceled } = await os.confirm({ type: 'info', text: i18n.ts.watermarkConfirm, diff --git a/packages/frontend/src/scripts/select-file.ts b/packages/frontend/src/scripts/select-file.ts index 747ce3600e..6c0d1526c6 100644 --- a/packages/frontend/src/scripts/select-file.ts +++ b/packages/frontend/src/scripts/select-file.ts @@ -12,6 +12,7 @@ import { i18n } from '@/i18n.js'; import { defaultStore } from '@/store.js'; import { uploadFile } from '@/scripts/upload.js'; import type { MenuItem } from '@/types/menu.js'; +import { canPreview } from './watermark.js'; export function chooseFileFromPc(opts?: { multiple?: boolean; @@ -94,7 +95,9 @@ function select(src: HTMLElement | EventTarget | null, opts?: { }): Promise { return new Promise((res, rej) => { const keepOriginal = ref(defaultStore.state.keepOriginalUploading); - const useWatermark = ref(opts?.dontUseWatermark ? false : defaultStore.state.useWatermark); + + const watermarkCanPreview = canPreview(defaultStore.reactiveState.watermarkConfig.value); + const useWatermark = ref(opts?.dontUseWatermark || !watermarkCanPreview ? false : defaultStore.state.useWatermark); const menu: MenuItem[] = []; @@ -115,6 +118,7 @@ function select(src: HTMLElement | EventTarget | null, opts?: { menu.push({ type: 'switch', text: i18n.ts.useWatermark, + disabled: !watermarkCanPreview, ref: useWatermark, }); }