uniapp-dyckui 4.1.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/LICENSE +21 -0
- package/README.md +104 -0
- package/dist/assets/style.BFlsbpSj.css +1472 -0
- package/dist/index.cjs.js +1380 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.es.js +1380 -0
- package/dist/index.es.js.map +1 -0
- package/dist/src/components/MyComs/Button/index.d.ts +3 -0
- package/dist/src/components/MyComs/Button/index.vue.d.ts +93 -0
- package/dist/src/components/MyComs/Dialog/index.d.ts +3 -0
- package/dist/src/components/MyComs/Dialog/index.vue.d.ts +65 -0
- package/dist/src/components/MyComs/Divider/index.d.ts +3 -0
- package/dist/src/components/MyComs/Divider/index.vue.d.ts +53 -0
- package/dist/src/components/MyComs/DropdownSelect/dropdownSelect.d.ts +10 -0
- package/dist/src/components/MyComs/DropdownSelect/index.d.ts +4 -0
- package/dist/src/components/MyComs/DropdownSelect/index.vue.d.ts +26 -0
- package/dist/src/components/MyComs/DropdownSelect/type.d.ts +13 -0
- package/dist/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.d.ts +5 -0
- package/dist/src/components/MyComs/DropdownWithBadge/index.d.ts +4 -0
- package/dist/src/components/MyComs/DropdownWithBadge/index.vue.d.ts +26 -0
- package/dist/src/components/MyComs/DropdownWithBadge/type.d.ts +9 -0
- package/dist/src/components/MyComs/FilterDrawer/hasBadge.d.ts +8 -0
- package/dist/src/components/MyComs/FilterDrawer/index.d.ts +5 -0
- package/dist/src/components/MyComs/FilterDrawer/index.vue.d.ts +26 -0
- package/dist/src/components/MyComs/FilterDrawer/type.d.ts +8 -0
- package/dist/src/components/MyComs/FilterDrawer/useFilterDrawer.d.ts +10 -0
- package/dist/src/components/MyComs/InfiniteScroll/index.d.ts +3 -0
- package/dist/src/components/MyComs/InfiniteScroll/index.vue.d.ts +65 -0
- package/dist/src/components/MyComs/Popup/index.d.ts +3 -0
- package/dist/src/components/MyComs/Popup/index.vue.d.ts +119 -0
- package/dist/src/components/MyComs/PullRefresh/index.d.ts +3 -0
- package/dist/src/components/MyComs/PullRefresh/index.vue.d.ts +117 -0
- package/dist/src/components/MyComs/Swiper/index.d.ts +3 -0
- package/dist/src/components/MyComs/Swiper/index.vue.d.ts +79 -0
- package/dist/src/components/MyComs/Toast/index.d.ts +3 -0
- package/dist/src/components/MyComs/Toast/index.vue.d.ts +108 -0
- package/dist/src/components/MyComs/index.d.ts +20 -0
- package/package.json +218 -0
- package/src/components/MyComs/Button/README.md +235 -0
- package/src/components/MyComs/Button/index.ts +3 -0
- package/src/components/MyComs/Button/index.vue +413 -0
- package/src/components/MyComs/Dialog/README.md +160 -0
- package/src/components/MyComs/Dialog/index.ts +2 -0
- package/src/components/MyComs/Dialog/index.vue +275 -0
- package/src/components/MyComs/Divider/README.md +0 -0
- package/src/components/MyComs/Divider/index.ts +2 -0
- package/src/components/MyComs/Divider/index.vue +106 -0
- package/src/components/MyComs/DropdownSelect/README.md +112 -0
- package/src/components/MyComs/DropdownSelect/dropdownSelect.less +75 -0
- package/src/components/MyComs/DropdownSelect/dropdownSelect.ts +59 -0
- package/src/components/MyComs/DropdownSelect/index.ts +4 -0
- package/src/components/MyComs/DropdownSelect/index.vue +88 -0
- package/src/components/MyComs/DropdownSelect/type.ts +15 -0
- package/src/components/MyComs/DropdownWithBadge/README.md +77 -0
- package/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.less +11 -0
- package/src/components/MyComs/DropdownWithBadge/dropdownWithBadge.ts +10 -0
- package/src/components/MyComs/DropdownWithBadge/index.ts +4 -0
- package/src/components/MyComs/DropdownWithBadge/index.vue +39 -0
- package/src/components/MyComs/DropdownWithBadge/type.ts +12 -0
- package/src/components/MyComs/FilterDrawer/filterDrawer.less +117 -0
- package/src/components/MyComs/FilterDrawer/hasBadge.ts +41 -0
- package/src/components/MyComs/FilterDrawer/index.ts +5 -0
- package/src/components/MyComs/FilterDrawer/index.vue +53 -0
- package/src/components/MyComs/FilterDrawer/type.ts +9 -0
- package/src/components/MyComs/FilterDrawer/useFilterDrawer.ts +38 -0
- package/src/components/MyComs/InfiniteScroll/index.ts +2 -0
- package/src/components/MyComs/InfiniteScroll/index.vue +171 -0
- package/src/components/MyComs/Popup/README.md +684 -0
- package/src/components/MyComs/Popup/index.ts +2 -0
- package/src/components/MyComs/Popup/index.vue +835 -0
- package/src/components/MyComs/PullRefresh/README.md +600 -0
- package/src/components/MyComs/PullRefresh/index.ts +2 -0
- package/src/components/MyComs/PullRefresh/index.vue +599 -0
- package/src/components/MyComs/Swiper/README.md +202 -0
- package/src/components/MyComs/Swiper/index.ts +2 -0
- package/src/components/MyComs/Swiper/index.vue +245 -0
- package/src/components/MyComs/Toast/README.md +604 -0
- package/src/components/MyComs/Toast/index.ts +2 -0
- package/src/components/MyComs/Toast/index.vue +372 -0
- package/src/components/MyComs/index.ts +33 -0
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view
|
|
3
|
+
v-show="showToast"
|
|
4
|
+
ref="toastRef"
|
|
5
|
+
class="sw-toast"
|
|
6
|
+
:class="[
|
|
7
|
+
`sw-toast--${type}`,
|
|
8
|
+
`sw-toast--${position}`,
|
|
9
|
+
{ 'sw-toast--large': large },
|
|
10
|
+
{ 'sw-toast--text': !showIcon && type === 'text' },
|
|
11
|
+
{ 'sw-toast--show': showToast && !isClosing },
|
|
12
|
+
{ 'sw-toast--hide': showToast && isClosing },
|
|
13
|
+
]"
|
|
14
|
+
:style="customStyle"
|
|
15
|
+
@click="onClick"
|
|
16
|
+
@transitionend="handleTransitionEnd"
|
|
17
|
+
>
|
|
18
|
+
<!-- 加载图标 -->
|
|
19
|
+
<view v-if="loading" class="sw-toast__loading">
|
|
20
|
+
<text v-if="!customIcon" class="sw-toast__spinner" />
|
|
21
|
+
<text v-else class="sw-toast__custom-icon">{{ customIcon }}</text>
|
|
22
|
+
</view>
|
|
23
|
+
|
|
24
|
+
<!-- 状态图标 -->
|
|
25
|
+
<view v-else-if="showIcon" class="sw-toast__icon">
|
|
26
|
+
<text v-if="type === 'success'" class="sw-toast__icon--success">✓</text>
|
|
27
|
+
<text v-else-if="type === 'fail'" class="sw-toast__icon--fail">✗</text>
|
|
28
|
+
<text v-else-if="customIcon" class="sw-toast__custom-icon">{{ customIcon }}</text>
|
|
29
|
+
</view>
|
|
30
|
+
|
|
31
|
+
<!-- 文本内容 -->
|
|
32
|
+
<text v-if="message" class="sw-toast__text">{{ message }}</text>
|
|
33
|
+
</view>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="ts">
|
|
37
|
+
import { computed, onMounted, onUnmounted, ref, watch, withDefaults } from 'vue'
|
|
38
|
+
|
|
39
|
+
// Props
|
|
40
|
+
interface Props {
|
|
41
|
+
/**
|
|
42
|
+
* 控制显示/隐藏(支持v-model)
|
|
43
|
+
*/
|
|
44
|
+
modelValue?: boolean
|
|
45
|
+
/**
|
|
46
|
+
* 提示类型
|
|
47
|
+
*/
|
|
48
|
+
type?: 'text' | 'loading' | 'success' | 'fail'
|
|
49
|
+
/**
|
|
50
|
+
* 显示位置
|
|
51
|
+
*/
|
|
52
|
+
position?: 'top' | 'middle' | 'bottom'
|
|
53
|
+
/**
|
|
54
|
+
* 提示文字
|
|
55
|
+
*/
|
|
56
|
+
message?: string
|
|
57
|
+
/**
|
|
58
|
+
* 自动关闭时间(毫秒),0表示不会自动关闭
|
|
59
|
+
*/
|
|
60
|
+
duration?: number
|
|
61
|
+
/**
|
|
62
|
+
* 是否显示加载图标
|
|
63
|
+
*/
|
|
64
|
+
loading?: boolean
|
|
65
|
+
/**
|
|
66
|
+
* 是否显示图标
|
|
67
|
+
*/
|
|
68
|
+
icon?: boolean
|
|
69
|
+
/**
|
|
70
|
+
* 自定义图标
|
|
71
|
+
*/
|
|
72
|
+
customIcon?: string
|
|
73
|
+
/**
|
|
74
|
+
* 是否为大尺寸
|
|
75
|
+
*/
|
|
76
|
+
large?: boolean
|
|
77
|
+
/**
|
|
78
|
+
* 自定义样式
|
|
79
|
+
*/
|
|
80
|
+
customStyle?: Record<string, any>
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
84
|
+
modelValue: false,
|
|
85
|
+
type: 'text',
|
|
86
|
+
position: 'middle',
|
|
87
|
+
message: '',
|
|
88
|
+
duration: 3000,
|
|
89
|
+
loading: false,
|
|
90
|
+
icon: true,
|
|
91
|
+
customIcon: '',
|
|
92
|
+
large: false,
|
|
93
|
+
customStyle: () => ({}),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
// Emits
|
|
97
|
+
const emit = defineEmits<{
|
|
98
|
+
/**
|
|
99
|
+
* 显示状态变化时触发
|
|
100
|
+
*/
|
|
101
|
+
(e: 'update:modelValue', value: boolean): void
|
|
102
|
+
/**
|
|
103
|
+
* 关闭时触发
|
|
104
|
+
*/
|
|
105
|
+
(e: 'close'): void
|
|
106
|
+
/**
|
|
107
|
+
* 点击时触发
|
|
108
|
+
*/
|
|
109
|
+
(e: 'click'): void
|
|
110
|
+
}>()
|
|
111
|
+
|
|
112
|
+
// Refs
|
|
113
|
+
const toastRef = ref<any>(null)
|
|
114
|
+
let timer: number | null | ReturnType<typeof setTimeout> = null
|
|
115
|
+
|
|
116
|
+
// 内部状态
|
|
117
|
+
const showToast = ref(props.modelValue)
|
|
118
|
+
const isClosing = ref(false)
|
|
119
|
+
|
|
120
|
+
// 计算是否需要显示图标
|
|
121
|
+
const showIcon = computed(() => {
|
|
122
|
+
if (props.loading)
|
|
123
|
+
return true
|
|
124
|
+
if (props.type === 'text')
|
|
125
|
+
return props.icon
|
|
126
|
+
return true
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
// 点击事件处理
|
|
130
|
+
function onClick() {
|
|
131
|
+
emit('click')
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 关闭Toast
|
|
135
|
+
function close() {
|
|
136
|
+
if (!showToast.value)
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
// 添加关闭动画
|
|
140
|
+
isClosing.value = true
|
|
141
|
+
emit('close')
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// 自动关闭定时器
|
|
145
|
+
function startTimer() {
|
|
146
|
+
// 清除之前的定时器
|
|
147
|
+
clearTimer()
|
|
148
|
+
|
|
149
|
+
if (props.duration > 0 && !props.loading) {
|
|
150
|
+
timer = setTimeout(() => {
|
|
151
|
+
close()
|
|
152
|
+
}, props.duration)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// 清除定时器
|
|
157
|
+
function clearTimer() {
|
|
158
|
+
if (timer) {
|
|
159
|
+
clearTimeout(timer)
|
|
160
|
+
timer = null
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// 过渡结束处理
|
|
165
|
+
function handleTransitionEnd() {
|
|
166
|
+
if (isClosing.value) {
|
|
167
|
+
showToast.value = false
|
|
168
|
+
isClosing.value = false
|
|
169
|
+
emit('update:modelValue', false)
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// 监听modelValue变化
|
|
174
|
+
watch(() => props.modelValue, (newVal) => {
|
|
175
|
+
if (newVal) {
|
|
176
|
+
// 显示Toast
|
|
177
|
+
showToast.value = true
|
|
178
|
+
isClosing.value = false
|
|
179
|
+
startTimer()
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// 隐藏Toast
|
|
183
|
+
close()
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
// 监听message变化,重新启动定时器
|
|
188
|
+
watch(() => props.message, () => {
|
|
189
|
+
if (showToast.value && !props.loading) {
|
|
190
|
+
startTimer()
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
// 生命周期
|
|
195
|
+
onMounted(() => {
|
|
196
|
+
if (props.modelValue) {
|
|
197
|
+
startTimer()
|
|
198
|
+
}
|
|
199
|
+
})
|
|
200
|
+
|
|
201
|
+
onUnmounted(() => {
|
|
202
|
+
clearTimer()
|
|
203
|
+
})
|
|
204
|
+
|
|
205
|
+
// 暴露方法
|
|
206
|
+
defineExpose({
|
|
207
|
+
/**
|
|
208
|
+
* 手动关闭Toast
|
|
209
|
+
*/
|
|
210
|
+
close,
|
|
211
|
+
})
|
|
212
|
+
</script>
|
|
213
|
+
|
|
214
|
+
<style scoped>
|
|
215
|
+
.sw-toast {
|
|
216
|
+
display: inline-flex;
|
|
217
|
+
align-items: center;
|
|
218
|
+
justify-content: center;
|
|
219
|
+
max-width: 80%;
|
|
220
|
+
padding: 20rpx 32rpx;
|
|
221
|
+
border-radius: 8rpx;
|
|
222
|
+
font-size: 28rpx;
|
|
223
|
+
line-height: 40rpx;
|
|
224
|
+
color: #fff;
|
|
225
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
226
|
+
box-sizing: border-box;
|
|
227
|
+
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
228
|
+
z-index: 9999;
|
|
229
|
+
position: fixed;
|
|
230
|
+
left: 50%;
|
|
231
|
+
transform: translateX(-50%) translateY(0);
|
|
232
|
+
word-wrap: break-word;
|
|
233
|
+
white-space: pre-wrap;
|
|
234
|
+
user-select: none;
|
|
235
|
+
opacity: 0;
|
|
236
|
+
visibility: hidden;
|
|
237
|
+
pointer-events: none;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* 显示动画 */
|
|
241
|
+
.sw-toast--show {
|
|
242
|
+
opacity: 1;
|
|
243
|
+
visibility: visible;
|
|
244
|
+
pointer-events: auto;
|
|
245
|
+
transform: translateX(-50%) translateY(0);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* 隐藏动画 */
|
|
249
|
+
.sw-toast--hide {
|
|
250
|
+
opacity: 0;
|
|
251
|
+
transform: translateX(-50%) translateY(-20rpx);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/* 位置样式 */
|
|
255
|
+
.sw-toast--top {
|
|
256
|
+
top: 100rpx;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.sw-toast--middle {
|
|
260
|
+
top: 50%;
|
|
261
|
+
transform: translate(-50%, -50%);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.sw-toast--middle.sw-toast--show {
|
|
265
|
+
transform: translate(-50%, -50%);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.sw-toast--middle.sw-toast--hide {
|
|
269
|
+
transform: translate(-50%, -60%);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.sw-toast--bottom {
|
|
273
|
+
bottom: 100rpx;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/* 类型样式 */
|
|
277
|
+
.sw-toast--text {
|
|
278
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.sw-toast--loading {
|
|
282
|
+
background-color: rgba(0, 0, 0, 0.7);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.sw-toast--success {
|
|
286
|
+
background-color: #67c23a;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.sw-toast--fail {
|
|
290
|
+
background-color: #f56c6c;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* 大尺寸样式 */
|
|
294
|
+
.sw-toast--large {
|
|
295
|
+
padding: 32rpx 48rpx;
|
|
296
|
+
font-size: 32rpx;
|
|
297
|
+
line-height: 48rpx;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/* 加载图标 */
|
|
301
|
+
.sw-toast__loading {
|
|
302
|
+
margin-right: 16rpx;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/* 加载动画 */
|
|
306
|
+
.sw-toast__spinner {
|
|
307
|
+
display: inline-block;
|
|
308
|
+
width: 40rpx;
|
|
309
|
+
height: 40rpx;
|
|
310
|
+
border: 4rpx solid rgba(255, 255, 255, 0.3);
|
|
311
|
+
border-radius: 50%;
|
|
312
|
+
border-top-color: #fff;
|
|
313
|
+
animation: sw-toast-spin 0.8s linear infinite;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
/* 自定义图标 */
|
|
317
|
+
.sw-toast__custom-icon {
|
|
318
|
+
font-size: 40rpx;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/* 状态图标 */
|
|
322
|
+
.sw-toast__icon {
|
|
323
|
+
margin-right: 16rpx;
|
|
324
|
+
|
|
325
|
+
&--success,
|
|
326
|
+
&--fail {
|
|
327
|
+
display: inline-block;
|
|
328
|
+
width: 40rpx;
|
|
329
|
+
height: 40rpx;
|
|
330
|
+
font-size: 40rpx;
|
|
331
|
+
font-weight: bold;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/* 文本内容 */
|
|
336
|
+
.sw-toast__text {
|
|
337
|
+
margin: 0;
|
|
338
|
+
word-wrap: break-word;
|
|
339
|
+
white-space: pre-wrap;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/* 加载动画 */
|
|
343
|
+
@keyframes sw-toast-spin {
|
|
344
|
+
to {
|
|
345
|
+
transform: rotate(360deg);
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/* 响应式设计 */
|
|
350
|
+
@media (max-width: 768px) {
|
|
351
|
+
.sw-toast {
|
|
352
|
+
max-width: 90%;
|
|
353
|
+
padding: 16rpx 24rpx;
|
|
354
|
+
font-size: 26rpx;
|
|
355
|
+
line-height: 36rpx;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.sw-toast--large {
|
|
359
|
+
padding: 24rpx 40rpx;
|
|
360
|
+
font-size: 30rpx;
|
|
361
|
+
line-height: 44rpx;
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
.sw-toast--top {
|
|
365
|
+
top: 60rpx;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
.sw-toast--bottom {
|
|
369
|
+
bottom: 60rpx;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
</style>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// 统一导出所有 MyComs 组件
|
|
2
|
+
|
|
3
|
+
// 基础组件
|
|
4
|
+
export { default as Button } from './Button/index.vue'
|
|
5
|
+
export { default as Dialog } from './Dialog/index.vue'
|
|
6
|
+
export { default as Divider } from './Divider/index.vue'
|
|
7
|
+
export { default as Popup } from './Popup/index.vue'
|
|
8
|
+
export { default as Toast } from './Toast/index.vue'
|
|
9
|
+
export { default as Swiper } from './Swiper/index.vue'
|
|
10
|
+
|
|
11
|
+
// 交互组件
|
|
12
|
+
export { default as InfiniteScroll } from './InfiniteScroll/index.vue'
|
|
13
|
+
export { default as PullRefresh } from './PullRefresh/index.vue'
|
|
14
|
+
|
|
15
|
+
// 表单组件
|
|
16
|
+
export { default as DropdownSelect } from './DropdownSelect/index.vue'
|
|
17
|
+
export type { DropdownSelectProps, DropdownSelectEmits } from './DropdownSelect/type'
|
|
18
|
+
export { default as DropdownWithBadge } from './DropdownWithBadge/index.vue'
|
|
19
|
+
export type { DropdownWithBadgeProps, DropdownWithBadgeEmits } from './DropdownWithBadge/type'
|
|
20
|
+
|
|
21
|
+
// 筛选组件
|
|
22
|
+
export { default as FilterDrawer } from './FilterDrawer/index.vue'
|
|
23
|
+
export type { FilterDrawerProps, FilterDrawerEmits } from './FilterDrawer/type'
|
|
24
|
+
|
|
25
|
+
// 导出所有类型
|
|
26
|
+
export type * from './DropdownSelect/type'
|
|
27
|
+
export type * from './DropdownWithBadge/type'
|
|
28
|
+
export type * from './FilterDrawer/type'
|
|
29
|
+
|
|
30
|
+
// 导出组合式函数
|
|
31
|
+
export { useDropdownSelect } from './DropdownSelect/dropdownSelect'
|
|
32
|
+
export { useDropdownWithBadge } from './DropdownWithBadge/dropdownWithBadge'
|
|
33
|
+
export { useFilterDrawer } from './FilterDrawer/useFilterDrawer'
|