hy-app 0.6.9 → 0.7.1
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/attributes.json +1 -1
- package/components/hy-avatar/hy-avatar.vue +12 -5
- package/components/hy-avatar/props.ts +4 -2
- package/components/hy-avatar/typing.d.ts +8 -1
- package/components/hy-calendar/hy-calendar.vue +3 -2
- package/components/hy-calendar/month.vue +25 -5
- package/components/hy-calendar/props.ts +1 -1
- package/components/hy-calendar/typing.d.ts +9 -0
- package/components/hy-cascader/hy-cascader.vue +503 -0
- package/components/hy-cascader/index.scss +84 -0
- package/components/hy-cascader/props.ts +88 -0
- package/components/hy-cascader/typing.d.ts +34 -0
- package/components/hy-check-button/typing.d.ts +12 -7
- package/components/hy-code-input/hy-code-input.vue +33 -11
- package/components/hy-code-input/typing.d.ts +4 -0
- package/components/hy-config-provider/hy-config-provider.vue +58 -53
- package/components/hy-count-down/hy-count-down.vue +8 -8
- package/components/hy-count-down/typing.d.ts +16 -0
- package/components/hy-count-to/hy-count-to.vue +7 -7
- package/components/hy-count-to/typing.d.ts +24 -0
- package/components/hy-datetime-picker/props.ts +1 -1
- package/components/hy-datetime-picker/typing.d.ts +1 -1
- package/components/hy-dropdown/typing.d.ts +5 -0
- package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -1
- package/components/hy-folding-panel/hy-folding-panel.vue +3 -3
- package/components/hy-folding-panel/typing.d.ts +23 -0
- package/components/hy-folding-panel-item/hy-folding-panel-item.vue +2 -2
- package/components/hy-folding-panel-item/typing.d.ts +21 -0
- package/components/hy-form/hy-form.vue +2 -2
- package/components/hy-form/typing.d.ts +37 -0
- package/components/hy-form-item/typing.d.ts +1 -1
- package/components/hy-grid/hy-grid.vue +12 -12
- package/components/hy-grid/index.scss +1 -2
- package/components/hy-grid/props.ts +7 -2
- package/components/hy-grid/typing.d.ts +1 -1
- package/components/hy-icon/typing.d.ts +52 -9
- package/components/hy-keyboard/constants.ts +83 -0
- package/components/hy-keyboard/hy-keyboard.vue +375 -0
- package/components/hy-keyboard/index.scss +73 -0
- package/components/hy-keyboard/key/index.scss +79 -0
- package/components/hy-keyboard/key/index.vue +91 -0
- package/components/hy-keyboard/key/types.ts +1 -0
- package/components/hy-keyboard/props.ts +108 -0
- package/components/hy-keyboard/typing.d.ts +18 -0
- package/components/hy-list/hy-list.vue +15 -13
- package/components/hy-list/props.ts +1 -1
- package/components/hy-modal/typing.d.ts +2 -2
- package/components/hy-notice-bar/hy-column-notice.vue +54 -94
- package/components/hy-notice-bar/hy-notice-bar.vue +128 -96
- package/components/hy-notice-bar/hy-row-notice.vue +89 -121
- package/components/hy-notice-bar/props.ts +86 -85
- package/components/hy-notify/hy-notify.vue +10 -10
- package/components/hy-notify/typing.d.ts +35 -0
- package/components/hy-number-step/hy-number-step.vue +370 -367
- package/components/hy-number-step/index.scss +1 -0
- package/components/hy-number-step/props.ts +1 -1
- package/components/hy-picker/hy-picker.vue +126 -149
- package/components/hy-picker/props.ts +4 -1
- package/components/hy-picker/typing.d.ts +22 -0
- package/components/hy-popover/hy-popover.vue +2 -2
- package/components/hy-popover/typing.d.ts +1 -1
- package/components/hy-popup/hy-popup.vue +1 -1
- package/components/hy-popup/index.scss +1 -0
- package/components/hy-price/hy-price.vue +52 -23
- package/components/hy-price/props.ts +54 -54
- package/components/hy-radio/props.ts +1 -1
- package/components/hy-radio/typing.d.ts +5 -1
- package/components/hy-rolling-num/typing.d.ts +1 -0
- package/components/hy-signature/hy-signature.vue +17 -17
- package/components/hy-signature/typing.d.ts +1 -1
- package/components/hy-skeleton/index.scss +17 -0
- package/components/hy-steps/hy-steps.vue +1 -1
- package/components/hy-submit-bar/typing.d.ts +3 -3
- package/components/hy-swipe-action/hy-swipe-action.vue +34 -15
- package/components/hy-swipe-action/index.scss +0 -1
- package/components/hy-switch/typing.d.ts +4 -0
- package/components/hy-tabbar/props.ts +2 -1
- package/components/hy-tabbar/typing.d.ts +5 -4
- package/components/hy-tabs/hy-tabs.vue +338 -336
- package/components/hy-tabs/index.scss +6 -6
- package/components/hy-tabs/typing.d.ts +41 -33
- package/components/hy-textarea/hy-textarea.vue +2 -2
- package/components/hy-textarea/typing.d.ts +4 -0
- package/components/hy-toast/hy-toast.vue +17 -9
- package/components/hy-toast/index.scss +1 -1
- package/components/hy-toast/typing.d.ts +56 -37
- package/components/hy-tooltip/hy-tooltip.vue +1 -1
- package/components/hy-tooltip/index.scss +1 -0
- package/components/hy-tooltip/props.ts +1 -1
- package/components/hy-upload/hy-upload.vue +16 -1
- package/components/hy-upload/index.scss +149 -144
- package/components/index.ts +6 -0
- package/global.d.ts +2 -0
- package/libs/api/http.ts +122 -119
- package/libs/config/icon.ts +442 -430
- package/libs/css/_function.scss +7 -13
- package/libs/css/iconfont.css +445 -441
- package/libs/css/theme.scss +3 -1
- package/libs/locale/lang/en-US.ts +4 -0
- package/libs/locale/lang/zh-CN.ts +4 -0
- package/libs/typing/index.ts +80 -0
- package/package.json +5 -2
- package/tags.json +1 -1
- package/web-types.json +1 -1
- package/components/hy-folding-panel/hy-folding-panel-group.vue +0 -163
- package/components/hy-qrcode/qrcode.js.bak +0 -1434
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 虚拟键盘主组件 -->
|
|
3
|
+
<hy-popup
|
|
4
|
+
v-model:show="show"
|
|
5
|
+
position="bottom"
|
|
6
|
+
:z-index="zIndex"
|
|
7
|
+
:safe-area-inset-bottom="safeAreaInsetBottom"
|
|
8
|
+
:overlay="overlay"
|
|
9
|
+
:overlayOpacity="overlayOpacity"
|
|
10
|
+
:close-on-click-modal="hideOnClickOutside"
|
|
11
|
+
:lock-scroll="lockScroll"
|
|
12
|
+
@close="handleClose"
|
|
13
|
+
>
|
|
14
|
+
<view :class="`hy-keyboard ${customClass}`" :style="customStyle">
|
|
15
|
+
<!-- 头部区域(标题 + 关闭按钮) -->
|
|
16
|
+
<view class="hy-keyboard__header" v-if="showHeader">
|
|
17
|
+
<!-- 标题插槽 -->
|
|
18
|
+
<slot name="title" v-if="showTitle">
|
|
19
|
+
<text class="hy-keyboard__title">{{ title }}</text>
|
|
20
|
+
</slot>
|
|
21
|
+
<!-- 关闭按钮 -->
|
|
22
|
+
<view
|
|
23
|
+
class="hy-keyboard__close"
|
|
24
|
+
hover-class="hy-keyboard__close--hover"
|
|
25
|
+
v-if="showClose"
|
|
26
|
+
@click="handleClose"
|
|
27
|
+
>
|
|
28
|
+
<text>{{ closeText }}</text>
|
|
29
|
+
</view>
|
|
30
|
+
</view>
|
|
31
|
+
|
|
32
|
+
<!-- 非车牌号键盘布局 -->
|
|
33
|
+
<template v-if="mode !== 'car'">
|
|
34
|
+
<view class="hy-keyboard__body">
|
|
35
|
+
<!-- 主按键区域 -->
|
|
36
|
+
<view class="hy-keyboard__keys">
|
|
37
|
+
<hy-keyboard-key
|
|
38
|
+
v-for="(key, index) in keys"
|
|
39
|
+
:key="index"
|
|
40
|
+
:text="key.text"
|
|
41
|
+
:type="key.type"
|
|
42
|
+
:wider="key.wider"
|
|
43
|
+
@press="handlePress"
|
|
44
|
+
></hy-keyboard-key>
|
|
45
|
+
</view>
|
|
46
|
+
<!-- 侧边栏(仅custom模式显示) -->
|
|
47
|
+
<view class="hy-keyboard__sidebar" v-if="mode === 'custom'">
|
|
48
|
+
<hy-keyboard-key
|
|
49
|
+
v-if="showDeleteKey"
|
|
50
|
+
large
|
|
51
|
+
:text="deleteText"
|
|
52
|
+
type="delete"
|
|
53
|
+
@press="handlePress"
|
|
54
|
+
></hy-keyboard-key>
|
|
55
|
+
<hy-keyboard-key
|
|
56
|
+
large
|
|
57
|
+
:text="closeText"
|
|
58
|
+
type="close"
|
|
59
|
+
:loading="closeButtonLoading"
|
|
60
|
+
@press="handlePress"
|
|
61
|
+
></hy-keyboard-key>
|
|
62
|
+
</view>
|
|
63
|
+
</view>
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<!-- 车牌号键盘布局 -->
|
|
67
|
+
<template v-if="mode === 'car'">
|
|
68
|
+
<view class="hy-keyboard__body">
|
|
69
|
+
<view class="hy-keyboard__car-keys">
|
|
70
|
+
<hy-keyboard-key
|
|
71
|
+
v-for="(key, index) in keys"
|
|
72
|
+
:key="index"
|
|
73
|
+
:text="key.text"
|
|
74
|
+
:type="key.type"
|
|
75
|
+
:wider="key.wider"
|
|
76
|
+
is-car
|
|
77
|
+
@press="handlePress"
|
|
78
|
+
></hy-keyboard-key>
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
</template>
|
|
82
|
+
</view>
|
|
83
|
+
</hy-popup>
|
|
84
|
+
</template>
|
|
85
|
+
|
|
86
|
+
<script lang="ts">
|
|
87
|
+
/**
|
|
88
|
+
* 虚拟键盘组件
|
|
89
|
+
* 支持多种键盘模式:数字键盘、自定义键盘、车牌号键盘、身份证键盘
|
|
90
|
+
*/
|
|
91
|
+
export default {
|
|
92
|
+
name: 'hy-keyboard',
|
|
93
|
+
options: {
|
|
94
|
+
virtualHost: true,
|
|
95
|
+
addGlobalClass: true,
|
|
96
|
+
styleIsolation: 'shared'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<script lang="ts" setup>
|
|
102
|
+
import { computed, ref, watch, useSlots } from 'vue'
|
|
103
|
+
import type { KeyboardMode, CarKeyboardLang, Key, IKeyboardEmits } from './typing'
|
|
104
|
+
import type { NumberKeyType } from './key/types'
|
|
105
|
+
import { CAR_KEYBOARD_AREAS, CAR_KEYBOARD_KEYS } from './constants'
|
|
106
|
+
import { keyboardProps } from './props'
|
|
107
|
+
import HyKeyboardKey from './key/index.vue'
|
|
108
|
+
|
|
109
|
+
const props = defineProps(keyboardProps)
|
|
110
|
+
const emit = defineEmits<IKeyboardEmits>()
|
|
111
|
+
const slots = useSlots()
|
|
112
|
+
|
|
113
|
+
const show = ref(props.show)
|
|
114
|
+
|
|
115
|
+
watch(
|
|
116
|
+
() => props.show,
|
|
117
|
+
(newValue) => {
|
|
118
|
+
show.value = newValue
|
|
119
|
+
}
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
const carLang = ref<CarKeyboardLang>('zh')
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* 车牌号键盘语言(支持受控/非受控两种模式)
|
|
126
|
+
*/
|
|
127
|
+
const carKeyboardLang = computed({
|
|
128
|
+
get: () => (props.carLang ? props.carLang : carLang.value),
|
|
129
|
+
set: (value: CarKeyboardLang) => {
|
|
130
|
+
carLang.value = value
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 当前键盘按键列表(根据模式动态生成)
|
|
136
|
+
*/
|
|
137
|
+
const keys = computed(() => {
|
|
138
|
+
switch (props.mode) {
|
|
139
|
+
case 'car':
|
|
140
|
+
return genCarKeys()
|
|
141
|
+
case 'idcard':
|
|
142
|
+
return genIdCardKeys()
|
|
143
|
+
case 'custom':
|
|
144
|
+
return genCustomKeys()
|
|
145
|
+
default:
|
|
146
|
+
return genDefaultKeys()
|
|
147
|
+
}
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* 是否显示关闭按钮
|
|
152
|
+
*/
|
|
153
|
+
const showClose = computed(() => {
|
|
154
|
+
return props.closeText && (props.mode === 'default' || props.mode === 'car')
|
|
155
|
+
})
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* 是否显示标题
|
|
159
|
+
*/
|
|
160
|
+
const showTitle = computed(() => {
|
|
161
|
+
return !!props.title || !!slots.title
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* 是否显示头部区域
|
|
166
|
+
*/
|
|
167
|
+
const showHeader = computed(() => {
|
|
168
|
+
return showTitle.value || showClose.value
|
|
169
|
+
})
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* 数组随机排序(Fisher-Yates 算法)
|
|
173
|
+
* @param arr 待排序数组
|
|
174
|
+
* @returns 排序后的新数组
|
|
175
|
+
*/
|
|
176
|
+
function shuffleArray<T>(arr: T[]): T[] {
|
|
177
|
+
const newArr = [...arr]
|
|
178
|
+
for (let i = newArr.length - 1; i > 0; i--) {
|
|
179
|
+
const j = Math.floor(Math.random() * (i + 1))
|
|
180
|
+
;[newArr[i], newArr[j]] = [newArr[j], newArr[i]]
|
|
181
|
+
}
|
|
182
|
+
return newArr
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* 生成基础数字按键(0-9)
|
|
187
|
+
* @returns 数字按键数组
|
|
188
|
+
*/
|
|
189
|
+
function genBasicKeys(): Key[] {
|
|
190
|
+
const keys = Array.from({ length: 10 }, (_, i) => ({ text: i }))
|
|
191
|
+
return props.randomKeyOrder ? shuffleArray(keys) : keys
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 生成默认数字键盘按键
|
|
196
|
+
* 布局:1 2 3 / 4 5 6 / 7 8 9 / . 0 删除
|
|
197
|
+
* @returns 默认键盘按键数组
|
|
198
|
+
*/
|
|
199
|
+
function genDefaultKeys(): Key[] {
|
|
200
|
+
const result: Key[] = []
|
|
201
|
+
const basicKeys = genBasicKeys()
|
|
202
|
+
|
|
203
|
+
// 第一行: 1, 2, 3
|
|
204
|
+
result.push(basicKeys[1], basicKeys[2], basicKeys[3])
|
|
205
|
+
// 第二行: 4, 5, 6
|
|
206
|
+
result.push(basicKeys[4], basicKeys[5], basicKeys[6])
|
|
207
|
+
// 第三行: 7, 8, 9
|
|
208
|
+
result.push(basicKeys[7], basicKeys[8], basicKeys[9])
|
|
209
|
+
// 第四行: 小数点, 0, 删除
|
|
210
|
+
const dotKey = props.showDotKey
|
|
211
|
+
? [{ text: (props.extraKey as string) || '.', type: 'extra' as NumberKeyType }]
|
|
212
|
+
: []
|
|
213
|
+
|
|
214
|
+
result.push(
|
|
215
|
+
...dotKey,
|
|
216
|
+
{ ...basicKeys[0], wider: true },
|
|
217
|
+
{
|
|
218
|
+
text: props.showDeleteKey ? props.deleteText : '',
|
|
219
|
+
type: props.showDeleteKey ? 'delete' : ''
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
return result
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* 生成自定义模式键盘按键(带侧边栏)
|
|
228
|
+
* @returns 自定义键盘按键数组
|
|
229
|
+
*/
|
|
230
|
+
function genCustomKeys(): Key[] {
|
|
231
|
+
const result: Key[] = []
|
|
232
|
+
const basicKeys = genBasicKeys()
|
|
233
|
+
const extraKeys = Array.isArray(props.extraKey) ? props.extraKey : [props.extraKey]
|
|
234
|
+
|
|
235
|
+
// 第一行: 1, 2, 3
|
|
236
|
+
result.push(basicKeys[1], basicKeys[2], basicKeys[3])
|
|
237
|
+
// 第二行: 4, 5, 6
|
|
238
|
+
result.push(basicKeys[4], basicKeys[5], basicKeys[6])
|
|
239
|
+
// 第三行: 7, 8, 9
|
|
240
|
+
result.push(basicKeys[7], basicKeys[8], basicKeys[9])
|
|
241
|
+
|
|
242
|
+
// 第四行根据extraKey数量调整
|
|
243
|
+
if (extraKeys.length === 1) {
|
|
244
|
+
console.log(extraKeys)
|
|
245
|
+
|
|
246
|
+
result.push({ ...basicKeys[0], wider: true }, { text: extraKeys[0] || '.', type: 'extra' })
|
|
247
|
+
} else if (extraKeys.length >= 2) {
|
|
248
|
+
result.push({ text: extraKeys[0], type: 'extra' }, basicKeys[0], {
|
|
249
|
+
text: extraKeys[1],
|
|
250
|
+
type: 'extra'
|
|
251
|
+
})
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
return result
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* 生成车牌号键盘按键
|
|
259
|
+
* 支持省份简称和字母数字切换
|
|
260
|
+
* @returns 车牌号键盘按键数组
|
|
261
|
+
*/
|
|
262
|
+
function genCarKeys(): Key[] {
|
|
263
|
+
const [keys, remainKeys] = splitCarKeys()
|
|
264
|
+
return [
|
|
265
|
+
...keys,
|
|
266
|
+
{ text: carKeyboardLang.value === 'zh' ? 'ABC' : '省份', type: 'extra', wider: true },
|
|
267
|
+
...remainKeys,
|
|
268
|
+
{ text: props.deleteText, type: 'delete', wider: true }
|
|
269
|
+
]
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 分割车牌号按键数组
|
|
274
|
+
* 用于在第30个按键后插入切换语言的按钮
|
|
275
|
+
* @returns 分割后的按键数组
|
|
276
|
+
*/
|
|
277
|
+
function splitCarKeys(): Key[][] {
|
|
278
|
+
const keys =
|
|
279
|
+
carKeyboardLang.value === 'zh'
|
|
280
|
+
? CAR_KEYBOARD_AREAS.map((key) => ({ text: key }))
|
|
281
|
+
: CAR_KEYBOARD_KEYS.map((key) => ({ text: key }))
|
|
282
|
+
return [keys.slice(0, 30), keys.slice(30)]
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 生成身份证键盘按键
|
|
287
|
+
* 布局:1 2 3 / 4 5 6 / 7 8 9 / X 0 删除
|
|
288
|
+
* @returns 身份证键盘按键数组
|
|
289
|
+
*/
|
|
290
|
+
function genIdCardKeys(): Key[] {
|
|
291
|
+
const result: Key[] = []
|
|
292
|
+
const basicKeys = genBasicKeys()
|
|
293
|
+
|
|
294
|
+
// 第一行: 1, 2, 3
|
|
295
|
+
result.push(basicKeys[0], basicKeys[1], basicKeys[2])
|
|
296
|
+
// 第二行: 4, 5, 6
|
|
297
|
+
result.push(basicKeys[3], basicKeys[4], basicKeys[5])
|
|
298
|
+
// 第三行: 7, 8, 9
|
|
299
|
+
result.push(basicKeys[6], basicKeys[7], basicKeys[8])
|
|
300
|
+
// 第四行: X, 0, 删除
|
|
301
|
+
result.push(
|
|
302
|
+
{ text: 'X', type: 'extra' },
|
|
303
|
+
{ text: 0 },
|
|
304
|
+
{
|
|
305
|
+
text: props.showDeleteKey ? props.deleteText : '',
|
|
306
|
+
type: props.showDeleteKey ? 'delete' : ''
|
|
307
|
+
}
|
|
308
|
+
)
|
|
309
|
+
|
|
310
|
+
return result
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* 处理关闭事件
|
|
315
|
+
*/
|
|
316
|
+
const handleClose = () => {
|
|
317
|
+
emit('close')
|
|
318
|
+
emit('update:show', false)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* 处理按键点击
|
|
323
|
+
* @param text 按键文本
|
|
324
|
+
* @param type 按键类型
|
|
325
|
+
*/
|
|
326
|
+
const handlePress = (text: string, type: NumberKeyType) => {
|
|
327
|
+
// 额外按键处理
|
|
328
|
+
if (type === 'extra') {
|
|
329
|
+
// 空文本不处理
|
|
330
|
+
if (text === '') {
|
|
331
|
+
return handleClose()
|
|
332
|
+
}
|
|
333
|
+
// 车牌号键盘语言切换
|
|
334
|
+
else if (text === 'ABC' || text === '省份') {
|
|
335
|
+
const newLang = carKeyboardLang.value === 'zh' ? 'en' : 'zh'
|
|
336
|
+
if (props.carLang) {
|
|
337
|
+
emit('update:carLang', newLang)
|
|
338
|
+
} else {
|
|
339
|
+
carKeyboardLang.value = newLang
|
|
340
|
+
}
|
|
341
|
+
return
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const value = props.modelValue
|
|
346
|
+
// 删除键处理
|
|
347
|
+
if (type === 'delete') {
|
|
348
|
+
emit('delete')
|
|
349
|
+
const newValue = value.slice(0, value.length - 1)
|
|
350
|
+
emit('update:modelValue', newValue)
|
|
351
|
+
// 车牌号键盘自动切换回省份模式
|
|
352
|
+
if (props.mode === 'car' && newValue.length === 0 && props.autoSwitchLang) {
|
|
353
|
+
carLang.value = 'zh'
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
// 关闭键处理
|
|
357
|
+
else if (type === 'close') {
|
|
358
|
+
handleClose()
|
|
359
|
+
}
|
|
360
|
+
// 普通按键输入处理
|
|
361
|
+
else if (value.length < +props.maxlength) {
|
|
362
|
+
emit('input', text)
|
|
363
|
+
const newValue = value + text
|
|
364
|
+
emit('update:modelValue', newValue)
|
|
365
|
+
// 车牌号键盘自动切换到字母模式
|
|
366
|
+
if (props.mode === 'car' && newValue.length === 1 && props.autoSwitchLang) {
|
|
367
|
+
carLang.value = 'en'
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
</script>
|
|
372
|
+
|
|
373
|
+
<style lang="scss">
|
|
374
|
+
@import './index.scss';
|
|
375
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
@use "../../libs/css/theme" as *;
|
|
2
|
+
@use "../../libs/css/mixin" as *;
|
|
3
|
+
|
|
4
|
+
$keyboard-header-height: 80rpx;
|
|
5
|
+
$keyboard-title-font-size: 32rpx;
|
|
6
|
+
$keyboard-close-font-size: 28rpx;
|
|
7
|
+
$keyboard-key-gap: $hy-border-margin-padding-sm;
|
|
8
|
+
|
|
9
|
+
@include b(keyboard) {
|
|
10
|
+
background: $hy-background--track;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
|
|
14
|
+
@include e(header) {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
height: $keyboard-header-height;
|
|
19
|
+
padding: 0 32rpx;
|
|
20
|
+
background: $hy-background--track;
|
|
21
|
+
border-bottom: $hy-border-line;
|
|
22
|
+
width: 100%;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@include e(title) {
|
|
27
|
+
font-size: $keyboard-title-font-size;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
color: $hy-primary;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include e(close) {
|
|
33
|
+
font-size: $keyboard-close-font-size;
|
|
34
|
+
padding: 10rpx 20rpx;
|
|
35
|
+
|
|
36
|
+
&--hover:active {
|
|
37
|
+
opacity: 0.7;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@include e(body) {
|
|
42
|
+
display: flex;
|
|
43
|
+
gap: $keyboard-key-gap;
|
|
44
|
+
width: 100%;
|
|
45
|
+
padding: $hy-border-margin-padding-sm;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@include e(keys) {
|
|
50
|
+
display: flex;
|
|
51
|
+
flex-wrap: wrap;
|
|
52
|
+
flex: 3;
|
|
53
|
+
gap: $keyboard-key-gap;
|
|
54
|
+
width: 100%;
|
|
55
|
+
box-sizing: border-box;
|
|
56
|
+
justify-content: space-between;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@include e(sidebar) {
|
|
60
|
+
width: 160rpx;
|
|
61
|
+
display: flex;
|
|
62
|
+
flex-direction: column;
|
|
63
|
+
gap: $keyboard-key-gap;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@include e(car-keys) {
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-wrap: wrap;
|
|
69
|
+
gap: $keyboard-key-gap;
|
|
70
|
+
width: 100%;
|
|
71
|
+
box-sizing: border-box;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
@use "../../../libs/css/theme" as *;
|
|
2
|
+
@use "../../../libs/css/mixin" as *;
|
|
3
|
+
|
|
4
|
+
$keyboard-key-height: 100rpx;
|
|
5
|
+
$keyboard-key-border-radius: 12rpx;
|
|
6
|
+
$keyboard-key-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.06);
|
|
7
|
+
|
|
8
|
+
@include b(keyboard) {
|
|
9
|
+
@include e(key) {
|
|
10
|
+
flex-basis: 32%;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
height: $keyboard-key-height;
|
|
15
|
+
background: $hy-background--container;
|
|
16
|
+
border-radius: $keyboard-key-border-radius;
|
|
17
|
+
box-shadow: $keyboard-key-shadow;
|
|
18
|
+
box-sizing: border-box;
|
|
19
|
+
transition: all 0.15s;
|
|
20
|
+
|
|
21
|
+
@include m(large) {
|
|
22
|
+
flex: 1;
|
|
23
|
+
align-self: stretch;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@include m(car) {
|
|
27
|
+
flex-basis: 8.7%;
|
|
28
|
+
height: 88rpx;
|
|
29
|
+
font-size: 28rpx;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@include m(wider) {
|
|
33
|
+
flex: 1;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@include m(delete) {
|
|
37
|
+
color: #FFFFFF;
|
|
38
|
+
background: $hy-error;
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column-reverse;
|
|
41
|
+
align-items: center;
|
|
42
|
+
justify-content: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@include m(extra) {
|
|
46
|
+
background: $hy-background--3;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@include m(close) {
|
|
50
|
+
color: #ffffff;
|
|
51
|
+
background: $hy-primary;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
&:active {
|
|
55
|
+
background: $hy-background--hover;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&-text {
|
|
59
|
+
font-size: $hy-font-size-lg;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@include e(delete-line) {
|
|
63
|
+
position: absolute;
|
|
64
|
+
width: 18rpx;
|
|
65
|
+
height: 2rpx;
|
|
66
|
+
background: #999999;
|
|
67
|
+
top: 50%;
|
|
68
|
+
left: 50%;
|
|
69
|
+
|
|
70
|
+
@include m(left) {
|
|
71
|
+
transform: translate(-50%, -50%) rotate(45deg);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@include m(right) {
|
|
75
|
+
transform: translate(-50%, -50%) rotate(-45deg);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 键盘按键组件 -->
|
|
3
|
+
<view
|
|
4
|
+
:class="[
|
|
5
|
+
'hy-keyboard__key',
|
|
6
|
+
{
|
|
7
|
+
'hy-keyboard__key--wider': wider, // 加宽样式
|
|
8
|
+
'hy-keyboard__key--large': large, // 大号样式(用于侧边栏)
|
|
9
|
+
'hy-keyboard__key--car': isCar, // 车牌号键盘样式
|
|
10
|
+
'hy-keyboard__key--delete': type === 'delete', // 删除键样式
|
|
11
|
+
'hy-keyboard__key--extra': type === 'extra', // 额外按键样式
|
|
12
|
+
'hy-keyboard__key--close': type === 'close' // 关闭键样式
|
|
13
|
+
}
|
|
14
|
+
]"
|
|
15
|
+
@click="handlePress"
|
|
16
|
+
>
|
|
17
|
+
<!-- 按键文本 -->
|
|
18
|
+
<text class="hy-keyboard__key-text">{{ text }}</text>
|
|
19
|
+
<!-- 删除键图标 -->
|
|
20
|
+
<view v-if="type === 'delete'" class="hy-keyboard__delete-icon">
|
|
21
|
+
<view class="hy-keyboard__delete-line hy-keyboard__delete-line--left">
|
|
22
|
+
<hy-icon
|
|
23
|
+
v-if="type === 'delete'"
|
|
24
|
+
:name="IconConfig.CLEAR"
|
|
25
|
+
class="hy-keyboard__key-icon"
|
|
26
|
+
color="#fff"
|
|
27
|
+
size="28"
|
|
28
|
+
/>
|
|
29
|
+
</view>
|
|
30
|
+
<view class="hy-keyboard__delete-line hy-keyboard__delete-line--right"></view>
|
|
31
|
+
</view>
|
|
32
|
+
</view>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script lang="ts">
|
|
36
|
+
export default {
|
|
37
|
+
name: 'hy-keyboard-key',
|
|
38
|
+
options: {
|
|
39
|
+
virtualHost: true,
|
|
40
|
+
addGlobalClass: true,
|
|
41
|
+
styleIsolation: 'shared'
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<script lang="ts" setup>
|
|
47
|
+
import { IconConfig } from '@/package/libs'
|
|
48
|
+
import type { NumberKeyType } from './types'
|
|
49
|
+
|
|
50
|
+
const props = defineProps({
|
|
51
|
+
/** 按键显示文本 */
|
|
52
|
+
text: {
|
|
53
|
+
type: [String, Number],
|
|
54
|
+
default: ''
|
|
55
|
+
},
|
|
56
|
+
/** 按键类型: delete(删除), extra(额外), close(关闭), ''(普通) */
|
|
57
|
+
type: {
|
|
58
|
+
type: String as () => NumberKeyType,
|
|
59
|
+
default: ''
|
|
60
|
+
},
|
|
61
|
+
/** 是否加宽(用于车牌号键盘的特殊按键) */
|
|
62
|
+
wider: {
|
|
63
|
+
type: Boolean,
|
|
64
|
+
default: false
|
|
65
|
+
},
|
|
66
|
+
/** 是否大号(用于侧边栏按键) */
|
|
67
|
+
large: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: false
|
|
70
|
+
},
|
|
71
|
+
/** 是否车牌号键盘的按键 */
|
|
72
|
+
isCar: {
|
|
73
|
+
type: Boolean,
|
|
74
|
+
default: false
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
const emit = defineEmits(['press'])
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* 处理按键点击
|
|
82
|
+
* 触发 press 事件,传递按键文本和类型
|
|
83
|
+
*/
|
|
84
|
+
const handlePress = () => {
|
|
85
|
+
emit('press', props.text, props.type)
|
|
86
|
+
}
|
|
87
|
+
</script>
|
|
88
|
+
|
|
89
|
+
<style lang="scss">
|
|
90
|
+
@import './index.scss';
|
|
91
|
+
</style>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type NumberKeyType = '' | 'delete' | 'extra' | 'close'
|