uview-pro 0.0.7 → 0.0.8
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/changelog.md +5 -0
- package/components/u-action-sheet/types.ts +35 -0
- package/components/u-action-sheet/u-action-sheet.vue +2 -47
- package/components/u-alert-tips/types.ts +39 -0
- package/components/u-alert-tips/u-alert-tips.vue +3 -32
- package/components/u-avatar/types.ts +34 -0
- package/components/u-avatar/u-avatar.vue +3 -30
- package/components/u-avatar-cropper/types.ts +23 -0
- package/components/u-avatar-cropper/u-avatar-cropper.vue +2 -45
- package/components/u-back-top/types.ts +39 -0
- package/components/u-back-top/u-back-top.vue +2 -33
- package/components/u-badge/types.ts +36 -0
- package/components/u-badge/u-badge.vue +2 -26
- package/components/u-button/types.ts +66 -0
- package/components/u-button/u-button.vue +3 -88
- package/components/u-calendar/types.ts +63 -0
- package/components/u-calendar/u-calendar.vue +2 -135
- package/components/u-car-keyboard/types.ts +12 -0
- package/components/u-car-keyboard/u-car-keyboard.vue +2 -4
- package/components/u-card/types.ts +59 -0
- package/components/u-card/u-card.vue +2 -48
- package/components/u-cell-group/types.ts +17 -0
- package/components/u-cell-group/u-cell-group.vue +3 -9
- package/components/u-cell-item/types.ts +54 -0
- package/components/u-cell-item/u-cell-item.vue +2 -45
- package/components/u-checkbox/types.ts +31 -0
- package/components/u-checkbox/u-checkbox.vue +2 -47
- package/components/u-checkbox-group/types.ts +32 -0
- package/components/u-checkbox-group/u-checkbox-group.vue +2 -57
- package/components/u-circle-progress/types.ts +52 -0
- package/components/u-circle-progress/u-circle-progress.vue +2 -23
- package/components/u-city-select/types.ts +20 -0
- package/components/u-city-select/u-city-select.vue +2 -10
- package/components/u-col/types.ts +30 -0
- package/components/u-col/u-col.vue +2 -14
- package/components/u-collapse/types.ts +31 -0
- package/components/u-collapse/u-collapse.vue +2 -16
- package/components/u-collapse-item/types.ts +25 -0
- package/components/u-collapse-item/u-collapse-item.vue +2 -16
- package/components/u-column-notice/types.ts +48 -0
- package/components/u-column-notice/u-column-notice.vue +2 -97
- package/components/u-count-down/types.ts +42 -0
- package/components/u-count-down/u-count-down.vue +2 -82
- package/components/u-count-to/types.ts +32 -0
- package/components/u-count-to/u-count-to.vue +2 -58
- package/components/u-divider/types.ts +31 -0
- package/components/u-divider/u-divider.vue +2 -22
- package/components/u-dropdown/types.ts +32 -0
- package/components/u-dropdown/u-dropdown.vue +2 -24
- package/components/u-dropdown-item/types.ts +27 -0
- package/components/u-dropdown-item/u-dropdown-item.vue +4 -16
- package/components/u-empty/types.ts +36 -0
- package/components/u-empty/u-empty.vue +3 -26
- package/components/u-field/types.ts +69 -0
- package/components/u-field/u-field.vue +2 -117
- package/components/u-form/types.ts +25 -0
- package/components/u-form/u-form.vue +2 -46
- package/components/u-form-item/types.ts +70 -0
- package/components/u-form-item/u-form-item.vue +2 -62
- package/components/u-full-screen/types.ts +14 -0
- package/components/u-full-screen/u-full-screen.vue +2 -0
- package/components/u-gap/types.ts +18 -0
- package/components/u-gap/u-gap.vue +2 -10
- package/components/u-grid/types.ts +19 -0
- package/components/u-grid/u-grid.vue +3 -11
- package/components/u-grid-item/types.ts +16 -0
- package/components/u-grid-item/u-grid-item.vue +2 -8
- package/components/u-icon/types.ts +62 -0
- package/components/u-icon/u-icon.vue +2 -123
- package/components/u-image/types.ts +39 -38
- package/components/u-index-anchor/types.ts +16 -0
- package/components/u-index-anchor/u-index-anchor.vue +2 -17
- package/components/u-index-list/types.ts +43 -0
- package/components/u-index-list/u-index-list.vue +13 -34
- package/components/u-input/types.ts +140 -0
- package/components/u-input/u-input.vue +2 -209
- package/components/u-keyboard/types.ts +40 -0
- package/components/u-keyboard/u-keyboard.vue +2 -32
- package/components/u-lazy-load/types.ts +37 -0
- package/components/u-lazy-load/u-lazy-load.vue +3 -58
- package/components/u-line/types.ts +44 -0
- package/components/u-line/u-line.vue +2 -14
- package/components/u-line-progress/types.ts +58 -0
- package/components/u-line-progress/u-line-progress.vue +2 -21
- package/components/u-link/types.ts +43 -0
- package/components/u-link/u-link.vue +2 -14
- package/components/u-loading/types.ts +35 -0
- package/components/u-loading/u-loading.vue +2 -23
- package/components/u-loadmore/types.ts +79 -0
- package/components/u-loadmore/u-loadmore.vue +2 -67
- package/components/u-mask/types.ts +43 -0
- package/components/u-mask/u-mask.vue +2 -33
- package/components/u-message-input/types.ts +74 -0
- package/components/u-message-input/u-message-input.vue +2 -62
- package/components/u-modal/types.ts +118 -0
- package/components/u-modal/u-modal.vue +2 -86
- package/components/u-navbar/types.ts +103 -0
- package/components/u-navbar/u-navbar.vue +2 -90
- package/components/u-no-network/types.ts +28 -0
- package/components/u-no-network/u-no-network.vue +2 -23
- package/components/u-notice-bar/types.ts +111 -0
- package/components/u-notice-bar/u-notice-bar.vue +2 -102
- package/components/u-number-box/types.ts +42 -0
- package/components/u-number-box/u-number-box.vue +2 -34
- package/components/u-number-keyboard/types.ts +26 -0
- package/components/u-number-keyboard/u-number-keyboard.vue +2 -8
- package/components/u-picker/types.ts +111 -0
- package/components/u-picker/u-picker.vue +3 -174
- package/components/u-popup/types.ts +59 -0
- package/components/u-popup/u-popup.vue +2 -47
- package/components/u-radio/types.ts +25 -0
- package/components/u-radio/u-radio.vue +2 -16
- package/components/u-radio-group/types.ts +29 -0
- package/components/u-radio-group/u-radio-group.vue +2 -20
- package/components/u-rate/types.ts +40 -0
- package/components/u-rate/u-rate.vue +2 -124
- package/components/u-read-more/types.ts +35 -0
- package/components/u-read-more/u-read-more.vue +2 -51
- package/components/u-row/types.ts +20 -0
- package/components/u-row/u-row.vue +2 -10
- package/components/u-row-notice/types.ts +39 -0
- package/components/u-row-notice/u-row-notice.vue +2 -72
- package/components/u-search/types.ts +53 -0
- package/components/u-search/u-search.vue +2 -44
- package/components/u-section/types.ts +32 -0
- package/components/u-section/u-section.vue +2 -52
- package/components/u-select/types.ts +43 -0
- package/components/u-select/u-select.vue +2 -34
- package/components/u-skeleton/types.ts +20 -0
- package/components/u-skeleton/u-skeleton.vue +2 -27
- package/components/u-slider/types.ts +32 -0
- package/components/u-slider/u-slider.vue +2 -57
- package/components/u-steps/types.ts +28 -0
- package/components/u-steps/u-steps.vue +2 -42
- package/components/u-sticky/types.ts +22 -0
- package/components/u-sticky/u-sticky.vue +2 -32
- package/components/u-subsection/types.ts +36 -0
- package/components/u-subsection/u-subsection.vue +2 -62
- package/components/u-swipe-action/types.ts +50 -0
- package/components/u-swipe-action/u-swipe-action.vue +2 -39
- package/components/u-swiper/types.ts +47 -0
- package/components/u-swiper/u-swiper.vue +2 -41
- package/components/u-switch/types.ts +28 -0
- package/components/u-switch/u-switch.vue +2 -20
- package/components/u-tabbar/types.ts +36 -0
- package/components/u-tabbar/u-tabbar.vue +6 -75
- package/components/u-table/types.ts +25 -0
- package/components/u-table/u-table.vue +2 -51
- package/components/u-tabs/types.ts +51 -0
- package/components/u-tabs/u-tabs.vue +6 -44
- package/components/u-tabs-swiper/types.ts +53 -0
- package/components/u-tabs-swiper/u-tabs-swiper.vue +3 -50
- package/components/u-tag/types.ts +37 -0
- package/components/u-tag/u-tag.vue +2 -28
- package/components/u-td/types.ts +12 -0
- package/components/u-td/u-td.vue +2 -9
- package/components/u-th/types.ts +12 -0
- package/components/u-th/u-th.vue +2 -9
- package/components/u-time-line-item/types.ts +14 -0
- package/components/u-time-line-item/u-time-line-item.vue +2 -12
- package/components/u-toast/types.ts +35 -3
- package/components/u-toast/u-toast.vue +2 -7
- package/components/u-top-tips/types.ts +14 -0
- package/components/u-top-tips/u-top-tips.vue +17 -22
- package/components/u-tr/types.ts +8 -0
- package/components/u-tr/u-tr.vue +3 -0
- package/components/u-upload/types.ts +71 -0
- package/components/u-upload/u-upload.vue +6 -67
- package/components/u-verification-code/types.ts +22 -0
- package/components/u-verification-code/u-verification-code.vue +2 -32
- package/components/u-waterfall/types.ts +16 -0
- package/components/u-waterfall/u-waterfall.vue +2 -18
- package/package.json +1 -1
- package/types/global.d.ts +200 -0
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
|
|
58
58
|
<script setup lang="ts">
|
|
59
59
|
import { ref, computed, watch } from 'vue';
|
|
60
|
+
import { SwiperProps } from './types';
|
|
60
61
|
|
|
61
62
|
defineOptions({ name: 'u-swiper' });
|
|
62
63
|
/**
|
|
@@ -81,47 +82,7 @@ defineOptions({ name: 'u-swiper' });
|
|
|
81
82
|
* @example <u-swiper :list="list" mode="dot" indicator-pos="bottomRight"></u-swiper>
|
|
82
83
|
*/
|
|
83
84
|
|
|
84
|
-
|
|
85
|
-
const props = defineProps({
|
|
86
|
-
/** 轮播图的数据,格式如:[{image: 'xxxx', title: 'xxxx'},{image: 'yyyy', title: 'yyyy'}],其中title字段可选 */
|
|
87
|
-
list: { type: Array as () => Array<Record<string, any>>, default: () => [] },
|
|
88
|
-
/** 是否显示title标题 */
|
|
89
|
-
title: { type: Boolean, default: false },
|
|
90
|
-
/** 用户自定义的指示器的样式 */
|
|
91
|
-
indicator: { type: Object, default: () => ({}) },
|
|
92
|
-
/** 圆角值 */
|
|
93
|
-
borderRadius: { type: [Number, String], default: 8 },
|
|
94
|
-
/** 隔多久自动切换 */
|
|
95
|
-
interval: { type: [String, Number], default: 3000 },
|
|
96
|
-
/** 指示器的模式,rect|dot|number|round */
|
|
97
|
-
mode: { type: String, default: 'round' },
|
|
98
|
-
/** list的高度,单位rpx */
|
|
99
|
-
height: { type: [Number, String], default: 250 },
|
|
100
|
-
/** 指示器的位置,topLeft|topCenter|topRight|bottomLeft|bottomCenter|bottomRight */
|
|
101
|
-
indicatorPos: { type: String, default: 'bottomCenter' },
|
|
102
|
-
/** 是否开启缩放效果 */
|
|
103
|
-
effect3d: { type: Boolean, default: false },
|
|
104
|
-
/** 3D模式的情况下,激活item与前后item之间的距离,单位rpx */
|
|
105
|
-
effect3dPreviousMargin: { type: [Number, String], default: 50 },
|
|
106
|
-
/** 是否自动播放 */
|
|
107
|
-
autoplay: { type: Boolean, default: true },
|
|
108
|
-
/** 自动轮播时间间隔,单位ms */
|
|
109
|
-
duration: { type: [Number, String], default: 500 },
|
|
110
|
-
/** 是否衔接滑动,即到最后一张时接着滑动,是否自动切换到第一张 */
|
|
111
|
-
circular: { type: Boolean, default: true },
|
|
112
|
-
/** 图片的裁剪模式 */
|
|
113
|
-
imgMode: { type: String, default: 'aspectFill' },
|
|
114
|
-
/** 从list数组中读取的图片的属性名 */
|
|
115
|
-
name: { type: String, default: 'image' },
|
|
116
|
-
/** 背景颜色 */
|
|
117
|
-
bgColor: { type: String, default: '#f3f4f6' },
|
|
118
|
-
/** 初始化时,默认显示第几项 */
|
|
119
|
-
current: { type: [Number, String], default: 0 },
|
|
120
|
-
/** 标题的样式,对象形式 */
|
|
121
|
-
titleStyle: { type: Object, default: () => ({}) }
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
// emits 定义
|
|
85
|
+
const props = defineProps(SwiperProps);
|
|
125
86
|
const emit = defineEmits(['click', 'change']);
|
|
126
87
|
|
|
127
88
|
// 当前活跃的swiper-item的index
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* SwitchProps 开关选择器 props 类型定义
|
|
5
|
+
* @description 选择开关,支持自定义颜色、尺寸、值等
|
|
6
|
+
*/
|
|
7
|
+
export const SwitchProps = {
|
|
8
|
+
/** 是否显示加载中状态 */
|
|
9
|
+
loading: { type: Boolean, default: false },
|
|
10
|
+
/** 是否禁用 */
|
|
11
|
+
disabled: { type: Boolean, default: false },
|
|
12
|
+
/** 开关尺寸,单位rpx */
|
|
13
|
+
size: { type: [Number, String] as PropType<number | string>, default: 50 },
|
|
14
|
+
/** 打开时的颜色 */
|
|
15
|
+
activeColor: { type: String, default: '#2979ff' },
|
|
16
|
+
/** 关闭时的颜色 */
|
|
17
|
+
inactiveColor: { type: String, default: '#ffffff' },
|
|
18
|
+
/** v-model 绑定值,是否选中 */
|
|
19
|
+
modelValue: { type: Boolean, default: false },
|
|
20
|
+
/** 是否开启轻微震动反馈 */
|
|
21
|
+
vibrateShort: { type: Boolean, default: false },
|
|
22
|
+
/** 打开时的值 */
|
|
23
|
+
activeValue: { type: [Number, String, Boolean] as PropType<number | string | boolean>, default: true },
|
|
24
|
+
/** 关闭时的值 */
|
|
25
|
+
inactiveValue: { type: [Number, String, Boolean] as PropType<number | string | boolean>, default: false }
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export type SwitchProps = ExtractPropTypes<typeof SwitchProps>;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { computed, nextTick } from 'vue';
|
|
17
17
|
import { $u } from '../..';
|
|
18
|
+
import { SwitchProps } from './types';
|
|
18
19
|
|
|
19
20
|
defineOptions({
|
|
20
21
|
name: 'u-switch'
|
|
@@ -34,26 +35,7 @@ defineOptions({
|
|
|
34
35
|
* @event {Function} change 在switch打开或关闭时触发
|
|
35
36
|
* @example <u-switch v-model="checked" active-color="red" inactive-color="#eee"></u-switch>
|
|
36
37
|
*/
|
|
37
|
-
const props = defineProps(
|
|
38
|
-
/** 是否为加载中状态 */
|
|
39
|
-
loading: { type: Boolean, default: false },
|
|
40
|
-
/** 是否为禁用状态 */
|
|
41
|
-
disabled: { type: Boolean, default: false },
|
|
42
|
-
/** 开关尺寸,单位rpx */
|
|
43
|
-
size: { type: [Number, String], default: 50 },
|
|
44
|
-
/** 打开时的背景颜色 */
|
|
45
|
-
activeColor: { type: String, default: '#2979ff' },
|
|
46
|
-
/** 关闭时的背景颜色 */
|
|
47
|
-
inactiveColor: { type: String, default: '#ffffff' },
|
|
48
|
-
/** 通过v-model双向绑定的值 */
|
|
49
|
-
modelValue: { type: Boolean, default: false },
|
|
50
|
-
/** 是否使手机发生短促震动,目前只在iOS的微信小程序有效(2020-05-06) */
|
|
51
|
-
vibrateShort: { type: Boolean, default: false },
|
|
52
|
-
/** 打开选择器时的值 */
|
|
53
|
-
activeValue: { type: [Number, String, Boolean], default: true },
|
|
54
|
-
/** 关闭选择器时的值 */
|
|
55
|
-
inactiveValue: { type: [Number, String, Boolean], default: false }
|
|
56
|
-
});
|
|
38
|
+
const props = defineProps(SwitchProps);
|
|
57
39
|
|
|
58
40
|
const emit = defineEmits(['update:modelValue', 'change']);
|
|
59
41
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TabbarProps 底部导航栏 props 类型定义
|
|
5
|
+
* @description 底部导航栏,支持凸起按钮、徽标、切换前回调等
|
|
6
|
+
*/
|
|
7
|
+
export const TabbarProps = {
|
|
8
|
+
/** 是否显示tabbar */
|
|
9
|
+
show: { type: Boolean, default: true },
|
|
10
|
+
/** v-model绑定当前激活项的值 */
|
|
11
|
+
modelValue: { type: [String, Number] as PropType<string | number>, default: 0 },
|
|
12
|
+
/** tabbar背景色 */
|
|
13
|
+
bgColor: { type: String, default: '#ffffff' },
|
|
14
|
+
/** tabbar高度,单位任意,数值默认rpx */
|
|
15
|
+
height: { type: [String, Number] as PropType<string | number>, default: '50px' },
|
|
16
|
+
/** 非凸起图标的大小,单位任意,数值默认rpx */
|
|
17
|
+
iconSize: { type: [String, Number] as PropType<string | number>, default: 40 },
|
|
18
|
+
/** 凸起图标的大小,单位任意,数值默认rpx */
|
|
19
|
+
midButtonSize: { type: [String, Number] as PropType<string | number>, default: 90 },
|
|
20
|
+
/** 激活时的颜色 */
|
|
21
|
+
activeColor: { type: String, default: '#303133' },
|
|
22
|
+
/** 未激活时的颜色 */
|
|
23
|
+
inactiveColor: { type: String, default: '#606266' },
|
|
24
|
+
/** 是否显示中部凸起按钮 */
|
|
25
|
+
midButton: { type: Boolean, default: false },
|
|
26
|
+
/** tabbar配置项数组 */
|
|
27
|
+
list: { type: Array as PropType<any[]>, default: () => [] },
|
|
28
|
+
/** 切换前回调,返回true或Promise */
|
|
29
|
+
beforeSwitch: { type: Function as PropType<((index: number) => boolean | Promise<any>) | null>, default: null },
|
|
30
|
+
/** 是否显示顶部横线 */
|
|
31
|
+
borderTop: { type: Boolean, default: true },
|
|
32
|
+
/** 是否隐藏原生tabbar */
|
|
33
|
+
hideTabBar: { type: Boolean, default: true }
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type TabbarProps = ExtractPropTypes<typeof TabbarProps>;
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
<script setup lang="ts">
|
|
44
44
|
import { ref, computed, onMounted, getCurrentInstance } from 'vue';
|
|
45
45
|
import { $u } from '../..';
|
|
46
|
+
import { TabbarProps } from './types';
|
|
46
47
|
|
|
47
48
|
defineOptions({ name: 'u-tabbar' });
|
|
48
49
|
|
|
@@ -63,73 +64,7 @@ defineOptions({ name: 'u-tabbar' });
|
|
|
63
64
|
* @property {Boolean} hideTabBar 是否隐藏原生tabbar
|
|
64
65
|
*/
|
|
65
66
|
|
|
66
|
-
const props = defineProps(
|
|
67
|
-
/** 显示与否 */
|
|
68
|
-
show: {
|
|
69
|
-
type: Boolean,
|
|
70
|
-
default: true
|
|
71
|
-
},
|
|
72
|
-
/** 通过v-model绑定current值 */
|
|
73
|
-
modelValue: {
|
|
74
|
-
type: [String, Number],
|
|
75
|
-
default: 0
|
|
76
|
-
},
|
|
77
|
-
/** 整个tabbar的背景颜色 */
|
|
78
|
-
bgColor: {
|
|
79
|
-
type: String,
|
|
80
|
-
default: '#ffffff'
|
|
81
|
-
},
|
|
82
|
-
/** tabbar的高度,默认50px,单位任意,如果为数值,则为rpx单位 */
|
|
83
|
-
height: {
|
|
84
|
-
type: [String, Number],
|
|
85
|
-
default: '50px'
|
|
86
|
-
},
|
|
87
|
-
/** 非凸起图标的大小,单位任意,数值默认rpx */
|
|
88
|
-
iconSize: {
|
|
89
|
-
type: [String, Number],
|
|
90
|
-
default: 40
|
|
91
|
-
},
|
|
92
|
-
/** 凸起的图标的大小,单位任意,数值默认rpx */
|
|
93
|
-
midButtonSize: {
|
|
94
|
-
type: [String, Number],
|
|
95
|
-
default: 90
|
|
96
|
-
},
|
|
97
|
-
/** 激活时的演示,包括字体图标,提示文字等的演示 */
|
|
98
|
-
activeColor: {
|
|
99
|
-
type: String,
|
|
100
|
-
default: '#303133'
|
|
101
|
-
},
|
|
102
|
-
/** 未激活时的颜色 */
|
|
103
|
-
inactiveColor: {
|
|
104
|
-
type: String,
|
|
105
|
-
default: '#606266'
|
|
106
|
-
},
|
|
107
|
-
/** 是否显示中部的凸起按钮 */
|
|
108
|
-
midButton: {
|
|
109
|
-
type: Boolean,
|
|
110
|
-
default: false
|
|
111
|
-
},
|
|
112
|
-
/** 配置参数 */
|
|
113
|
-
list: {
|
|
114
|
-
type: Array as () => any[],
|
|
115
|
-
default: () => []
|
|
116
|
-
},
|
|
117
|
-
/** 切换前的回调 */
|
|
118
|
-
beforeSwitch: {
|
|
119
|
-
type: Function,
|
|
120
|
-
default: null
|
|
121
|
-
},
|
|
122
|
-
/** 是否显示顶部的横线 */
|
|
123
|
-
borderTop: {
|
|
124
|
-
type: Boolean,
|
|
125
|
-
default: true
|
|
126
|
-
},
|
|
127
|
-
/** 是否隐藏原生tabbar */
|
|
128
|
-
hideTabBar: {
|
|
129
|
-
type: Boolean,
|
|
130
|
-
default: true
|
|
131
|
-
}
|
|
132
|
-
});
|
|
67
|
+
const props = defineProps(TabbarProps);
|
|
133
68
|
|
|
134
69
|
const emit = defineEmits<{ (e: 'change', index: number): void; (e: 'update:modelValue', index: number): void }>();
|
|
135
70
|
|
|
@@ -194,20 +129,16 @@ const elColor = computed<(index: number) => string>(() => {
|
|
|
194
129
|
async function clickHandler(index: number) {
|
|
195
130
|
if (props.beforeSwitch && typeof props.beforeSwitch === 'function') {
|
|
196
131
|
// 执行回调,同时传入索引当作参数
|
|
197
|
-
|
|
198
|
-
// 通过bind()方法,绑定父组件的this,让this.customBack()的this为父组件的上下文
|
|
199
|
-
// let beforeSwitch = props.beforeSwitch.bind($u.$parent.call(getCurrentInstance()?.proxy))(index);
|
|
200
|
-
// 或许有问题
|
|
201
|
-
let beforeSwitch = props.beforeSwitch(index);
|
|
132
|
+
let beforeSwitchResult = props.beforeSwitch(index);
|
|
202
133
|
// 判断是否返回了promise
|
|
203
|
-
if (
|
|
204
|
-
await
|
|
134
|
+
if (typeof beforeSwitchResult === 'object' && beforeSwitchResult !== null && typeof beforeSwitchResult.then === 'function') {
|
|
135
|
+
await beforeSwitchResult
|
|
205
136
|
.then(() => {
|
|
206
137
|
// promise返回成功,
|
|
207
138
|
switchTab(index);
|
|
208
139
|
})
|
|
209
140
|
.catch(() => {});
|
|
210
|
-
} else if (
|
|
141
|
+
} else if (beforeSwitchResult === true) {
|
|
211
142
|
// 如果返回true
|
|
212
143
|
switchTab(index);
|
|
213
144
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { TextAlign } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TableProps 表格 props 类型定义
|
|
6
|
+
* @description 表格组件,支持自定义边框、背景、对齐方式等
|
|
7
|
+
*/
|
|
8
|
+
export const TableProps = {
|
|
9
|
+
/** 表格边框的颜色 */
|
|
10
|
+
borderColor: { type: String, default: '#e4e7ed' },
|
|
11
|
+
/** 单元格的内容对齐方式,作用类似css的text-align */
|
|
12
|
+
align: { type: String as PropType<TextAlign>, default: 'center' },
|
|
13
|
+
/** 单元格的内边距,同css的padding写法 */
|
|
14
|
+
padding: { type: String, default: '10rpx 6rpx' },
|
|
15
|
+
/** 单元格字体大小,单位rpx */
|
|
16
|
+
fontSize: { type: [String, Number] as PropType<number | string>, default: 28 },
|
|
17
|
+
/** 单元格字体颜色 */
|
|
18
|
+
color: { type: String, default: '#606266' },
|
|
19
|
+
/** th单元格的样式,对象形式(将th所需参数放在table组件,是为了避免每一个th组件要写一遍) */
|
|
20
|
+
thStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
21
|
+
/** 表格的背景颜色 */
|
|
22
|
+
bgColor: { type: String, default: '#ffffff' }
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type TableProps = ExtractPropTypes<typeof TableProps>;
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
|
+
import { TableProps } from './types';
|
|
9
10
|
|
|
10
11
|
defineOptions({ name: 'u-table' });
|
|
11
12
|
|
|
@@ -25,57 +26,7 @@ defineOptions({ name: 'u-table' });
|
|
|
25
26
|
* @example <u-table></u-table>
|
|
26
27
|
*/
|
|
27
28
|
|
|
28
|
-
const props = defineProps(
|
|
29
|
-
/**
|
|
30
|
-
* 表格边框的颜色
|
|
31
|
-
*/
|
|
32
|
-
borderColor: {
|
|
33
|
-
type: String,
|
|
34
|
-
default: '#e4e7ed'
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* 单元格的内容对齐方式
|
|
38
|
-
*/
|
|
39
|
-
align: {
|
|
40
|
-
type: String,
|
|
41
|
-
default: 'center'
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* td的内边距
|
|
45
|
-
*/
|
|
46
|
-
padding: {
|
|
47
|
-
type: String,
|
|
48
|
-
default: '10rpx 6rpx'
|
|
49
|
-
},
|
|
50
|
-
/**
|
|
51
|
-
* 字体大小
|
|
52
|
-
*/
|
|
53
|
-
fontSize: {
|
|
54
|
-
type: [String, Number],
|
|
55
|
-
default: 28
|
|
56
|
-
},
|
|
57
|
-
/**
|
|
58
|
-
* 字体颜色
|
|
59
|
-
*/
|
|
60
|
-
color: {
|
|
61
|
-
type: String,
|
|
62
|
-
default: '#606266'
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* th的自定义样式
|
|
66
|
-
*/
|
|
67
|
-
thStyle: {
|
|
68
|
-
type: Object as () => Record<string, any>,
|
|
69
|
-
default: () => ({})
|
|
70
|
-
},
|
|
71
|
-
/**
|
|
72
|
-
* table的背景颜色
|
|
73
|
-
*/
|
|
74
|
-
bgColor: {
|
|
75
|
-
type: String,
|
|
76
|
-
default: '#ffffff'
|
|
77
|
-
}
|
|
78
|
-
});
|
|
29
|
+
const props = defineProps(TableProps);
|
|
79
30
|
|
|
80
31
|
/**
|
|
81
32
|
* 计算表格样式
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { TabsItem } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TabsProps tabs标签 props 类型定义
|
|
6
|
+
* @description 标签组件,支持横向滚动、滑块、徽标等
|
|
7
|
+
*/
|
|
8
|
+
export const TabsProps = {
|
|
9
|
+
/** tabs是否可以左右拖动 */
|
|
10
|
+
isScroll: { type: Boolean, default: true },
|
|
11
|
+
/** 标签数组 */
|
|
12
|
+
list: { type: Array as PropType<Array<TabsItem>>, default: () => [] },
|
|
13
|
+
/** 当前活动tab的索引 */
|
|
14
|
+
current: { type: [Number, String] as PropType<number | string>, default: 0 },
|
|
15
|
+
/** 导航栏的高度和行高 */
|
|
16
|
+
height: { type: [String, Number] as PropType<number | string>, default: 80 },
|
|
17
|
+
/** 字体大小 */
|
|
18
|
+
fontSize: { type: [String, Number] as PropType<number | string>, default: 30 },
|
|
19
|
+
/** 过渡动画时长, 单位s */
|
|
20
|
+
duration: { type: [String, Number] as PropType<number | string>, default: 0.5 },
|
|
21
|
+
/** 选中项的主题颜色 */
|
|
22
|
+
activeColor: { type: String, default: '#2979ff' },
|
|
23
|
+
/** 未选中项的颜色 */
|
|
24
|
+
inactiveColor: { type: String, default: '#303133' },
|
|
25
|
+
/** 菜单底部移动的bar的宽度,单位rpx */
|
|
26
|
+
barWidth: { type: [String, Number] as PropType<number | string>, default: 40 },
|
|
27
|
+
/** 移动bar的高度 */
|
|
28
|
+
barHeight: { type: [String, Number] as PropType<number | string>, default: 6 },
|
|
29
|
+
/** 单个tab的左右内边距之和,单位rpx */
|
|
30
|
+
gutter: { type: [String, Number] as PropType<number | string>, default: 30 },
|
|
31
|
+
/** 导航栏的背景颜色 */
|
|
32
|
+
bgColor: { type: String, default: '#ffffff' },
|
|
33
|
+
/** 读取传入的数组对象的属性(tab名称) */
|
|
34
|
+
name: { type: String, default: 'name' },
|
|
35
|
+
/** 读取传入的数组对象的属性(徽标数) */
|
|
36
|
+
count: { type: String, default: 'count' },
|
|
37
|
+
/** 徽标数位置偏移 */
|
|
38
|
+
offset: { type: Array as unknown as PropType<[number, number]>, default: () => [5, 20] },
|
|
39
|
+
/** 活动tab字体是否加粗 */
|
|
40
|
+
bold: { type: Boolean, default: true },
|
|
41
|
+
/** 当前活动tab item的样式 */
|
|
42
|
+
activeItemStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
43
|
+
/** 是否显示底部的滑块 */
|
|
44
|
+
showBar: { type: Boolean, default: true },
|
|
45
|
+
/** 底部滑块的自定义样式 */
|
|
46
|
+
barStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
47
|
+
/** 标签的宽度 */
|
|
48
|
+
itemWidth: { type: [String, Number] as PropType<number | string>, default: 'auto' }
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export type TabsProps = ExtractPropTypes<typeof TabsProps>;
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
<script setup lang="ts">
|
|
19
19
|
import { ref, computed, watch, onMounted, nextTick, getCurrentInstance } from 'vue';
|
|
20
20
|
import { $u } from '../..';
|
|
21
|
+
import { TabsProps } from './types';
|
|
21
22
|
|
|
22
23
|
defineOptions({ name: 'u-tabs' });
|
|
23
24
|
|
|
@@ -49,51 +50,12 @@ defineOptions({ name: 'u-tabs' });
|
|
|
49
50
|
* @example <u-tabs ref="tabs" :list="list" :is-scroll="false"></u-tabs>
|
|
50
51
|
*/
|
|
51
52
|
|
|
52
|
-
// props
|
|
53
|
-
const props = defineProps(
|
|
54
|
-
/** tabs是否可以左右拖动 */
|
|
55
|
-
isScroll: { type: Boolean, default: true },
|
|
56
|
-
/** 标签数组 */
|
|
57
|
-
list: { type: Array as () => Array<Record<string, any>>, default: () => [] },
|
|
58
|
-
/** 当前活动tab的索引 */
|
|
59
|
-
current: { type: [Number, String], default: 0 },
|
|
60
|
-
/** 导航栏的高度和行高 */
|
|
61
|
-
height: { type: [String, Number], default: 80 },
|
|
62
|
-
/** 字体大小 */
|
|
63
|
-
fontSize: { type: [String, Number], default: 30 },
|
|
64
|
-
/** 过渡动画时长, 单位s */
|
|
65
|
-
duration: { type: [String, Number], default: 0.5 },
|
|
66
|
-
/** 选中项的主题颜色 */
|
|
67
|
-
activeColor: { type: String, default: '#2979ff' },
|
|
68
|
-
/** 未选中项的颜色 */
|
|
69
|
-
inactiveColor: { type: String, default: '#303133' },
|
|
70
|
-
/** 菜单底部移动的bar的宽度,单位rpx */
|
|
71
|
-
barWidth: { type: [String, Number], default: 40 },
|
|
72
|
-
/** 移动bar的高度 */
|
|
73
|
-
barHeight: { type: [String, Number], default: 6 },
|
|
74
|
-
/** 单个tab的左右内边距之和,单位rpx */
|
|
75
|
-
gutter: { type: [String, Number], default: 30 },
|
|
76
|
-
/** 导航栏的背景颜色 */
|
|
77
|
-
bgColor: { type: String, default: '#ffffff' },
|
|
78
|
-
/** 读取传入的数组对象的属性(tab名称) */
|
|
79
|
-
name: { type: String, default: 'name' },
|
|
80
|
-
/** 读取传入的数组对象的属性(徽标数) */
|
|
81
|
-
count: { type: String, default: 'count' },
|
|
82
|
-
/** 徽标数位置偏移 */
|
|
83
|
-
offset: { type: Array, default: () => [5, 20] },
|
|
84
|
-
/** 活动tab字体是否加粗 */
|
|
85
|
-
bold: { type: Boolean, default: true },
|
|
86
|
-
/** 当前活动tab item的样式 */
|
|
87
|
-
activeItemStyle: { type: Object, default: () => ({}) },
|
|
88
|
-
/** 是否显示底部的滑块 */
|
|
89
|
-
showBar: { type: Boolean, default: true },
|
|
90
|
-
/** 底部滑块的自定义样式 */
|
|
91
|
-
barStyle: { type: Object, default: () => ({}) },
|
|
92
|
-
/** 标签的宽度 */
|
|
93
|
-
itemWidth: { type: [Number, String], default: 'auto' }
|
|
94
|
-
});
|
|
53
|
+
// props 定义
|
|
54
|
+
const props = defineProps(TabsProps);
|
|
95
55
|
|
|
96
|
-
|
|
56
|
+
/**
|
|
57
|
+
* emits 定义
|
|
58
|
+
*/
|
|
97
59
|
const emit = defineEmits(['change']);
|
|
98
60
|
const instance = getCurrentInstance();
|
|
99
61
|
// 滚动scroll-view的左边滚动距离
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { TabsSwiperAutoCenterMode, TabsSwiperListItem } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TabsSwiperProps 全屏选项卡 props 类型定义
|
|
6
|
+
* @description 全屏选项卡,支持滑块、渐变色、滚动居中等
|
|
7
|
+
*/
|
|
8
|
+
export const TabsSwiperProps = {
|
|
9
|
+
/** tabs是否可以左右拖动 */
|
|
10
|
+
isScroll: { type: Boolean, default: true },
|
|
11
|
+
/** 标签数组,元素为对象,如[{name: '推荐'}] */
|
|
12
|
+
list: { type: Array as PropType<Array<TabsSwiperListItem>>, default: () => [] },
|
|
13
|
+
/** 指定哪个tab为激活状态 */
|
|
14
|
+
current: { type: [Number, String] as PropType<number | string>, default: 0 },
|
|
15
|
+
/** 导航栏的高度,单位rpx */
|
|
16
|
+
height: { type: [Number, String] as PropType<number | string>, default: 80 },
|
|
17
|
+
/** tab文字大小,单位rpx */
|
|
18
|
+
fontSize: { type: [Number, String] as PropType<number | string>, default: 30 },
|
|
19
|
+
/** tabs组件外部swiper的宽度,单位rpx */
|
|
20
|
+
swiperWidth: { type: [String, Number] as PropType<number | string>, default: 750 },
|
|
21
|
+
/** 滑块和激活tab文字的颜色 */
|
|
22
|
+
activeColor: { type: String, default: '#2979ff' },
|
|
23
|
+
/** tabs文字颜色 */
|
|
24
|
+
inactiveColor: { type: String, default: '#303133' },
|
|
25
|
+
/** 滑块宽度,单位rpx */
|
|
26
|
+
barWidth: { type: [Number, String] as PropType<number | string>, default: 40 },
|
|
27
|
+
/** 滑块高度,单位rpx */
|
|
28
|
+
barHeight: { type: [Number, String] as PropType<number | string>, default: 6 },
|
|
29
|
+
/** 单个tab标签的左右内边距之和,单位rpx */
|
|
30
|
+
gutter: { type: [Number, String] as PropType<number | string>, default: 40 },
|
|
31
|
+
/** z-index 层级 */
|
|
32
|
+
zIndex: { type: [Number, String] as PropType<number | string>, default: 1 },
|
|
33
|
+
/** tabs导航栏的背景颜色 */
|
|
34
|
+
bgColor: { type: String, default: '#ffffff' },
|
|
35
|
+
/** 居中模式,window/组件宽度 */
|
|
36
|
+
autoCenterMode: { type: String as unknown as PropType<TabsSwiperAutoCenterMode>, default: 'window' },
|
|
37
|
+
/** 组件内部读取的list参数中的属性名(tab名称) */
|
|
38
|
+
name: { type: String, default: 'name' },
|
|
39
|
+
/** 组件内部读取的list参数中的属性名(badge徽标数) */
|
|
40
|
+
count: { type: String, default: 'count' },
|
|
41
|
+
/** 设置badge徽标数的位置偏移,格式为 [x, y],单位rpx */
|
|
42
|
+
offset: { type: Array as unknown as PropType<[number, number]>, default: () => [5, 20] },
|
|
43
|
+
/** 激活选项的字体是否加粗 */
|
|
44
|
+
bold: { type: Boolean, default: true },
|
|
45
|
+
/** 活动tabs item的样式,对象形式 */
|
|
46
|
+
activeItemStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
47
|
+
/** 是否显示底部的滑块 */
|
|
48
|
+
showBar: { type: Boolean, default: true },
|
|
49
|
+
/** 底部滑块的样式,对象形式 */
|
|
50
|
+
barStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export type TabsSwiperProps = ExtractPropTypes<typeof TabsSwiperProps>;
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { ref, computed, watch, nextTick, onMounted, getCurrentInstance } from 'vue';
|
|
17
17
|
import colorGradient from '../../libs/function/colorGradient';
|
|
18
|
+
import { TabsSwiperProps } from './types';
|
|
18
19
|
|
|
19
20
|
defineOptions({ name: 'u-tabs-swiper' });
|
|
20
21
|
|
|
@@ -45,56 +46,8 @@ defineOptions({ name: 'u-tabs-swiper' });
|
|
|
45
46
|
* @example <u-tabs-swiper ref="tabs" :list="list" :is-scroll="false"></u-tabs-swiper>
|
|
46
47
|
*/
|
|
47
48
|
|
|
48
|
-
// props
|
|
49
|
-
const props = defineProps(
|
|
50
|
-
/** tabs是否可以左右拖动 */
|
|
51
|
-
isScroll: { type: Boolean, default: true },
|
|
52
|
-
/** 标签数组 */
|
|
53
|
-
list: { type: Array as () => Array<Record<string, any>>, default: () => [] },
|
|
54
|
-
/** 当前活动tab的索引 */
|
|
55
|
-
current: { type: [Number, String], default: 0 },
|
|
56
|
-
/** 导航栏的高度和行高,单位rpx */
|
|
57
|
-
height: { type: [Number, String], default: 80 },
|
|
58
|
-
/** 字体大小,单位rpx */
|
|
59
|
-
fontSize: { type: [Number, String], default: 30 },
|
|
60
|
-
// 过渡动画时长, 单位s
|
|
61
|
-
// duration: {
|
|
62
|
-
// type: [Number, String],
|
|
63
|
-
// default: 0.5
|
|
64
|
-
// },
|
|
65
|
-
/** 外部swiper的宽度, 单位rpx */
|
|
66
|
-
swiperWidth: { type: [String, Number], default: 750 },
|
|
67
|
-
/** 选中项的主题颜色 */
|
|
68
|
-
activeColor: { type: String, default: '#2979ff' },
|
|
69
|
-
/** 未选中项的颜色 */
|
|
70
|
-
inactiveColor: { type: String, default: '#303133' },
|
|
71
|
-
/** 菜单底部移动的bar的宽度,单位rpx */
|
|
72
|
-
barWidth: { type: [Number, String], default: 40 },
|
|
73
|
-
/** 移动bar的高度 */
|
|
74
|
-
barHeight: { type: [Number, String], default: 6 },
|
|
75
|
-
/** 单个tab的左或右内边距(各占一半),单位rpx */
|
|
76
|
-
gutter: { type: [Number, String], default: 40 },
|
|
77
|
-
/** 如果是绝对定位,添加z-index值 */
|
|
78
|
-
zIndex: { type: [Number, String], default: 1 },
|
|
79
|
-
/** 导航栏的背景颜色 */
|
|
80
|
-
bgColor: { type: String, default: '#ffffff' },
|
|
81
|
-
/** 滚动至中心目标类型 */
|
|
82
|
-
autoCenterMode: { type: String, default: 'window' },
|
|
83
|
-
/** 读取传入的数组对象的属性(tab名称) */
|
|
84
|
-
name: { type: String, default: 'name' },
|
|
85
|
-
/** 读取传入的数组对象的属性(徽标数) */
|
|
86
|
-
count: { type: String, default: 'count' },
|
|
87
|
-
/** 徽标数位置偏移 */
|
|
88
|
-
offset: { type: Array, default: () => [5, 20] },
|
|
89
|
-
/** 活动tab字体是否加粗 */
|
|
90
|
-
bold: { type: Boolean, default: true },
|
|
91
|
-
/** 当前活动tab item的样式 */
|
|
92
|
-
activeItemStyle: { type: Object, default: () => ({}) },
|
|
93
|
-
/** 是否显示底部的滑块 */
|
|
94
|
-
showBar: { type: Boolean, default: true },
|
|
95
|
-
/** 底部滑块的自定义样式 */
|
|
96
|
-
barStyle: { type: Object, default: () => ({}) }
|
|
97
|
-
});
|
|
49
|
+
// props 定义
|
|
50
|
+
const props = defineProps(TabsSwiperProps);
|
|
98
51
|
|
|
99
52
|
const color = colorGradient;
|
|
100
53
|
const { windowWidth } = uni.getSystemInfoSync();
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue';
|
|
2
|
+
import type { Shape, TagMode, TagSize, ThemeType } from '../../types/global';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TagProps tag props 类型定义
|
|
6
|
+
* @description 标签组件,支持多种类型、尺寸、形状、可关闭等
|
|
7
|
+
*/
|
|
8
|
+
export const TagProps = {
|
|
9
|
+
/** 类型,primary、success、info、warning、error */
|
|
10
|
+
type: { type: String as PropType<ThemeType>, default: 'primary' },
|
|
11
|
+
/** 是否禁用 */
|
|
12
|
+
disabled: { type: [Boolean, String] as PropType<boolean | string>, default: false },
|
|
13
|
+
/** 尺寸,default/mini/medium */
|
|
14
|
+
size: { type: String as PropType<TagSize>, default: 'default' },
|
|
15
|
+
/** 形状,square为方形,circle为圆形 */
|
|
16
|
+
shape: { type: String as PropType<Shape>, default: 'square' },
|
|
17
|
+
/** 显示的文本内容 */
|
|
18
|
+
text: { type: [String, Number] as PropType<string | number>, default: '' },
|
|
19
|
+
/** 文字颜色 */
|
|
20
|
+
color: { type: String, default: '' },
|
|
21
|
+
/** 背景颜色 */
|
|
22
|
+
bgColor: { type: String, default: '' },
|
|
23
|
+
/** 边框颜色 */
|
|
24
|
+
borderColor: { type: String, default: '' },
|
|
25
|
+
/** 关闭按钮颜色 */
|
|
26
|
+
closeColor: { type: String, default: '' },
|
|
27
|
+
/** 索引值 */
|
|
28
|
+
index: { type: [String, Number] as PropType<string | number>, default: '' },
|
|
29
|
+
/** 模式,light/dark/plain等 */
|
|
30
|
+
mode: { type: String as PropType<TagMode>, default: 'light' },
|
|
31
|
+
/** 是否可关闭 */
|
|
32
|
+
closeable: { type: Boolean, default: false },
|
|
33
|
+
/** 是否显示 */
|
|
34
|
+
show: { type: Boolean, default: true }
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type TagProps = ExtractPropTypes<typeof TagProps>;
|