@didaoktv/didaoui-uniapp 2.13.0 → 2.15.0

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.
Files changed (69) hide show
  1. package/README.md +6 -6
  2. package/components/dd-album/dd-album.vue +280 -228
  3. package/components/dd-avatar/dd-avatar.vue +132 -75
  4. package/components/dd-avatar-group/dd-avatar-group.vue +52 -30
  5. package/components/dd-barcode/dd-barcode.vue +884 -947
  6. package/components/dd-button/dd-button.vue +47 -21
  7. package/components/dd-canvas/dd-canvas.vue +1156 -985
  8. package/components/dd-car-keyboard/dd-car-keyboard.vue +12 -12
  9. package/components/dd-champion-card/dd-champion-card.vue +49 -21
  10. package/components/dd-checkbox-group/dd-checkbox-group.vue +2 -0
  11. package/components/dd-copy/dd-copy.vue +51 -56
  12. package/components/dd-cropper/dd-cropper.vue +1224 -1135
  13. package/components/dd-divider/dd-divider.vue +9 -2
  14. package/components/dd-form/dd-form.vue +2 -0
  15. package/components/dd-goods-sku/dd-goods-sku.vue +6 -1
  16. package/components/dd-icon/dd-icon.vue +1 -1
  17. package/components/dd-keyboard/dd-keyboard.vue +95 -46
  18. package/components/dd-link/dd-link.vue +72 -49
  19. package/components/dd-markdown/dd-markdown.vue +154 -154
  20. package/components/dd-number-keyboard/dd-number-keyboard.vue +109 -94
  21. package/components/dd-package-sku/dd-package-sku.vue +24 -1
  22. package/components/dd-parse/dd-parse.vue +473 -442
  23. package/components/dd-poster/dd-poster.vue +579 -567
  24. package/components/dd-pull-refresh/dd-pull-refresh.vue +1 -9
  25. package/components/dd-qrcode/dd-qrcode.vue +431 -405
  26. package/components/dd-radio-group/dd-radio-group.vue +1 -1
  27. package/components/dd-segmented-tab/dd-segmented-tab.vue +61 -16
  28. package/components/dd-signature/dd-signature.vue +377 -357
  29. package/components/dd-step/dd-step.vue +1 -1
  30. package/components/dd-sticky/dd-sticky.vue +5 -10
  31. package/components/dd-swipe-action/dd-swipe-action.vue +1 -9
  32. package/components/dd-swipe-item/dd-swipe-item.vue +2 -0
  33. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -5
  34. package/components/dd-switch/dd-switch.vue +1 -1
  35. package/components/dd-text/dd-text.vue +304 -82
  36. package/components/dd-waterfall/dd-waterfall.vue +147 -0
  37. package/components/dd-waterfall/waterfall.ts +17 -0
  38. package/index.ts +4 -3
  39. package/libs/function/index.d.ts +88 -0
  40. package/libs/function/index.js +14 -0
  41. package/libs/function/test.d.ts +65 -0
  42. package/package.json +1 -1
  43. package/scss/_mixins.scss +8 -0
  44. package/scss/_theme-tokens.scss +7 -0
  45. package/scss/_variables.scss +283 -156
  46. package/components/dd-album/album.js +0 -19
  47. package/components/dd-album/props.js +0 -89
  48. package/components/dd-avatar/avatar.js +0 -19
  49. package/components/dd-avatar/props.js +0 -84
  50. package/components/dd-avatar-group/avatarGroup.js +0 -14
  51. package/components/dd-avatar-group/props.js +0 -57
  52. package/components/dd-keyboard/keyboard.js +0 -19
  53. package/components/dd-keyboard/props.js +0 -79
  54. package/components/dd-link/link.js +0 -17
  55. package/components/dd-link/props.js +0 -44
  56. package/components/dd-number-keyboard/numberKeyboard.js +0 -8
  57. package/components/dd-number-keyboard/props.js +0 -24
  58. package/components/dd-parse/props.js +0 -57
  59. package/components/dd-text/props.js +0 -120
  60. package/components/dd-text/text.js +0 -30
  61. package/components/dd-text/value.js +0 -87
  62. package/libs/config/color.js +0 -16
  63. package/libs/config/props.js +0 -184
  64. package/libs/mixin/button.js +0 -18
  65. package/libs/mixin/mixin.js +0 -44
  66. package/libs/mixin/mpMixin.js +0 -13
  67. package/libs/mixin/openType.js +0 -27
  68. package/libs/vue.js +0 -3
  69. package/scss/_dd-shared.scss +0 -40
