From 29cf2a08b11f0951fde3ee2458232de1121e61ac Mon Sep 17 00:00:00 2001 From: qiang Date: Mon, 26 Apr 2021 15:25:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=94=AF=E6=8C=81=E4=BC=A0=E5=85=A5?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E7=BB=9D=E5=AF=B9=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/platforms/app-plus/helpers/get-real-path.js | 11 +++++++---- src/platforms/app-plus/service/api/util.js | 6 +++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/platforms/app-plus/helpers/get-real-path.js b/src/platforms/app-plus/helpers/get-real-path.js index 4cd92cc2c..a3216ae3d 100644 --- a/src/platforms/app-plus/helpers/get-real-path.js +++ b/src/platforms/app-plus/helpers/get-real-path.js @@ -22,10 +22,13 @@ function addBase (filePath) { export default function getRealPath (filePath) { if (filePath.indexOf('/') === 0) { if (filePath.indexOf('//') === 0) { - filePath = 'https:' + filePath - } else { - return addBase(filePath.substr(1)) + return 'https:' + filePath } + // 平台绝对路径 安卓、iOS + if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) { + return 'file://' + filePath + } + return addBase(filePath.substr(1)) } // 网络资源或base64 if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) { @@ -43,4 +46,4 @@ export default function getRealPath (filePath) { } return filePath -} +} diff --git a/src/platforms/app-plus/service/api/util.js b/src/platforms/app-plus/service/api/util.js index f9cc4393c..f64c0cfb4 100644 --- a/src/platforms/app-plus/service/api/util.js +++ b/src/platforms/app-plus/service/api/util.js @@ -60,7 +60,7 @@ export function getRealPath (filePath) { // 无协议的情况补全 https if (filePath.indexOf('//') === 0) { - filePath = 'https:' + filePath + return 'https:' + filePath } // 网络资源或base64 @@ -75,6 +75,10 @@ export function getRealPath (filePath) { const wwwPath = 'file://' + _handleLocalPath('_www') // 绝对路径转换为本地文件系统路径 if (filePath.indexOf('/') === 0) { + // 平台绝对路径 安卓、iOS + if (filePath.startsWith('/storage/') || filePath.includes('/Containers/Data/Application/')) { + return 'file://' + filePath + } return wwwPath + filePath } // 相对资源 -- GitLab