@didaoktv/didaoui-uniapp 2.13.0 → 2.14.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 (59) 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-icon/dd-icon.vue +1 -1
  16. package/components/dd-keyboard/dd-keyboard.vue +95 -46
  17. package/components/dd-link/dd-link.vue +72 -49
  18. package/components/dd-markdown/dd-markdown.vue +154 -154
  19. package/components/dd-number-keyboard/dd-number-keyboard.vue +109 -94
  20. package/components/dd-parse/dd-parse.vue +473 -442
  21. package/components/dd-poster/dd-poster.vue +579 -567
  22. package/components/dd-pull-refresh/dd-pull-refresh.vue +1 -9
  23. package/components/dd-qrcode/dd-qrcode.vue +431 -405
  24. package/components/dd-radio-group/dd-radio-group.vue +1 -1
  25. package/components/dd-segmented-tab/dd-segmented-tab.vue +22 -14
  26. package/components/dd-signature/dd-signature.vue +377 -357
  27. package/components/dd-step/dd-step.vue +1 -1
  28. package/components/dd-sticky/dd-sticky.vue +5 -10
  29. package/components/dd-swipe-action/dd-swipe-action.vue +1 -9
  30. package/components/dd-swipe-item/dd-swipe-item.vue +2 -0
  31. package/components/dd-swipeable-tab/dd-swipeable-tab.vue +1 -5
  32. package/components/dd-switch/dd-switch.vue +1 -1
  33. package/components/dd-text/dd-text.vue +304 -82
  34. package/components/dd-waterfall/dd-waterfall.vue +89 -0
  35. package/index.ts +4 -3
  36. package/libs/function/index.d.ts +88 -0
  37. package/libs/function/index.js +14 -0
  38. package/libs/function/test.d.ts +65 -0
  39. package/package.json +1 -1
  40. package/scss/_mixins.scss +8 -0
  41. package/scss/_theme-tokens.scss +7 -0
  42. package/scss/_variables.scss +283 -156
  43. package/components/dd-album/album.js +0 -19
  44. package/components/dd-album/props.js +0 -89
  45. package/components/dd-avatar/avatar.js +0 -19
  46. package/components/dd-avatar/props.js +0 -84
  47. package/components/dd-avatar-group/avatarGroup.js +0 -14
  48. package/components/dd-avatar-group/props.js +0 -57
  49. package/components/dd-keyboard/keyboard.js +0 -19
  50. package/components/dd-keyboard/props.js +0 -79
  51. package/components/dd-link/link.js +0 -17
  52. package/components/dd-link/props.js +0 -44
  53. package/components/dd-number-keyboard/numberKeyboard.js +0 -8
  54. package/components/dd-number-keyboard/props.js +0 -24
  55. package/components/dd-parse/props.js +0 -57
  56. package/components/dd-text/props.js +0 -120
  57. package/components/dd-text/text.js +0 -30
  58. package/components/dd-text/value.js +0 -87
  59. package/scss/_dd-shared.scss +0 -40
@@ -15,182 +15,182 @@
15
15
  </view>
16
16
  </template>
17
17
 
18
- <script>
19
- import { marked } from './marked.esm.mjs';
18
+ <script setup lang="ts">
19
+ import { ref, watch } from 'vue'
20
+ // @ts-ignore marked.esm.mjs 无类型声明
21
+ import { marked } from './marked.esm.mjs'
20
22
 
