From 56a43dc01d15f1d41bbda9a973da18294389d7c7 Mon Sep 17 00:00:00 2001 From: かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:11:44 +0900 Subject: fix(frontend): blurhashが無い場合に何も出力されないのを修正 (#14250) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(frontend): blurhashが無い場合に何も出力されないのを修正 * Update Changelog * Update packages/frontend/src/components/MkImgWithBlurhash.vue Co-authored-by: tamaina * attempt to fix test * Update packages/frontend/src/components/MkImgWithBlurhash.vue Co-authored-by: tamaina * attempt to ignore test --------- Co-authored-by: tamaina --- packages/frontend/src/components/MkImgWithBlurhash.vue | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'packages/frontend/src/components') diff --git a/packages/frontend/src/components/MkImgWithBlurhash.vue b/packages/frontend/src/components/MkImgWithBlurhash.vue index 617404f5c4..8d301f16bd 100644 --- a/packages/frontend/src/components/MkImgWithBlurhash.vue +++ b/packages/frontend/src/components/MkImgWithBlurhash.vue @@ -151,22 +151,26 @@ function drawImage(bitmap: CanvasImageSource) { } function drawAvg() { - if (!canvas.value || !props.hash) return; + if (!canvas.value) return; + + const color = (props.hash != null && extractAvgColorFromBlurhash(props.hash)) || '#888'; const ctx = canvas.value.getContext('2d'); if (!ctx) return; // avgColorでお茶をにごす ctx.beginPath(); - ctx.fillStyle = extractAvgColorFromBlurhash(props.hash) ?? '#888'; + ctx.fillStyle = color; ctx.fillRect(0, 0, canvasWidth.value, canvasHeight.value); } async function draw() { - if (props.hash == null) return; + if (import.meta.env.MODE === 'test' && props.hash == null) return; drawAvg(); + if (props.hash == null) return; + if (props.onlyAvgColor) return; const work = await canvasPromise; -- cgit v1.2.3-freya