diff --git a/src/platforms/app-plus/helpers/get-real-path.js b/src/platforms/app-plus/helpers/get-real-path.js index 4cd92cc2c0acafe6a226e7b96f58874a1896e033..a3216ae3db8a7e5926a9e1063c1b621e8545b606 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 f9cc4393ca17827092f96a861c8491dc637021bb..f64c0cfb4ffc17954a39ad4b6ef5aec75c628dea 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 } // 相对资源