uview-pro 0.5.3 → 0.5.4
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 +29 -8
- package/components/u-action-sheet/types.ts +1 -1
- package/components/u-action-sheet/u-action-sheet.vue +5 -5
- package/components/u-action-sheet-item/types.ts +1 -1
- package/components/u-alert-tips/types.ts +1 -1
- package/components/u-alert-tips/u-alert-tips.vue +1 -1
- package/components/u-avatar/types.ts +1 -1
- package/components/u-avatar-cropper/types.ts +1 -1
- package/components/u-back-top/types.ts +1 -1
- package/components/u-badge/types.ts +1 -1
- package/components/u-button/u-button.vue +4 -3
- package/components/u-calendar/types.ts +1 -1
- package/components/u-calendar/u-calendar.vue +1 -1
- package/components/u-car-keyboard/types.ts +1 -1
- package/components/u-card/types.ts +1 -1
- package/components/u-cell-group/types.ts +1 -1
- package/components/u-cell-item/types.ts +1 -1
- package/components/u-checkbox/types.ts +1 -1
- package/components/u-checkbox-group/types.ts +1 -1
- package/components/u-circle-progress/types.ts +1 -1
- package/components/u-circle-progress/u-circle-progress.vue +1 -1
- package/components/u-dropdown-item/u-dropdown-item.vue +1 -1
- package/components/u-empty/u-empty.vue +1 -1
- package/components/u-fab/u-fab.vue +1 -1
- package/components/u-field/types.ts +9 -9
- package/components/u-field/u-field.vue +8 -7
- package/components/u-form-item/u-form-item.vue +1 -1
- package/components/u-image/types.ts +1 -1
- package/components/u-index-anchor/u-index-anchor.vue +5 -5
- package/components/u-input/u-input.vue +8 -7
- package/components/u-loading/types.ts +2 -0
- package/components/u-loading/u-loading.vue +3 -2
- package/components/u-loadmore/types.ts +2 -0
- package/components/u-loadmore/u-loadmore.vue +11 -8
- package/components/u-message-input/u-message-input.vue +4 -3
- package/components/u-navbar/u-navbar.vue +4 -4
- package/components/u-notice-bar/u-notice-bar.vue +1 -1
- package/components/u-pagination/u-pagination.vue +1 -1
- package/components/u-popup/u-popup.vue +2 -2
- package/components/u-rate/u-rate.vue +4 -4
- package/components/u-safe-bottom/u-safe-bottom.vue +4 -1
- package/components/u-search/u-search.vue +1 -1
- package/components/u-section/types.ts +1 -1
- package/components/u-switch/u-switch.vue +1 -1
- package/components/u-tabbar/types.ts +4 -1
- package/components/u-tabbar/u-tabbar.vue +4 -4
- package/components/u-text/u-text.vue +17 -16
- package/components/u-textarea/types.ts +1 -1
- package/components/u-textarea/u-textarea.vue +5 -4
- package/components/u-toast/service.ts +21 -0
- package/components/u-toast/types.ts +7 -2
- package/components/u-toast/u-toast.vue +82 -19
- package/components/u-upload/types.ts +2 -2
- package/components/u-upload/u-upload.vue +1 -1
- package/index.ts +1 -1
- package/libs/function/clipboard.ts +5 -5
- package/libs/function/color.ts +3 -1
- package/libs/function/styleUtils.ts +5 -5
- package/libs/function/test.ts +6 -6
- package/libs/function/type2icon.ts +3 -4
- package/libs/hooks/index.ts +1 -0
- package/libs/hooks/useCompRelation.ts +4 -4
- package/libs/hooks/useRect.ts +9 -4
- package/libs/hooks/useToast.ts +90 -0
- package/libs/index.ts +1 -1
- package/libs/request/index.ts +4 -4
- package/package.json +1 -1
- package/types/global.d.ts +1 -1
|
@@ -38,7 +38,10 @@ const style = computed(() => {
|
|
|
38
38
|
let result: CSSProperties = {};
|
|
39
39
|
// #ifdef APP-NVUE || MP-TOUTIAO
|
|
40
40
|
// nvue下,高度使用js计算填充
|
|
41
|
-
|
|
41
|
+
const safeAreaInsets = $u.sys()?.safeAreaInsets;
|
|
42
|
+
if (safeAreaInsets?.bottom) {
|
|
43
|
+
result.height = $u.addUnit(safeAreaInsets.bottom, 'px');
|
|
44
|
+
}
|
|
42
45
|
// #endif
|
|
43
46
|
return result;
|
|
44
47
|
});
|
|
@@ -32,7 +32,10 @@ export const TabbarProps = {
|
|
|
32
32
|
/** tabbar配置项数组 */
|
|
33
33
|
list: { type: Array as PropType<TabbarItem[]>, default: () => [] },
|
|
34
34
|
/** 切换前回调,返回true或Promise */
|
|
35
|
-
beforeSwitch: {
|
|
35
|
+
beforeSwitch: {
|
|
36
|
+
type: Function as unknown as PropType<((index: number) => boolean | Promise<any>) | null>,
|
|
37
|
+
default: null
|
|
38
|
+
},
|
|
36
39
|
/** 是否显示顶部横线 */
|
|
37
40
|
borderTop: { type: Boolean, default: true },
|
|
38
41
|
/** 是否隐藏原生tabbar */
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
:is-dot="item.isDot"
|
|
45
45
|
v-if="item.count || item.isDot"
|
|
46
46
|
:offset="[
|
|
47
|
-
getBadgeOffsetTop(item.count, item.isDot),
|
|
48
|
-
getOffsetRight(item.count, item.isDot)
|
|
47
|
+
getBadgeOffsetTop(item.count || 0, item.isDot || false),
|
|
48
|
+
getOffsetRight(item.count || 0, item.isDot || false)
|
|
49
49
|
]"
|
|
50
50
|
></u-badge>
|
|
51
51
|
</view>
|
|
@@ -146,7 +146,7 @@ onMounted(() => {
|
|
|
146
146
|
/**
|
|
147
147
|
* 计算当前item的icon路径
|
|
148
148
|
*/
|
|
149
|
-
const elIconPath = computed<(index: number) => string>(() => {
|
|
149
|
+
const elIconPath = computed<(index: number) => string | undefined>(() => {
|
|
150
150
|
return (index: number) => {
|
|
151
151
|
// 历遍u-tabbar的每一项item时,判断是否传入了pagePath参数,如果传入了
|
|
152
152
|
// 和data中的pageUrl参数对比,如果相等,即可判断当前的item对应当前的tabbar页面,设置高亮图标
|
|
@@ -247,7 +247,7 @@ function switchTab(index: number) {
|
|
|
247
247
|
emit('change', index);
|
|
248
248
|
// 如果有配置pagePath属性,使用uni.switchTab进行跳转
|
|
249
249
|
if (props.list[index]?.pagePath) {
|
|
250
|
-
uni.switchTab({ url: props.list[index].pagePath });
|
|
250
|
+
uni.switchTab({ url: props.list[index].pagePath as string });
|
|
251
251
|
} else {
|
|
252
252
|
// 如果配置了papgePath属性,将不会双向绑定v-model传入的value值
|
|
253
253
|
// 因为这个模式下,不再需要v-model绑定的value值了,而是通过getCurrentPages()适配
|
|
@@ -29,24 +29,25 @@
|
|
|
29
29
|
<slot>{{ displayValue }}</slot>
|
|
30
30
|
</u-link>
|
|
31
31
|
<template v-else-if="props.openType">
|
|
32
|
+
<!-- prettier-ignore -->
|
|
32
33
|
<button
|
|
33
34
|
class="u-reset-button u-text__value u-text__button"
|
|
34
35
|
:class="props.type && `u-text__value--${props.type}`"
|
|
35
36
|
:style="textValueStyle"
|
|
36
|
-
:openType="props.openType"
|
|
37
|
-
|
|
38
|
-
@contact="onContact"
|
|
39
|
-
@getphonenumber="onGetPhoneNumber"
|
|
40
|
-
@error="onError"
|
|
41
|
-
@launchapp="onLaunchApp"
|
|
42
|
-
@opensetting="onOpenSetting"
|
|
43
|
-
:lang="props.lang"
|
|
37
|
+
:openType="(props.openType as any)"
|
|
38
|
+
:lang="(props.lang as any)"
|
|
44
39
|
:session-from="props.sessionFrom"
|
|
45
40
|
:send-message-title="props.sendMessageTitle"
|
|
46
41
|
:send-message-path="props.sendMessagePath"
|
|
47
42
|
:send-message-img="props.sendMessageImg"
|
|
48
43
|
:show-message-card="props.showMessageCard"
|
|
49
44
|
:app-parameter="props.appParameter"
|
|
45
|
+
@getuserinfo="onGetUserInfo"
|
|
46
|
+
@contact="onContact"
|
|
47
|
+
@getphonenumber="onGetPhoneNumber"
|
|
48
|
+
@error="onError"
|
|
49
|
+
@launchapp="onLaunchApp"
|
|
50
|
+
@opensetting="onOpenSetting"
|
|
50
51
|
>
|
|
51
52
|
<slot>{{ displayValue }}</slot>
|
|
52
53
|
</button>
|
|
@@ -161,14 +162,14 @@ const displayValue = computed(() => {
|
|
|
161
162
|
if (!$u.test.string(val)) return val;
|
|
162
163
|
if (format === 'encrypt') {
|
|
163
164
|
// 如果format为encrypt,则将姓名进行星号加密处理
|
|
164
|
-
return $u.formatName(val);
|
|
165
|
+
return $u.formatName(String(val));
|
|
165
166
|
}
|
|
166
167
|
break;
|
|
167
168
|
case 'date':
|
|
168
169
|
// 进行格式化,判断用户传入的format参数为正则,或者函数,如果没有传入format,则使用默认的格式化处理
|
|
169
170
|
if ($u.test.string(format) && !$u.test.empty(format)) {
|
|
170
171
|
// 如果format非正则,非函数,则使用默认的时间格式化方法进行操作
|
|
171
|
-
return $u.timeFormat(val, format);
|
|
172
|
+
return $u.timeFormat(val, format as string);
|
|
172
173
|
}
|
|
173
174
|
// 如果没有设置format,则设置为默认的时间格式化形式
|
|
174
175
|
return $u.timeFormat(val, 'yyyy-mm-dd');
|
|
@@ -240,22 +241,22 @@ function onClick() {
|
|
|
240
241
|
}
|
|
241
242
|
emit('click');
|
|
242
243
|
}
|
|
243
|
-
function onGetUserInfo(event) {
|
|
244
|
+
function onGetUserInfo(event: any) {
|
|
244
245
|
emit('getuserinfo', event.detail);
|
|
245
246
|
}
|
|
246
|
-
function onContact(event) {
|
|
247
|
+
function onContact(event: any) {
|
|
247
248
|
emit('contact', event.detail);
|
|
248
249
|
}
|
|
249
|
-
function onGetPhoneNumber(event) {
|
|
250
|
+
function onGetPhoneNumber(event: any) {
|
|
250
251
|
emit('getphonenumber', event.detail);
|
|
251
252
|
}
|
|
252
|
-
function onError(event) {
|
|
253
|
+
function onError(event: any) {
|
|
253
254
|
emit('error', event.detail);
|
|
254
255
|
}
|
|
255
|
-
function onLaunchApp(event) {
|
|
256
|
+
function onLaunchApp(event: any) {
|
|
256
257
|
emit('launchapp', event.detail);
|
|
257
258
|
}
|
|
258
|
-
function onOpenSetting(event) {
|
|
259
|
+
function onOpenSetting(event: any) {
|
|
259
260
|
emit('opensetting', event.detail);
|
|
260
261
|
}
|
|
261
262
|
</script>
|
|
@@ -75,7 +75,7 @@ export const TextareaProps = {
|
|
|
75
75
|
// 边框类型,surround-四周边框,bottom-底部边框
|
|
76
76
|
border: { type: [String, Boolean] as PropType<TextareaBorder | boolean>, default: textarea.border },
|
|
77
77
|
// 用于处理或者过滤输入框内容的方法
|
|
78
|
-
formatter: { type: Function as PropType<((val: any) => any) | null>, default: textarea.formatter },
|
|
78
|
+
formatter: { type: Function as unknown as PropType<((val: any) => any) | null>, default: textarea.formatter },
|
|
79
79
|
// 是否忽略组件内对文本合成系统事件的处理
|
|
80
80
|
ignoreCompositionEvent: { type: Boolean as PropType<boolean>, default: true },
|
|
81
81
|
/** 是否可清空(默认true) */
|
|
@@ -10,11 +10,12 @@
|
|
|
10
10
|
]"
|
|
11
11
|
:style="$u.toStyle(textareaStyle, customStyle)"
|
|
12
12
|
>
|
|
13
|
+
<!-- prettier-ignore -->
|
|
13
14
|
<textarea
|
|
14
15
|
class="u-textarea__field"
|
|
15
16
|
:value="innerValue"
|
|
16
17
|
:style="getStyle"
|
|
17
|
-
:placeholder="props.placeholder"
|
|
18
|
+
:placeholder="String(props.placeholder)"
|
|
18
19
|
:placeholder-style="$u.toStyle(props.placeholderStyle)"
|
|
19
20
|
:placeholder-class="props.placeholderClass"
|
|
20
21
|
:disabled="props.disabled"
|
|
@@ -22,15 +23,15 @@
|
|
|
22
23
|
:autoHeight="props.autoHeight"
|
|
23
24
|
:fixed="props.fixed"
|
|
24
25
|
:cursorSpacing="props.cursorSpacing"
|
|
25
|
-
:cursor="props.cursor"
|
|
26
|
+
:cursor="Number(props.cursor)"
|
|
26
27
|
:showConfirmBar="props.showConfirmBar"
|
|
27
28
|
:selectionStart="props.selectionStart"
|
|
28
29
|
:selectionEnd="props.selectionEnd"
|
|
29
30
|
:adjustPosition="props.adjustPosition"
|
|
30
31
|
:disableDefaultPadding="props.disableDefaultPadding"
|
|
31
32
|
:holdKeyboard="props.holdKeyboard"
|
|
32
|
-
:maxlength="props.maxlength"
|
|
33
|
-
:confirmType="props.confirmType"
|
|
33
|
+
:maxlength="Number(props.maxlength)"
|
|
34
|
+
:confirmType="(props.confirmType as any)"
|
|
34
35
|
:ignoreCompositionEvent="props.ignoreCompositionEvent"
|
|
35
36
|
@focus="onFocus"
|
|
36
37
|
@blur="onBlur"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* u-toast 函数式调用事件名(全平台)
|
|
3
|
+
* @description
|
|
4
|
+
* - useToast() 通过 uni.$emit 派发事件
|
|
5
|
+
* - <u-toast /> 通过 uni.$on 监听事件并转调自身 show/hide
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { ToastProps } from './types';
|
|
9
|
+
|
|
10
|
+
// 普通(页面级)toast 事件
|
|
11
|
+
export const U_TOAST_EVENT_SHOW = 'uview-pro:u-toast:show';
|
|
12
|
+
export const U_TOAST_EVENT_HIDE = 'uview-pro:u-toast:hide';
|
|
13
|
+
|
|
14
|
+
// 全局(App 根部)toast 事件,供 useToast() 使用
|
|
15
|
+
export const U_TOAST_GLOBAL_EVENT_SHOW = 'uview-pro:u-toast:global:show';
|
|
16
|
+
export const U_TOAST_GLOBAL_EVENT_HIDE = 'uview-pro:u-toast:global:hide';
|
|
17
|
+
|
|
18
|
+
export type ToastPayload = Partial<ToastProps> & {
|
|
19
|
+
/** 文案(兼容 toast.show('xxx')) */
|
|
20
|
+
title?: string;
|
|
21
|
+
};
|
|
@@ -20,7 +20,7 @@ export const ToastProps = {
|
|
|
20
20
|
/** 显示位置,center/top/bottom */
|
|
21
21
|
position: { type: String as PropType<ToastPosition>, default: 'center' },
|
|
22
22
|
/** 关闭时的回调函数 */
|
|
23
|
-
callback: { type: Function as PropType<(() => void) | null>, default: null },
|
|
23
|
+
callback: { type: Function as unknown as PropType<(() => void) | null>, default: null },
|
|
24
24
|
/** 是否返回上一页 */
|
|
25
25
|
back: { type: Boolean, default: false },
|
|
26
26
|
/** 是否为tab页面跳转 */
|
|
@@ -28,7 +28,11 @@ export const ToastProps = {
|
|
|
28
28
|
/** 跳转的url */
|
|
29
29
|
url: { type: String, default: '' },
|
|
30
30
|
/** 跳转参数对象 */
|
|
31
|
-
params: { type: Object as PropType<Record<string, any>>, default: () => ({}) }
|
|
31
|
+
params: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
|
|
32
|
+
/** 是否作为全局根部 toast(通常放在 App.vue 中,给 useToast() 使用) */
|
|
33
|
+
global: { type: Boolean, default: false },
|
|
34
|
+
/** 是否为loading “常驻” */
|
|
35
|
+
loading: { type: Boolean, default: false }
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
export type ToastProps = ExtractPropTypes<typeof ToastProps>;
|
|
@@ -36,4 +40,5 @@ export type ToastProps = ExtractPropTypes<typeof ToastProps>;
|
|
|
36
40
|
export type ToastExpose = {
|
|
37
41
|
show: (options: Record<string, any>) => void;
|
|
38
42
|
hide: () => void;
|
|
43
|
+
close: () => void;
|
|
39
44
|
};
|
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
<u-mask :z-index="uZIndex" :show="isShow" custom-style="background-color:transparent;">
|
|
3
|
+
<view
|
|
4
|
+
class="u-toast"
|
|
5
|
+
:class="[
|
|
6
|
+
isShow ? 'u-show' : '',
|
|
7
|
+
'u-type-' + tmpConfig.type,
|
|
8
|
+
'u-position-' + tmpConfig.position,
|
|
9
|
+
customClass
|
|
10
|
+
]"
|
|
11
|
+
:style="$u.toStyle({ zIndex: uZIndex }, customStyle)"
|
|
12
|
+
>
|
|
13
|
+
<view class="u-icon-wrap">
|
|
14
|
+
<!-- loading 类型走独立的加载动画组件 -->
|
|
15
|
+
<u-loading
|
|
16
|
+
v-if="tmpConfig.loading"
|
|
17
|
+
mode="circle"
|
|
18
|
+
custom-style="margin-right: 16rpx;"
|
|
19
|
+
:color="($u.color as any)[tmpConfig.type]"
|
|
20
|
+
></u-loading>
|
|
21
|
+
<!-- 其它类型仍然使用图标 -->
|
|
22
|
+
<u-icon
|
|
23
|
+
v-else-if="tmpConfig.icon && iconName"
|
|
24
|
+
custom-class="u-toast_icon"
|
|
25
|
+
custom-style="margin-right: 10rpx;"
|
|
26
|
+
:name="iconName"
|
|
27
|
+
:size="40"
|
|
28
|
+
:color="tmpConfig.type"
|
|
29
|
+
></u-icon>
|
|
30
|
+
</view>
|
|
31
|
+
<text class="u-text">{{ tmpConfig.title }}</text>
|
|
15
32
|
</view>
|
|
16
|
-
|
|
17
|
-
</view>
|
|
33
|
+
</u-mask>
|
|
18
34
|
</template>
|
|
19
35
|
|
|
20
36
|
<script lang="ts">
|
|
@@ -31,10 +47,17 @@ export default {
|
|
|
31
47
|
</script>
|
|
32
48
|
|
|
33
49
|
<script setup lang="ts">
|
|
34
|
-
import { ref, computed } from 'vue';
|
|
50
|
+
import { ref, computed, onMounted, onBeforeUnmount } from 'vue';
|
|
35
51
|
import { $u } from '../..';
|
|
36
52
|
import type { ToastExpose } from './types';
|
|
37
53
|
import { ToastProps } from './types';
|
|
54
|
+
import {
|
|
55
|
+
U_TOAST_EVENT_HIDE,
|
|
56
|
+
U_TOAST_EVENT_SHOW,
|
|
57
|
+
U_TOAST_GLOBAL_EVENT_HIDE,
|
|
58
|
+
U_TOAST_GLOBAL_EVENT_SHOW,
|
|
59
|
+
type ToastPayload
|
|
60
|
+
} from './service';
|
|
38
61
|
|
|
39
62
|
/**
|
|
40
63
|
* toast 消息提示
|
|
@@ -63,6 +86,7 @@ const config = computed(() => {
|
|
|
63
86
|
isTab: props.isTab, // 是否跳转tab页面
|
|
64
87
|
url: props.url, // toast消失后是否跳转页面,有则跳转,优先级高于back参数
|
|
65
88
|
params: props.params, // URL跳转的参数,对象
|
|
89
|
+
loading: props.loading,
|
|
66
90
|
title: '' // 显示文本
|
|
67
91
|
};
|
|
68
92
|
});
|
|
@@ -154,9 +178,44 @@ function timeEnd() {
|
|
|
154
178
|
}
|
|
155
179
|
}
|
|
156
180
|
|
|
181
|
+
/**
|
|
182
|
+
* @description
|
|
183
|
+
* 函数式调用支持:
|
|
184
|
+
* - useToast() 内部通过 uni.$emit 派发「全局」事件,仅由 App 根部的 <u-toast global /> 承接
|
|
185
|
+
* - 普通页面级 <u-toast /> 监听「页面级」事件(当前版本暂未开放对应函数式 API,仅支持 ref 调用)
|
|
186
|
+
* - 不影响原有 ref.show()/ref.hide() 使用方式
|
|
187
|
+
*/
|
|
188
|
+
function onServiceShow(payload: ToastPayload) {
|
|
189
|
+
show(payload || {});
|
|
190
|
+
}
|
|
191
|
+
function onServiceHide() {
|
|
192
|
+
hide();
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 是否为 App 根部的“全局 toast”
|
|
196
|
+
const isGlobal = computed(() => props.global);
|
|
197
|
+
|
|
198
|
+
const showEvent = computed(() => (isGlobal.value ? U_TOAST_GLOBAL_EVENT_SHOW : U_TOAST_EVENT_SHOW));
|
|
199
|
+
const hideEvent = computed(() => (isGlobal.value ? U_TOAST_GLOBAL_EVENT_HIDE : U_TOAST_EVENT_HIDE));
|
|
200
|
+
|
|
201
|
+
onMounted(() => {
|
|
202
|
+
if (isGlobal.value) {
|
|
203
|
+
uni?.$on && uni.$on(showEvent.value, onServiceShow);
|
|
204
|
+
uni?.$on && uni.$on(hideEvent.value, onServiceHide);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
onBeforeUnmount(() => {
|
|
209
|
+
if (isGlobal.value) {
|
|
210
|
+
uni?.$off && uni.$off(showEvent.value, onServiceShow);
|
|
211
|
+
uni?.$off && uni.$off(hideEvent.value, onServiceHide);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
|
|
157
215
|
defineExpose<ToastExpose>({
|
|
158
216
|
show,
|
|
159
|
-
hide
|
|
217
|
+
hide,
|
|
218
|
+
close: hide
|
|
160
219
|
});
|
|
161
220
|
</script>
|
|
162
221
|
|
|
@@ -177,7 +236,7 @@ defineExpose<ToastExpose>({
|
|
|
177
236
|
font-size: 28rpx;
|
|
178
237
|
opacity: 0;
|
|
179
238
|
pointer-events: none;
|
|
180
|
-
padding:
|
|
239
|
+
padding: 30rpx 40rpx;
|
|
181
240
|
}
|
|
182
241
|
|
|
183
242
|
.u-toast.u-show {
|
|
@@ -190,8 +249,12 @@ defineExpose<ToastExpose>({
|
|
|
190
249
|
/* #endif */
|
|
191
250
|
}
|
|
192
251
|
|
|
252
|
+
.u-text {
|
|
253
|
+
word-break: break-all;
|
|
254
|
+
}
|
|
255
|
+
|
|
193
256
|
:deep(.u-toast_icon) {
|
|
194
|
-
margin-right:
|
|
257
|
+
margin-right: 10rpx;
|
|
195
258
|
@include vue-flex;
|
|
196
259
|
align-items: center;
|
|
197
260
|
line-height: normal;
|
|
@@ -70,12 +70,12 @@ export const UploadProps = {
|
|
|
70
70
|
showTips: { type: Boolean, default: true },
|
|
71
71
|
/** 上传前钩子,返回true或Promise */
|
|
72
72
|
beforeUpload: {
|
|
73
|
-
type: Function as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>,
|
|
73
|
+
type: Function as unknown as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>,
|
|
74
74
|
default: null
|
|
75
75
|
},
|
|
76
76
|
/** 删除前钩子,返回true或Promise */
|
|
77
77
|
beforeRemove: {
|
|
78
|
-
type: Function as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>,
|
|
78
|
+
type: Function as unknown as PropType<((index: number, files: any[]) => boolean | Promise<any>) | null>,
|
|
79
79
|
default: null
|
|
80
80
|
},
|
|
81
81
|
/** 如果上传后的返回值为json字符串,是否转为json格式 */
|
package/index.ts
CHANGED
|
@@ -76,7 +76,7 @@ const install = (app: any, options?: UViewProOptions): void => {
|
|
|
76
76
|
// 设置调试模式
|
|
77
77
|
logger
|
|
78
78
|
.setDebugMode(options?.log?.debug ?? false)
|
|
79
|
-
.setPrefix(options?.log?.prefix)
|
|
79
|
+
.setPrefix(options?.log?.prefix || '')
|
|
80
80
|
.setShowCallerInfo(options?.log?.showCallerInfo ?? true);
|
|
81
81
|
} else {
|
|
82
82
|
// 默认初始化系统主题
|
|
@@ -6,8 +6,8 @@ function H5Copy(text: string, config: TClipboardOptions) {
|
|
|
6
6
|
icon: 'none'
|
|
7
7
|
});
|
|
8
8
|
}
|
|
9
|
-
config.success(result);
|
|
10
|
-
config.complete(result);
|
|
9
|
+
config.success?.(result);
|
|
10
|
+
config.complete?.(result);
|
|
11
11
|
};
|
|
12
12
|
const fail = (err: string) => {
|
|
13
13
|
if (config.showToast) {
|
|
@@ -16,8 +16,8 @@ function H5Copy(text: string, config: TClipboardOptions) {
|
|
|
16
16
|
icon: 'none'
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
config.fail(err);
|
|
20
|
-
config.complete(err);
|
|
19
|
+
config.fail?.(err);
|
|
20
|
+
config.complete?.(err);
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
const textarea = document.createElement('textarea');
|
|
@@ -40,7 +40,7 @@ function H5Copy(text: string, config: TClipboardOptions) {
|
|
|
40
40
|
}
|
|
41
41
|
} catch (err) {
|
|
42
42
|
// console.error('【Clipboard Error】:', err);
|
|
43
|
-
fail(err);
|
|
43
|
+
fail(String(err));
|
|
44
44
|
} finally {
|
|
45
45
|
document.body.removeChild(textarea);
|
|
46
46
|
}
|
package/libs/function/color.ts
CHANGED
|
@@ -20,7 +20,9 @@ export function getColor(name: ColorType): string {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export function setColor(theme: Partial<ThemeColor> | undefined) {
|
|
23
|
-
|
|
23
|
+
if (theme) {
|
|
24
|
+
configProvider.setThemeColor(theme);
|
|
25
|
+
}
|
|
24
26
|
}
|
|
25
27
|
|
|
26
28
|
export default color;
|
|
@@ -25,7 +25,7 @@ function cssStrToObj(str: string): object {
|
|
|
25
25
|
const value = values.join(':');
|
|
26
26
|
if (prop && value) {
|
|
27
27
|
const camelProp = prop.replace(/-([a-z])/g, (match, letter) => letter.toUpperCase());
|
|
28
|
-
result[camelProp] = value;
|
|
28
|
+
(result as Record<string, string>)[camelProp] = value;
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
return result;
|
|
@@ -53,16 +53,16 @@ function cssObjToStr(obj: object): string {
|
|
|
53
53
|
* 合并多个 CSS 输入(对象或字符串),返回一个 CSS 对象
|
|
54
54
|
*/
|
|
55
55
|
export function mergeStyles(...args: (object | string)[]): CSSProperties {
|
|
56
|
-
const result = {}
|
|
56
|
+
const result = {} as Record<string, any>;
|
|
57
57
|
for (let i = 0; i < args.length; i++) {
|
|
58
58
|
const arg = args[i];
|
|
59
|
-
if (!isValidValue(arg)) return;
|
|
59
|
+
if (!isValidValue(arg)) return result as CSSProperties;
|
|
60
60
|
if (typeof arg === 'string') {
|
|
61
61
|
Object.assign(result, cssStrToObj(arg));
|
|
62
62
|
} else if (test.object(arg)) {
|
|
63
|
-
const cleanedObj = {};
|
|
63
|
+
const cleanedObj: Record<string, any> = {};
|
|
64
64
|
Object.keys(arg).forEach(key => {
|
|
65
|
-
const value = arg[key];
|
|
65
|
+
const value = (arg as Record<string, any>)[key];
|
|
66
66
|
if (isValidValue(value)) {
|
|
67
67
|
// 有效
|
|
68
68
|
cleanedObj[key] = value;
|
package/libs/function/test.ts
CHANGED
|
@@ -210,7 +210,7 @@ function code(value: string, len: number = 6): boolean {
|
|
|
210
210
|
* 是否函数方法
|
|
211
211
|
* @param {Object} value
|
|
212
212
|
*/
|
|
213
|
-
function func(value) {
|
|
213
|
+
function func(value: any) {
|
|
214
214
|
return typeof value === 'function';
|
|
215
215
|
}
|
|
216
216
|
|
|
@@ -218,14 +218,14 @@ function func(value) {
|
|
|
218
218
|
* 是否promise对象
|
|
219
219
|
* @param {Object} value
|
|
220
220
|
*/
|
|
221
|
-
function promise(value) {
|
|
221
|
+
function promise(value: any) {
|
|
222
222
|
return object(value) && func(value.then) && func(value.catch);
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
/** 是否图片格式
|
|
226
226
|
* @param {Object} value
|
|
227
227
|
*/
|
|
228
|
-
function image(value) {
|
|
228
|
+
function image(value: any) {
|
|
229
229
|
const newValue = value.split('?')[0];
|
|
230
230
|
const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i;
|
|
231
231
|
return IMAGE_REGEXP.test(newValue);
|
|
@@ -235,7 +235,7 @@ function image(value) {
|
|
|
235
235
|
* 是否视频格式
|
|
236
236
|
* @param {Object} value
|
|
237
237
|
*/
|
|
238
|
-
function video(value) {
|
|
238
|
+
function video(value: any) {
|
|
239
239
|
const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i;
|
|
240
240
|
return VIDEO_REGEXP.test(value);
|
|
241
241
|
}
|
|
@@ -245,14 +245,14 @@ function video(value) {
|
|
|
245
245
|
* @param {Object}
|
|
246
246
|
* @return {Boolean}
|
|
247
247
|
*/
|
|
248
|
-
function regExp(o) {
|
|
248
|
+
function regExp(o: any) {
|
|
249
249
|
return o && Object.prototype.toString.call(o) === '[object RegExp]';
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
253
|
* 验证字符串
|
|
254
254
|
*/
|
|
255
|
-
function string(value) {
|
|
255
|
+
function string(value: any) {
|
|
256
256
|
return typeof value === 'string';
|
|
257
257
|
}
|
|
258
258
|
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
+
import type { ThemeType } from '../../types/global';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* 根据主题type值,获取对应的图标
|
|
3
5
|
* @param type 主题名称, primary|info|error|warning|success,默认success
|
|
4
6
|
* @param fill 是否使用fill填充实体的图标,默认false
|
|
5
7
|
* @returns 图标名称字符串
|
|
6
8
|
*/
|
|
7
|
-
function type2icon(
|
|
8
|
-
type: 'primary' | 'info' | 'error' | 'warning' | 'success' = 'success',
|
|
9
|
-
fill: boolean = false
|
|
10
|
-
): string {
|
|
9
|
+
function type2icon(type: ThemeType = 'success', fill: boolean = false): string {
|
|
11
10
|
// 如果非预置值,默认为success
|
|
12
11
|
if (!['primary', 'info', 'error', 'warning', 'success'].includes(type)) type = 'success';
|
|
13
12
|
let iconName = '';
|
package/libs/hooks/index.ts
CHANGED
|
@@ -199,13 +199,13 @@ export function useParent(componentName?: string) {
|
|
|
199
199
|
};
|
|
200
200
|
|
|
201
201
|
if (instance.proxy) {
|
|
202
|
-
instance.proxy[PARENT_CONTEXT_SYMBOL] = parentContext;
|
|
202
|
+
(instance.proxy as any)[PARENT_CONTEXT_SYMBOL] = parentContext;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
onUnmounted(() => {
|
|
206
206
|
childrenMap.forEach((_, childId) => parentContext.removeChild(childId));
|
|
207
207
|
if (instance.proxy) {
|
|
208
|
-
delete instance.proxy[PARENT_CONTEXT_SYMBOL];
|
|
208
|
+
delete (instance.proxy as any)[PARENT_CONTEXT_SYMBOL];
|
|
209
209
|
}
|
|
210
210
|
logger.log(`Parent ${name} unmounted and cleaned up`);
|
|
211
211
|
});
|
|
@@ -279,7 +279,7 @@ export function useChildren(componentName?: string, parentName?: string) {
|
|
|
279
279
|
|
|
280
280
|
let current = instance.parent;
|
|
281
281
|
while (current) {
|
|
282
|
-
const context = current.proxy?.[PARENT_CONTEXT_SYMBOL];
|
|
282
|
+
const context = (current.proxy as any)?.[PARENT_CONTEXT_SYMBOL];
|
|
283
283
|
if (context) {
|
|
284
284
|
if (!context.getInstance) {
|
|
285
285
|
context.getInstance = () => current;
|
|
@@ -384,7 +384,7 @@ export function hasParent(parentName?: string): boolean {
|
|
|
384
384
|
|
|
385
385
|
let current = instance.parent;
|
|
386
386
|
while (current) {
|
|
387
|
-
if (current.proxy?.[PARENT_CONTEXT_SYMBOL]) return true;
|
|
387
|
+
if ((current.proxy as any)?.[PARENT_CONTEXT_SYMBOL]) return true;
|
|
388
388
|
current = current.parent;
|
|
389
389
|
}
|
|
390
390
|
return false;
|
package/libs/hooks/useRect.ts
CHANGED
|
@@ -6,11 +6,11 @@ import { getCurrentInstance, nextTick, ref } from 'vue';
|
|
|
6
6
|
* @param all 是否获取所有匹配元素
|
|
7
7
|
* @returns rect 响应式的节点信息,refresh 主动刷新方法
|
|
8
8
|
*/
|
|
9
|
-
export function useRect(selector: string = null, all = false) {
|
|
9
|
+
export function useRect(selector: string | null = null, all = false) {
|
|
10
10
|
const rect = ref<any>(all ? [] : null);
|
|
11
11
|
const instance = getCurrentInstance();
|
|
12
12
|
|
|
13
|
-
async function getRect(realSelector: string = null, delay = 0): Promise<any> {
|
|
13
|
+
async function getRect(realSelector: string | null = null, delay = 0): Promise<any> {
|
|
14
14
|
realSelector = realSelector || selector;
|
|
15
15
|
if (!realSelector) return rect.value;
|
|
16
16
|
await nextTick();
|
|
@@ -18,7 +18,7 @@ export function useRect(selector: string = null, all = false) {
|
|
|
18
18
|
setTimeout(() => {
|
|
19
19
|
uni.createSelectorQuery()
|
|
20
20
|
.in(instance?.proxy)
|
|
21
|
-
[all ? 'selectAll' : 'select'](realSelector)
|
|
21
|
+
[all ? 'selectAll' : 'select'](realSelector as string)
|
|
22
22
|
.boundingClientRect((res: any) => {
|
|
23
23
|
rect.value = res;
|
|
24
24
|
resolve(res);
|
|
@@ -28,8 +28,13 @@ export function useRect(selector: string = null, all = false) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
function refresh(selector?: string | null, delay?: number): Promise<any> {
|
|
32
|
+
return getRect(selector, delay);
|
|
33
|
+
}
|
|
34
|
+
|
|
31
35
|
return {
|
|
32
36
|
rect,
|
|
33
|
-
getRect
|
|
37
|
+
getRect,
|
|
38
|
+
refresh
|
|
34
39
|
};
|
|
35
40
|
}
|