fix(frontend): blurhashが無い場合に何も出力されないのを修正 (#14250)

* fix(frontend): blurhashが無い場合に何も出力されないのを修正

* Update Changelog

* Update packages/frontend/src/components/MkImgWithBlurhash.vue

Co-authored-by: tamaina <tamaina@hotmail.co.jp>

* attempt to fix test

* Update packages/frontend/src/components/MkImgWithBlurhash.vue

Co-authored-by: tamaina <tamaina@hotmail.co.jp>

* attempt to ignore test

---------

Co-authored-by: tamaina <tamaina@hotmail.co.jp>
This commit is contained in:
かっこかり
2024-07-19 10:11:44 +09:00
committed by GitHub
parent 6920f0fa7e
commit 56a43dc01d
2 changed files with 8 additions and 3 deletions

View File

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