21
- export default {
22
- name: 'dd-markdown',
23
- // #ifdef VUE3
24
- emits: ['load', 'ready', 'imgtap', 'linktap', 'play', 'error'],
25
- // #endif
26
- props: {
27
- // markdown内容
28
- content: {
29
- type: String,
30
- default: ''
31
- },
32
- // 是否启用图片预览
33
- previewImg: {
34
- type: Boolean,
35
- default: true
36
- },
37
- // 是否允许外部链接被点击时自动打开
38
- copyLink: {
39
- type: [Boolean, String],
40
- default: true
41
- },
42
- // 主域名,用于 dd-parse 处理相对链接
43
- domain: {
44
- type: String,
45
- default: ''
46
- },
47
- // 是否显示代码块行号
48
- showLineNumber: {
49
- type: Boolean,
50
- default: false
51
- },
52
- // 主题样式 'light' | 'dark'
53
- theme: {
54
- type: String,
55
- default: 'light'
56
- }
57
- },
58
- data() {
59
- return {
60
- parsedContent: ''
61
- };
62
- },
63
- watch: {
64
- content: {
65
- handler(newVal) {
66
- this.parseMarkdown(newVal);
67
- },
68
- immediate: true
69
- }
23
+ interface Props {
24
+ // markdown内容
25
+ content?: string
26
+ // 是否启用图片预览
27
+ previewImg?: boolean
28
+ // 是否允许外部链接被点击时自动打开
29
+ copyLink?: boolean | string
30
+ // 主域名,用于 dd-parse 处理相对链接
31
+ domain?: string
32
+ // 是否显示代码块行号
33
+ showLineNumber?: boolean
34
+ // 主题样式 'light' | 'dark'
35
+ theme?: string
36
+ }
37
+
38
+ const props = withDefaults(defineProps<Props>(), {
39
+ content: '',
40
+ previewImg: true,
41
+ copyLink: true,
42
+ domain: '',
43
+ showLineNumber: false,
44
+ theme: 'light',
45
+ })
46
+
47
+ const emit = defineEmits<{
48
+ (e: 'load', event: any): void
49
+ (e: 'ready', event: any): void
50
+ (e: 'imgtap', event: any): void
51
+ (e: 'linktap', event: any): void
52
+ (e: 'play', event: any): void
53
+ (e: 'error', event: any): void
54
+ }>()
55
+
56
+ const parsedContent = ref('')
57
+
58
+ watch(
59
+ () => props.content,
60
+ (newVal: string) => {
61
+ parseMarkdown(newVal)
70
62
  },
71
- methods: {
72
- // 解析markdown内容
73
- parseMarkdown(content) {
74
- if (!content) {
75
- this.parsedContent = '';
76
- return;
77
- }
63
+ { immediate: true }
64
+ )
78
65
 
79
- // 使用marked解析markdown
80
- let parsed = marked(content);
81
-
82
- // 处理代码块
83
- parsed = this.handleCodeBlock(parsed);
84
-
85
- // 应用主题样式
86
- parsed = this.applyTheme(parsed);
87
-
88
- this.parsedContent = parsed;
89
- },
90
-
91
- // 处理代码块
92
- handleCodeBlock(html) {
93
- // 添加代码块样式和行号
94
- return html.replace(/<pre><code([^>]*)>([^<]+)<\/code><\/pre>/g, (match, lang, code) => {
95
- const language = lang.match(/class="language-([^"]+)"/);
96
- const langClass = language ? `language-${language[1]}` : '';
97
-
98
- let result = `<pre class="dd-markdown-code ${langClass}">`;
99
-
100
- if (this.showLineNumber) {
101
- // 添加行号
102
- const lines = code.split('\n').filter(line => line.trim() !== '');
103
- result += '<span class="dd-markdown-line-numbers">';
104
- lines.push('');
105
- lines.forEach((_, index) => {
106
- result += `<span class="dd-markdown-line-number">${index + 1}</span>`;
107
- });
108
- result += '</span>';
109
- }
110
-
111
- result += `<code class='code-lang ${langClass}'>${code}</code></pre>`;
112
- return result;
113
- });
114
- },
115
-
116
- // 应用主题样式
117
- applyTheme(html) {
118
- // 可以根据theme属性添加不同的样式类
119
- return html;
120
- },
121
- emitLoad(event) {
122
- this.$emit('load', event)
123
- },
124
- emitReady(event) {
125
- this.$emit('ready', event)
126
- },
127
- emitImgtap(event) {
128
- this.$emit('imgtap', event)
129
- },
130
- emitLinktap(event) {
131
- this.$emit('linktap', event)
132
- },
133
- emitPlay(event) {
134
- this.$emit('play', event)
135
- },
136
- emitError(event) {
137
- this.$emit('error', event)
138
- }
66
+ // 解析markdown内容
67
+ function parseMarkdown(content: string) {
68
+ if (!content) {
69
+ parsedContent.value = ''
70
+ return
139
71
  }
140
- };
72
+
73
+ // 使用marked解析markdown
74
+ let parsed = marked(content)
75
+
76
+ // 处理代码块
77
+ parsed = handleCodeBlock(parsed)
78
+
79
+ // 应用主题样式
80
+ parsed = applyTheme(parsed)
81
+
82
+ parsedContent.value = parsed
83
+ }
84
+
85
+ // 处理代码块
86
+ function handleCodeBlock(html: string) {
87
+ // 添加代码块样式和行号
88
+ return html.replace(/<pre><code([^>]*)>([^<]+)<\/code><\/pre>/g, (match, lang, code) => {
89
+ const language = lang.match(/class="language-([^"]+)"/)
90
+ const langClass = language ? `language-${language[1]}` : ''
91
+
92
+ let result = `<pre class="dd-markdown-code ${langClass}">`
93
+
94
+ if (props.showLineNumber) {
95
+ // 添加行号
96
+ const lines = code.split('\n').filter((line: any) => line.trim() !== '')
97
+ result += '<span class="dd-markdown-line-numbers">'
98
+ lines.push('')
99
+ lines.forEach((_: any, index: number) => {
100
+ result += `<span class="dd-markdown-line-number">${index + 1}</span>`
101
+ })
102
+ result += '</span>'
103
+ }
104
+
105
+ result += `<code class='code-lang ${langClass}'>${code}</code></pre>`
106
+ return result
107
+ })
108
+ }
109
+
110
+ // 应用主题样式
111
+ function applyTheme(html: string) {
112
+ // 可以根据theme属性添加不同的样式类
113
+ return html
114
+ }
115
+
116
+ function emitLoad(event: any) {
117
+ emit('load', event)
118
+ }
119
+
120
+ function emitReady(event: any) {
121
+ emit('ready', event)
122
+ }
123
+
124
+ function emitImgtap(event: any) {
125
+ emit('imgtap', event)
126
+ }
127
+
128
+ function emitLinktap(event: any) {
129
+ emit('linktap', event)
130
+ }
131
+
132
+ function emitPlay(event: any) {
133
+ emit('play', event)
134
+ }
135
+
136
+ function emitError(event: any) {
137
+ emit('error', event)
138
+ }
139
+
140
+ defineExpose({ parsedContent, parseMarkdown, handleCodeBlock, applyTheme })
141
141
  </script>
