From 3a6811da8273c8f315c5c2f092b0c1ecee1f0952 Mon Sep 17 00:00:00 2001 From: qiang Date: Thu, 5 Sep 2019 12:24:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=20svg=20=E6=88=96?= =?UTF-8?q?=E9=9D=9E=20base64=20=E6=A0=BC=E5=BC=8F=E7=9A=84=20Data=20URI?= =?UTF-8?q?=20=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=20fixed=20#668?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/view/components/canvas/index.vue | 2 +- src/platforms/app-plus/helpers/get-real-path.js | 4 ++-- src/platforms/app-plus/service/api/util.js | 4 ++-- src/platforms/h5/helpers/get-real-path.js | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/core/view/components/canvas/index.vue b/src/core/view/components/canvas/index.vue index d1a39d8dd..a5babc476 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 72033e8ee..78ead12c6 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 e6221cfbf..d7c3d97a1 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 56b048645..0b018beca 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 } -- GitLab