From 8ae1d578ff5dd55420cf7ff4bb1d59bfa11faa9d Mon Sep 17 00:00:00 2001 From: BTMuli Date: Fri, 3 Nov 2023 00:13:16 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=BF=9D=E5=AD=98=E5=A4=B1=E8=B4=A5=EF=BC=88=E7=9C=9F?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix #56 --- src/utils/TGClient.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/TGClient.ts b/src/utils/TGClient.ts index 03a214b8..ef476de7 100644 --- a/src/utils/TGClient.ts +++ b/src/utils/TGClient.ts @@ -442,7 +442,8 @@ class TGClient { */ async onClickImg(payload: any): Promise { const url = payload.image_list[0].url; - const savePath = `${await path.downloadDir()}${path.sep}${Date.now().toString()}.png`; + const imageType = url.endsWith(".png") ? "png" : url.endsWith(".jpg") ? "jpg" : "png"; + const savePath = `${await path.downloadDir()}${path.sep}${Date.now().toString()}.${imageType}`; const executeJS = `javascript:(async function() { const _t = window.__TAURI__; const savePath = await _t.dialog.save({ @@ -456,9 +457,8 @@ class TGClient { responseType: _t.http.ResponseType.Binary }); const buffer = new Uint8Array(resBlob.data); - const blob = new Blob([buffer], { type: 'image/png' }); await _t.fs.writeBinaryFile({ - contents: blob, + contents: buffer, path: savePath, }); alert('保存成功');