first commit

This commit is contained in:
编码猿
2024-09-27 02:06:13 +08:00
commit 852d94fbb9
36760 changed files with 3274413 additions and 0 deletions

View File

@@ -0,0 +1,10 @@
(global["webpackJsonp"]=global["webpackJsonp"]||[]).push([["components/lime-painter/index"],{"44af":function(t,e,n){"use strict";n.r(e);var r=n("d173"),a=n("7b5e");for(var i in a)"default"!==i&&function(t){n.d(e,t,(function(){return a[t]}))}(i);var o,c=n("f0c5"),u=Object(c["a"])(a["default"],r["b"],r["c"],!1,null,null,null,!1,r["a"],o);e["default"]=u.exports},5159:function(t,e,n){"use strict";(function(t){Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=c(n("4795")),a=n("ed92"),i=n("0981"),o=n("75f7");function c(t){return t&&t.__esModule?t:{default:t}}function u(t,e,n,r,a,i,o){try{var c=t[i](o),u=c.value}catch(s){return void n(s)}c.done?e(u):Promise.resolve(u).then(r,a)}function s(t){return function(){var e=this,n=arguments;return new Promise((function(r,a){var i=t.apply(e,n);function o(t){u(i,r,a,o,c,"next",t)}function c(t){u(i,r,a,o,c,"throw",t)}o(void 0)}))}}var d={name:"l-painter",props:{board:Object,fileType:{type:String,default:"jpg"},pixelRatio:Number,customStyle:String,isRenderImage:Boolean,isH5RenderBlob:Boolean,type:{type:String,default:""}},data:function(){var t="l-painter";return{canvasId:t,use2dCanvas:!1,draw:null,ctx:null}},watch:{board:{handler:function(t){"{}"!==JSON.stringify(t)&&this.render()},immediate:!0,deep:!0}},computed:{style:function(){return"width:".concat(this.boardWidth,"px; height: ").concat(this.boardHeight,"px; ").concat(this.customStyle)},dpr:function(){return this.pixelRatio||wx.getSystemInfoSync().pixelRatio},boardWidth:function(){var t=this.board||{},e=t.width,n=void 0===e?200:e;return(0,a.toPx)(n)},boardHeight:function(){var t=this.board||{},e=t.height,n=void 0===e?200:e;return(0,a.toPx)(n)}},created:function(){},mounted:function(){},methods:{render:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.getContext().then(function(){var n=s(r.default.mark((function n(o){var c,u,s,d,l,f,h,v,p;return r.default.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(t.ctx||(t.ctx=o),c=t.use2dCanvas,u=t.boardWidth,s=t.boardHeight,d=t.board,l=t.canvas,f=t.isH5RenderBlob,h=e.width,v=e.height,!c||l){n.next=5;break}return n.abrupt("return",Promise.reject(new Error("render: fail canvas has not been created")));case 5:return t.boundary={top:0,left:0,width:u||h,height:s||v},t.ctx.clearRect(0,0,u,s),t.draw||(t.draw=new i.Draw(t.ctx,l,c)),n.next=10,t.draw.drawBoard("{}"!=JSON.stringify(e)?e:d);case 10:if(c){n.next=15;break}return n.next=13,t.canvasDraw(t.ctx,t.isRenderImage);case 13:p=n.sent,p&&t.isRenderImage&&t.canvasToTempFilePath().then((function(e){if(/^data:image\/(\w+);base64/.test(e.tempFilePath)&&f){var n=URL.createObjectURL((0,a.dataURItoBlob)(e.tempFilePath));t.$emit("success",n)}else t.$emit("success",e.tempFilePath)})).catch((function(e){t.$emit("fail",e),new Error(JSON.stringify(e))}));case 15:return n.abrupt("return",Promise.resolve("ok"));case 16:case"end":return n.stop()}}),n)})));return function(t){return n.apply(this,arguments)}}())},canvasDraw:function(t,e){return new Promise((function(n){t.draw(e,(function(){n(!0)}))}))},getContext:function(){var e=this,n=this.type,r=this.dpr,a=this.boardWidth,i=this.boardHeight;if(""===n){var c=t.createCanvasContext(this.canvasId,this);return Promise.resolve(c)}return new Promise((function(c){t.createSelectorQuery().in(e).select("#l-painter").node().exec((function(t){var u=t[0].node,s=u.getContext(n);e.inited||(e.inited=!0,u.width=a*r,u.height=i*r,e.use2dCanvas=!0,e.canvas=u,s.scale(r,r)),c((0,o.adaptor)(s))}))}))},canvasToTempFilePath:function(){var e=this,n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=this.use2dCanvas,a=this.canvasId;return new Promise((function(i,o){var c=e.boundary,u=c.top,s=void 0===u?0:u,d=c.left,l=void 0===d?0:d,f=c.width,h=c.height,v={x:l,y:s,width:f,height:h,destWidth:f*e.dpr,destHeight:h*e.dpr,canvasId:a,fileType:n.fileType||e.fileType||"png",quality:n.quality||1,success:i,fail:o};r&&(delete v.canvasId,v.canvas=e.canvas),t.canvasToTempFilePath(v,e)}))}}};e.default=d}).call(this,n("543d")["default"])},"7b5e":function(t,e,n){"use strict";n.r(e);var r=n("5159"),a=n.n(r);for(var i in r)"default"!==i&&function(t){n.d(e,t,(function(){return r[t]}))}(i);e["default"]=a.a},d173:function(t,e,n){"use strict";var r,a=function(){var t=this,e=t.$createElement;t._self._c},i=[];n.d(e,"b",(function(){return a})),n.d(e,"c",(function(){return i})),n.d(e,"a",(function(){return r}))}}]);
;(global["webpackJsonp"] = global["webpackJsonp"] || []).push([
'components/lime-painter/index-create-component',
{
'components/lime-painter/index-create-component':(function(module, exports, __webpack_require__){
__webpack_require__('543d')['createComponent'](__webpack_require__("44af"))
})
},
[['components/lime-painter/index-create-component']]
]);

View File

@@ -0,0 +1,4 @@
{
"usingComponents": {},
"component": true
}

View File

@@ -0,0 +1 @@
<canvas style="{{(style)}}" type="{{type}}" id="l-painter" canvas-id="{{canvasId}}"></canvas>