@tuya-miniapp/smart-ui 2.3.6 → 2.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -58,20 +58,16 @@ SmartComponent({
58
58
  value: true,
59
59
  },
60
60
  },
61
- watch: {
62
- dpr() {
63
- this.render(this.data.percent, this.data.canvasId);
64
- },
65
- },
66
61
  data: {
67
62
  canvasId: '',
68
63
  dpr: 1,
69
64
  },
70
- created() { },
71
- mounted() {
65
+ created() {
72
66
  this.initId();
73
67
  this.initRate();
74
- // this.render(this.data.percent, this.data.canvasId);
68
+ },
69
+ mounted() {
70
+ this.render(this.data.percent, this.data.canvasId);
75
71
  },
76
72
  destroyed() {
77
73
  idListRef.value = idListRef.value.filter(id => id !== this.data.canvasId);
@@ -94,20 +90,25 @@ SmartComponent({
94
90
  wx.getSystemInfo({
95
91
  success: res => {
96
92
  const dpr = res.pixelRatio; // 获取设备像素比
97
- const sizeVal = this.parseSize();
98
- const params = {
99
- width: +sizeVal,
100
- height: +sizeVal,
101
- lineWidth: this.data.trackWidth,
102
- trackColor: this.data.trackColor,
103
- fillColor: this.data.fillColor,
104
- fillColorStops: this.data.fillColorStops,
105
- maskColor: this.data.maskColor,
106
- dpr: this.data.dpr,
107
- };
108
- this.setData(Object.assign(Object.assign({}, params), { dpr: dpr }));
93
+ this.setData({
94
+ dpr: dpr,
95
+ });
109
96
  },
110
97
  });
98
+ const sizeVal = this.parseSize();
99
+ const params = {
100
+ canvasWidth: +sizeVal,
101
+ canvasHeight: +sizeVal,
102
+ width: +sizeVal,
103
+ height: +sizeVal,
104
+ lineWidth: this.data.trackWidth,
105
+ trackColor: this.data.trackColor,
106
+ fillColor: this.data.fillColor,
107
+ fillColorStops: this.data.fillColorStops,
108
+ maskColor: this.data.maskColor,
109
+ dpr: this.data.dpr,
110
+ };
111
+ this.setData(params);
111
112
  },
112
113
  renderAll(canvas, ctx, progress, ops = {
113
114
  lineCap: 'round',
@@ -118,6 +119,7 @@ SmartComponent({
118
119
  const endAngle = 4 * Math.PI; // 结束角度(360度)
119
120
  // 绘制环形进度条的函数
120
121
  function drawProgressBar(progress, color) {
122
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
121
123
  // 绘制灰色背景
122
124
  ctx.beginPath();
123
125
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -147,6 +149,7 @@ SmartComponent({
147
149
  }
148
150
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
149
151
  ctx.stroke();
152
+ ctx.scale(canvas.dpr, canvas.dpr);
150
153
  ctx.draw();
151
154
  }
152
155
  // 示例:绘制不同的进度条
@@ -161,6 +164,7 @@ SmartComponent({
161
164
  const endAngle = 2 * Math.PI; // 结束角度(360度)
162
165
  // 绘制环形进度条的函数
163
166
  function drawProgressBar(progress, color) {
167
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
164
168
  // 绘制灰色背景
165
169
  ctx.beginPath();
166
170
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -190,6 +194,7 @@ SmartComponent({
190
194
  }
191
195
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
192
196
  ctx.stroke();
197
+ ctx.scale(canvas.dpr, canvas.dpr);
193
198
  ctx.draw();
194
199
  }
195
200
  // 示例:绘制不同的进度条
@@ -215,6 +220,7 @@ SmartComponent({
215
220
  const endAngle = 2.2 * Math.PI; // 结束角度(360度)
216
221
  // 绘制环形进度条的函数
217
222
  function drawProgressBar(progress, color) {
223
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
218
224
  // 绘制灰色背景
219
225
  ctx.beginPath();
220
226
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -244,6 +250,7 @@ SmartComponent({
244
250
  }
245
251
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
246
252
  ctx.stroke();
253
+ ctx.scale(canvas.dpr, canvas.dpr);
247
254
  ctx.draw();
248
255
  }
249
256
  // 示例:绘制不同的进度条
@@ -252,11 +259,6 @@ SmartComponent({
252
259
  render(val, canvasId) {
253
260
  // @ts-ignore
254
261
  const context = ty.createCanvasContext(canvasId);
255
- context.clearRect(0, 0, this.data.width, this.data.height); // 清除画布
256
- context.scale(this.data.dpr, this.data.dpr);
257
- this.data.width /= this.data.dpr;
258
- this.data.height /= this.data.dpr;
259
- this.data.lineWidth /= this.data.dpr;
260
262
  if (this.data.mode === 'basic') {
261
263
  this.renderAll(this.data, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
262
264
  }
@@ -2,8 +2,8 @@
2
2
  class="smart-progress-circle"
3
3
  type="2d"
4
4
  wx:if="{{canvasId}}"
5
- width="{{ width * dpr }}"
6
- height="{{ height * dpr }}"
5
+ width="{{ canvasWidth * dpr }}"
6
+ height="{{ canvasHeight * dpr }}"
7
7
  canvas-id="{{canvasId}}"
8
8
  style="width: {{width}}px; height:{{height}}px; {{customStyle}}"
9
9
  ></canvas>
@@ -2,7 +2,8 @@
2
2
  var style = require('../wxs/style.wxs');
3
3
 
4
4
  function popupStyle(data) {
5
- const transformStyle = "transform: translate3d(0, calc(100% + " + data.bottomSafeHeight + "px), 0)";
5
+ const transformStyle = data.position === 'bottom' ? "transform: translate3d(0, calc(100% + " + data.bottomSafeHeight + "px), 0)" : null;
6
+
6
7
  return style([
7
8
  {
8
9
  'margin-bottom': data.bottomSafeHeight + 'px',
@@ -3,7 +3,7 @@
3
3
  <view
4
4
  wx:if="{{ inited }}"
5
5
  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
6
- style="{{ computed.popupStyle({ status, zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
6
+ style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
7
7
  catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
8
8
  >
9
9
  <slot />
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  Object.defineProperty(exports, "__esModule", { value: true });
14
3
  /* eslint-disable guard-for-in */
15
4
  /* eslint-disable no-restricted-syntax */
@@ -71,20 +60,16 @@ var idListRef = {
71
60
  value: true,
72
61
  },
73
62
  },
74
- watch: {
75
- dpr: function () {
76
- this.render(this.data.percent, this.data.canvasId);
77
- },
78
- },
79
63
  data: {
80
64
  canvasId: '',
81
65
  dpr: 1,
82
66
  },
83
- created: function () { },
84
- mounted: function () {
67
+ created: function () {
85
68
  this.initId();
86
69
  this.initRate();
87
- // this.render(this.data.percent, this.data.canvasId);
70
+ },
71
+ mounted: function () {
72
+ this.render(this.data.percent, this.data.canvasId);
88
73
  },
89
74
  destroyed: function () {
90
75
  var _this = this;
@@ -109,20 +94,25 @@ var idListRef = {
109
94
  wx.getSystemInfo({
110
95
  success: function (res) {
111
96
  var dpr = res.pixelRatio; // 获取设备像素比
112
- var sizeVal = _this.parseSize();
113
- var params = {
114
- width: +sizeVal,
115
- height: +sizeVal,
116
- lineWidth: _this.data.trackWidth,
117
- trackColor: _this.data.trackColor,
118
- fillColor: _this.data.fillColor,
119
- fillColorStops: _this.data.fillColorStops,
120
- maskColor: _this.data.maskColor,
121
- dpr: _this.data.dpr,
122
- };
123
- _this.setData(__assign(__assign({}, params), { dpr: dpr }));
97
+ _this.setData({
98
+ dpr: dpr,
99
+ });
124
100
  },
125
101
  });
102
+ var sizeVal = this.parseSize();
103
+ var params = {
104
+ canvasWidth: +sizeVal,
105
+ canvasHeight: +sizeVal,
106
+ width: +sizeVal,
107
+ height: +sizeVal,
108
+ lineWidth: this.data.trackWidth,
109
+ trackColor: this.data.trackColor,
110
+ fillColor: this.data.fillColor,
111
+ fillColorStops: this.data.fillColorStops,
112
+ maskColor: this.data.maskColor,
113
+ dpr: this.data.dpr,
114
+ };
115
+ this.setData(params);
126
116
  },
127
117
  renderAll: function (canvas, ctx, progress, ops) {
128
118
  if (ops === void 0) { ops = {
@@ -134,6 +124,7 @@ var idListRef = {
134
124
  var endAngle = 4 * Math.PI; // 结束角度(360度)
135
125
  // 绘制环形进度条的函数
136
126
  function drawProgressBar(progress, color) {
127
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
137
128
  // 绘制灰色背景
138
129
  ctx.beginPath();
139
130
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -163,6 +154,7 @@ var idListRef = {
163
154
  }
164
155
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
165
156
  ctx.stroke();
157
+ ctx.scale(canvas.dpr, canvas.dpr);
166
158
  ctx.draw();
167
159
  }
168
160
  // 示例:绘制不同的进度条
@@ -178,6 +170,7 @@ var idListRef = {
178
170
  var endAngle = 2 * Math.PI; // 结束角度(360度)
179
171
  // 绘制环形进度条的函数
180
172
  function drawProgressBar(progress, color) {
173
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
181
174
  // 绘制灰色背景
182
175
  ctx.beginPath();
183
176
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -207,6 +200,7 @@ var idListRef = {
207
200
  }
208
201
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
209
202
  ctx.stroke();
203
+ ctx.scale(canvas.dpr, canvas.dpr);
210
204
  ctx.draw();
211
205
  }
212
206
  // 示例:绘制不同的进度条
@@ -233,6 +227,7 @@ var idListRef = {
233
227
  var endAngle = 2.2 * Math.PI; // 结束角度(360度)
234
228
  // 绘制环形进度条的函数
235
229
  function drawProgressBar(progress, color) {
230
+ ctx.clearRect(0, 0, canvas.width, canvas.height); // 清除画布
236
231
  // 绘制灰色背景
237
232
  ctx.beginPath();
238
233
  ctx.arc(canvas.width / 2, canvas.height / 2, radius, startAngle, endAngle);
@@ -262,6 +257,7 @@ var idListRef = {
262
257
  }
263
258
  ctx.setLineCap(ops.lineCap); // 设置圆角效果
264
259
  ctx.stroke();
260
+ ctx.scale(canvas.dpr, canvas.dpr);
265
261
  ctx.draw();
266
262
  }
267
263
  // 示例:绘制不同的进度条
@@ -270,11 +266,6 @@ var idListRef = {
270
266
  render: function (val, canvasId) {
271
267
  // @ts-ignore
272
268
  var context = ty.createCanvasContext(canvasId);
273
- context.clearRect(0, 0, this.data.width, this.data.height); // 清除画布
274
- context.scale(this.data.dpr, this.data.dpr);
275
- this.data.width /= this.data.dpr;
276
- this.data.height /= this.data.dpr;
277
- this.data.lineWidth /= this.data.dpr;
278
269
  if (this.data.mode === 'basic') {
279
270
  this.renderAll(this.data, context, val / 100, this.data.round ? { lineCap: 'round' } : { lineCap: '' });
280
271
  }
@@ -2,8 +2,8 @@
2
2
  class="smart-progress-circle"
3
3
  type="2d"
4
4
  wx:if="{{canvasId}}"
5
- width="{{ width * dpr }}"
6
- height="{{ height * dpr }}"
5
+ width="{{ canvasWidth * dpr }}"
6
+ height="{{ canvasHeight * dpr }}"
7
7
  canvas-id="{{canvasId}}"
8
8
  style="width: {{width}}px; height:{{height}}px; {{customStyle}}"
9
9
  ></canvas>
@@ -2,7 +2,8 @@
2
2
  var style = require('../wxs/style.wxs');
3
3
 
4
4
  function popupStyle(data) {
5
- const transformStyle = "transform: translate3d(0, calc(100% + " + data.bottomSafeHeight + "px), 0)";
5
+ const transformStyle = data.position === 'bottom' ? "transform: translate3d(0, calc(100% + " + data.bottomSafeHeight + "px), 0)" : null;
6
+
6
7
  return style([
7
8
  {
8
9
  'margin-bottom': data.bottomSafeHeight + 'px',
@@ -3,7 +3,7 @@
3
3
  <view
4
4
  wx:if="{{ inited }}"
5
5
  class="custom-class {{ classes }} {{ utils.bem('popup', [position, { round, safeTop: safeAreaInsetTop, safeTabBar: safeAreaTabBar }]) }}"
6
- style="{{ computed.popupStyle({ status, zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
6
+ style="{{ computed.popupStyle({ position, status, zIndex, currentDuration, display, customStyle, bottomSafeHeight }) }}"
7
7
  catch:touchmove="{{ lockScroll ? 'noop' : ''}}"
8
8
  >
9
9
  <slot />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tuya-miniapp/smart-ui",
3
- "version": "2.3.6",
3
+ "version": "2.3.7",
4
4
  "author": "MiniApp Team",
5
5
  "license": "MIT",
6
6
  "miniprogram": "lib",