From 195e2d37bc1b6a2377ae678f6f61257c177b4489 Mon Sep 17 00:00:00 2001 From: Allilengyi Date: Sun, 4 Feb 2024 01:26:14 +0100 Subject: [PATCH] migrated files to vue.js 3.x --- src/components/Image/BlurhashImg.vue | 30 ++++---- src/components/Image/BlurhashImgWrapper.vue | 80 ++++++--------------- 2 files changed, 36 insertions(+), 74 deletions(-) diff --git a/src/components/Image/BlurhashImg.vue b/src/components/Image/BlurhashImg.vue index 306efdc87..fa93943f3 100644 --- a/src/components/Image/BlurhashImg.vue +++ b/src/components/Image/BlurhashImg.vue @@ -18,25 +18,21 @@ const props = withDefaults( const canvas = ref(undefined); onMounted(() => { - try { - if (canvas.value) { - const pixels = decode(props.hash, 128, 32); - const imageData = new ImageData(pixels, 128, 32); - const context = canvas.value.getContext("2d"); - if (context) { - context.putImageData(imageData, 0, 0); - } - } + updateCanvas(); +}); - @Watch("hash") - updateHashChange(): void { - try { - const pixels = decode(this.hash, 128, 32); - const imageData = new ImageData(pixels, 128, 32); - const context = this.canvas.getContext("2d"); - context.putImageData(imageData, 0, 0); +watch(() => props.hash, () => { + updateCanvas(); +}); + +function updateCanvas() { + try { + const pixels = decode(props.hash, 128, 32); + const imageData = new ImageData(pixels, 128, 32); + const context = canvasRef.value.getContext('2d'); + context.putImageData(imageData, 0, 0); } catch (e) { console.error(e); } -}); +} diff --git a/src/components/Image/BlurhashImgWrapper.vue b/src/components/Image/BlurhashImgWrapper.vue index 8a6b15b01..c1bb3a555 100644 --- a/src/components/Image/BlurhashImgWrapper.vue +++ b/src/components/Image/BlurhashImgWrapper.vue @@ -10,71 +10,37 @@ - -