From 5e32cce930c001d19f1d0e274e190eaecad3307b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9B=AE=E6=A3=83?= Date: Tue, 9 Jul 2024 17:10:23 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E8=B7=AF=E5=BE=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/TGClient.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/utils/TGClient.ts b/src/utils/TGClient.ts index 4b1e3594..03e37d55 100644 --- a/src/utils/TGClient.ts +++ b/src/utils/TGClient.ts @@ -909,19 +909,16 @@ class TGClient { var buffer = new Uint8Array(atob('${image}'.split(',')[1]).split('').map(function(item) { return item.charCodeAt(0); })); - var _t = window.__TAURI__; - var savePath = await _t.path.downloadDir() + Date.now() + '.png'; - var save = await _t.dialog.save({ - title: '保存图片', - filters: [{ name: '图片', extensions: ['png'] }], - defaultPath: savePath, + var _path = window.__TAURI__.path; + var saveDefault = await _path.downloadDir() + _path.sep() + Date.now() + ".png"; + var savePath = await window.__TAURI_PLUGIN_DIALOG__.save({ + title: "保存图片", + filters: [{ name: "图片", extensions: ["png"] }], + defaultPath: saveDefault, }); - if (save) { - await _t.fs.writeBinaryFile({ - contents: buffer, - path: save, - }); - alert('保存成功'); + if (savePath !== null) { + await window.__TAURI_PLUGIN_FS__.writeFile(savePath, buffer); + alert("保存成功"); } mhyWebBridge('${arg.callback}', {}); })();`;