Skip to content

Commit

Permalink
🐛 修复帖子内图片无法保存到本地
Browse files Browse the repository at this point in the history
  • Loading branch information
BTMuli committed Jul 11, 2024
1 parent 012be32 commit 3f93be2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
31 changes: 31 additions & 0 deletions src-tauri/capabilities/SubWindow.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"permissions": [
"app:allow-version",
"app:default",
"dialog:allow-save",
"dialog:default",
"event:allow-listen",
"event:default",
"fs:default",
"http:allow-fetch",
"log:allow-log",
"log:default",
Expand All @@ -21,6 +24,34 @@
"window:allow-set-title",
"window:allow-set-fullscreen",
"window:allow-show",
{
"identifier": "fs:allow-exists",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-mkdir",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-read-dir",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-read-text-file",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-remove",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-write-file",
"allow": [{ "path": "**" }]
},
{
"identifier": "fs:allow-write-text-file",
"allow": [{ "path": "**" }]
},
{
"identifier": "http:default",
"allow": [
Expand Down
10 changes: 10 additions & 0 deletions src-tauri/gen/schemas/capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,11 @@
"permissions": [
"app:allow-version",
"app:default",
"dialog:allow-save",
"dialog:default",
"event:allow-listen",
"event:default",
"fs:default",
"http:allow-fetch",
"log:allow-log",
"log:default",
Expand All @@ -74,6 +77,13 @@
"window:allow-set-title",
"window:allow-set-fullscreen",
"window:allow-show",
{ "identifier": "fs:allow-exists", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-mkdir", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-read-dir", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-read-text-file", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-remove", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-write-file", "allow": [{ "path": "**" }] },
{ "identifier": "fs:allow-write-text-file", "allow": [{ "path": "**" }] },
{
"identifier": "http:default",
"allow": [{ "url": "https://*.miyoushe.com/*" }, { "url": "https://*.mihoyo.com/*" }]
Expand Down
4 changes: 2 additions & 2 deletions src/utils/TGShare.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function saveCanvasImg(
const res = await save({
title: "保存图片",
filters: [{ name: "图片", extensions: [format] }],
defaultPath: `${await path.downloadDir()}${path.sep}${filename}.${format}`,
defaultPath: `${await path.downloadDir()}${path.sep()}${filename}.${format}`,
});
if (res === null) {
await TGLogger.Info(`[saveCanvasImg][${filename}] 未选择保存路径`);
Expand Down Expand Up @@ -63,7 +63,7 @@ export async function saveImgLocal(url: string): Promise<string> {
* @returns {Promise<Uint8Array>} 图片 buffer
*/
export async function getImageBuffer(url: string): Promise<Uint8Array> {
const res = await TGHttp<Uint8Array>(url, { method: "GET" });
const res = await TGHttp<Uint8Array>(url, { method: "GET", isBlob: true });
return new Uint8Array(res);
}

Expand Down

0 comments on commit 3f93be2

Please sign in to comment.