tang-ui-x 1.0.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.
- package/LICENSE +21 -0
- package/README.md +141 -0
- package/components/TActionSheet/index.uvue +170 -0
- package/components/TActionSheet/type.uts +29 -0
- package/components/TAvatar/index.uvue +156 -0
- package/components/TAvatar/type.uts +54 -0
- package/components/TBadge/index.uvue +152 -0
- package/components/TBadge/type.uts +48 -0
- package/components/TButton/README.md +111 -0
- package/components/TButton/index.uvue +380 -0
- package/components/TButton/type.uts +95 -0
- package/components/TCard/index.uvue +174 -0
- package/components/TCard/type.uts +50 -0
- package/components/TCell/index.uvue +49 -0
- package/components/TCheckbox/index.uvue +187 -0
- package/components/TCheckboxGroup/index.uvue +139 -0
- package/components/TCheckboxGroup/type.uts +26 -0
- package/components/TCol/index.uvue +82 -0
- package/components/TCol/type.uts +30 -0
- package/components/TCollapse/index.uvue +93 -0
- package/components/TCollapse/type.uts +36 -0
- package/components/TCollapseItem/index.uvue +194 -0
- package/components/TCollapseItem/type.uts +25 -0
- package/components/TDialog/index.uvue +386 -0
- package/components/TDialog/type.uts +84 -0
- package/components/TDivider/index.uvue +235 -0
- package/components/TDivider/type.uts +91 -0
- package/components/TEmpty/index.uvue +128 -0
- package/components/TErrorState/index.uvue +57 -0
- package/components/TGrid/index.uvue +115 -0
- package/components/TGrid/type.uts +77 -0
- package/components/TGridItem/index.uvue +243 -0
- package/components/TGridItem/type.uts +64 -0
- package/components/TIcon/index.uvue +96 -0
- package/components/TImage/index.uvue +255 -0
- package/components/TImage/type.uts +146 -0
- package/components/TInput/README.md +119 -0
- package/components/TInput/index.uvue +376 -0
- package/components/TInput/type.uts +138 -0
- package/components/TList/index.uvue +82 -0
- package/components/TList/type.uts +68 -0
- package/components/TListItem/index.uvue +161 -0
- package/components/TListItem/type.uts +49 -0
- package/components/TLoading/index.uvue +153 -0
- package/components/TLoading/type.uts +43 -0
- package/components/TNavBar/index.uvue +120 -0
- package/components/TNavBar/type.uts +22 -0
- package/components/TNoticeBar/index.uvue +106 -0
- package/components/TNoticeBar/type.uts +21 -0
- package/components/TNumberInput/index.uvue +226 -0
- package/components/TPicker/index.uvue +276 -0
- package/components/TPicker/type.uts +105 -0
- package/components/TPopup/index.uvue +442 -0
- package/components/TProgress/index.uvue +103 -0
- package/components/TProgress/type.uts +64 -0
- package/components/TRadioButton/index.uvue +232 -0
- package/components/TRadioGroup/index.uvue +117 -0
- package/components/TRadioGroup/type.uts +25 -0
- package/components/TRate/index.uvue +182 -0
- package/components/TRow/index.uvue +105 -0
- package/components/TRow/type.uts +52 -0
- package/components/TSearchBar/index.uvue +255 -0
- package/components/TSearchBar/type.uts +140 -0
- package/components/TSelect/index.uvue +655 -0
- package/components/TSelect/type.uts +57 -0
- package/components/TSlider/index.uvue +72 -0
- package/components/TSlider/type.uts +21 -0
- package/components/TSwiper/index.uvue +222 -0
- package/components/TSwiper/type.uts +77 -0
- package/components/TSwitch/index.uvue +177 -0
- package/components/TSwitch/type.uts +52 -0
- package/components/TText/README.md +124 -0
- package/components/TText/index.uvue +257 -0
- package/components/TText/type.uts +114 -0
- package/components/TTextarea/index.uvue +239 -0
- package/components/TTextarea/type.uts +106 -0
- package/components/TToast/type.uts +14 -0
- package/components/Tabs/README.md +297 -0
- package/components/Tabs/index.uvue +383 -0
- package/components/Tabs/type.uts +10 -0
- package/components/Tags/README.md +297 -0
- package/components/Tags/index.uvue +383 -0
- package/components/Tags/type.uts +10 -0
- package/components/VbenFrom/index.uvue +392 -0
- package/composables/useModal.uts +294 -0
- package/composables/useTheme.uts +235 -0
- package/composables/useToast.uts +322 -0
- package/index.js +62 -0
- package/package.json +48 -0
- package/style/colors/index.scss +157 -0
- package/style/index.scss +399 -0
- package/types/index.uts +52 -0
- package/uni.scss +79 -0
- package/utils/color.uts +92 -0
- package/utils/common.uts +245 -0
- package/utils/dom.uts +275 -0
- package/utils/index.uts +10 -0
- package/utils/validator.uts +155 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TGridItem 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TGridItem Props 接口
|
|
7
|
+
*/
|
|
8
|
+
export interface TGridItemProps {
|
|
9
|
+
/**
|
|
10
|
+
* 图标名称
|
|
11
|
+
*/
|
|
12
|
+
icon?: string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* 图标颜色
|
|
16
|
+
*/
|
|
17
|
+
iconColor?: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 图片链接
|
|
21
|
+
*/
|
|
22
|
+
image?: string
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 文字内容
|
|
26
|
+
*/
|
|
27
|
+
text?: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 文字颜色
|
|
31
|
+
*/
|
|
32
|
+
textColor?: string
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 徽标内容
|
|
36
|
+
*/
|
|
37
|
+
badge?: string | number
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 徽标是否显示为小红点
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
dot?: boolean
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 自定义类名
|
|
47
|
+
*/
|
|
48
|
+
customClass?: string
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 自定义样式
|
|
52
|
+
*/
|
|
53
|
+
customStyle?: string
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* TGridItem 事件接口
|
|
58
|
+
*/
|
|
59
|
+
export interface TGridItemEmits {
|
|
60
|
+
/**
|
|
61
|
+
* 点击事件
|
|
62
|
+
*/
|
|
63
|
+
click: () => void
|
|
64
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script setup lang="uts" >
|
|
2
|
+
/**
|
|
3
|
+
* Icon 图标组件
|
|
4
|
+
* 支持 iconfont 字体图标
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 组件属性
|
|
9
|
+
*/
|
|
10
|
+
type IconProps = {
|
|
11
|
+
/** 图标名称 */
|
|
12
|
+
name : string
|
|
13
|
+
/** 图标大小 */
|
|
14
|
+
size ?: string | number
|
|
15
|
+
/** 图标颜色 */
|
|
16
|
+
color ?: string
|
|
17
|
+
/** 是否加粗 */
|
|
18
|
+
bold ?: boolean
|
|
19
|
+
/** 自定义类名 */
|
|
20
|
+
customClass ?: string
|
|
21
|
+
/** 自定义样式 */
|
|
22
|
+
customStyle ?: string
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = withDefaults(defineProps<IconProps>(), {
|
|
26
|
+
name: '',
|
|
27
|
+
size: 48,
|
|
28
|
+
color: '#333333',
|
|
29
|
+
bold: false,
|
|
30
|
+
customClass: '',
|
|
31
|
+
customStyle: ''
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 事件
|
|
36
|
+
*/
|
|
37
|
+
const emit = defineEmits<{
|
|
38
|
+
click : []
|
|
39
|
+
}>()
|
|
40
|
+
|
|
41
|
+
// 计算图标大小
|
|
42
|
+
const iconSize = computed(() : string => {
|
|
43
|
+
if (typeof props.size === 'number') {
|
|
44
|
+
return props.size + 'rpx'
|
|
45
|
+
}
|
|
46
|
+
return props.size
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// 计算图标样式
|
|
50
|
+
const iconStyle = computed(() : string => {
|
|
51
|
+
const styles : string[] = []
|
|
52
|
+
|
|
53
|
+
styles.push(`font-size: ${iconSize.value}`)
|
|
54
|
+
styles.push(`color: ${props.color}`)
|
|
55
|
+
|
|
56
|
+
if (props.bold) {
|
|
57
|
+
styles.push('font-weight: bold')
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (props.customStyle) {
|
|
61
|
+
styles.push(props.customStyle)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return styles.join('; ')
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// 计算图标类名
|
|
68
|
+
const iconClass = computed(() : string => {
|
|
69
|
+
const classes : string[] = ['icon', 'iconfont']
|
|
70
|
+
|
|
71
|
+
if (props.name) {
|
|
72
|
+
classes.push(props.name)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (props.customClass) {
|
|
76
|
+
classes.push(props.customClass)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return classes.join(' ')
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 图标点击事件
|
|
84
|
+
*/
|
|
85
|
+
const handleClick = () => {
|
|
86
|
+
emit('click')
|
|
87
|
+
}
|
|
88
|
+
</script>
|
|
89
|
+
|
|
90
|
+
<template>
|
|
91
|
+
<text :class="iconClass" :style="iconStyle" @click="handleClick"></text>
|
|
92
|
+
</template>
|
|
93
|
+
|
|
94
|
+
<style lang="scss" scoped>
|
|
95
|
+
|
|
96
|
+
</style>
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
<script setup lang="uts">
|
|
2
|
+
import { ref, computed } from 'vue'
|
|
3
|
+
import type { ImageMode, ImageShape } from './type.uts'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* TImage 图片组件
|
|
7
|
+
* @description 增强的图片组件,支持懒加载、预览、加载失败处理等功能
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Props 定义
|
|
11
|
+
interface Props {
|
|
12
|
+
src: string
|
|
13
|
+
mode?: ImageMode
|
|
14
|
+
width?: string | number
|
|
15
|
+
height?: string | number
|
|
16
|
+
shape?: ImageShape
|
|
17
|
+
radius?: string | number
|
|
18
|
+
showLoading?: boolean
|
|
19
|
+
showError?: boolean
|
|
20
|
+
lazyLoad?: boolean
|
|
21
|
+
loadingText?: string
|
|
22
|
+
errorText?: string
|
|
23
|
+
previewable?: boolean
|
|
24
|
+
previewList?: string[]
|
|
25
|
+
previewIndex?: number
|
|
26
|
+
customClass?: string
|
|
27
|
+
customStyle?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
31
|
+
mode: 'aspectFill',
|
|
32
|
+
width: '100%',
|
|
33
|
+
height: '200rpx',
|
|
34
|
+
shape: 'square',
|
|
35
|
+
radius: '0',
|
|
36
|
+
showLoading: true,
|
|
37
|
+
showError: true,
|
|
38
|
+
lazyLoad: false,
|
|
39
|
+
loadingText: '加载中...',
|
|
40
|
+
errorText: '加载失败',
|
|
41
|
+
previewable: false,
|
|
42
|
+
previewList: () => [] as string[],
|
|
43
|
+
previewIndex: 0,
|
|
44
|
+
customClass: '',
|
|
45
|
+
customStyle: ''
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
// Emits 定义
|
|
49
|
+
const emit = defineEmits<{
|
|
50
|
+
load: [event: Event]
|
|
51
|
+
error: [event: Event]
|
|
52
|
+
click: []
|
|
53
|
+
preview: []
|
|
54
|
+
}>()
|
|
55
|
+
|
|
56
|
+
// 状态管理
|
|
57
|
+
const loading = ref<boolean>(true)
|
|
58
|
+
const loadError = ref<boolean>(false)
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 计算图片容器样式
|
|
62
|
+
*/
|
|
63
|
+
const containerStyle = computed((): string => {
|
|
64
|
+
const styles: string[] = []
|
|
65
|
+
|
|
66
|
+
// 宽度
|
|
67
|
+
if (typeof props.width === 'number') {
|
|
68
|
+
styles.push(`width: ${props.width}px`)
|
|
69
|
+
} else {
|
|
70
|
+
styles.push(`width: ${props.width}`)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// 高度
|
|
74
|
+
if (typeof props.height === 'number') {
|
|
75
|
+
styles.push(`height: ${props.height}px`)
|
|
76
|
+
} else {
|
|
77
|
+
styles.push(`height: ${props.height}`)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// 圆角
|
|
81
|
+
if (props.shape === 'round') {
|
|
82
|
+
styles.push('border-radius: 8px')
|
|
83
|
+
} else if (props.shape === 'circle') {
|
|
84
|
+
styles.push('border-radius: 50%')
|
|
85
|
+
} else if (props.radius) {
|
|
86
|
+
if (typeof props.radius === 'number') {
|
|
87
|
+
styles.push(`border-radius: ${props.radius}px`)
|
|
88
|
+
} else {
|
|
89
|
+
styles.push(`border-radius: ${props.radius}`)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// 自定义样式
|
|
94
|
+
if (props.customStyle) {
|
|
95
|
+
styles.push(props.customStyle)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return styles.join('; ')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 计算图片类名
|
|
103
|
+
*/
|
|
104
|
+
const imageClasses = computed((): string => {
|
|
105
|
+
const classes: string[] = ['t-image__img']
|
|
106
|
+
|
|
107
|
+
if (props.customClass) {
|
|
108
|
+
classes.push(props.customClass)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return classes.join(' ')
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 图片加载完成
|
|
116
|
+
*/
|
|
117
|
+
const handleLoad = (event: Event): void => {
|
|
118
|
+
loading.value = false
|
|
119
|
+
loadError.value = false
|
|
120
|
+
emit('load', event)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 图片加载失败
|
|
125
|
+
*/
|
|
126
|
+
const handleError = (event: Event): void => {
|
|
127
|
+
loading.value = false
|
|
128
|
+
loadError.value = true
|
|
129
|
+
emit('error', event)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 点击图片
|
|
134
|
+
*/
|
|
135
|
+
const handleClick = (): void => {
|
|
136
|
+
emit('click')
|
|
137
|
+
|
|
138
|
+
if (props.previewable) {
|
|
139
|
+
handlePreview()
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 预览图片
|
|
145
|
+
*/
|
|
146
|
+
const handlePreview = (): void => {
|
|
147
|
+
emit('preview')
|
|
148
|
+
|
|
149
|
+
const urls = props.previewList.length > 0 ? props.previewList : [props.src]
|
|
150
|
+
const current = props.previewList.length > 0 ? props.previewIndex : 0
|
|
151
|
+
|
|
152
|
+
uni.previewImage({
|
|
153
|
+
urls: urls,
|
|
154
|
+
current: current
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
</script>
|
|
158
|
+
|
|
159
|
+
<template>
|
|
160
|
+
<view
|
|
161
|
+
class="t-image"
|
|
162
|
+
:class="{ 't-image--clickable': previewable }"
|
|
163
|
+
:style="containerStyle"
|
|
164
|
+
@click="handleClick"
|
|
165
|
+
>
|
|
166
|
+
<!-- 图片 -->
|
|
167
|
+
<image
|
|
168
|
+
v-if="!loadError"
|
|
169
|
+
:src="src"
|
|
170
|
+
:mode="mode"
|
|
171
|
+
:lazy-load="lazyLoad"
|
|
172
|
+
:class="imageClasses"
|
|
173
|
+
@load="handleLoad"
|
|
174
|
+
@error="handleError"
|
|
175
|
+
/>
|
|
176
|
+
|
|
177
|
+
<!-- 加载中状态 -->
|
|
178
|
+
<view v-if="loading && showLoading" class="t-image__loading">
|
|
179
|
+
<view class="t-image__loading-icon"></view>
|
|
180
|
+
<text class="t-image__loading-text">{{ loadingText }}</text>
|
|
181
|
+
</view>
|
|
182
|
+
|
|
183
|
+
<!-- 加载失败状态 -->
|
|
184
|
+
<view v-if="loadError && showError" class="t-image__error">
|
|
185
|
+
<text class="t-image__error-icon">✕</text>
|
|
186
|
+
<text class="t-image__error-text">{{ errorText }}</text>
|
|
187
|
+
</view>
|
|
188
|
+
|
|
189
|
+
<!-- 插槽:自定义内容 -->
|
|
190
|
+
<slot></slot>
|
|
191
|
+
</view>
|
|
192
|
+
</template>
|
|
193
|
+
|
|
194
|
+
<style lang="scss" scoped>
|
|
195
|
+
.t-image {
|
|
196
|
+
position: relative;
|
|
197
|
+
display: inline-block;
|
|
198
|
+
overflow: hidden;
|
|
199
|
+
background-color: #f5f5f5;
|
|
200
|
+
|
|
201
|
+
&--clickable {
|
|
202
|
+
cursor: pointer;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
.t-image__img {
|
|
207
|
+
width: 100%;
|
|
208
|
+
height: 100%;
|
|
209
|
+
display: block;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.t-image__loading,
|
|
213
|
+
.t-image__error {
|
|
214
|
+
position: absolute;
|
|
215
|
+
top: 0;
|
|
216
|
+
left: 0;
|
|
217
|
+
width: 100%;
|
|
218
|
+
height: 100%;
|
|
219
|
+
display: flex;
|
|
220
|
+
flex-direction: column;
|
|
221
|
+
align-items: center;
|
|
222
|
+
justify-content: center;
|
|
223
|
+
background-color: #f5f5f5;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.t-image__loading-icon {
|
|
227
|
+
width: 32px;
|
|
228
|
+
height: 32px;
|
|
229
|
+
border: 3px solid #e0e0e0;
|
|
230
|
+
border-top-color: #1890ff;
|
|
231
|
+
border-radius: 50%;
|
|
232
|
+
animation: t-image-rotate 0.8s linear infinite;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.t-image__loading-text,
|
|
236
|
+
.t-image__error-text {
|
|
237
|
+
margin-top: 8px;
|
|
238
|
+
font-size: 12px;
|
|
239
|
+
color: #999;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.t-image__error-icon {
|
|
243
|
+
font-size: 32px;
|
|
244
|
+
color: #ccc;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@keyframes t-image-rotate {
|
|
248
|
+
0% {
|
|
249
|
+
transform: rotate(0deg);
|
|
250
|
+
}
|
|
251
|
+
100% {
|
|
252
|
+
transform: rotate(360deg);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
</style>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TImage 组件类型定义
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 图片裁剪模式
|
|
7
|
+
*/
|
|
8
|
+
export type ImageMode =
|
|
9
|
+
| 'scaleToFill' // 缩放:不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素
|
|
10
|
+
| 'aspectFit' // 缩放:保持纵横比缩放图片,使图片的长边能完全显示出来
|
|
11
|
+
| 'aspectFill' // 缩放:保持纵横比缩放图片,只保证图片的短边能完全显示出来
|
|
12
|
+
| 'widthFix' // 缩放:宽度不变,高度自动变化,保持原图宽高比不变
|
|
13
|
+
| 'heightFix' // 缩放:高度不变,宽度自动变化,保持原图宽高比不变
|
|
14
|
+
| 'top' // 裁剪:不缩放图片,只显示图片的顶部区域
|
|
15
|
+
| 'bottom' // 裁剪:不缩放图片,只显示图片的底部区域
|
|
16
|
+
| 'center' // 裁剪:不缩放图片,只显示图片的中间区域
|
|
17
|
+
| 'left' // 裁剪:不缩放图片,只显示图片的左边区域
|
|
18
|
+
| 'right' // 裁剪:不缩放图片,只显示图片的右边区域
|
|
19
|
+
| 'top left' // 裁剪:不缩放图片,只显示图片的左上边区域
|
|
20
|
+
| 'top right' // 裁剪:不缩放图片,只显示图片的右上边区域
|
|
21
|
+
| 'bottom left' // 裁剪:不缩放图片,只显示图片的左下边区域
|
|
22
|
+
| 'bottom right' // 裁剪:不缩放图片,只显示图片的右下边区域
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 图片形状
|
|
26
|
+
*/
|
|
27
|
+
export type ImageShape = 'square' | 'round' | 'circle'
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* TImage Props 接口
|
|
31
|
+
*/
|
|
32
|
+
export interface TImageProps {
|
|
33
|
+
/**
|
|
34
|
+
* 图片链接
|
|
35
|
+
*/
|
|
36
|
+
src: string
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 图片裁剪、缩放的模式
|
|
40
|
+
* @default 'aspectFill'
|
|
41
|
+
*/
|
|
42
|
+
mode?: ImageMode
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 图片宽度
|
|
46
|
+
*/
|
|
47
|
+
width?: string | number
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 图片高度
|
|
51
|
+
*/
|
|
52
|
+
height?: string | number
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* 图片形状
|
|
56
|
+
* @default 'square'
|
|
57
|
+
*/
|
|
58
|
+
shape?: ImageShape
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 圆角大小(仅 shape 为 square 时有效)
|
|
62
|
+
*/
|
|
63
|
+
radius?: string | number
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 是否显示加载中状态
|
|
67
|
+
* @default true
|
|
68
|
+
*/
|
|
69
|
+
showLoading?: boolean
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* 是否显示加载失败状态
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
showError?: boolean
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* 是否开启懒加载
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
lazyLoad?: boolean
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 加载中提示文本
|
|
85
|
+
* @default '加载中...'
|
|
86
|
+
*/
|
|
87
|
+
loadingText?: string
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 加载失败提示文本
|
|
91
|
+
* @default '加载失败'
|
|
92
|
+
*/
|
|
93
|
+
errorText?: string
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* 是否可预览
|
|
97
|
+
* @default false
|
|
98
|
+
*/
|
|
99
|
+
previewable?: boolean
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 预览图片列表(用于图片预览切换)
|
|
103
|
+
*/
|
|
104
|
+
previewList?: string[]
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* 当前预览图片索引
|
|
108
|
+
* @default 0
|
|
109
|
+
*/
|
|
110
|
+
previewIndex?: number
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 自定义类名
|
|
114
|
+
*/
|
|
115
|
+
customClass?: string
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* 自定义样式
|
|
119
|
+
*/
|
|
120
|
+
customStyle?: string
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* TImage 事件接口
|
|
125
|
+
*/
|
|
126
|
+
export interface TImageEmits {
|
|
127
|
+
/**
|
|
128
|
+
* 图片加载完成事件
|
|
129
|
+
*/
|
|
130
|
+
load: (event: Event) => void
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* 图片加载失败事件
|
|
134
|
+
*/
|
|
135
|
+
error: (event: Event) => void
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* 点击图片事件
|
|
139
|
+
*/
|
|
140
|
+
click: () => void
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 预览图片事件
|
|
144
|
+
*/
|
|
145
|
+
preview: () => void
|
|
146
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# TInput 输入框组件
|
|
2
|
+
|
|
3
|
+
输入框组件,支持多种类型、尺寸和状态。
|
|
4
|
+
|
|
5
|
+
## 基础用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<TInput v-model="value" placeholder="请输入内容" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { ref } from 'vue'
|
|
14
|
+
const value = ref('')
|
|
15
|
+
</script>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 输入框类型
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<template>
|
|
22
|
+
<TInput type="text" placeholder="文本输入" />
|
|
23
|
+
<TInput type="number" placeholder="数字输入" />
|
|
24
|
+
<TInput type="password" placeholder="密码输入" />
|
|
25
|
+
<TInput type="tel" placeholder="电话输入" />
|
|
26
|
+
</template>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 输入框尺寸
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<template>
|
|
33
|
+
<TInput size="large" placeholder="大型输入框" />
|
|
34
|
+
<TInput size="medium" placeholder="中等输入框" />
|
|
35
|
+
<TInput size="small" placeholder="小型输入框" />
|
|
36
|
+
<TInput size="mini" placeholder="迷你输入框" />
|
|
37
|
+
</template>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 禁用状态
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<template>
|
|
44
|
+
<TInput disabled placeholder="禁用状态" />
|
|
45
|
+
<TInput disabled value="禁用状态" />
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 只读状态
|
|
50
|
+
|
|
51
|
+
```vue
|
|
52
|
+
<template>
|
|
53
|
+
<TInput readonly value="只读状态" />
|
|
54
|
+
</template>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 清除按钮
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<template>
|
|
61
|
+
<TInput v-model="value" clearable placeholder="可清除" />
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 显示字数统计
|
|
66
|
+
|
|
67
|
+
```vue
|
|
68
|
+
<template>
|
|
69
|
+
<TInput v-model="value" maxlength="20" show-count placeholder="最多输入20个字符" />
|
|
70
|
+
</template>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## 带图标
|
|
74
|
+
|
|
75
|
+
```vue
|
|
76
|
+
<template>
|
|
77
|
+
<TInput prefix-icon="🔍" placeholder="搜索" />
|
|
78
|
+
<TInput suffix-icon="✓" placeholder="验证" />
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 文本域
|
|
83
|
+
|
|
84
|
+
```vue
|
|
85
|
+
<template>
|
|
86
|
+
<TInput type="textarea" placeholder="请输入多行文本" />
|
|
87
|
+
<TInput type="textarea" :rows="5" placeholder="5行文本域" />
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Props
|
|
92
|
+
|
|
93
|
+
| 参数 | 说明 | 类型 | 可选值 | 默认值 |
|
|
94
|
+
|------|------|------|--------|--------|
|
|
95
|
+
| v-model | 绑定值 (使用 defineModel) | string / number | - | - |
|
|
96
|
+
| type | 输入框类型 | string | text / number / password / tel / textarea | text |
|
|
97
|
+
| size | 输入框尺寸 | string | large / medium / small / mini | medium |
|
|
98
|
+
| placeholder | 占位文本 | string | - | - |
|
|
99
|
+
| disabled | 是否禁用 | boolean | - | false |
|
|
100
|
+
| readonly | 是否只读 | boolean | - | false |
|
|
101
|
+
| clearable | 是否显示清除按钮 | boolean | - | false |
|
|
102
|
+
| showCount | 是否显示字数统计 | boolean | - | false |
|
|
103
|
+
| maxlength | 最大输入长度 | number | - | -1 |
|
|
104
|
+
| prefixIcon | 前缀图标 | string | - | - |
|
|
105
|
+
| suffixIcon | 后缀图标 | string | - | - |
|
|
106
|
+
| rows | 文本域行数 | number | - | 3 |
|
|
107
|
+
| autoHeight | 文本域自动高度 | boolean | - | false |
|
|
108
|
+
| customClass | 自定义类名 | string | - | - |
|
|
109
|
+
| customStyle | 自定义样式 | string | - | - |
|
|
110
|
+
|
|
111
|
+
## Events
|
|
112
|
+
|
|
113
|
+
| 事件名 | 说明 | 回调参数 |
|
|
114
|
+
|--------|------|----------|
|
|
115
|
+
| input | 输入时触发 | (value: string \| number) |
|
|
116
|
+
| change | 值改变时触发 | (value: string \| number) |
|
|
117
|
+
| focus | 获得焦点时触发 | - |
|
|
118
|
+
| blur | 失去焦点时触发 | - |
|
|
119
|
+
| clear | 点击清除按钮时触发 | - |
|