From 2531b085383b94a16823b1599cee74381904bfaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Thu, 28 Nov 2024 10:41:51 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=8F=90=E9=AB=98=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/file.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/common/file.ts b/src/common/file.ts index 487325ae..1d1f5a67 100644 --- a/src/common/file.ts +++ b/src/common/file.ts @@ -190,16 +190,18 @@ export async function checkUriType(Uri: string) { }, Uri); if (LocalFileRet) return LocalFileRet; const OtherFileRet = await solveProblem((uri: string) => { - //再判断是否是Http + // 再判断是否是Http if (uri.startsWith('http://') || uri.startsWith('https://')) { return { Uri: uri, Type: FileUriType.Remote }; } - //再判断是否是Base64 - if (uri.startsWith('base64://')) { + // 再判断是否是Base64 + if (uri.startsWith('base64:')) { return { Uri: uri, Type: FileUriType.Base64 }; } - if (uri.startsWith('file://')) { + if (uri.startsWith('file:')) { let filePath: string = uri.slice(7); + // file://C:\1.jpg + // file:///test/1.jpg return { Uri: filePath, Type: FileUriType.Local }; } if (uri.startsWith('data:')) { @@ -235,7 +237,7 @@ export async function uri2local(dir: string, uri: string, filename: string | und fs.copyFileSync(HandledUri, filePath); return { success: true, errMsg: '', fileName: filename, ext: fileExt, path: filePath }; } - + //接下来都要有文件名 if (UriType == FileUriType.Remote) { const pathInfo = path.parse(decodeURIComponent(new URL(HandledUri).pathname));