From 3a42c58013f3e617854ccabfef15b00924c943e9 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Fri, 5 Apr 2024 11:45:54 +0800 Subject: [PATCH] :bug: Fix cannot read image in some browser --- src/views/users/me/personalize.vue | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/views/users/me/personalize.vue b/src/views/users/me/personalize.vue index b2e57f7..1feb96d 100644 --- a/src/views/users/me/personalize.vue +++ b/src/views/users/me/personalize.vue @@ -38,6 +38,7 @@ +
+
+ + + + Due to limitations of some browsers (such as Safari). You cannot edit your personal images in this browser. + We recommend Chrome or any Chromium-based browser. You can also use a PWA for a better experience! + +
@@ -90,7 +99,7 @@ :stencil-props="{ aspectRatio: image.ratio }" /> - + Cancel @@ -123,6 +132,8 @@ const image = ref({ const cropper = ref() const cropping = ref(false) +const canEditImage = computed(() => navigator.userAgent.toLowerCase().indexOf("safari") > -1) + watch( id.userinfo, (val) => { @@ -200,8 +211,12 @@ async function applyImage() { const payload = new FormData() payload.set(image.value.type, await new Promise((resolve, reject) => { canvas.toBlob((data: Blob | null) => { - if (data == null) reject("Cannot get blob data") - else resolve(data) + if (data == null) { + showErrorSnackbar("Cannot get blob data through canvas, please try again in desktop browser.") + reject("Cannot get blob data") + } else { + resolve(data) + } }) }))