@tuya-miniapp/smart-ui 2.7.4-beta-2 → 2.7.4-beta-4
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.
- package/dist/circle/index.js +7 -3
- package/dist/circle/index.rjs +29 -12
- package/dist/toast/index.js +5 -0
- package/dist/toast/index.wxml +5 -5
- package/dist/toast/toast.d.ts +2 -0
- package/lib/circle/index.js +7 -3
- package/lib/circle/index.rjs +29 -12
- package/lib/toast/index.js +5 -0
- package/lib/toast/index.wxml +5 -5
- package/lib/toast/toast.d.ts +2 -0
- package/package.json +1 -1
package/dist/circle/index.js
CHANGED
|
@@ -31,17 +31,21 @@ SmartComponent({
|
|
|
31
31
|
},
|
|
32
32
|
maskColor: {
|
|
33
33
|
type: String,
|
|
34
|
-
value: '
|
|
34
|
+
value: 'transparent',
|
|
35
35
|
},
|
|
36
36
|
fillColorStops: {
|
|
37
37
|
type: null,
|
|
38
38
|
},
|
|
39
|
+
angleOffset: {
|
|
40
|
+
type: Number,
|
|
41
|
+
value: -1,
|
|
42
|
+
},
|
|
39
43
|
percent: {
|
|
40
44
|
type: Number,
|
|
41
45
|
value: 0,
|
|
42
46
|
observer(val) {
|
|
43
47
|
if (this.render && this.data.dpr) {
|
|
44
|
-
this.render.init(this.data);
|
|
48
|
+
this.render.init(this.data, this.data.angleOffset);
|
|
45
49
|
}
|
|
46
50
|
},
|
|
47
51
|
},
|
|
@@ -64,7 +68,7 @@ SmartComponent({
|
|
|
64
68
|
watch: {
|
|
65
69
|
dpr() {
|
|
66
70
|
if (this.render) {
|
|
67
|
-
this.render.init(this.data);
|
|
71
|
+
this.render.init(this.data, this.data.angleOffset);
|
|
68
72
|
}
|
|
69
73
|
},
|
|
70
74
|
},
|
package/dist/circle/index.rjs
CHANGED
|
@@ -7,7 +7,7 @@ export default Render({
|
|
|
7
7
|
dpr: 1,
|
|
8
8
|
fillColor: '#007AFF',
|
|
9
9
|
|
|
10
|
-
async init(data) {
|
|
10
|
+
async init(data, offsetValue) {
|
|
11
11
|
let canvas = this.canvas;
|
|
12
12
|
if (!canvas) {
|
|
13
13
|
canvas = await getCanvasById(data.canvasId);
|
|
@@ -42,7 +42,7 @@ export default Render({
|
|
|
42
42
|
this.round = data.round;
|
|
43
43
|
|
|
44
44
|
ctx.scale(this.dpr, this.dpr);
|
|
45
|
-
this.render(data.percent);
|
|
45
|
+
this.render(data.percent, offsetValue);
|
|
46
46
|
},
|
|
47
47
|
percentToDecimal(percent) {
|
|
48
48
|
percent = percent.replace('%', '');
|
|
@@ -107,6 +107,7 @@ export default Render({
|
|
|
107
107
|
progress,
|
|
108
108
|
ops = {
|
|
109
109
|
lineCap: 'round',
|
|
110
|
+
offset: 1,
|
|
110
111
|
}
|
|
111
112
|
) {
|
|
112
113
|
const canvas = this.canvas;
|
|
@@ -114,8 +115,14 @@ export default Render({
|
|
|
114
115
|
|
|
115
116
|
const lineWidth = this.lineWidth; // 进度条宽度
|
|
116
117
|
const radius = ((this.width - lineWidth) * 1) / 2; // 圆形半径
|
|
117
|
-
|
|
118
|
-
const
|
|
118
|
+
|
|
119
|
+
const offset = ops.offset || 1;
|
|
120
|
+
const startOffset = (180 - offset) / 180;
|
|
121
|
+
const endOffset = ((180 - offset) + 180 + offset * 2) / 180;
|
|
122
|
+
|
|
123
|
+
const startAngle = startOffset * Math.PI; // 起始角度(3点钟方向)
|
|
124
|
+
const endAngle = endOffset * Math.PI; // 结束角度(360度)
|
|
125
|
+
const availableAngle = endAngle - startAngle; // 实际可用角度范围
|
|
119
126
|
|
|
120
127
|
// 绘制环形进度条的函数
|
|
121
128
|
const drawProgressBar = (progress, color) => {
|
|
@@ -133,7 +140,9 @@ export default Render({
|
|
|
133
140
|
ctx.stroke();
|
|
134
141
|
|
|
135
142
|
// 绘制进度条
|
|
136
|
-
|
|
143
|
+
// progress 的范围是 0-0.5(对应 percent 0-100%),需要归一化到 0-1
|
|
144
|
+
const normalizedProgress = progress * 2; // 将 0-0.5 映射到 0-1
|
|
145
|
+
const progressAngle = normalizedProgress * availableAngle; // 根据归一化进度和实际可用角度范围计算角度
|
|
137
146
|
ctx.beginPath();
|
|
138
147
|
ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
|
|
139
148
|
ctx.lineWidth = lineWidth;
|
|
@@ -164,6 +173,7 @@ export default Render({
|
|
|
164
173
|
progress,
|
|
165
174
|
ops = {
|
|
166
175
|
lineCap: 'round',
|
|
176
|
+
offset: 36,
|
|
167
177
|
}
|
|
168
178
|
) {
|
|
169
179
|
const canvas = this.canvas;
|
|
@@ -172,8 +182,12 @@ export default Render({
|
|
|
172
182
|
const lineWidth = this.lineWidth; // 进度条宽度
|
|
173
183
|
const radius = ((this.width - lineWidth) * 1) / 2; // 圆形半径
|
|
174
184
|
|
|
175
|
-
const
|
|
176
|
-
const
|
|
185
|
+
const offset = ops.offset || 36;
|
|
186
|
+
const startOffset = (180 - offset) / 180;
|
|
187
|
+
const endOffset = ((180 - offset) + 180 + offset * 2) / 180;
|
|
188
|
+
const startAngle = startOffset * Math.PI; // 起始角度(3点钟方向)
|
|
189
|
+
const endAngle = endOffset * Math.PI; // 结束角度(360度)
|
|
190
|
+
const availableAngle = endAngle - startAngle; // 实际可用角度范围
|
|
177
191
|
|
|
178
192
|
// 绘制环形进度条的函数
|
|
179
193
|
const drawProgressBar = (progress, color) => {
|
|
@@ -191,7 +205,9 @@ export default Render({
|
|
|
191
205
|
ctx.stroke();
|
|
192
206
|
|
|
193
207
|
// 绘制进度条
|
|
194
|
-
|
|
208
|
+
// progress 的范围是 0-0.666...(对应 percent 0-100%),需要归一化到 0-1
|
|
209
|
+
const normalizedProgress = progress * 1.5; // 将 0-0.666... 映射到 0-1 (1 / 0.666... = 1.5)
|
|
210
|
+
const progressAngle = normalizedProgress * availableAngle; // 根据归一化进度和实际可用角度范围计算角度
|
|
195
211
|
ctx.beginPath();
|
|
196
212
|
ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
|
|
197
213
|
ctx.lineWidth = lineWidth;
|
|
@@ -217,16 +233,17 @@ export default Render({
|
|
|
217
233
|
// 示例:绘制不同的进度条
|
|
218
234
|
drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
|
|
219
235
|
},
|
|
220
|
-
render(val) {
|
|
221
|
-
|
|
236
|
+
render(val, offsetValue) {
|
|
237
|
+
var offset = offsetValue !== -1 ? Math.max(offsetValue, 1) : undefined;
|
|
238
|
+
val = Math.min(Math.max(0, val), 100);
|
|
222
239
|
if (this.mode === 'basic') {
|
|
223
240
|
this.renderAll(val / 100, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
224
241
|
}
|
|
225
242
|
if (this.mode === 'angle') {
|
|
226
|
-
this.renderHalf(val / 200, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
243
|
+
this.renderHalf(val / 200, this.round ? { lineCap: 'round', offset: offset } : { lineCap: '', offset: offset });
|
|
227
244
|
}
|
|
228
245
|
if (this.mode === 'angle2') {
|
|
229
|
-
this.renderHalf2(val / 150, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
246
|
+
this.renderHalf2(val / 150, this.round ? { lineCap: 'round', offset: offset } : { lineCap: '', offset: offset });
|
|
230
247
|
}
|
|
231
248
|
},
|
|
232
249
|
});
|
package/dist/toast/index.js
CHANGED
package/dist/toast/index.wxml
CHANGED
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
>
|
|
17
17
|
|
|
18
18
|
<!-- text only -->
|
|
19
|
-
<text class="smart-toast__text" wx:if="{{ type === 'text' }}">{{ message }}</text>
|
|
19
|
+
<text class="smart-toast__text" style="{{ textColor ? ('color: ' + textColor) : '' }}" wx:if="{{ type === 'text' }}">{{ message }}</text>
|
|
20
20
|
|
|
21
21
|
<!-- html only -->
|
|
22
|
-
<rich-text wx:elif="{{ type === 'html' }}" nodes="{{ message }}"></rich-text>
|
|
22
|
+
<rich-text wx:elif="{{ type === 'html' }}" nodes="{{ message }}" style="{{ textColor ? ('color: ' + textColor) : '' }}"></rich-text>
|
|
23
23
|
|
|
24
24
|
<!-- with icon -->
|
|
25
25
|
<block wx:else>
|
|
26
|
-
<smart-loading wx:if="{{ type === 'loading' }}" color="
|
|
27
|
-
<smart-icon wx:else color="
|
|
28
|
-
<text wx:if="{{ message }}" class="smart-toast__text">{{ message }}</text>
|
|
26
|
+
<smart-loading wx:if="{{ type === 'loading' }}" color="{{iconColor}}" style="transform:scale(1.6);" type="{{loadingType}}" />
|
|
27
|
+
<smart-icon wx:else color="{{iconColor}}" class="smart-toast__icon" style="transform:scale({{ type === 'success' ? 1.4 : type === 'fail' ? 1.1 : 1 }})" name="{{ type === 'success' ? success : type === 'fail' ? error : type === 'warn' ? warn : success }}" />
|
|
28
|
+
<text wx:if="{{ message }}" class="smart-toast__text" style="{{ textColor ? ('color: ' + textColor) : '' }}">{{ message }}</text>
|
|
29
29
|
</block>
|
|
30
30
|
|
|
31
31
|
<slot />
|
package/dist/toast/toast.d.ts
CHANGED
package/lib/circle/index.js
CHANGED
|
@@ -36,17 +36,21 @@ var idListRef = {
|
|
|
36
36
|
},
|
|
37
37
|
maskColor: {
|
|
38
38
|
type: String,
|
|
39
|
-
value: '
|
|
39
|
+
value: 'transparent',
|
|
40
40
|
},
|
|
41
41
|
fillColorStops: {
|
|
42
42
|
type: null,
|
|
43
43
|
},
|
|
44
|
+
angleOffset: {
|
|
45
|
+
type: Number,
|
|
46
|
+
value: -1,
|
|
47
|
+
},
|
|
44
48
|
percent: {
|
|
45
49
|
type: Number,
|
|
46
50
|
value: 0,
|
|
47
51
|
observer: function (val) {
|
|
48
52
|
if (this.render && this.data.dpr) {
|
|
49
|
-
this.render.init(this.data);
|
|
53
|
+
this.render.init(this.data, this.data.angleOffset);
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
},
|
|
@@ -69,7 +73,7 @@ var idListRef = {
|
|
|
69
73
|
watch: {
|
|
70
74
|
dpr: function () {
|
|
71
75
|
if (this.render) {
|
|
72
|
-
this.render.init(this.data);
|
|
76
|
+
this.render.init(this.data, this.data.angleOffset);
|
|
73
77
|
}
|
|
74
78
|
},
|
|
75
79
|
},
|
package/lib/circle/index.rjs
CHANGED
|
@@ -7,7 +7,7 @@ export default Render({
|
|
|
7
7
|
dpr: 1,
|
|
8
8
|
fillColor: '#007AFF',
|
|
9
9
|
|
|
10
|
-
async init(data) {
|
|
10
|
+
async init(data, offsetValue) {
|
|
11
11
|
let canvas = this.canvas;
|
|
12
12
|
if (!canvas) {
|
|
13
13
|
canvas = await getCanvasById(data.canvasId);
|
|
@@ -42,7 +42,7 @@ export default Render({
|
|
|
42
42
|
this.round = data.round;
|
|
43
43
|
|
|
44
44
|
ctx.scale(this.dpr, this.dpr);
|
|
45
|
-
this.render(data.percent);
|
|
45
|
+
this.render(data.percent, offsetValue);
|
|
46
46
|
},
|
|
47
47
|
percentToDecimal(percent) {
|
|
48
48
|
percent = percent.replace('%', '');
|
|
@@ -107,6 +107,7 @@ export default Render({
|
|
|
107
107
|
progress,
|
|
108
108
|
ops = {
|
|
109
109
|
lineCap: 'round',
|
|
110
|
+
offset: 1,
|
|
110
111
|
}
|
|
111
112
|
) {
|
|
112
113
|
const canvas = this.canvas;
|
|
@@ -114,8 +115,14 @@ export default Render({
|
|
|
114
115
|
|
|
115
116
|
const lineWidth = this.lineWidth; // 进度条宽度
|
|
116
117
|
const radius = ((this.width - lineWidth) * 1) / 2; // 圆形半径
|
|
117
|
-
|
|
118
|
-
const
|
|
118
|
+
|
|
119
|
+
const offset = ops.offset || 1;
|
|
120
|
+
const startOffset = (180 - offset) / 180;
|
|
121
|
+
const endOffset = ((180 - offset) + 180 + offset * 2) / 180;
|
|
122
|
+
|
|
123
|
+
const startAngle = startOffset * Math.PI; // 起始角度(3点钟方向)
|
|
124
|
+
const endAngle = endOffset * Math.PI; // 结束角度(360度)
|
|
125
|
+
const availableAngle = endAngle - startAngle; // 实际可用角度范围
|
|
119
126
|
|
|
120
127
|
// 绘制环形进度条的函数
|
|
121
128
|
const drawProgressBar = (progress, color) => {
|
|
@@ -133,7 +140,9 @@ export default Render({
|
|
|
133
140
|
ctx.stroke();
|
|
134
141
|
|
|
135
142
|
// 绘制进度条
|
|
136
|
-
|
|
143
|
+
// progress 的范围是 0-0.5(对应 percent 0-100%),需要归一化到 0-1
|
|
144
|
+
const normalizedProgress = progress * 2; // 将 0-0.5 映射到 0-1
|
|
145
|
+
const progressAngle = normalizedProgress * availableAngle; // 根据归一化进度和实际可用角度范围计算角度
|
|
137
146
|
ctx.beginPath();
|
|
138
147
|
ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
|
|
139
148
|
ctx.lineWidth = lineWidth;
|
|
@@ -164,6 +173,7 @@ export default Render({
|
|
|
164
173
|
progress,
|
|
165
174
|
ops = {
|
|
166
175
|
lineCap: 'round',
|
|
176
|
+
offset: 36,
|
|
167
177
|
}
|
|
168
178
|
) {
|
|
169
179
|
const canvas = this.canvas;
|
|
@@ -172,8 +182,12 @@ export default Render({
|
|
|
172
182
|
const lineWidth = this.lineWidth; // 进度条宽度
|
|
173
183
|
const radius = ((this.width - lineWidth) * 1) / 2; // 圆形半径
|
|
174
184
|
|
|
175
|
-
const
|
|
176
|
-
const
|
|
185
|
+
const offset = ops.offset || 36;
|
|
186
|
+
const startOffset = (180 - offset) / 180;
|
|
187
|
+
const endOffset = ((180 - offset) + 180 + offset * 2) / 180;
|
|
188
|
+
const startAngle = startOffset * Math.PI; // 起始角度(3点钟方向)
|
|
189
|
+
const endAngle = endOffset * Math.PI; // 结束角度(360度)
|
|
190
|
+
const availableAngle = endAngle - startAngle; // 实际可用角度范围
|
|
177
191
|
|
|
178
192
|
// 绘制环形进度条的函数
|
|
179
193
|
const drawProgressBar = (progress, color) => {
|
|
@@ -191,7 +205,9 @@ export default Render({
|
|
|
191
205
|
ctx.stroke();
|
|
192
206
|
|
|
193
207
|
// 绘制进度条
|
|
194
|
-
|
|
208
|
+
// progress 的范围是 0-0.666...(对应 percent 0-100%),需要归一化到 0-1
|
|
209
|
+
const normalizedProgress = progress * 1.5; // 将 0-0.666... 映射到 0-1 (1 / 0.666... = 1.5)
|
|
210
|
+
const progressAngle = normalizedProgress * availableAngle; // 根据归一化进度和实际可用角度范围计算角度
|
|
195
211
|
ctx.beginPath();
|
|
196
212
|
ctx.arc(this.width / 2, this.height / 2, radius, startAngle, startAngle + progressAngle);
|
|
197
213
|
ctx.lineWidth = lineWidth;
|
|
@@ -217,16 +233,17 @@ export default Render({
|
|
|
217
233
|
// 示例:绘制不同的进度条
|
|
218
234
|
drawProgressBar(progress, this.fillColor); // 25%的蓝色进度条
|
|
219
235
|
},
|
|
220
|
-
render(val) {
|
|
221
|
-
|
|
236
|
+
render(val, offsetValue) {
|
|
237
|
+
var offset = offsetValue !== -1 ? Math.max(offsetValue, 1) : undefined;
|
|
238
|
+
val = Math.min(Math.max(0, val), 100);
|
|
222
239
|
if (this.mode === 'basic') {
|
|
223
240
|
this.renderAll(val / 100, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
224
241
|
}
|
|
225
242
|
if (this.mode === 'angle') {
|
|
226
|
-
this.renderHalf(val / 200, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
243
|
+
this.renderHalf(val / 200, this.round ? { lineCap: 'round', offset: offset } : { lineCap: '', offset: offset });
|
|
227
244
|
}
|
|
228
245
|
if (this.mode === 'angle2') {
|
|
229
|
-
this.renderHalf2(val / 150, this.round ? { lineCap: 'round' } : { lineCap: '' });
|
|
246
|
+
this.renderHalf2(val / 150, this.round ? { lineCap: 'round', offset: offset } : { lineCap: '', offset: offset });
|
|
230
247
|
}
|
|
231
248
|
},
|
|
232
249
|
});
|
package/lib/toast/index.js
CHANGED
|
@@ -15,6 +15,11 @@ var appLog_1 = __importDefault(require("../common/appLog"));
|
|
|
15
15
|
message: String,
|
|
16
16
|
forbidClick: Boolean,
|
|
17
17
|
nativeDisabled: Boolean,
|
|
18
|
+
iconColor: {
|
|
19
|
+
type: String,
|
|
20
|
+
value: 'white',
|
|
21
|
+
},
|
|
22
|
+
textColor: String,
|
|
18
23
|
zIndex: {
|
|
19
24
|
type: Number,
|
|
20
25
|
value: 1000,
|
package/lib/toast/index.wxml
CHANGED
|
@@ -16,16 +16,16 @@
|
|
|
16
16
|
>
|
|
17
17
|
|
|
18
18
|
<!-- text only -->
|
|
19
|
-
<text class="smart-toast__text" wx:if="{{ type === 'text' }}">{{ message }}</text>
|
|
19
|
+
<text class="smart-toast__text" style="{{ textColor ? ('color: ' + textColor) : '' }}" wx:if="{{ type === 'text' }}">{{ message }}</text>
|
|
20
20
|
|
|
21
21
|
<!-- html only -->
|
|
22
|
-
<rich-text wx:elif="{{ type === 'html' }}" nodes="{{ message }}"></rich-text>
|
|
22
|
+
<rich-text wx:elif="{{ type === 'html' }}" nodes="{{ message }}" style="{{ textColor ? ('color: ' + textColor) : '' }}"></rich-text>
|
|
23
23
|
|
|
24
24
|
<!-- with icon -->
|
|
25
25
|
<block wx:else>
|
|
26
|
-
<smart-loading wx:if="{{ type === 'loading' }}" color="
|
|
27
|
-
<smart-icon wx:else color="
|
|
28
|
-
<text wx:if="{{ message }}" class="smart-toast__text">{{ message }}</text>
|
|
26
|
+
<smart-loading wx:if="{{ type === 'loading' }}" color="{{iconColor}}" style="transform:scale(1.6);" type="{{loadingType}}" />
|
|
27
|
+
<smart-icon wx:else color="{{iconColor}}" class="smart-toast__icon" style="transform:scale({{ type === 'success' ? 1.4 : type === 'fail' ? 1.1 : 1 }})" name="{{ type === 'success' ? success : type === 'fail' ? error : type === 'warn' ? warn : success }}" />
|
|
28
|
+
<text wx:if="{{ message }}" class="smart-toast__text" style="{{ textColor ? ('color: ' + textColor) : '' }}">{{ message }}</text>
|
|
29
29
|
</block>
|
|
30
30
|
|
|
31
31
|
<slot />
|
package/lib/toast/toast.d.ts
CHANGED