uview-pro 0.0.15 → 0.0.17

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 CHANGED
@@ -1,16 +1,29 @@
1
+ ## 0.0.17(2025-09-02)
2
+
3
+ ### ♻️ Code Refactoring | 代码重构
4
+
5
+ - 瀑布流组件示例代码重构为 Vue3 ([93949ad](https://github.com/anyup/uView-Pro/commit/93949ad8ae2a36c6130f87340c222ab9ec69d21f))
6
+
7
+ ### ✨ Features | 新功能
8
+
9
+ - 新增组件 u-loading-popup,一个可以配置的加载提示弹窗 ([6245df9](https://github.com/anyup/uView-Pro/commit/6245df951034b06225ab36d3f18cae8e7ab4b329))
10
+ - 新增 Loading 加载弹窗组件的示例页面 ([1bce868](https://github.com/anyup/uView-Pro/commit/1bce86810863012c5a73104ca0a85ebacb4aa92a))
11
+
12
+ ### 🐛 Bug Fixes | Bug 修复
13
+
14
+ - 修复瀑布流组件 u-waterfll,暴露 celar/remove/modify 方法 ([240e023](https://github.com/anyup/uView-Pro/commit/240e0238af092d4c6bde86d0db9e49636b806d6f))
15
+
1
16
  ## 0.0.15(2025-08-30)
2
17
 
3
18
  ### ✨ Features | 新功能
4
19
 
5
20
  - 优化 u-image 组件 slot 使用体验,兼容头条小程序 ([a6ca54f](https://github.com/anyup/uView-Pro/commit/a6ca54fce06b20b7a6938d0bef9342954b787641))
6
21
 
7
- ### 🐛 Bug Fixes | Bug 修复
22
+ ### ♻️ Bug Fixes | Bug 修复
8
23
 
9
24
  - 优化 label 的声明错误问题 ([314c394](https://github.com/anyup/uView-Pro/commit/314c3940145c657b12f16d005af7d271f4ae74e3))
10
25
  - 优化头条小程序 form 表单校验的兼容性问题 ([3912fd6](https://github.com/anyup/uView-Pro/commit/3912fd6ade3a1d612f6f5e86ddc0336376ee5618))
11
26
 
12
- ### 🐛 Bug Fixes | Bug 修复
13
-
14
27
  ## 0.0.14(2025-08-28)
15
28
 
16
29
  ### 🐛 Bug Fixes | Bug 修复
@@ -0,0 +1,26 @@
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ type LoadingMode = 'circle' | 'flower';
3
+
4
+ /**
5
+ * u-loading-popup 组件 props 类型定义
6
+ */
7
+ export const LoadingPopupProps = {
8
+ /** 是否显示加载弹窗 */
9
+ modelValue: { type: Boolean, default: false },
10
+ /** 加载提示文本 */
11
+ text: { type: String, default: '' },
12
+ /** 方向,可选 'vertical' | 'horizontal' */
13
+ direction: { type: String as PropType<'vertical' | 'horizontal'>, default: 'vertical' },
14
+ /** 自动关闭的持续时间(ms),0为不自动关闭 */
15
+ duration: { type: Number, default: 0 },
16
+ /** 允许点击遮罩关闭的最短时间(ms) */
17
+ cancelTime: { type: Number, default: 10000 },
18
+ /** 动画的类型 */
19
+ mode: { type: String as PropType<LoadingMode>, default: 'circle' },
20
+ /** 动画的颜色 */
21
+ color: { type: String, default: '#c7c7c7' },
22
+ /** 加载图标的大小,单位rpx */
23
+ size: { type: [String, Number] as PropType<string | number>, default: '48' }
24
+ };
25
+
26
+ export type LoadingPopupProps = ExtractPropTypes<typeof LoadingPopupProps>;
@@ -0,0 +1,239 @@
1
+ <template>
2
+ <view @touchmove.stop.prevent>
3
+ <view v-if="popupValue" class="u-loading-init" :class="[direction]">
4
+ <u-loading :mode="mode" :color="color" :size="size" />
5
+ <view v-if="currentText" class="u-loading-tips">
6
+ {{ currentText }}
7
+ </view>
8
+ </view>
9
+ <view class="u-loading-mask" :class="[popupValue ? 'u-mask-show' : '']" @click="onMaskClick" />
10
+ </view>
11
+ </template>
12
+ <script lang="ts" setup>
13
+ import { computed, onUnmounted, ref, watch } from 'vue';
14
+ import { LoadingPopupProps } from './types';
15
+
16
+ // 组件props类型
17
+ const props = defineProps(LoadingPopupProps);
18
+ const emit = defineEmits(['update:modelValue', 'cancel']);
19
+
20
+ // 自动关闭的持续时间定时器
21
+ let durationTimer: ReturnType<typeof setTimeout> | null = null;
22
+ // 关闭按钮倒计时定时器
23
+ let cancelTimer: ReturnType<typeof setTimeout> | null = null;
24
+ // 记录弹窗显示的时间戳
25
+ const now = ref(0);
26
+ // 点击遮罩层是否可关闭(超时后)
27
+ const canClose = ref(false);
28
+ // 当前显示的text,优先级:loading参数 > props.text
29
+ const currentText = ref(props.text);
30
+
31
+ const popupValue = computed({
32
+ get: () => props.modelValue,
33
+ set: (val: boolean) => emit('update:modelValue', val)
34
+ });
35
+
36
+ watch(
37
+ () => popupValue.value,
38
+ val => {
39
+ if (val) {
40
+ doOpen(currentText.value);
41
+ } else {
42
+ doClose();
43
+ }
44
+ }
45
+ );
46
+
47
+ // 响应 props 变更,自动刷新当前 text
48
+ watch(
49
+ () => props.text,
50
+ val => {
51
+ currentText.value = val;
52
+ }
53
+ );
54
+
55
+ // 响应 cancelTime/duration 变化,重启定时器
56
+ watch(
57
+ () => [props.cancelTime, props.duration],
58
+ () => {
59
+ if (popupValue.value) {
60
+ clearDurationTimer();
61
+ startCancelTime();
62
+ startDurationTime();
63
+ }
64
+ }
65
+ );
66
+
67
+ /**
68
+ * 启动超时关闭按钮计时
69
+ */
70
+ function startCancelTime() {
71
+ clearCancelTimer();
72
+ canClose.value = false;
73
+ if (props.cancelTime > 0) {
74
+ cancelTimer = setTimeout(() => {
75
+ canClose.value = true;
76
+ }, props.cancelTime);
77
+ }
78
+ }
79
+
80
+ /**
81
+ * 启动持续时间计时
82
+ */
83
+ function startDurationTime() {
84
+ clearDurationTimer();
85
+ if (props.duration) {
86
+ durationTimer = setTimeout(() => {
87
+ close();
88
+ }, props.duration);
89
+ }
90
+ }
91
+
92
+ /**
93
+ * 内部显示逻辑,初始化所有状态
94
+ */
95
+ function doOpen(text?: string) {
96
+ canClose.value = false;
97
+ clearDurationTimer();
98
+ clearCancelTimer();
99
+ now.value = Date.now();
100
+ if (typeof text === 'string' && text !== '') {
101
+ currentText.value = text;
102
+ } else {
103
+ currentText.value = props.text;
104
+ }
105
+ startCancelTime();
106
+ startDurationTime();
107
+ }
108
+
109
+ /**
110
+ * 内部关闭逻辑,重置所有状态
111
+ */
112
+ function doClose() {
113
+ canClose.value = false;
114
+ currentText.value = props.text;
115
+ clearDurationTimer();
116
+ clearCancelTimer();
117
+ }
118
+
119
+ /**
120
+ * 显示弹窗
121
+ * @param text 可选,优先显示的文案
122
+ */
123
+ function open(text?: string) {
124
+ currentText.value = text || props.text;
125
+ popupValue.value = true;
126
+ }
127
+
128
+ /**
129
+ * 隐藏弹窗
130
+ */
131
+ function close() {
132
+ popupValue.value = false;
133
+ }
134
+
135
+ // 清理定时器
136
+ function clearDurationTimer() {
137
+ if (durationTimer) {
138
+ clearTimeout(durationTimer);
139
+ durationTimer = null;
140
+ }
141
+ }
142
+ function clearCancelTimer() {
143
+ if (cancelTimer) {
144
+ clearTimeout(cancelTimer);
145
+ cancelTimer = null;
146
+ }
147
+ }
148
+
149
+ // 遮罩点击事件
150
+ function onMaskClick() {
151
+ // 只有显示关闭按钮时才允许关闭
152
+ if (canClose.value) {
153
+ emit('cancel');
154
+ close();
155
+ }
156
+ }
157
+
158
+ onUnmounted(() => {
159
+ clearDurationTimer();
160
+ clearCancelTimer();
161
+ });
162
+
163
+ defineExpose({
164
+ open,
165
+ close
166
+ });
167
+ </script>
168
+
169
+ <style lang="scss">
170
+ .u-loading-mask {
171
+ position: fixed;
172
+ top: 0;
173
+ left: 0;
174
+ right: 0;
175
+ bottom: 0;
176
+ background: rgba(0, 0, 0, 0);
177
+ z-index: 9999996;
178
+ transition: all 0.3s ease-in-out;
179
+ opacity: 0;
180
+ visibility: hidden;
181
+ }
182
+
183
+ .u-mask-show {
184
+ visibility: visible;
185
+ opacity: 1;
186
+ }
187
+
188
+ .u-loading-init {
189
+ position: relative;
190
+ min-width: 200rpx;
191
+ min-height: 200rpx;
192
+ max-width: 500rpx;
193
+ padding: 15rpx 0;
194
+ display: flex;
195
+ align-items: center;
196
+ justify-content: center;
197
+ flex-direction: column;
198
+ position: fixed;
199
+ top: 50%;
200
+ left: 50%;
201
+ transform: translate(-50%, -50%);
202
+ z-index: 9999;
203
+ font-size: 30rpx;
204
+ color: #fff;
205
+ background: rgba(0, 0, 0, 0.7);
206
+ border-radius: 7px;
207
+
208
+ .u-icon-close {
209
+ position: absolute;
210
+ top: 4rpx;
211
+ right: 2rpx;
212
+ color: #ffffff;
213
+ opacity: 0.8;
214
+ }
215
+
216
+ &.horizontal {
217
+ flex-direction: row;
218
+ align-items: center;
219
+ justify-content: left;
220
+ width: 600rpx;
221
+ max-width: 600rpx;
222
+ min-height: 150rpx;
223
+ padding-left: 40rpx;
224
+
225
+ .u-loading-tips {
226
+ margin-top: 0;
227
+ margin-left: 20rpx;
228
+ font-size: 32rpx;
229
+ }
230
+ }
231
+ }
232
+
233
+ .u-loading-tips {
234
+ text-align: center;
235
+ padding: 0 20rpx;
236
+ box-sizing: border-box;
237
+ margin-top: 36rpx;
238
+ }
239
+ </style>
@@ -146,6 +146,11 @@ function modify(id: string | number, key: string, value: any) {
146
146
  emit('update:modelValue', data);
147
147
  }
148
148
  }
149
+ defineExpose({
150
+ clear,
151
+ remove,
152
+ modify
153
+ });
149
154
  </script>
150
155
 
151
156
  <style lang="scss" scoped>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【Vue3重构版】uView Pro|基于Vue3+TS全面重构的70+精选UI组件库",
5
- "version": "0.0.15",
5
+ "version": "0.0.17",
6
6
  "description": "uView Pro,是全面支持Vue3的uni-app生态框架,70+精选组件已使用TypeScript重构,已全面支持uni-app Vue3.0",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",
@@ -46,6 +46,7 @@ declare module 'vue' {
46
46
  uLink: typeof import('../components/u-link/u-link.vue')['default'];
47
47
  uLoadMore: typeof import('../components/u-loadmore/u-loadmore.vue')['default'];
48
48
  uLoading: typeof import('../components/u-loading/u-loading.vue')['default'];
49
+ uLoadingPopup: typeof import('../components/u-loading-popup/u-loading-popup.vue')['default'];
49
50
  uMask: typeof import('../components/u-mask/u-mask.vue')['default'];
50
51
  uMessageInput: typeof import('../components/u-message-input/u-message-input.vue')['default'];
51
52
  uModal: typeof import('../components/u-modal/u-modal.vue')['default'];