acdr-ui/dist/dev/mp-weixin/uni_modules/lime-painter/components/l-painter/l-painter.js.map

1 line
24 KiB
Plaintext
Raw Normal View History

2024-09-19 07:20:14 +08:00
{"version":3,"file":"l-painter.js","sources":["../../../../../../../src/uni_modules/lime-painter/components/l-painter/l-painter.vue","../../../../../../../uniComponent:/RDovQXBwL1dvcmsvYWRkci9hY2RyLXVpL3NyYy91bmlfbW9kdWxlcy9saW1lLXBhaW50ZXIvY29tcG9uZW50cy9sLXBhaW50ZXIvbC1wYWludGVyLnZ1ZQ"],"sourcesContent":["<template>\r\n <view class=\"lime-painter\" ref=\"limepainter\">\r\n <view v-if=\"canvasId && size\" :style=\"styles\">\r\n <!-- #ifndef APP-NVUE -->\r\n <canvas\r\n class=\"lime-painter__canvas\"\r\n v-if=\"use2dCanvas\"\r\n :id=\"canvasId\"\r\n type=\"2d\"\r\n :style=\"size\"\r\n ></canvas>\r\n <canvas\r\n class=\"lime-painter__canvas\"\r\n v-else\r\n :id=\"canvasId\"\r\n :canvas-id=\"canvasId\"\r\n :style=\"size\"\r\n :width=\"boardWidth * dpr\"\r\n :height=\"boardHeight * dpr\"\r\n :hidpi=\"hidpi\"\r\n ></canvas>\r\n\r\n <!-- #endif -->\r\n <!-- #ifdef APP-NVUE -->\r\n <web-view\r\n :style=\"size\"\r\n ref=\"webview\"\r\n src=\"/uni_modules/lime-painter/hybrid/html/index.html\"\r\n class=\"lime-painter__canvas\"\r\n @pagefinish=\"onPageFinish\"\r\n @error=\"onError\"\r\n @onPostMessage=\"onMessage\"\r\n ></web-view>\r\n <!-- #endif -->\r\n </view>\r\n <slot />\r\n </view>\r\n</template>\r\n\r\n<script>\r\nimport { parent } from '../common/relation'\r\nimport props from './props'\r\nimport { toPx, base64ToPath, pathToBase64, isBase64, sleep, getImageInfo } from './utils'\r\n// #ifndef APP-NVUE\r\nimport { canIUseCanvas2d, isPC } from './utils'\r\nimport Painter from './painter'\r\n// import Painter from '@painter'\r\nconst nvue = {}\r\n// #endif\r\n// #ifdef APP-NVUE\r\nimport nvue from './nvue'\r\n// #endif\r\nexport default {\r\n name: 'lime-painter',\r\n mixins: [props, parent('painter'), nvue],\r\n data() {\r\n return {\r\n use2dCanvas: false,\r\n canvasHeight: 150,\r\n canvasWidth: null,\r\n parentWidth: 0,\r\n inited: false,\r\n progress: 0,\r\n firstRender: 0,\r\n done: false,\r\n tasks: [],\r\n }\r\n },\r\n computed: {\r\n styles() {\r\n return (\r\n `${this.size}${this.customStyle || ''};` +\r\n (this.hidden && 'position: fixed; left: 1500rpx;')\r\n )\r\n },\r\n canvasId() {\r\n return `l-painter${(this._ && this._.uid) || this._uid}`\r\n },\r\n size() {\r\n if (this.boardWidth && this.boardHeight) {\r\n return `width:${this.boardWidth}px; height: ${this.boardHeight}px;`\r\n }\r\n },\r\n dpr() {\r\n return this.pixelRatio || uni.getSystemInfoSync().pixelRatio\r\n },\r\n boardWidth() {\r\n const { width = 0 } = (this.elements && this.elements.css) || this.elements || this\r\n const w = toPx(width || this.width)\r\n return w || Math.max(w, toPx(this.canvasWidth))\r\n },\r\n boardHeight() {\r\n const { height = 0 } = (this.elements && this.elements.css) || this.elements || this\r\n const h = toPx(height || this.height)\r\n return h || Math.max(h, toPx(this.canvasHeight))\r\n },\r\n hasBoard() {\r\n return this.board && Object.keys(this.board).length\r\n },\r\n elements() {\r\n return this.hasBoard ? this.board : JSON.parse(JSON.stringify(this.el))\r\n },\r\n },\r\n created() {\r\n this.use2dCanvas = this.type === '2d' && canIUseCanvas2d() && !isPC\r\n },\r\n async mounted() {\r\n await sleep(30)\r\n await this.getParentWeith()\r\n this.$nextTick(() => {\r\n setTimeout(() => {\r\n this.$watch('elements', this.watchRender, {\r\n deep: true,\r\n immediate: true,\r\n })\r\n }, 30)\r\n })\r\n },\r\n // #ifdef VUE3\r\n unmounted() {\r\n this.done = false\r\n this.inited = false\r\n this.firstRender = 0\r\n this.progress = 0\r\n this.painter = null\r\n clearTimeout(this.rendertimer)\r\n },\r\n // #endif\r\n // #ifdef VUE2\r\n destroyed()