142
142
 
143
143
  <style lang="scss" scoped>
144
144
  @import '../../scss/variables';
145
-
145
+ @import '../../scss/mixins';
146
146
  .dd-markdown {
147
147
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
148
- font-size: 16px;
148
+ font-size: $dd-font-size-h4;
149
149
  line-height: 1.6;
150
150
  color: var(--dd-fg, #{$dd-fg});
151
- padding: 16px;
151
+ padding: $dd-space-4;
152
152
  word-wrap: break-word;
153
153
 
154
154
  /* 标题样式 */
155
155
  :deep(h1) {
156
- font-size: 32px;
157
- margin: 8px 0;
156
+ font-size: $dd-font-size-display;
157
+ margin: $dd-space-2 0;
158
158
  font-weight: bold;
159
159
  }
160
160
 
161
161
  :deep(h2) {
162
- font-size: 24px;
163
- margin: 8px 0;
162
+ font-size: $dd-font-size-h1;
163
+ margin: $dd-space-2 0;
164
164
  font-weight: bold;
165
165
  }
166
166
 
167
167
  :deep(h3) {
168
- font-size: 18px;
169
- margin: 7px 0;
168
+ font-size: $dd-font-size-h3;
169
+ margin: 14rpx 0;
170
170
  font-weight: bold;
171
171
  }
172
172
 
173
173
  :deep(h4) {
174
- font-size: 16px;
175
- margin: 7px 0;
174
+ font-size: $dd-font-size-h4;
175
+ margin: 14rpx 0;
176
176
  font-weight: bold;
177
177
  }
178
178
 
179
179
  :deep(h5) {
180
- font-size: 13px;
181
- margin: 6px 0;
180
+ font-size: 26rpx;
181
+ margin: 12rpx 0;
182
182
  font-weight: bold;
183
183
  }
184
184
 
185
185
  :deep(h6) {
186
- font-size: 10px;
187
- margin: 5px 0;
186
+ font-size: $dd-font-size-overline;
187
+ margin: 10rpx 0;
188
188
  font-weight: bold;
189
189
  }
190
190
 
191
191
  /* 段落样式 */
192
192
  :deep(p) {
193
- margin: 16px 0;
193
+ margin: $dd-space-4 0;
194
194
  }
195
195
 
196
196
  /* 链接样式 */
@@ -206,11 +206,11 @@ export default {
206
206
  /* 列表样式 */
207
207
  :deep(ul,
208
208
  :deep ol) {
209
- margin: 16px 0;
210
- padding-left: 32px;
209
+ margin: $dd-space-4 0;
210
+ padding-left: $dd-space-6;
211
211
 
212
212
  li {
213
- margin: 8px 0;
213
+ margin: $dd-space-2 0;
214
214
  }
215
215
  }
216
216
 
@@ -224,8 +224,8 @@ export default {
224
224
 
225
225
  /* 引用样式 */
226
226
  :deep(blockquote) {
227
- margin: 8px 0;
228
- padding: 0 10px;
227
+ margin: $dd-space-2 0;
228
+ padding: 0 20rpx;
229
229
  border-left: 4px solid var(--dd-border-default, #{$dd-border-default});
230
230
  color: var(--dd-text-secondary, #{$dd-text-secondary});
231
231
  }
@@ -233,10 +233,10 @@ export default {
233
233
  /* 代码样式 */
234
234
  :deep(&-code) {
235
235
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
236
- font-size: 14px;
236
+ font-size: $dd-font-size-body;
237
237
  background-color: var(--dd-surface-container, #{$dd-surface-container});
238
- padding: 3px 6px;
239
- border-radius: 3px;
238
+ padding: 6rpx 12rpx;
239
+ border-radius: 6rpx;
240
240
  display: flex;
241
241
  }
242
242
  :deep(.code-lang) {
@@ -246,12 +246,12 @@ export default {
246
246
 
247
247
  :deep(pre) {
248
248
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
249
- font-size: 14px;
249
+ font-size: $dd-font-size-body;
250
250
  background-color: var(--dd-surface-container, #{$dd-surface-container});
251
- padding: 16px;
251
+ padding: $dd-space-4;
252
252
  overflow: auto;
253
- border-radius: 6px;
254
- margin: 16px 0;
253
+ border-radius: 12rpx;
254
+ margin: $dd-space-4 0;
255
255
 
256
256
  :deep(code) {
257
257
  background: none;
@@ -262,12 +262,12 @@ export default {
262
262
  /* 表格样式 */
263
263
  :deep(table) {
264
264
  border-collapse: collapse;
265
- margin: 16px 0;
265
+ margin: $dd-space-4 0;
266
266
  width: 100%;
267
267
 
268
268
  th,
269
269
  td {
270
- padding: 6px 13px;
270
+ padding: 12rpx 26rpx;
271
271
  border: 1px solid #dfe2e5;
272
272
  }
273
273
 
@@ -285,14 +285,14 @@ export default {
285
285
  max-width: 100%;
286
286
  box-sizing: content-box;
287
287
  background-color: #fff;
288
- margin: 16px 0;
288
+ margin: $dd-space-4 0;
289
289
  }
290
290
 
291
291
  /* 分割线样式 */
292
292
  :deep(hr) {
293
293
  height: 1px;
294
294
  padding: 0;
295
- margin: 24px 0;
295
+ margin: $dd-space-5 0;
296
296
  background-color: var(--dd-rule, #{$dd-rule});
297
297
  border: 0;
298
298
  }
@@ -306,14 +306,14 @@ export default {
306
306
  display: flex;
307
307
  flex-direction: column;
308
308
  align-items: flex-start;
309
- padding-right: 10px;
310
- margin-right: 10px;
309
+ padding-right: 20rpx;
310
+ margin-right: 20rpx;
311
311
  border-right: 1px solid #ddd;
312
312
  user-select: none;
313
313
 
314
314
  .dd-markdown-line-number {
315
315
  color: #999;
316
- font-size: 14px;
316
+ font-size: $dd-font-size-body;
317
317
  line-height: 1.6;
318
318
  }
319
319
  }
@@ -40,11 +40,10 @@
40
40
  </view>
41
41
  </template>
42
42
 
43
- <script>
44
- import { props } from './props';
45
- import { mpMixin } from '../../libs/mixin/mpMixin';
46
- import { mixin } from '../../libs/mixin/mixin';
47
- import { randomArray } from '../../libs/function/index';
43
+ <script setup lang="ts">
44
+ import { computed, ref } from 'vue'
45
+ import DdIcon from '../dd-icon/dd-icon.vue'
46
+ import { randomArray } from '../../libs/function/index.js';
48
47
  /**
49
48
  * keyboard 键盘组件
50
49
  * @description
@@ -56,112 +55,128 @@
56
55
  * @event {Function} backspace 点击退格键触发
57
56
  * @example
58
57
  */
59
- export default {
60
- name: 'dd-number-keyboard',
61
- mixins: [mpMixin, mixin, props],
62
- data() {
63
- return {
64
- backspace: 'backspace', // 退格键内容
65
- dot: '.', // 点
66
- timer: null, // 长按多次删除的事件监听
67
- isTouch: false, // 本次退格是否来自触摸(防 tap 重复删除)
68
- cardX: 'X' // 身份证的X符号
69
- };
70
- },
71
- computed: {
72
- // 键盘需要显示的内容
73
- numList() {
74
- let tmp = [];
75
- if (this.dotDisabled && this.mode == 'number') {
76
- if (!this.random) {
77
- return [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
78
- } else {
79
- return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
80
- }
81
- } else if (!this.dotDisabled && this.mode == 'number') {
82
- if (!this.random) {
83
- return [1, 2, 3, 4, 5, 6, 7, 8, 9, this.dot, 0];
84
- } else {
85
- return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, this.dot, 0]);
86
- }
87
- } else if (this.mode == 'card') {
88
- if (!this.random) {
89
- return [1, 2, 3, 4, 5, 6, 7, 8, 9, this.cardX, 0];
90
- } else {
91
- return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, this.cardX, 0]);
92
- }
93
- }
94
- },
95
- // 按键的样式,在非乱序&&数字键盘&&不显示点按钮时,index为9时,"0"键占位两个空间(flex 拉伸为 2 倍宽)
96
- itemStyle() {
97
- return index => {
98
- let style = {};
99
- if (this.mode == 'number' && this.dotDisabled && index == 9) style.flex = '2 1 30%';
100
- return style;
101
- };
102
- },
103
- // 是否让按键显示灰色,只在非乱序&&数字键盘&&且允许点按键的时候("."键 / 身份证"X"键)
104
- btnBgGray() {
105
- return index => {
106
- if (!this.random && index == 9 && (this.mode != 'number' || (this.mode == 'number' && !this
107
- .dotDisabled))) return true;
108
- else return false;
109
- };
110
- },
111
- },
112
- created() {
113
- },
114
- emits: ["backspace", "change"],
115
- methods: {
116
- // 点击退格键(触摸路径:touchstart 立删 + 长按连删;鼠标路径:tap 单删,isTouch 防移动端触摸后 tap 二次删除)
117
- backspaceTouchStart() {
118
- this.isTouch = true
119
- this.$emit('backspace');
120
- clearInterval(this.timer); //再次清空定时器,防止重复注册定时器
121
- this.timer = null;
122
- this.timer = setInterval(() => {
123
- this.$emit('backspace');
124
- }, 250);
125
- },
126
- backspaceTap() {
127
- if (this.isTouch) {
128
- this.isTouch = false;
129
- return;
130
- }
131
- this.$emit('backspace');
132
- },
133
- clearTimer() {
134
- clearInterval(this.timer);
135
- this.timer = null;
136
- },
137
- // 获取键盘显示的内容
138
- keyboardClick(val) {
139
- // 允许键盘显示点模式和触发非点按键时,将内容转为数字类型
140
- if (!this.dotDisabled && val != this.dot && val != this.cardX) val = Number(val);
141
- this.$emit('change', val);
58
+ interface Props {
59
+ // 键盘的类型,number-数字键盘,card-身份证键盘
60
+ mode?: string
61
+ // 是否显示键盘的"."符号
62
+ dotDisabled?: boolean
63
+ // 是否打乱键盘按键的顺序
64
+ random?: boolean
65
+ }
66
+
67
+ const props = withDefaults(defineProps<Props>(), {
68
+ mode: 'number',
69
+ dotDisabled: false,
70
+ random: false,
71
+ })
72
+
73
+ const emit = defineEmits<{
74
+ (e: 'backspace'): void;
75
+ (e: 'change', val: any): void;
76
+ }>()
77
+
78
+ const backspace = ref('backspace') // 退格键内容
79
+ const dot = ref('.') // 点
80
+ let timer: any = null // 长按多次删除的事件监听
81
+ const isTouch = ref(false) // 本次退格是否来自触摸(防 tap 重复删除)
82
+ const cardX = ref('X') // 身份证的X符号
83
+
84
+ // 空操作:模板 @touchmove.stop.prevent="noop"
85
+ const noop = (e: any) => { e && typeof e.stopPropagation === 'function' && e.stopPropagation() }
86
+
87
+ // 键盘需要显示的内容
88
+ const numList = computed(() => {
89
+ if (props.dotDisabled && props.mode == 'number') {
90
+ if (!props.random) {
91
+ return [1, 2, 3, 4, 5, 6, 7, 8, 9, 0];
92
+ } else {
93
+ return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]);
94
+ }
95
+ } else if (!props.dotDisabled && props.mode == 'number') {
96
+ if (!props.random) {
97
+ return [1, 2, 3, 4, 5, 6, 7, 8, 9, dot.value, 0];
98
+ } else {
99
+ return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, dot.value, 0]);
142
100
  }
101
+ } else if (props.mode == 'card') {
102
+ if (!props.random) {
103
+ return [1, 2, 3, 4, 5, 6, 7, 8, 9, cardX.value, 0];
104
+ } else {
105
+ return randomArray([1, 2, 3, 4, 5, 6, 7, 8, 9, cardX.value, 0]);
106
+ }
107
+ }
108
+ })
109
+
110
+ // 按键的样式,在非乱序&&数字键盘&&不显示点按钮时,index为9时,"0"键占位两个空间(flex 拉伸为 2 倍宽)
111
+ const itemStyle = computed(() => {
112
+ return (index: number) => {
113
+ let style: Record<string, any> = {};
114
+ if (props.mode == 'number' && props.dotDisabled && index == 9) style.flex = '2 1 30%';
115
+ return style;
116
+ };
117
+ })
118
+
119
+ // 是否让按键显示灰色,只在非乱序&&数字键盘&&且允许点按键的时候("."键 / 身份证"X"键)
120
+ const btnBgGray = computed(() => {
121
+ return (index: number) => {
122
+ if (!props.random && index == 9 && (props.mode != 'number' || (props.mode == 'number' && !props
123
+ .dotDisabled))) return true;
124
+ else return false;
125
+ };
126
+ })
127
+
128
+ // 点击退格键(触摸路径:touchstart 立删 + 长按连删;鼠标路径:tap 单删,isTouch 防移动端触摸后 tap 二次删除)
129
+ function backspaceTouchStart() {
130
+ isTouch.value = true
131
+ emit('backspace');
132
+ clearInterval(timer); //再次清空定时器,防止重复注册定时器
133
+ timer = null;
134
+ timer = setInterval(() => {
135
+ emit('backspace');
136
+ }, 250);
137
+ }
138
+
139
+ function backspaceTap() {
140
+ if (isTouch.value) {
141
+ isTouch.value = false;
142
+ return;
143
143
  }
144
- };
144
+ emit('backspace');
145
+ }
146
+
147
+ function clearTimer() {
148
+ clearInterval(timer);
149
+ timer = null;
150
+ }
151
+
152
+ // 获取键盘显示的内容
153
+ function keyboardClick(val: any) {
154
+ // 允许键盘显示点模式和触发非点按键时,将内容转为数字类型
155
+ if (!props.dotDisabled && val != dot.value && val != cardX.value) val = Number(val);
156
+ emit('change', val);
157
+ }
158
+
159
+ defineExpose({ numList, itemStyle, btnBgGray, backspace, dot, isTouch, cardX, backspaceTouchStart, backspaceTap, clearTimer, keyboardClick })
145
160
  </script>
146
161
 
147
162
  <style lang="scss" scoped>
148
163
  @import '../../scss/variables';
149
- @import '../../scss/dd-shared';
164
+ @import '../../scss/mixins';
150
165
  $dd-number-keyboard-background-color: var(--dd-bg-section, #{$dd-bg-section}) !default;
151
- $dd-number-keyboard-padding:8px 10rpx 8px 10rpx !default;
166
+ $dd-number-keyboard-padding:$dd-space-2 10rpx $dd-space-2 10rpx !default;
152
167
  $dd-number-keyboard-gap:6rpx !default;
153
168
  $dd-number-keyboard-button-border-radius:$dd-radius-sm !default;
154
169
  $dd-number-keyboard-button-height: 90rpx!default;
155
170
  $dd-number-keyboard-button-background-color:var(--dd-surface-container-high, #{$dd-surface-container-high}) !default;
156
171
  $dd-number-keyboard-button-box-shadow:0 2px 0px var(--dd-bg, #{$dd-bg}) !default;
157
- $dd-number-keyboard-text-font-size:20px !default;
172
+ $dd-number-keyboard-text-font-size:$dd-font-size-h2 !default;
158
173
  $dd-number-keyboard-text-font-weight:500 !default;
159
174
  $dd-number-keyboard-text-color:var(--dd-text-primary, #{$dd-text-primary}) !default;
160
175
  $dd-number-keyboard-gray-background-color:var(--dd-surface-container-highest, #{$dd-surface-container-highest}) !default;
161
176
  $dd-number-keyboard-dd-keyboard-hover-background-color: var(--dd-surface-hover, #{$dd-surface-hover}) !default;
162
177
 
163
178
  .dd-keyboard {
164
- @include flex;
179
+ @include dd-flex;
165
180
  flex-direction: row;
166
181
  flex-wrap: wrap;
167
182
  gap: $dd-number-keyboard-gap;
@@ -178,7 +193,7 @@
178
193
  width: 100%;
179
194
  height: $dd-number-keyboard-button-height;
180
195
  background-color: $dd-number-keyboard-button-background-color;
181
- @include flex;
196
+ @include dd-flex;
182
197
  justify-content: center;
183
198
  align-items: center;
184
199
  border-radius: $dd-number-keyboard-button-border-radius;