diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index d1a39d8dd908299a7d96d66d1e3567193755bb51..a5babc476675dfcd638dbf5eda64f7879d389d12 100644 --- a/src/core/view/components/canvas/index.vue +++ b/src/core/view/components/canvas/index.vue @@ -344,7 +344,7 @@ export default { if (window.plus && src.indexOf('http://') !== 0 && src.indexOf('https://') !== 0) { loadFile(src) - } else if (/^data:[a-z-]+\/[a-z-]+;base64,/.test(src)) { + } else if (/^data:.*,.*/.test(src)) { sefl._images[src].src = src } else { loadUrl(src) diff --git a/src/platforms/app-plus/helpers/get-real-path.js b/src/platforms/app-plus/helpers/get-real-path.js index 72033e8eeb5936a8935381765e31325fb93a8ee8..78ead12c6f4f68834cc4e6858bf9567d6f25cdd6 100644 --- a/src/platforms/app-plus/helpers/get-real-path.js +++ b/src/platforms/app-plus/helpers/get-real-path.js @@ -1,7 +1,7 @@ import getRealRoute from 'uni-helpers/get-real-route' const SCHEME_RE = /^([a-z-]+:)?\/\//i -const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ +const DATA_RE = /^data:.*,.*/ function addBase (filePath) { return filePath @@ -16,7 +16,7 @@ export default function getRealPath (filePath) { } } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath) || filePath.indexOf('blob:') === 0) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) { return filePath } diff --git a/src/platforms/app-plus/service/api/util.js b/src/platforms/app-plus/service/api/util.js index e6221cfbfe4f39ad7831f72ece98aaea3a9c9fa4..d7c3d97a1983111a20e1dd361435357653bc72e7 100644 --- a/src/platforms/app-plus/service/api/util.js +++ b/src/platforms/app-plus/service/api/util.js @@ -44,7 +44,7 @@ const _handleLocalPath = filePath => { export function getRealPath (filePath) { const SCHEME_RE = /^([a-z-]+:)?\/\//i - const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ + const DATA_RE = /^data:.*,.*/ // 无协议的情况补全 https if (filePath.indexOf('//') === 0) { @@ -52,7 +52,7 @@ export function getRealPath (filePath) { } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath)) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath)) { return filePath } diff --git a/src/platforms/h5/helpers/get-real-path.js b/src/platforms/h5/helpers/get-real-path.js index 56b04864539eb7fa2dc1fc0991b9d2f14e7da2df..0b018beca4426037c549aed50facf451b36c1aef 100644 --- a/src/platforms/h5/helpers/get-real-path.js +++ b/src/platforms/h5/helpers/get-real-path.js @@ -1,7 +1,7 @@ import getRealRoute from 'uni-helpers/get-real-route' const SCHEME_RE = /^([a-z-]+:)?\/\//i -const BASE64_RE = /^data:[a-z-]+\/[a-z-]+;base64,/ +const DATA_RE = /^data:.*,.*/ function addBase (filePath) { if (__uniConfig.router.base) { @@ -19,7 +19,7 @@ export default function getRealPath (filePath) { } } // 网络资源或base64 - if (SCHEME_RE.test(filePath) || BASE64_RE.test(filePath) || filePath.indexOf('blob:') === 0) { + if (SCHEME_RE.test(filePath) || DATA_RE.test(filePath) || filePath.indexOf('blob:') === 0) { return filePath }