From 4eadd58473c2d5cb17143d4d13bf7a7632ad09e0 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 26 Mar 2025 16:20:20 +0700 Subject: [PATCH] refactor: update image URL variable and improve translation keys in CanvasComponent and MainLayout --- src/components/CanvasComponent.vue | 99 ++++++++++++------------------ src/layouts/MainLayout.vue | 2 +- 2 files changed, 39 insertions(+), 62 deletions(-) diff --git a/src/components/CanvasComponent.vue b/src/components/CanvasComponent.vue index a6297f6b..e53554d4 100644 --- a/src/components/CanvasComponent.vue +++ b/src/components/CanvasComponent.vue @@ -18,7 +18,7 @@ const cropper = ref(); const tab = ref('draw'); const uploadFile = ref(undefined); -const profileUrl = ref(''); +const imgUrl = ref(''); const inputFile = (() => { const element = document.createElement('input'); element.type = 'file'; @@ -26,7 +26,7 @@ const inputFile = (() => { const reader = new FileReader(); reader.addEventListener('load', () => { - if (typeof reader.result === 'string') profileUrl.value = reader.result; + if (typeof reader.result === 'string') imgUrl.value = reader.result; }); element.addEventListener('change', () => { @@ -39,9 +39,11 @@ const inputFile = (() => { return element; })(); -async function initializeSignaturePad(canva?: HTMLCanvasElement) { - if (canva) { - signaturePad.value = new SignaturePad(canva, { +async function initializeSignaturePad() { + const canvas = canvasRef.value; + + if (canvas) { + signaturePad.value = new SignaturePad(canvas, { backgroundColor: isDarkActive.value ? 'rgb(21,25,29)' : 'rgb(248,249,250)', @@ -82,29 +84,27 @@ function clearCanvas() { } function clearUpload() { - profileUrl.value = ''; + imgUrl.value = ''; } watch( () => tab.value, async () => { - await initializeSignaturePad(canvasRef.value); - await initializeCropper(imageRef.value); + await initializeSignaturePad(); }, ); onMounted(async () => { - await initializeSignaturePad(canvasRef.value); - await initializeCropper(imageRef.value); + await initializeSignaturePad(); });