im-ui-mobile 0.1.12 → 0.1.14
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/im-badge/im-badge.vue +21 -30
- package/components/im-tabs/im-tabs.vue +3 -2
- package/components/im-tabs/utils/compatibility.ts +69 -0
- package/components/im-upload/im-upload.vue +172 -214
- package/components/im-upload/utils/file-chooser.js +67 -0
- package/package.json +59 -57
- package/styles/functions.scss +24 -0
- package/styles/mixins.scss +148 -0
- package/styles/variables.scss +58 -0
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
!childrenSlot && !isAbsolute ? 'im-badge--standalone' : '',
|
|
9
9
|
isAbsolute ? 'im-badge--absolute' : ''
|
|
10
10
|
]" :style="{
|
|
11
|
-
'--badge-bg-color': bgColor ||
|
|
11
|
+
'--badge-bg-color': bgColor || innerBgColor,
|
|
12
12
|
'--badge-text-color': textColor || undefined,
|
|
13
13
|
'--badge-offset-x': offset[0] + 'px',
|
|
14
14
|
'--badge-offset-y': offset[1] + 'px'
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
</template>
|
|
36
36
|
|
|
37
37
|
<script setup lang="ts">
|
|
38
|
-
import {
|
|
38
|
+
import { computed, useSlots } from 'vue'
|
|
39
39
|
|
|
40
40
|
// 定义Props
|
|
41
41
|
interface BadgeProps {
|
|
@@ -120,6 +120,20 @@ const typeClass = computed(() => `im-badge--${props.type}`)
|
|
|
120
120
|
const sizeClass = computed(() => `im-badge--${props.size}`)
|
|
121
121
|
const shapeClass = computed(() => `im-badge--${props.shape}`)
|
|
122
122
|
const isAbsolute = computed(() => props.absolute && childrenSlot.value)
|
|
123
|
+
const innerBgColor = computed(() => {
|
|
124
|
+
switch (props.type) {
|
|
125
|
+
case 'primary':
|
|
126
|
+
return '#409eff';
|
|
127
|
+
case 'success':
|
|
128
|
+
return '#67c23a';
|
|
129
|
+
case 'warning':
|
|
130
|
+
return '#e6a23c';
|
|
131
|
+
case 'danger':
|
|
132
|
+
return '#f56c6c';
|
|
133
|
+
case 'info':
|
|
134
|
+
return '#909399';
|
|
135
|
+
}
|
|
136
|
+
})
|
|
123
137
|
|
|
124
138
|
// 事件处理
|
|
125
139
|
const handleClick = (event: MouseEvent) => {
|
|
@@ -133,6 +147,8 @@ defineExpose({
|
|
|
133
147
|
</script>
|
|
134
148
|
|
|
135
149
|
<style lang="scss" scoped>
|
|
150
|
+
@import "../../styles/variables.scss";
|
|
151
|
+
|
|
136
152
|
.im-badge {
|
|
137
153
|
display: inline-flex;
|
|
138
154
|
position: relative;
|
|
@@ -176,36 +192,11 @@ defineExpose({
|
|
|
176
192
|
font-size: 12px;
|
|
177
193
|
font-weight: 500;
|
|
178
194
|
line-height: 1;
|
|
179
|
-
color:
|
|
195
|
+
color: #ffffff;
|
|
180
196
|
text-align: center;
|
|
181
197
|
white-space: nowrap;
|
|
182
198
|
}
|
|
183
199
|
|
|
184
|
-
// 类型样式
|
|
185
|
-
&--primary {
|
|
186
|
-
--badge-bg-color: #409eff;
|
|
187
|
-
--badge-text-color: #ffffff;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
&--success {
|
|
191
|
-
--badge-bg-color: #67c23a;
|
|
192
|
-
--badge-text-color: #ffffff;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
&--warning {
|
|
196
|
-
--badge-bg-color: #e6a23c;
|
|
197
|
-
--badge-text-color: #ffffff;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
&--danger {
|
|
201
|
-
--badge-bg-color: #f56c6c;
|
|
202
|
-
--badge-text-color: #ffffff;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
&--info {
|
|
206
|
-
--badge-bg-color: #909399;
|
|
207
|
-
--badge-text-color: #ffffff;
|
|
208
|
-
}
|
|
209
200
|
|
|
210
201
|
// 尺寸样式
|
|
211
202
|
&--small {
|
|
@@ -302,7 +293,7 @@ defineExpose({
|
|
|
302
293
|
align-items: center;
|
|
303
294
|
justify-content: center;
|
|
304
295
|
background-color: var(--badge-bg-color);
|
|
305
|
-
color: var(--badge-text-color);
|
|
296
|
+
color: var(--badge-text-color) !important;
|
|
306
297
|
|
|
307
298
|
// 添加阴影增强视觉效果
|
|
308
299
|
box-shadow: 0 0 0 1px #fff;
|
|
@@ -316,7 +307,7 @@ defineExpose({
|
|
|
316
307
|
align-items: center;
|
|
317
308
|
justify-content: center;
|
|
318
309
|
background-color: var(--badge-bg-color);
|
|
319
|
-
color: var(--badge-text-color);
|
|
310
|
+
color: var(--badge-text-color) !important;
|
|
320
311
|
|
|
321
312
|
// 添加阴影增强视觉效果
|
|
322
313
|
box-shadow: 0 0 0 1px #fff;
|
|
@@ -53,6 +53,7 @@ import {
|
|
|
53
53
|
} from 'vue'
|
|
54
54
|
import type { TabsProps, TabsEmits, TabItem } from '../../types/components/tabs'
|
|
55
55
|
import TabsNavigation from './tabs-navigation.vue'
|
|
56
|
+
import { safeRequestAnimationFrame } from './utils/compatibility'
|
|
56
57
|
|
|
57
58
|
const props = withDefaults(defineProps<TabsProps>(), {
|
|
58
59
|
modelValue: 0,
|
|
@@ -340,7 +341,7 @@ const scrollToActiveTab = () => {
|
|
|
340
341
|
if (!props.scrollable) return
|
|
341
342
|
|
|
342
343
|
// 使用 requestAnimationFrame
|
|
343
|
-
|
|
344
|
+
safeRequestAnimationFrame(() => {
|
|
344
345
|
scrollToActiveTabImpl()
|
|
345
346
|
})
|
|
346
347
|
}
|
|
@@ -436,7 +437,7 @@ const onPageScroll = (event: any) => {
|
|
|
436
437
|
try {
|
|
437
438
|
const scrollTop = event.scrollTop || 0
|
|
438
439
|
|
|
439
|
-
|
|
440
|
+
safeRequestAnimationFrame(() => {
|
|
440
441
|
const query = uni.createSelectorQuery().in(instance)
|
|
441
442
|
|
|
442
443
|
query.select('.im-tabs-sticky').boundingClientRect((res: any) => {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// utils/compatibility.ts
|
|
2
|
+
/**
|
|
3
|
+
* 兼容 requestAnimationFrame
|
|
4
|
+
*/
|
|
5
|
+
export const requestAnimationFrame = (callback: FrameRequestCallback): number => {
|
|
6
|
+
// 微信小程序环境
|
|
7
|
+
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ
|
|
8
|
+
return setTimeout(() => {
|
|
9
|
+
callback(Date.now())
|
|
10
|
+
}, 16) as unknown as number
|
|
11
|
+
// #endif
|
|
12
|
+
|
|
13
|
+
// H5 环境
|
|
14
|
+
// #ifdef H5
|
|
15
|
+
return window.requestAnimationFrame(callback)
|
|
16
|
+
// #endif
|
|
17
|
+
|
|
18
|
+
// App 环境
|
|
19
|
+
// #ifdef APP
|
|
20
|
+
return setTimeout(() => {
|
|
21
|
+
callback(Date.now())
|
|
22
|
+
}, 16) as unknown as number
|
|
23
|
+
// #endif
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 兼容 cancelAnimationFrame
|
|
28
|
+
*/
|
|
29
|
+
export const cancelAnimationFrame = (id: number): void => {
|
|
30
|
+
// 微信小程序环境
|
|
31
|
+
// #ifdef MP-WEIXIN || MP-ALIPAY || MP-BAIDU || MP-TOUTIAO || MP-QQ
|
|
32
|
+
return clearTimeout(id)
|
|
33
|
+
// #endif
|
|
34
|
+
|
|
35
|
+
// H5 环境
|
|
36
|
+
// #ifdef H5
|
|
37
|
+
return window.cancelAnimationFrame(id)
|
|
38
|
+
// #endif
|
|
39
|
+
|
|
40
|
+
// App 环境
|
|
41
|
+
// #ifdef APP
|
|
42
|
+
return clearTimeout(id)
|
|
43
|
+
// #endif
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 安全执行 requestAnimationFrame,避免错误
|
|
48
|
+
*/
|
|
49
|
+
export const safeRequestAnimationFrame = (callback: FrameRequestCallback): number => {
|
|
50
|
+
try {
|
|
51
|
+
return requestAnimationFrame(callback)
|
|
52
|
+
} catch (error) {
|
|
53
|
+
// 如果 requestAnimationFrame 不存在,使用 setTimeout 模拟
|
|
54
|
+
return setTimeout(() => {
|
|
55
|
+
callback(Date.now())
|
|
56
|
+
}, 16) as unknown as number
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* 安全执行 cancelAnimationFrame
|
|
62
|
+
*/
|
|
63
|
+
export const safeCancelAnimationFrame = (id: number): void => {
|
|
64
|
+
try {
|
|
65
|
+
cancelAnimationFrame(id)
|
|
66
|
+
} catch (error) {
|
|
67
|
+
clearTimeout(id)
|
|
68
|
+
}
|
|
69
|
+
}
|