@ecolovo/uniapp-components 2.0.3 → 2.0.5
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/components/badge/badge.vue +22 -11
- package/components/badge/types.d.ts +6 -0
- package/components/badge/types.js +4 -0
- package/components/badge/types.ts +10 -0
- package/components/button/button.vue +77 -48
- package/components/button/types.d.ts +20 -0
- package/components/button/types.js +4 -0
- package/components/button/types.ts +24 -0
- package/components/checkbox/checkbox.scss +1 -1
- package/components/checkbox/checkbox.vue +2 -0
- package/components/checkbox/types.d.ts +10 -0
- package/components/checkbox/types.js +4 -0
- package/components/checkbox/types.ts +16 -0
- package/components/checkbox-group/checkbox-group.vue +2 -0
- package/components/checkbox-group/types.d.ts +10 -0
- package/components/checkbox-group/types.js +8 -0
- package/components/checkbox-group/types.ts +20 -0
- package/components/checkbox-group2/checkbox-group2.vue +2 -0
- package/components/data-list/data-list.vue +13 -7
- package/components/date-picker/date-picker.vue +2 -0
- package/components/date-picker/types.d.ts +12 -0
- package/components/date-picker/types.js +4 -0
- package/components/date-picker/types.ts +18 -0
- package/components/dialog/dialog-content.vue +61 -46
- package/components/dialog/dialog.vue +55 -29
- package/components/dialog/types.d.ts +20 -0
- package/components/dialog/types.js +4 -0
- package/components/dialog/types.ts +24 -0
- package/components/dropdown/dropdown.vue +2 -0
- package/components/dropdown/types.d.ts +10 -0
- package/components/dropdown/types.js +4 -0
- package/components/dropdown/types.ts +16 -0
- package/components/empty/empty.vue +37 -20
- package/components/empty/types.d.ts +12 -0
- package/components/empty/types.js +9 -0
- package/components/empty/types.ts +21 -0
- package/components/flex/flex.vue +2 -0
- package/components/flex/types.d.ts +12 -0
- package/components/flex/types.js +4 -0
- package/components/flex/types.ts +22 -0
- package/components/form/form.vue +2 -0
- package/components/form/types.d.ts +6 -0
- package/components/form/types.js +4 -0
- package/components/form/types.ts +10 -0
- package/components/form-item/form-item.scss +6 -0
- package/components/form-item/form-item.vue +9 -3
- package/components/form-item/types.d.ts +6 -0
- package/components/form-item/types.js +4 -0
- package/components/form-item/types.ts +12 -0
- package/components/image/image.vue +28 -21
- package/components/image/types.d.ts +18 -0
- package/components/image/types.js +4 -0
- package/components/image/types.ts +23 -0
- package/components/index.d.ts +2 -1
- package/components/index.js +2 -1
- package/components/index.ts +2 -1
- package/components/input/input.scss +9 -0
- package/components/input/input.vue +11 -4
- package/components/input/password-input.vue +3 -1
- package/components/input/types.d.ts +20 -0
- package/components/input/types.js +8 -0
- package/components/input/types.ts +31 -0
- package/components/list-page/list-page.vue +21 -24
- package/components/list-page/types.d.ts +6 -0
- package/components/list-page/types.js +4 -0
- package/components/list-page/types.ts +12 -0
- package/components/load-more/load-more.scss +1 -0
- package/components/load-more/load-more.vue +66 -6
- package/components/load-more/types.d.ts +6 -0
- package/components/load-more/types.js +4 -0
- package/components/load-more/types.ts +12 -0
- package/components/loading/loading.vue +2 -0
- package/components/loading/types.d.ts +6 -0
- package/components/loading/types.js +4 -0
- package/components/loading/types.ts +12 -0
- package/components/message-box/message-box.d.ts +14 -16
- package/components/message-box/message-box.ts +0 -2
- package/components/message-box/message-box.vue +18 -43
- package/components/message-box/types.d.ts +16 -0
- package/components/message-box/types.js +4 -0
- package/components/message-box/types.ts +22 -0
- package/components/number-dialog/number-dialog.vue +5 -3
- package/components/number-dialog/types.d.ts +18 -0
- package/components/number-dialog/types.js +4 -0
- package/components/number-dialog/types.ts +24 -0
- package/components/number-input/number-input.scss +1 -1
- package/components/number-input/number-input.vue +5 -3
- package/components/number-input/types.d.ts +20 -0
- package/components/number-input/types.js +4 -0
- package/components/number-input/types.ts +26 -0
- package/components/numpad/numpad.vue +2 -0
- package/components/numpad/types.d.ts +10 -0
- package/components/numpad/types.js +4 -0
- package/components/numpad/types.ts +14 -0
- package/components/page/page-body.scss +1 -1
- package/components/page/page-footer.vue +2 -3
- package/components/page/page-header.vue +19 -9
- package/components/page/page.vue +45 -14
- package/components/page/types.d.ts +16 -0
- package/components/page/types.js +8 -0
- package/components/page/types.ts +27 -0
- package/components/picker/picker-popup.vue +10 -6
- package/components/picker/picker.vue +8 -0
- package/components/picker/types.d.ts +14 -0
- package/components/picker/types.js +4 -0
- package/components/picker/types.ts +18 -0
- package/components/popover/popover-content.vue +10 -1
- package/components/popover/popover-mask.vue +5 -5
- package/components/popover/popover.vue +34 -29
- package/components/popover/types.d.ts +10 -0
- package/components/popover/types.js +4 -0
- package/components/popover/types.ts +16 -0
- package/components/popup/popup-content.vue +61 -43
- package/components/popup/popup.vue +34 -28
- package/components/popup/types.d.ts +20 -0
- package/components/popup/types.js +4 -0
- package/components/popup/types.ts +24 -0
- package/components/price/price.scss +7 -3
- package/components/price/price.vue +6 -0
- package/components/price/types.d.ts +10 -0
- package/components/price/types.js +4 -0
- package/components/price/types.ts +14 -0
- package/components/search/search.vue +2 -0
- package/components/search/types.d.ts +14 -0
- package/components/search/types.js +4 -0
- package/components/search/types.ts +18 -0
- package/components/searching/searching.scss +9 -9
- package/components/searching/searching.vue +2 -0
- package/components/searching/types.d.ts +8 -0
- package/components/searching/types.js +4 -0
- package/components/searching/types.ts +14 -0
- package/components/switch/switch.vue +5 -8
- package/components/switch/types.d.ts +8 -0
- package/components/switch/types.js +4 -0
- package/components/switch/types.ts +12 -0
- package/components/tab/tab.vue +2 -0
- package/components/tab/types.d.ts +8 -0
- package/components/tab/types.js +4 -0
- package/components/tab/types.ts +12 -0
- package/components/textarea/textarea.scss +10 -0
- package/components/textarea/textarea.vue +17 -9
- package/components/textarea/types.d.ts +12 -0
- package/components/textarea/types.js +4 -0
- package/components/textarea/types.ts +18 -0
- package/components/upload/composable.d.ts +24 -0
- package/components/upload/composable.js +173 -0
- package/components/upload/composable.ts +228 -0
- package/components/upload/media-upload.scss +12 -0
- package/components/upload/media-upload.vue +250 -0
- package/components/upload/types.d.ts +29 -0
- package/components/upload/types.js +4 -0
- package/components/upload/types.ts +38 -0
- package/composable/component-name.d.ts +8 -0
- package/composable/component-name.js +11 -4
- package/composable/component-name.ts +8 -0
- package/composable/dialog.d.ts +40 -0
- package/composable/dialog.js +96 -0
- package/composable/dialog.ts +113 -0
- package/composable/index.d.ts +5 -0
- package/composable/index.js +5 -0
- package/composable/index.ts +5 -0
- package/composable/message-box.d.ts +45 -28
- package/composable/message-box.js +68 -53
- package/composable/message-box.ts +101 -36
- package/composable/model.d.ts +8 -0
- package/composable/model.js +23 -0
- package/composable/model.ts +27 -0
- package/composable/page.d.ts +41 -0
- package/composable/page.js +25 -0
- package/composable/page.ts +34 -0
- package/configs/index.d.ts +24 -19
- package/configs/index.js +38 -35
- package/configs/index.ts +19 -0
- package/easyCom.d.ts +6 -6
- package/easyCom.js +19 -31
- package/easyCom.ts +4 -4
- package/globals.d.ts +93 -33
- package/globals.js +1 -0
- package/globals.ts +118 -0
- package/index.d.ts +3 -3
- package/index.js +2 -3
- package/index.ts +3 -2
- package/init.d.ts +11 -6
- package/init.js +84 -14
- package/init.ts +86 -1
- package/package.json +9 -9
- package/styles/var/component.scss +1 -0
- package/utils/date.d.ts +14 -19
- package/utils/date.js +77 -87
- package/utils/freezeDeep.js +7 -7
- package/utils/price.d.ts +15 -18
- package/utils/price.js +36 -37
- package/utils/upload.d.ts +1 -0
- package/utils/upload.js +8 -0
- package/utils/upload.ts +12 -0
- package/utils/windowInfo.d.ts +1 -9
- package/utils/windowInfo.js +10 -17
- package/utils/round.d.ts +0 -2
- package/utils/round.js +0 -13
- package/utils/round.ts +0 -14
|
@@ -4,67 +4,130 @@ import type { default as MessageBox } from '../components/message-box/message-bo
|
|
|
4
4
|
import type { default as Page } from '../components/page/page.vue';
|
|
5
5
|
import type { MessageBoxOptions } from '../components/message-box/message-box';
|
|
6
6
|
|
|
7
|
-
type MessageBoxShowCustomFunc = (
|
|
8
|
-
options: Omit<MessageBoxOptions, 'modelValue'>
|
|
9
|
-
) => Promise<void>;
|
|
7
|
+
type MessageBoxShowCustomFunc = (options: MessageBoxOptions) => Promise<void>;
|
|
10
8
|
type MessageBoxShowConfirmFunc = (
|
|
11
|
-
options:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
options:
|
|
10
|
+
| string
|
|
11
|
+
| Pick<
|
|
12
|
+
MessageBoxOptions & {
|
|
13
|
+
content: string;
|
|
14
|
+
confirm?: string;
|
|
15
|
+
cancel?: string;
|
|
16
|
+
},
|
|
17
|
+
'modal' | 'title' | 'content' | 'confirm' | 'cancel'
|
|
18
|
+
>
|
|
15
19
|
) => Promise<void>;
|
|
16
20
|
type MessageBoxShowMessageBoxFunc = (
|
|
17
|
-
options:
|
|
21
|
+
options:
|
|
22
|
+
| string
|
|
23
|
+
| Pick<
|
|
24
|
+
MessageBoxOptions & {
|
|
25
|
+
content: string;
|
|
26
|
+
confirm?: string;
|
|
27
|
+
cancel?: string;
|
|
28
|
+
},
|
|
29
|
+
'modal' | 'title' | 'content' | 'confirm' | 'cancel'
|
|
30
|
+
>
|
|
18
31
|
) => Promise<void>;
|
|
19
32
|
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
type UseMessageBoxReturn = {
|
|
34
|
+
/**
|
|
35
|
+
* 显示消息框,选项自定义
|
|
36
|
+
*
|
|
37
|
+
* @param options 消息框选项
|
|
38
|
+
*/
|
|
39
|
+
show: MessageBoxShowCustomFunc;
|
|
40
|
+
/**
|
|
41
|
+
* 显示确认框,仅部分选项自定义
|
|
42
|
+
*
|
|
43
|
+
* @param options 确认框选项
|
|
44
|
+
*/
|
|
45
|
+
showConfirm: MessageBoxShowConfirmFunc;
|
|
46
|
+
/**
|
|
47
|
+
* 显示消息框,仅部分选项自定义
|
|
48
|
+
*
|
|
49
|
+
* @param options 消息框选项
|
|
50
|
+
*/
|
|
51
|
+
showMessageBox: MessageBoxShowMessageBoxFunc;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const useMessageBoxComponent = (
|
|
55
|
+
messageBoxRef?: Ref<InstanceType<typeof MessageBox> | undefined>
|
|
22
56
|
) => {
|
|
57
|
+
const _messageBoxRef = ref(messageBoxRef);
|
|
58
|
+
|
|
23
59
|
const show: MessageBoxShowCustomFunc = async (options) => {
|
|
24
|
-
await
|
|
60
|
+
await _messageBoxRef.value?.show(options);
|
|
25
61
|
};
|
|
26
62
|
|
|
27
|
-
const showConfirm: MessageBoxShowConfirmFunc =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
63
|
+
const showConfirm: MessageBoxShowConfirmFunc = (options) => {
|
|
64
|
+
if (typeof options === 'string') {
|
|
65
|
+
options = { content: options };
|
|
66
|
+
}
|
|
67
|
+
const {
|
|
68
|
+
title = '提示',
|
|
69
|
+
content,
|
|
70
|
+
modal = true,
|
|
71
|
+
confirm = '确认',
|
|
72
|
+
cancel = '取消',
|
|
73
|
+
} = options;
|
|
74
|
+
|
|
75
|
+
return show({
|
|
76
|
+
title,
|
|
77
|
+
content,
|
|
78
|
+
modal,
|
|
79
|
+
confirm,
|
|
80
|
+
cancel,
|
|
32
81
|
showClose: false,
|
|
33
|
-
cancel: '取消',
|
|
34
|
-
confirm: '确认',
|
|
35
82
|
});
|
|
36
83
|
};
|
|
37
84
|
|
|
38
|
-
const showMessageBox: MessageBoxShowMessageBoxFunc =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
85
|
+
const showMessageBox: MessageBoxShowMessageBoxFunc = (options) => {
|
|
86
|
+
if (typeof options === 'string') {
|
|
87
|
+
options = { content: options };
|
|
88
|
+
}
|
|
89
|
+
const {
|
|
90
|
+
title = '提示',
|
|
91
|
+
content,
|
|
92
|
+
modal = false,
|
|
93
|
+
confirm: _confirm,
|
|
94
|
+
cancel: _cancel,
|
|
95
|
+
} = options;
|
|
96
|
+
|
|
97
|
+
// 仅显示一个按钮,要么是确认按钮,要么是取消按钮
|
|
98
|
+
const isCancel = _confirm === undefined && _cancel !== undefined;
|
|
99
|
+
const confirm = isCancel ? false : _confirm || '我知道了';
|
|
100
|
+
const cancel = !isCancel ? false : _cancel || '我知道了';
|
|
101
|
+
|
|
102
|
+
return show({
|
|
103
|
+
title,
|
|
104
|
+
content,
|
|
105
|
+
modal,
|
|
106
|
+
confirm,
|
|
107
|
+
cancel,
|
|
43
108
|
showClose: false,
|
|
44
|
-
cancel: false,
|
|
45
|
-
confirm: '我知道了',
|
|
46
109
|
});
|
|
47
110
|
};
|
|
48
111
|
|
|
49
112
|
return {
|
|
113
|
+
messageBoxRef: _messageBoxRef,
|
|
50
114
|
show,
|
|
51
115
|
showConfirm,
|
|
52
116
|
showMessageBox,
|
|
53
117
|
};
|
|
54
118
|
};
|
|
55
119
|
|
|
56
|
-
|
|
120
|
+
/**
|
|
121
|
+
* 页面公用消息框,仅单一个实例,使用时需注意
|
|
122
|
+
*
|
|
123
|
+
* @param isInPage 是否在 Page 中使用,当为 `true` 时,须将返回的 `pageRef` 绑定到 `Page` 组件上
|
|
124
|
+
*/
|
|
125
|
+
function useMessageBox(isInPage: true): UseMessageBoxReturn & {
|
|
126
|
+
/** page 组件实例 */
|
|
57
127
|
pageRef: Ref<InstanceType<typeof Page>>;
|
|
58
|
-
show: MessageBoxShowCustomFunc;
|
|
59
|
-
showConfirm: MessageBoxShowConfirmFunc;
|
|
60
|
-
showMessageBox: MessageBoxShowMessageBoxFunc;
|
|
61
128
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
showConfirm: MessageBoxShowConfirmFunc;
|
|
65
|
-
showMessageBox: MessageBoxShowMessageBoxFunc;
|
|
66
|
-
};
|
|
67
|
-
export function usePageMessageBox(isInPage: boolean = false) {
|
|
129
|
+
function useMessageBox(isInPage?: false): UseMessageBoxReturn;
|
|
130
|
+
function useMessageBox(isInPage: boolean = false) {
|
|
68
131
|
if (!isInPage) {
|
|
69
132
|
const pageMessageBoxRef = inject<Ref<InstanceType<typeof MessageBox>>>(
|
|
70
133
|
'ecolovo/page/messageBoxRef'
|
|
@@ -72,7 +135,7 @@ export function usePageMessageBox(isInPage: boolean = false) {
|
|
|
72
135
|
if (!pageMessageBoxRef) {
|
|
73
136
|
throw new Error('该组件必须在 Page 中使用');
|
|
74
137
|
}
|
|
75
|
-
return
|
|
138
|
+
return useMessageBoxComponent(pageMessageBoxRef);
|
|
76
139
|
}
|
|
77
140
|
|
|
78
141
|
const pageRef = ref<InstanceType<typeof Page>>();
|
|
@@ -96,3 +159,5 @@ export function usePageMessageBox(isInPage: boolean = false) {
|
|
|
96
159
|
showMessageBox,
|
|
97
160
|
};
|
|
98
161
|
}
|
|
162
|
+
|
|
163
|
+
export { useMessageBox, useMessageBoxComponent };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { customRef } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* 组件绑定值,未绑定时使用内部值
|
|
4
|
+
*
|
|
5
|
+
* @param modelValue 组件绑定值,默认值必须是 `undefined`
|
|
6
|
+
*/
|
|
7
|
+
function useModelValue(modelValue) {
|
|
8
|
+
let innerValue = modelValue.value;
|
|
9
|
+
return customRef((track, trigger) => {
|
|
10
|
+
return {
|
|
11
|
+
get() {
|
|
12
|
+
track();
|
|
13
|
+
return modelValue.value ?? innerValue;
|
|
14
|
+
},
|
|
15
|
+
set(newValue) {
|
|
16
|
+
modelValue.value = newValue;
|
|
17
|
+
innerValue = newValue;
|
|
18
|
+
trigger();
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export { useModelValue };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { customRef } from 'vue';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 组件绑定值,未绑定时使用内部值
|
|
6
|
+
*
|
|
7
|
+
* @param modelValue 组件绑定值,默认值必须是 `undefined`
|
|
8
|
+
*/
|
|
9
|
+
function useModelValue<T>(modelValue: undefined extends T ? Ref<T> : never) {
|
|
10
|
+
let innerValue: T = modelValue.value;
|
|
11
|
+
|
|
12
|
+
return customRef<T>((track, trigger) => {
|
|
13
|
+
return {
|
|
14
|
+
get() {
|
|
15
|
+
track();
|
|
16
|
+
return modelValue.value ?? innerValue;
|
|
17
|
+
},
|
|
18
|
+
set(newValue) {
|
|
19
|
+
modelValue.value = newValue;
|
|
20
|
+
innerValue = newValue;
|
|
21
|
+
trigger();
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { useModelValue };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** 当前页面路由 */
|
|
2
|
+
declare const useCurrentPageRoute: () => {
|
|
3
|
+
/** 当前页面栈 */
|
|
4
|
+
currentPages: import("vue").Ref<{
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
onInit?: ((query?: AnyObject) => void) | undefined;
|
|
7
|
+
onLoad?: ((query?: AnyObject) => void) | undefined;
|
|
8
|
+
onShow?: (() => void) | undefined;
|
|
9
|
+
onPageShow?: (() => void) | undefined;
|
|
10
|
+
onReady?: (() => void) | undefined;
|
|
11
|
+
onHide?: (() => void) | undefined;
|
|
12
|
+
onPageHide?: (() => void) | undefined;
|
|
13
|
+
onUnload?: (() => void) | undefined;
|
|
14
|
+
onPullDownRefresh?: (() => void) | undefined;
|
|
15
|
+
onReachBottom?: (() => void) | undefined;
|
|
16
|
+
onTitleClick?: (() => void) | undefined;
|
|
17
|
+
onLiveMount?: ((options: Page.LiveMountOptions) => Page.LiveMountContent | Promise<Page.LiveMountContent>) | undefined;
|
|
18
|
+
onUploadDouyinVideo?: ((options: Page.UploadDouyinVideoOptions) => Page.UploadDouyinVideoContent | Promise<Page.UploadDouyinVideoContent>) | undefined;
|
|
19
|
+
onShareAppMessage?: ((options: Page.ShareAppMessageOption) => Page.CustomShareContent | Promise<Omit<Page.CustomShareContent, "promise">>) | undefined;
|
|
20
|
+
onShareTimeline?: ((options: Page.OnShareTimelineOptions) => Page.ShareTimelineContent) | undefined;
|
|
21
|
+
onAddToFavorites?: ((options: Page.AddToFavoritesOption) => Page.CustomFavoritesContent) | undefined;
|
|
22
|
+
onPageScroll?: ((options: Page.PageScrollOption) => void) | undefined;
|
|
23
|
+
onResize?: ((options: Page.ResizeOption) => void) | undefined;
|
|
24
|
+
onTabItemTap?: ((options: Page.TabItemTapOption) => void) | undefined;
|
|
25
|
+
onNavigationBarButtonTap?: ((options: Page.NavigationBarButtonTapOption) => void) | undefined;
|
|
26
|
+
onBackPress?: ((options: Page.BackPressOption) => any) | undefined;
|
|
27
|
+
onNavigationBarSearchInputChanged?: ((event: Page.NavigationBarSearchInputEvent) => void) | undefined;
|
|
28
|
+
onNavigationBarSearchInputConfirmed?: ((event: Page.NavigationBarSearchInputEvent) => void) | undefined;
|
|
29
|
+
onNavigationBarSearchInputClicked?: (() => void) | undefined;
|
|
30
|
+
onShareChat?: ((options: Page.OnShareChatOptions) => Page.ShareChatContent) | undefined;
|
|
31
|
+
onCopyUrl?: ((options: Page.OnCopyUrlOptions) => Page.CopyUrlContent) | undefined;
|
|
32
|
+
route?: string | undefined;
|
|
33
|
+
$getAppWebview?: (() => PlusWebviewWebviewObject) | undefined;
|
|
34
|
+
$vm?: any;
|
|
35
|
+
}[]>;
|
|
36
|
+
/** 当前页面路由 */
|
|
37
|
+
currentPageRoute: import("vue").ComputedRef<string>;
|
|
38
|
+
/** 当前页面是否是 tabbar 页面,需配置 tabbarList */
|
|
39
|
+
isTabbarPage: import("vue").ComputedRef<boolean>;
|
|
40
|
+
};
|
|
41
|
+
export { useCurrentPageRoute };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { computed, onMounted, ref } from 'vue';
|
|
2
|
+
import { tabbarList } from '../configs';
|
|
3
|
+
/** 当前页面路由 */
|
|
4
|
+
const useCurrentPageRoute = () => {
|
|
5
|
+
/** 当前页面栈 */
|
|
6
|
+
const currentPages = ref([]);
|
|
7
|
+
/** 当前页面路由 */
|
|
8
|
+
const currentPageRoute = computed(() => {
|
|
9
|
+
return currentPages.value.slice(-1)[0]?.route || '';
|
|
10
|
+
});
|
|
11
|
+
/** 当前页面是否是 tabbar 页面,需配置 tabbarList */
|
|
12
|
+
const isTabbarPage = computed(() => tabbarList.findIndex((item) => item.pagePath === currentPageRoute.value) >= 0);
|
|
13
|
+
onMounted(() => {
|
|
14
|
+
currentPages.value = getCurrentPages() || [];
|
|
15
|
+
});
|
|
16
|
+
return {
|
|
17
|
+
/** 当前页面栈 */
|
|
18
|
+
currentPages,
|
|
19
|
+
/** 当前页面路由 */
|
|
20
|
+
currentPageRoute,
|
|
21
|
+
/** 当前页面是否是 tabbar 页面,需配置 tabbarList */
|
|
22
|
+
isTabbarPage,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export { useCurrentPageRoute };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { computed, onMounted, ref } from 'vue';
|
|
2
|
+
import { tabbarList } from '../configs';
|
|
3
|
+
|
|
4
|
+
/** 当前页面路由 */
|
|
5
|
+
const useCurrentPageRoute = () => {
|
|
6
|
+
/** 当前页面栈 */
|
|
7
|
+
const currentPages = ref<ReturnType<typeof getCurrentPages>>([]);
|
|
8
|
+
/** 当前页面路由 */
|
|
9
|
+
const currentPageRoute = computed(() => {
|
|
10
|
+
return currentPages.value.slice(-1)[0]?.route || '';
|
|
11
|
+
});
|
|
12
|
+
/** 当前页面是否是 tabbar 页面,需配置 tabbarList */
|
|
13
|
+
const isTabbarPage = computed(
|
|
14
|
+
() =>
|
|
15
|
+
tabbarList.findIndex(
|
|
16
|
+
(item) => item.pagePath === currentPageRoute.value
|
|
17
|
+
) >= 0
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
onMounted(() => {
|
|
21
|
+
currentPages.value = getCurrentPages() || [];
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
/** 当前页面栈 */
|
|
26
|
+
currentPages,
|
|
27
|
+
/** 当前页面路由 */
|
|
28
|
+
currentPageRoute,
|
|
29
|
+
/** 当前页面是否是 tabbar 页面,需配置 tabbarList */
|
|
30
|
+
isTabbarPage,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { useCurrentPageRoute };
|
package/configs/index.d.ts
CHANGED
|
@@ -1,44 +1,49 @@
|
|
|
1
|
+
import type { TabBarItem } from '@ecolovo/utils';
|
|
1
2
|
/** 组件前缀 */
|
|
2
3
|
declare let componentPrefix: string;
|
|
3
4
|
/** 首页路径 */
|
|
4
5
|
declare let homePath: string;
|
|
6
|
+
/** tabbar 列表 */
|
|
7
|
+
declare let tabbarList: TabBarItem[];
|
|
5
8
|
/**
|
|
6
9
|
* 设置组件前缀
|
|
10
|
+
*
|
|
7
11
|
* @param prefix 组件前缀
|
|
8
12
|
*/
|
|
9
13
|
declare function setComponentPrefix(prefix?: string): void;
|
|
10
14
|
/**
|
|
11
15
|
* 设置首页路径
|
|
16
|
+
*
|
|
12
17
|
* @param path 首页路径
|
|
13
18
|
*/
|
|
14
19
|
declare function setHomePath(path?: string): void;
|
|
20
|
+
/**
|
|
21
|
+
* 设置 tabbar 列表
|
|
22
|
+
*
|
|
23
|
+
* @param list tabbar 列表
|
|
24
|
+
*/
|
|
25
|
+
declare function setTabbarList(list?: TabBarItem[]): void;
|
|
15
26
|
interface IconInfo {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
/** 字体文件名 */
|
|
28
|
+
fontFamily: string;
|
|
29
|
+
/** 图标前缀 */
|
|
30
|
+
prefix: string;
|
|
31
|
+
/** 图标名称 */
|
|
32
|
+
name: string;
|
|
22
33
|
}
|
|
23
34
|
/** iconfont 图标 map */
|
|
24
35
|
declare const iconMap: Map<string, IconInfo>;
|
|
25
36
|
export interface IconFontJson {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
37
|
+
font_family: string;
|
|
38
|
+
css_prefix_text: string;
|
|
39
|
+
glyphs: {
|
|
40
|
+
font_class: string;
|
|
41
|
+
}[];
|
|
31
42
|
}
|
|
32
43
|
/**
|
|
33
44
|
* 添加一组图标,传入 iconfont.json 文件内容
|
|
45
|
+
*
|
|
34
46
|
* @param iconJson iconfont.json 文件内容
|
|
35
47
|
*/
|
|
36
48
|
declare function addIcons(iconJson: IconFontJson): void;
|
|
37
|
-
export {
|
|
38
|
-
componentPrefix,
|
|
39
|
-
homePath,
|
|
40
|
-
setComponentPrefix,
|
|
41
|
-
setHomePath,
|
|
42
|
-
iconMap,
|
|
43
|
-
addIcons,
|
|
44
|
-
};
|
|
49
|
+
export { componentPrefix, homePath, tabbarList, setComponentPrefix, setHomePath, setTabbarList, iconMap, addIcons, };
|
package/configs/index.js
CHANGED
|
@@ -3,68 +3,71 @@ import defaultIconfonts from '../resources/iconfont/uniapp_ui_icon/iconfont.json
|
|
|
3
3
|
let componentPrefix = 'app';
|
|
4
4
|
/** 首页路径 */
|
|
5
5
|
let homePath = '/pages/index/index';
|
|
6
|
+
/** tabbar 列表 */
|
|
7
|
+
let tabbarList = [];
|
|
6
8
|
/**
|
|
7
9
|
* 设置组件前缀
|
|
10
|
+
*
|
|
8
11
|
* @param prefix 组件前缀
|
|
9
12
|
*/
|
|
10
13
|
function setComponentPrefix(prefix = 'app') {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
componentPrefix = prefix;
|
|
14
|
+
if (!prefix)
|
|
15
|
+
throw new Error('组件前缀不能为空');
|
|
16
|
+
componentPrefix = prefix;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* 设置首页路径
|
|
20
|
+
*
|
|
18
21
|
* @param path 首页路径
|
|
19
22
|
*/
|
|
20
23
|
function setHomePath(path = '/pages/index/index') {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
if (!path)
|
|
25
|
+
throw new Error('app 首页不能为空');
|
|
26
|
+
homePath = path;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* 设置 tabbar 列表
|
|
30
|
+
*
|
|
31
|
+
* @param list tabbar 列表
|
|
32
|
+
*/
|
|
33
|
+
function setTabbarList(list = []) {
|
|
34
|
+
if (!list)
|
|
35
|
+
throw new Error('tabbar 列表不能为空');
|
|
36
|
+
tabbarList = list;
|
|
25
37
|
}
|
|
26
38
|
/** iconfont 图标 map */
|
|
27
39
|
const iconMap = new Map();
|
|
28
40
|
/**
|
|
29
41
|
* 添加单个图标
|
|
42
|
+
*
|
|
30
43
|
* @param fontFamily 字体文件名
|
|
31
44
|
* @param prefix 图标前缀
|
|
32
45
|
* @param name 图标名称
|
|
33
46
|
*/
|
|
34
47
|
function addIconToMap(fontFamily, prefix, name) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
fontFamily,
|
|
45
|
-
prefix,
|
|
46
|
-
name,
|
|
47
|
-
});
|
|
48
|
+
if (iconMap.has(name)) {
|
|
49
|
+
// eslint-disable-next-line no-console
|
|
50
|
+
console.warn(`图标库 "${fontFamily}" 中的图标 "${name}" 在图标库 "${iconMap.get(name).fontFamily}" 中已存在,新的图标将会覆盖已存在的同名图标`);
|
|
51
|
+
}
|
|
52
|
+
iconMap.set(name, {
|
|
53
|
+
fontFamily,
|
|
54
|
+
prefix,
|
|
55
|
+
name,
|
|
56
|
+
});
|
|
48
57
|
}
|
|
49
58
|
/**
|
|
50
59
|
* 添加一组图标,传入 iconfont.json 文件内容
|
|
60
|
+
*
|
|
51
61
|
* @param iconJson iconfont.json 文件内容
|
|
52
62
|
*/
|
|
53
63
|
function addIcons(iconJson) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
const fontFamily = iconJson.font_family;
|
|
65
|
+
const prefix = iconJson.css_prefix_text;
|
|
66
|
+
const glyphs = iconJson.glyphs;
|
|
67
|
+
glyphs.forEach((glyph) => {
|
|
68
|
+
addIconToMap(fontFamily, prefix, glyph.font_class);
|
|
69
|
+
});
|
|
60
70
|
}
|
|
61
71
|
// 添加内部图标库
|
|
62
72
|
addIcons(defaultIconfonts);
|
|
63
|
-
export {
|
|
64
|
-
componentPrefix,
|
|
65
|
-
homePath,
|
|
66
|
-
setComponentPrefix,
|
|
67
|
-
setHomePath,
|
|
68
|
-
iconMap,
|
|
69
|
-
addIcons,
|
|
70
|
-
};
|
|
73
|
+
export { componentPrefix, homePath, tabbarList, setComponentPrefix, setHomePath, setTabbarList, iconMap, addIcons, };
|
package/configs/index.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import defaultIconfonts from '../resources/iconfont/uniapp_ui_icon/iconfont.json';
|
|
2
|
+
import type { TabBarItem } from '@ecolovo/utils';
|
|
2
3
|
|
|
3
4
|
/** 组件前缀 */
|
|
4
5
|
let componentPrefix = 'app';
|
|
5
6
|
/** 首页路径 */
|
|
6
7
|
let homePath = '/pages/index/index';
|
|
8
|
+
/** tabbar 列表 */
|
|
9
|
+
let tabbarList: TabBarItem[] = [];
|
|
7
10
|
|
|
8
11
|
/**
|
|
9
12
|
* 设置组件前缀
|
|
13
|
+
*
|
|
10
14
|
* @param prefix 组件前缀
|
|
11
15
|
*/
|
|
12
16
|
function setComponentPrefix(prefix: string = 'app') {
|
|
@@ -16,6 +20,7 @@ function setComponentPrefix(prefix: string = 'app') {
|
|
|
16
20
|
|
|
17
21
|
/**
|
|
18
22
|
* 设置首页路径
|
|
23
|
+
*
|
|
19
24
|
* @param path 首页路径
|
|
20
25
|
*/
|
|
21
26
|
function setHomePath(path: string = '/pages/index/index') {
|
|
@@ -23,6 +28,16 @@ function setHomePath(path: string = '/pages/index/index') {
|
|
|
23
28
|
homePath = path;
|
|
24
29
|
}
|
|
25
30
|
|
|
31
|
+
/**
|
|
32
|
+
* 设置 tabbar 列表
|
|
33
|
+
*
|
|
34
|
+
* @param list tabbar 列表
|
|
35
|
+
*/
|
|
36
|
+
function setTabbarList(list: TabBarItem[] = []) {
|
|
37
|
+
if (!list) throw new Error('tabbar 列表不能为空');
|
|
38
|
+
tabbarList = list;
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
interface IconInfo {
|
|
27
42
|
/** 字体文件名 */
|
|
28
43
|
fontFamily: string;
|
|
@@ -37,6 +52,7 @@ const iconMap: Map<string, IconInfo> = new Map();
|
|
|
37
52
|
|
|
38
53
|
/**
|
|
39
54
|
* 添加单个图标
|
|
55
|
+
*
|
|
40
56
|
* @param fontFamily 字体文件名
|
|
41
57
|
* @param prefix 图标前缀
|
|
42
58
|
* @param name 图标名称
|
|
@@ -65,6 +81,7 @@ export interface IconFontJson {
|
|
|
65
81
|
|
|
66
82
|
/**
|
|
67
83
|
* 添加一组图标,传入 iconfont.json 文件内容
|
|
84
|
+
*
|
|
68
85
|
* @param iconJson iconfont.json 文件内容
|
|
69
86
|
*/
|
|
70
87
|
function addIcons(iconJson: IconFontJson) {
|
|
@@ -82,8 +99,10 @@ addIcons(defaultIconfonts);
|
|
|
82
99
|
export {
|
|
83
100
|
componentPrefix,
|
|
84
101
|
homePath,
|
|
102
|
+
tabbarList,
|
|
85
103
|
setComponentPrefix,
|
|
86
104
|
setHomePath,
|
|
105
|
+
setTabbarList,
|
|
87
106
|
iconMap,
|
|
88
107
|
addIcons,
|
|
89
108
|
};
|
package/easyCom.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare function componentEasyCom(componentPrefix?: string): {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
easycom: {
|
|
3
|
+
autoscan: boolean;
|
|
4
|
+
custom: {
|
|
5
|
+
[x: string]: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
8
|
};
|
|
9
9
|
export default componentEasyCom;
|
package/easyCom.js
CHANGED
|
@@ -1,35 +1,23 @@
|
|
|
1
1
|
function componentEasyCom(componentPrefix = 'app') {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
'@ecolovo/uniapp-components/components/popover/popover-mask.vue',
|
|
22
|
-
[`^${componentPrefix}-popup-content`]:
|
|
23
|
-
'@ecolovo/uniapp-components/components/popup/popup-content.vue',
|
|
24
|
-
[`^${componentPrefix}-media-uploader`]:
|
|
25
|
-
'@ecolovo/uniapp-components/components/uploader/media-uploader.vue',
|
|
26
|
-
[`^${componentPrefix}-file-uploader`]:
|
|
27
|
-
'@ecolovo/uniapp-components/components/uploader/file-uploader.vue',
|
|
28
|
-
[`^${componentPrefix}-(.*)`]:
|
|
29
|
-
'@ecolovo/uniapp-components/components/$1/$1.vue',
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
2
|
+
return {
|
|
3
|
+
easycom: {
|
|
4
|
+
autoscan: true,
|
|
5
|
+
custom: {
|
|
6
|
+
[`^${componentPrefix}-date-picker-view`]: '@ecolovo/uniapp-components/components/date-picker/date-picker-view.vue',
|
|
7
|
+
[`^${componentPrefix}-dialog-content`]: '@ecolovo/uniapp-components/components/dialog/dialog-content.vue',
|
|
8
|
+
[`^${componentPrefix}-loading-animation(.*)`]: '@ecolovo/uniapp-components/components/loading/animations/loading-animation$1.vue',
|
|
9
|
+
[`^${componentPrefix}-page-(.*)`]: '@ecolovo/uniapp-components/components/page/page-$1.vue',
|
|
10
|
+
[`^${componentPrefix}-password-input`]: '@ecolovo/uniapp-components/components/input/password-input.vue',
|
|
11
|
+
[`^${componentPrefix}-picker-popup`]: '@ecolovo/uniapp-components/components/picker/picker-popup.vue',
|
|
12
|
+
[`^${componentPrefix}-popover-content`]: '@ecolovo/uniapp-components/components/popover/popover-content.vue',
|
|
13
|
+
[`^${componentPrefix}-popover-mask`]: '@ecolovo/uniapp-components/components/popover/popover-mask.vue',
|
|
14
|
+
[`^${componentPrefix}-popup-content`]: '@ecolovo/uniapp-components/components/popup/popup-content.vue',
|
|
15
|
+
[`^${componentPrefix}-media-upload`]: '@ecolovo/uniapp-components/components/upload/media-upload.vue',
|
|
16
|
+
[`^${componentPrefix}-file-upload`]: '@ecolovo/uniapp-components/components/upload/file-upload.vue',
|
|
17
|
+
[`^${componentPrefix}-(.*)`]: '@ecolovo/uniapp-components/components/$1/$1.vue',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
33
21
|
}
|
|
34
22
|
// 导出 easycom 配置
|
|
35
23
|
export default componentEasyCom;
|
package/easyCom.ts
CHANGED
|
@@ -21,10 +21,10 @@ function componentEasyCom(componentPrefix = 'app') {
|
|
|
21
21
|
'@ecolovo/uniapp-components/components/popover/popover-mask.vue',
|
|
22
22
|
[`^${componentPrefix}-popup-content`]:
|
|
23
23
|
'@ecolovo/uniapp-components/components/popup/popup-content.vue',
|
|
24
|
-
[`^${componentPrefix}-media-
|
|
25
|
-
'@ecolovo/uniapp-components/components/
|
|
26
|
-
[`^${componentPrefix}-file-
|
|
27
|
-
'@ecolovo/uniapp-components/components/
|
|
24
|
+
[`^${componentPrefix}-media-upload`]:
|
|
25
|
+
'@ecolovo/uniapp-components/components/upload/media-upload.vue',
|
|
26
|
+
[`^${componentPrefix}-file-upload`]:
|
|
27
|
+
'@ecolovo/uniapp-components/components/upload/file-upload.vue',
|
|
28
28
|
[`^${componentPrefix}-(.*)`]:
|
|
29
29
|
'@ecolovo/uniapp-components/components/$1/$1.vue',
|
|
30
30
|
},
|