mp-painter
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -58,4 +58,4 @@ "use strict"; | ||
src = _b.sent(); | ||
console.log("调用小程序绘制,使用:", src); | ||
if (src) { | ||
console.log("调用小程序drawImage,使用:", src); | ||
this.ctx.drawImage(src, this.upx2px(contentSize.left), this.upx2px(contentSize.top), this.upx2px(contentSize.width), this.upx2px(contentSize.height)); | ||
@@ -74,3 +74,3 @@ } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var platform, ALIPAY_LOCAL_RESOURCE_URL_REG, WEIXIN_LOCAL_RESOURCE_URL_REG, shouldDownload; | ||
var platform, ALIPAY_LOCAL_RESOURCE_URL_REG, WEIXIN_LOCAL_RESOURCE_URL_REG, BAIDU_LOCAL_RESOURCE_URL_REG, shouldDownload; | ||
return __generator(this, function (_a) { | ||
@@ -82,2 +82,3 @@ switch (_a.label) { | ||
WEIXIN_LOCAL_RESOURCE_URL_REG = /^wxfile:/; | ||
BAIDU_LOCAL_RESOURCE_URL_REG = /^bdfile:\/\/tmp/; | ||
shouldDownload = | ||
@@ -87,3 +88,5 @@ // 支付宝中需要先下载图片再绘制 | ||
// 微信小程序开发者工具中不需要先下载再绘制, 但在手机中预览时需要 | ||
platform == "mp-weixin" && !WEIXIN_LOCAL_RESOURCE_URL_REG.test(image.src); | ||
platform == "mp-weixin" && !WEIXIN_LOCAL_RESOURCE_URL_REG.test(image.src) || | ||
// 百度小程序手机预览时不下载图片会导致背景变为黑色 | ||
platform == "mp-baidu" && !BAIDU_LOCAL_RESOURCE_URL_REG.test(image.src); | ||
if (!shouldDownload) | ||
@@ -90,0 +93,0 @@ return [2 /*return*/, image.src]; |
{ | ||
"name": "mp-painter", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A declarative canvas lib using with mini-program, espacially with uniapp.", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/painter.js", |
@@ -37,4 +37,5 @@ import Painter, { PaintBaseOption } from "./painter"; | ||
let src = await getDrawableImageSrc(this, image); | ||
console.log("调用小程序绘制,使用:", src); | ||
if(src){ | ||
console.log("调用小程序drawImage,使用:", src); | ||
this.ctx.drawImage( | ||
@@ -60,2 +61,8 @@ src, | ||
const WEIXIN_LOCAL_RESOURCE_URL_REG = /^wxfile:/; | ||
/** | ||
* @example "bdfile://tmp/program/bf0738...9143805.png" 开发者工具(当前百度开发者工具中会绘制失败) | ||
* @example "bdfile://tmp_xxxxx" 手机预览 | ||
*/ | ||
const BAIDU_LOCAL_RESOURCE_URL_REG = /^bdfile:\/\/tmp/; | ||
let shouldDownload = | ||
@@ -65,4 +72,5 @@ // 支付宝中需要先下载图片再绘制 | ||
// 微信小程序开发者工具中不需要先下载再绘制, 但在手机中预览时需要 | ||
platform == "mp-weixin" && !WEIXIN_LOCAL_RESOURCE_URL_REG.test(image.src) | ||
// 百度小程序开发者工具/手机中不需要下载文件即可绘制 | ||
platform == "mp-weixin" && !WEIXIN_LOCAL_RESOURCE_URL_REG.test(image.src) || | ||
// 百度小程序手机预览时不下载图片会导致背景变为黑色 | ||
platform == "mp-baidu" && !BAIDU_LOCAL_RESOURCE_URL_REG.test(image.src) | ||
; | ||
@@ -69,0 +77,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90196
1604