@@ -71,350 +71,370 @@
71
71
  </view>
72
72
  </template>
73
73
 
74
- <script>
75
- export default {
76
- name: 'dd-signature',
77
- props: {
78
- // 画布宽度
79
- width: {
80
- type: [String, Number],
81
- default: 300
82
- },
83
- // 画布高度
84
- height: {
85
- type: [String, Number],
86
- default: 200
87
- },
88
- // 背景颜色
89
- bgColor: {
90
- type: String,
91
- default: '#ffffff'
92
- },
93
- // 默认笔画颜色
94
- color: {
95
- type: String,
96
- default: '#000000'
97
- },
98
- // 默认笔画粗细
99
- thickness: {
100
- type: [String, Number],
101
- default: 3
102
- },
103
- // 是否显示工具栏
104
- showToolbar: {
105
- type: Boolean,
106
- default: true
107
- }
108
- },
109
- data() {
110
- return {
111
- canvasId: 'dd-signature-' + Math.random().toString(36).substr(2, 9),
112
- canvasWidth: 300,
113
- canvasHeight: 200,
114
- lineColor: '',
115
- lineWidth: 3,
116
- isDrawing: false,
117
- pathStack: [], // 存储绘制路径用于回退
118
- currentPath: [], // 当前绘制路径
119
- isEmpty: true,
120
- presetColors: [
121
- '#000000', // 黑色
122
- '#ff0000', // 红色
123
- '#00ff00', // 绿色
124
- '#0000ff', // 蓝色
125
- '#ffff00', // 黄色
126
- '#00ffff', // 青色
127
- '#ff00ff', // 紫色
128
- '#ffffff' // 白色
129
- ],
130
- showBrushSettings: false,
131
- showColorSettings: false,
132
- lastPoint: null, // 保存上一个点的坐标
133
- canvasInstance: null // 缓存canvas实例
134
- }
135
- },
136
- computed: {
137
- // ponytail: 剥离运行时主题;签名画布默认保持白底(导出图片需白底)
138
- resolvedBgColor() {
139
- return this.bgColor
140
- },
141
- iconDefaultColor() {
142
- return '#999999'
143
- },
144
- iconDisabledColor() {
145
- return '#5c5c5c'
146
- }
147
- },
148
- mounted() {
149
- // 初始化时获取canvas实例
150
- this.$nextTick(() => {
151
- this.getCanvasInstance();
152
- this.clearCanvas();
153
- });
154
- },
155
- watch: {
156
- width: {
157
- handler(newVal) {
158
- this.canvasWidth = Number(newVal)
159
- },
160
- immediate: true
161
- },
162
- height: {
163
- handler(newVal) {
164
- this.canvasHeight = Number(newVal)
165
- },
166
- immediate: true
167
- },
168
- color: {
169
- handler(newVal) {
170
- this.lineColor = this.resolveStrokeColor(newVal)
171
- },
172
- immediate: true
173
- },
174
- thickness: {
175
- handler(newVal) {
176
- this.lineWidth = Number(newVal)
177
- },
178
- immediate: true
179
- }
180
- },
181
- methods: {
182
- resolveStrokeColor(color) {
183
- return color
184
- },
185
-
186
- // 获取签名画布实例
187
- getCanvasInstance() {
188
- if (this.canvasInstance) {
189
- return this.canvasInstance;
190
- }
191
-
192
- const canvasRef = this.$refs.signatureCanvas;
193
- if (canvasRef) {
194
- this.canvasInstance = canvasRef;
195
- return canvasRef;
196
- }
197
- return null;
198
- },
199
-
200
- touchStart(e) {
201
- if (!this.canvasInstance || !this.canvasInstance.ctx) {
202
- this.getCanvasInstance();
203
- }
204
-
205
- if (!this.canvasInstance || !this.canvasInstance.ctx) return;
206
-
207
- this.isDrawing = true;
208
- this.isEmpty = false;
209
- this.currentPath = [];
210
-
211
- const { x, y } = this.getCanvasPoint(e);
212
-
74
+ <script setup lang="ts">
75
+ import { computed, nextTick, onMounted, ref, watch } from 'vue'
76
+
77
+ interface Props {
78
+ // 画布宽度
79
+ width?: string | number
80
+ // 画布高度
81
+ height?: string | number
82
+ // 背景颜色
83
+ bgColor?: string
84
+ // 默认笔画颜色
85
+ color?: string
86
+ // 默认笔画粗细
87
+ thickness?: string | number
88
+ // 是否显示工具栏
89
+ showToolbar?: boolean
90
+ }
91
+
92
+ const props = withDefaults(defineProps<Props>(), {
93
+ width: 300,
94
+ height: 200,
95
+ bgColor: '#ffffff',
96
+ color: '#000000',
97
+ thickness: 3,
98
+ showToolbar: true,
99
+ })
100
+
101
+ const emit = defineEmits<{
102
+ (e: 'clear'): void
103
+ (e: 'confirm', path: string): void
104
+ (e: 'error', error: unknown): void
105
+ }>()
106
+
107
+ const canvasId = 'dd-signature-' + Math.random().toString(36).substr(2, 9)
108
+ const canvasWidth = ref(300)
109
+ const canvasHeight = ref(200)
110
+ const lineColor = ref('')
111
+ const lineWidth = ref(3)
112
+ const isDrawing = ref(false)
113
+ const pathStack = ref<any[]>([]) // 存储绘制路径用于回退
114
+ const currentPath = ref<any[]>([]) // 当前绘制路径
115
+ const isEmpty = ref(true)
116
+ const presetColors = [
117
+ '#000000', // 黑色
118
+ '#ff0000', // 红色
119
+ '#00ff00', // 绿色
120
+ '#0000ff', // 蓝色
121
+ '#ffff00', // 黄色
122
+ '#00ffff', // 青色
123
+ '#ff00ff', // 紫色
124
+ '#ffffff' // 白色
125
+ ]
126
+ const showBrushSettings = ref(false)
127
+ const showColorSettings = ref(false)
128
+ const lastPoint = ref<any>(null) // 保存上一个点的坐标
129
+ const canvasInstance = ref<any>(null) // 缓存canvas实例
130
+ const signatureCanvas = ref<any>(null)
131
+
132
+ // ponytail: 剥离运行时主题;签名画布默认保持白底(导出图片需白底)
133
+ const resolvedBgColor = computed(() => props.bgColor)
134
+ const iconDefaultColor = computed(() => '#999999')
135
+ const iconDisabledColor = computed(() => '#5c5c5c')
136
+
137
+ onMounted(() => {
138
+ // 初始化时获取canvas实例
139
+ nextTick(() => {
140
+ getCanvasInstance()
141
+ clearCanvas()
142
+ })
143
+ })
144
+
145
+ watch(
146
+ () => props.width,
147
+ (newVal: any) => {
148
+ canvasWidth.value = Number(newVal)
149
+ },
150
+ { immediate: true }
151
+ )
152
+ watch(
153
+ () => props.height,
154
+ (newVal: any) => {
155
+ canvasHeight.value = Number(newVal)
156
+ },
157
+ { immediate: true }
158
+ )
159
+ watch(
160
+ () => props.color,
161
+ (newVal: any) => {
162
+ lineColor.value = resolveStrokeColor(newVal)
163
+ },
164
+ { immediate: true }
165
+ )
166
+ watch(
167
+ () => props.thickness,
168
+ (newVal: any) => {
169
+ lineWidth.value = Number(newVal)
170
+ },
171
+ { immediate: true }
172
+ )
173
+
174
+ function resolveStrokeColor(color: any) {
175
+ return color
176
+ }
177
+
178
+ // 获取签名画布实例
179
+ function getCanvasInstance() {
180
+ if (canvasInstance.value) {
181
+ return canvasInstance.value
182
+ }
183
+
184
+ const canvasRef = signatureCanvas.value
185
+ if (canvasRef) {
186
+ canvasInstance.value = canvasRef
187
+ return canvasRef
188
+ }
189
+ return null
190
+ }
191
+
192
+ function touchStart(e: any) {
193
+ if (!canvasInstance.value || !canvasInstance.value.ctx) {
194
+ getCanvasInstance()
195
+ }
196
+
197
+ if (!canvasInstance.value || !canvasInstance.value.ctx) return
198
+
199
+ isDrawing.value = true
200
+ isEmpty.value = false
201
+ currentPath.value = []
202
+
203
+ const { x, y } = getCanvasPoint(e)
204
+
205
+ // 设置线条样式
206
+ canvasInstance.value.setLineStyle(lineColor.value, lineWidth.value)
207
+
208
+ // 开始路径
209
+ canvasInstance.value.beginPath()
210
+ canvasInstance.value.moveTo(x, y)
211
+
212
+ // 记录起始点
213
+ currentPath.value.push({
214
+ x,
215
+ y,
216
+ type: 'start',
217
+ color: lineColor.value,
218
+ width: lineWidth.value
219
+ })
220
+
221
+ // 保存上一个点
222
+ lastPoint.value = { x, y }
223
+
224
+ // 阻止默认事件以提高性能
225
+ e.preventDefault()
226
+ }
227
+
228
+ function touchMove(e: any) {
229
+ if (!isDrawing.value || !canvasInstance.value || !canvasInstance.value.ctx) return
230
+
231
+ // 阻止默认事件以提高性能
232
+ e.preventDefault()
233
+
234
+ const { x, y } = getCanvasPoint(e)
235
+
236
+ // 从上一个点画线到当前点
237
+ canvasInstance.value.lineTo(x, y)
238
+ canvasInstance.value.stroke() // 实时绘制当前线段
239
+ currentPath.value.push({
240
+ x,
241
+ y,
242
+ type: 'move'
243
+ })
244
+ canvasInstance.value.draw(false)
245
+
246
+ // 更新上一个点
247
+ lastPoint.value = { x, y }
248
+ }
249
+
250
+ function touchEnd(e: any) {
251
+ if (!isDrawing.value || !canvasInstance.value || !canvasInstance.value.ctx) return
252
+
253
+ isDrawing.value = false
254
+ canvasInstance.value.closePath()
255
+ lastPoint.value = null
256
+
257
+ // 将当前路径加入栈中用于回退
258
+ if (currentPath.value.length > 0) {
259
+ pathStack.value.push([...currentPath.value])
260
+ }
261
+
262
+ // 最后统一执行一次绘制
263
+ canvasInstance.value.draw(true)
264
+ }
265
+
266
+ // 同步获取canvas坐标点(兼容处理)
267
+ function getCanvasPoint(e: any) {
268
+ let touch
269
+ // #ifdef MP-WEIXIN
270
+ touch = e.touches && e.touches[0] ? e.touches[0] : e.mp.touches[0]
271
+ // #endif
272
+ // #ifndef MP-WEIXIN
273
+ touch = e.touches[0]
274
+ // #endif
275
+
276
+ // 计算相对于canvas的坐标
277
+ // 由于无法直接获取canvas位置,这里简化处理
278
+ // 实际应用中可能需要通过uni.createSelectorQuery获取canvas位置
279
+ return {
280
+ x: touch.x,
281
+ y: touch.y
282
+ }
283
+ }
284
+
285
+ // 选择颜色
286
+ function selectColor(color: string) {
287
+ lineColor.value = color
288
+ }
289
+
290
+ // 回退操作
291
+ function undo() {
292
+ if (pathStack.value.length === 0) return
293
+
294
+ // 弹出最后一个路径
295
+ pathStack.value.pop()
296
+
297
+ // 重新绘制
298
+ redraw()
299
+ }
300
+
301
+ // 重新绘制所有路径
302
+ function redraw() {
303
+ if (!canvasInstance.value) {
304
+ getCanvasInstance()
305
+ }
306
+
307
+ if (!canvasInstance.value) return
308
+
309
+ // 先清空画布
310
+ canvasInstance.value.clearCanvas()
311
+
312
+ if (pathStack.value.length === 0) {
313
+ isEmpty.value = true
314
+ return
315
+ }
316
+
317
+ isEmpty.value = false
318
+
319
+ // 逐个绘制路径
320
+ pathStack.value.forEach((path: any) => {
321
+ if (path.length === 0) return
322
+
323
+ canvasInstance.value.beginPath()
324
+
325
+ let lastPoint = null
326
+ path.forEach((point: any, index: number) => {
327
+ if (index === 0 && point.type === 'start') {
213
328
  // 设置线条样式
214
- this.canvasInstance.setLineStyle(this.lineColor, this.lineWidth);
215
-
216
- // 开始路径
217
- this.canvasInstance.beginPath();
218
- this.canvasInstance.moveTo(x, y);
219
-
220
- // 记录起始点
221
- this.currentPath.push({
222
- x,
223
- y,
224
- type: 'start',
225
- color: this.lineColor,
226
- width: this.lineWidth
227
- });
228
-
229
- // 保存上一个点
230
- this.lastPoint = { x, y };
231
-
232
- // 阻止默认事件以提高性能
233
- e.preventDefault();
234
- },
235
-
236
- touchMove(e) {
237
- if (!this.isDrawing || !this.canvasInstance || !this.canvasInstance.ctx) return;
238
-
239
- // 阻止默认事件以提高性能
240
- e.preventDefault();
241
-
242
- const { x, y } = this.getCanvasPoint(e);
243
-
244
- // 从上一个点画线到当前点
245
- this.canvasInstance.lineTo(x, y);
246
- this.canvasInstance.stroke(); // 实时绘制当前线段
247
- this.currentPath.push({
248
- x,
249
- y,
250
- type: 'move'
251
- });
252
- this.canvasInstance.draw(false);
253
-
254
- // 更新上一个点
255
- this.lastPoint = { x, y };
256
- },
257
-
258
- touchEnd(e) {
259
- if (!this.isDrawing || !this.canvasInstance || !this.canvasInstance.ctx) return;
260
-
261
- this.isDrawing = false;
262
- this.canvasInstance.closePath();
263
- this.lastPoint = null;
264
-
265
- // 将当前路径加入栈中用于回退
266
- if (this.currentPath.length > 0) {
267
- this.pathStack.push([...this.currentPath]);
268
- }
269
-
270
- // 最后统一执行一次绘制
271
- this.canvasInstance.draw(true);
272
- },
273
-
274
- // 同步获取canvas坐标点(兼容处理)
275
- getCanvasPoint(e) {
276
- let touch;
277
- // #ifdef MP-WEIXIN
278
- touch = e.touches && e.touches[0] ? e.touches[0] : e.mp.touches[0];
279
- // #endif
280
- // #ifndef MP-WEIXIN
281
- touch = e.touches[0];
282
- // #endif
283
-
284
- // 计算相对于canvas的坐标
285
- // 由于无法直接获取canvas位置,这里简化处理
286
- // 实际应用中可能需要通过uni.createSelectorQuery获取canvas位置
287
- return {
288
- x: touch.x,
289
- y: touch.y
290
- };
291
- },
292
-
293
- // 选择颜色
294
- selectColor(color) {
295
- this.lineColor = color
296
- },
297
-
298
- // 回退操作
299
- undo() {
300
- if (this.pathStack.length === 0) return
301
-
302
- // 弹出最后一个路径
303
- this.pathStack.pop()
304
-
305
- // 重新绘制
306
- this.redraw()
307
- },
308
-
309
- // 重新绘制所有路径
310
- redraw() {
311
- if (!this.canvasInstance) {
312
- this.getCanvasInstance();
313
- }
314
-
315
- if (!this.canvasInstance) return;
316
-
317
- // 先清空画布
318
- this.canvasInstance.clearCanvas();
319
-
320
- if (this.pathStack.length === 0) {
321
- this.isEmpty = true;
322
- return;
323
- }
324
-
325
- this.isEmpty = false;
326
-
327
- // 逐个绘制路径
328
- this.pathStack.forEach(path => {
329
- if (path.length === 0) return;
330
-
331
- this.canvasInstance.beginPath();
332
-
333
- let lastPoint = null;
334
- path.forEach((point, index) => {
335
- if (index === 0 && point.type === 'start') {
336
- // 设置线条样式
337
- this.canvasInstance.setLineStyle(point.color, point.width);
338
- this.canvasInstance.moveTo(point.x, point.y);
339
- lastPoint = { x: point.x, y: point.y };
340
- } else if (point.type === 'move') {
341
- this.canvasInstance.lineTo(point.x, point.y);
342
- lastPoint = { x: point.x, y: point.y };
343
- }
344
- });
345
- this.canvasInstance.stroke();
346
- this.canvasInstance.draw(true);
347
- });
348
- },
349
-
350
- // 清空画布内容
351
- clearCanvas() {
352
- if (!this.canvasInstance) {
353
- this.getCanvasInstance();
354
- }
355
-
356
- if (!this.canvasInstance) return;
357
-
358
- this.canvasInstance.clearCanvas();
359
- },
360
-
361
- // 对外暴露的清空方法(供工具栏与ref调用)
362
- clear() {
363
- this.pathStack = []
364
- this.currentPath = []
365
- this.lastPoint = null
366
- this.isDrawing = false
367
- this.isEmpty = true
368
- this.clearCanvas()
369
- this.$emit('clear')
370
- },
371
-
372
- // 导出签名图片
373
- async exportSignature() {
374
- if (this.isEmpty) {
375
- console.warn('签名为空,无法导出');
376
- return;
377
- }
378
-
379
- if (!this.canvasInstance) {
380
- this.getCanvasInstance();
381
- }
382
-
383
- if (!this.canvasInstance) {
384
- console.error('无法获取画布实例');
385
- return;
386
- }
387
-
388
- try {
389
- // 先重绘整个签名内容
390
- this.redraw();
391
-
392
- // 导出图片
393
- const imagePath = await this.canvasInstance.exportImage('png', 1);
394
- this.$emit('confirm', imagePath);
395
- } catch (error) {
396
- console.error('导出签名图片失败:', error);
397
- this.$emit('error', error);
398
- }
399
- },
400
-
401
- // 切换笔画设置显示
402
- toggleBrushSettings() {
403
- this.showBrushSettings = !this.showBrushSettings;
404
- if (this.showBrushSettings) {
405
- this.showColorSettings = false;
406
- }
407
- },
408
-
409
- // 切换颜色设置显示
410
- toggleColorSettings() {
411
- this.showColorSettings = !this.showColorSettings;
412
- if (this.showColorSettings) {
413
- this.showBrushSettings = false;
414
- }
415
- },
416
- }
329
+ canvasInstance.value.setLineStyle(point.color, point.width)
330
+ canvasInstance.value.moveTo(point.x, point.y)
331
+ lastPoint = { x: point.x, y: point.y }
332
+ } else if (point.type === 'move') {
333
+ canvasInstance.value.lineTo(point.x, point.y)
334
+ lastPoint = { x: point.x, y: point.y }
335
+ }
336
+ })
337
+ canvasInstance.value.stroke()
338
+ canvasInstance.value.draw(true)
339
+ })
340
+ }
341
+
342
+ // 清空画布内容
343
+ function clearCanvas() {
344
+ if (!canvasInstance.value) {
345
+ getCanvasInstance()
346
+ }
347
+
348
+ if (!canvasInstance.value) return
349
+
350
+ canvasInstance.value.clearCanvas()
351
+ }
352
+
353
+ // 对外暴露的清空方法(供工具栏与ref调用)
354
+ function clear() {
355
+ pathStack.value = []
356
+ currentPath.value = []
357
+ lastPoint.value = null
358
+ isDrawing.value = false
359
+ isEmpty.value = true
360
+ clearCanvas()
361
+ emit('clear')
362
+ }
363
+
364
+ // 导出签名图片
365
+ async function exportSignature() {
366
+ if (isEmpty.value) {
367
+ console.warn('签名为空,无法导出')
368
+ return
369
+ }
370
+
371
+ if (!canvasInstance.value) {
372
+ getCanvasInstance()
417
373
  }
374
+
375
+ if (!canvasInstance.value) {
376
+ console.error('无法获取画布实例')
377
+ return
378
+ }
379
+
380
+ try {
381
+ // 先重绘整个签名内容
382
+ redraw()
383
+
384
+ // 导出图片
385
+ const imagePath = await canvasInstance.value.exportImage('png', 1)
386
+ emit('confirm', imagePath)
387
+ } catch (error) {
388
+ console.error('导出签名图片失败:', error)
389
+ emit('error', error)
390
+ }
391
+ }
392
+
393
+ // 切换笔画设置显示
394
+ function toggleBrushSettings() {
395
+ showBrushSettings.value = !showBrushSettings.value
396
+ if (showBrushSettings.value) {
397
+ showColorSettings.value = false
398
+ }
399
+ }
400
+
401
+ // 切换颜色设置显示
402
+ function toggleColorSettings() {
403
+ showColorSettings.value = !showColorSettings.value
404
+ if (showColorSettings.value) {
405
+ showBrushSettings.value = false
406
+ }
407
+ }
408
+
409
+ defineExpose({
410
+ canvasId,
411
+ canvasWidth,
412
+ canvasHeight,
413
+ lineColor,
414
+ lineWidth,
415
+ isDrawing,
416
+ pathStack,
417
+ currentPath,
418
+ isEmpty,
419
+ presetColors,
420
+ showBrushSettings,
421
+ showColorSettings,
422
+ lastPoint,
423
+ resolveStrokeColor,
424
+ getCanvasInstance,
425
+ touchStart,
426
+ touchMove,
427
+ touchEnd,
428
+ getCanvasPoint,
429
+ selectColor,
430
+ undo,
431
+ redraw,
432
+ clearCanvas,
433
+ clear,
434
+ exportSignature,
435
+ toggleBrushSettings,
436
+ toggleColorSettings,
437
+ })
418
438
  </script>
419
439
 
420
440
  <style lang="scss" scoped>
@@ -426,7 +446,7 @@
426
446
 
427
447
  &__canvas-wrap {
428
448
  border: 1px solid var(--dd-border-default, #{$dd-border-default});
429
- border-radius: 4px;
449
+ border-radius: $dd-radius-md;
430
450
  overflow: hidden;
431
451
  }
432
452
 
@@ -436,7 +456,7 @@
436
456
  }
437
457
 
438
458
  &__toolbar {
439
- margin-top: 5px;
459
+ margin-top: 10rpx;
440
460
  background-color: var(--dd-bg-elevated, #{$dd-bg-elevated});
441
461
  }
442
462
 
@@ -446,38 +466,38 @@
446
466
  align-items: center;
447
467
  padding: 1px 0;
448
468
  // border: 1px solid #e0e0e0;
449
- border-radius: 4px;
469
+ border-radius: $dd-radius-md;
450
470
  }
451
471
 
452
472
  &__toolbar-icon {
453
- padding: 5px;
473
+ padding: 10rpx;
454
474
  }
455
475
 
456
476
  &__brush-settings,
457
477
  &__color-settings {
458
- margin-top: 15px;
478
+ margin-top: 30rpx;
459
479
  padding: 1px;
460
480
  // border: 1px solid #e0e0e0;
461
- border-radius: 4px;
481
+ border-radius: $dd-radius-md;
462
482
  }
463
483
 
464
484
  &__progress {
465
485
  &-label {
466
486
  display: block;
467
- margin-bottom: 10px;
468
- font-size: 14px;
487
+ margin-bottom: 20rpx;
488
+ font-size: $dd-font-size-body;
469
489
  color: var(--dd-text-tertiary, #{$dd-text-tertiary});
470
490
  }
471
491
  }
472
492
 
473
493
  &__color-picker {
474
- margin-bottom: 10px;
494
+ margin-bottom: 20rpx;
475
495
  }
476
496
 
477
497
  &__color-label {
478
498
  display: block;
479
- margin-bottom: 10px;
480
- font-size: 14px;
499
+ margin-bottom: 20rpx;
500
+ font-size: $dd-font-size-body;
481
501
  color: var(--dd-text-tertiary, #{$dd-text-tertiary});
482
502
  }
483
503
 
@@ -485,12 +505,12 @@
485
505
  display: flex;
486
506
  flex-direction: row;
487
507
  flex-wrap: wrap;
488
- gap: 10px;
508
+ gap: 20rpx;
489
509
  }
490
510
 
491
511
  &__color-item {
492
- width: 30px;
493
- height: 30px;
512
+ width: 60rpx;
513
+ height: 60rpx;
494
514
  border-radius: 50%;
495
515
  border: 2px solid var(--dd-border-default, #{$dd-border-default});
496
516
  cursor: pointer;
@@ -504,7 +524,7 @@
504
524
  &__actions {
505
525
  display: flex;
506
526
  flex-direction: row;
507
- gap: 10px;
527
+ gap: 20rpx;
508
528
  justify-content: center;
509
529
  }
510
530
  }