im-ui-mobile 0.1.19 → 0.1.22
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.
|
@@ -2,15 +2,16 @@
|
|
|
2
2
|
<view class="avatar none-pointer-events" @click="showUserInfo" :title="title">
|
|
3
3
|
<image v-if="url" class="avatar-image" :src="url" :style="avatarImageStyle" lazy-load="true"
|
|
4
4
|
mode="aspectFill" />
|
|
5
|
-
<view v-else class="avatar-text" :style="avatarTextStyle">
|
|
5
|
+
<view v-else-if="title" class="avatar-text" :style="avatarTextStyle">
|
|
6
6
|
{{ title?.substring(0, 1).toUpperCase() }}
|
|
7
7
|
</view>
|
|
8
8
|
<view v-if="online" class="online" title="用户当前在线" />
|
|
9
|
+
<slot />
|
|
9
10
|
</view>
|
|
10
11
|
</template>
|
|
11
12
|
|
|
12
13
|
<script setup lang="ts">
|
|
13
|
-
import {
|
|
14
|
+
import { computed } from 'vue'
|
|
14
15
|
|
|
15
16
|
interface Props {
|
|
16
17
|
id?: number;
|
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
customClass
|
|
58
58
|
]" :style="[
|
|
59
59
|
iconStyles,
|
|
60
|
+
colorStyle,
|
|
60
61
|
customStyle
|
|
61
62
|
]" @click="handleClick">
|
|
62
63
|
<slot>
|
|
@@ -336,11 +337,12 @@ const iconStyles = computed(() => {
|
|
|
336
337
|
styles.width = sizeValue.value
|
|
337
338
|
styles.height = sizeValue.value
|
|
338
339
|
} else if (props.type === 'custom') {
|
|
339
|
-
styles.width = sizeValue.value
|
|
340
|
-
styles.height = sizeValue.value
|
|
341
|
-
styles.display = 'flex'
|
|
342
|
-
styles.alignItems = 'center'
|
|
343
|
-
styles.justifyContent = 'center'
|
|
340
|
+
// styles.width = sizeValue.value
|
|
341
|
+
// styles.height = sizeValue.value
|
|
342
|
+
// styles.display = 'flex'
|
|
343
|
+
// styles.alignItems = 'center'
|
|
344
|
+
// styles.justifyContent = 'center'
|
|
345
|
+
styles.fontSize = fontSizeValue.value
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
if (props.disabled) {
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
{ 'im-upload__area--drag-over': dragOver }
|
|
9
9
|
]" @tap="handleUploadTap" @touchmove="handleDragOver" @touchend="handleDragLeave">
|
|
10
10
|
<!-- 按钮类型 -->
|
|
11
|
-
<template v-if="type === 'button'">
|
|
11
|
+
<template v-if="type === 'button' && maxCount !== fileList.length">
|
|
12
12
|
<im-button :type="buttonType" :size="buttonSize" :disabled="disabled" :loading="uploading">
|
|
13
13
|
<!-- <view> -->
|
|
14
14
|
<text v-if="!uploading" class="im-upload__icon">+</text>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
</template>
|
|
19
19
|
|
|
20
20
|
<!-- 卡片类型 -->
|
|
21
|
-
<template v-else-if="type === 'card'">
|
|
21
|
+
<template v-else-if="type === 'card' && maxCount !== fileList.length">
|
|
22
22
|
<view class="im-upload__card">
|
|
23
23
|
<text class="im-upload__card-icon">+</text>
|
|
24
24
|
<text class="im-upload__card-text">{{ cardText }}</text>
|
|
@@ -28,14 +28,16 @@
|
|
|
28
28
|
|
|
29
29
|
<!-- 头像类型 -->
|
|
30
30
|
<template v-else-if="type === 'avatar'">
|
|
31
|
-
<view class="im-upload__avatar">
|
|
31
|
+
<view class="im-upload__avatar" :style="{ width: avatarSize + 'rpx' }">
|
|
32
32
|
<im-avatar :url="fileList[0]?.url" :size="avatarSize" :radius="avatarRadius">
|
|
33
33
|
<template v-if="!fileList[0]?.url">
|
|
34
|
-
<im-icon name="
|
|
34
|
+
<im-icon name="user" :size="avatarSize" color="#8c939d" />
|
|
35
35
|
</template>
|
|
36
36
|
</im-avatar>
|
|
37
|
-
<text class="im-upload__avatar-text">{{ avatarText }}</text>
|
|
37
|
+
<text v-if="avatarText" class="im-upload__avatar-text">{{ avatarText }}</text>
|
|
38
38
|
</view>
|
|
39
|
+
<im-icon v-if="showAvatarCamera && !avatarText" name="camera" :color="avatarCameraColor" size="36"
|
|
40
|
+
style="position: absolute; top: calc(-1 * var(0px, 0px));right: calc(-1 * var(0px, 0px));transform: translate(200%, -100%);" />
|
|
39
41
|
</template>
|
|
40
42
|
|
|
41
43
|
<!-- 拖拽区域类型 -->
|
|
@@ -51,9 +53,9 @@
|
|
|
51
53
|
</view>
|
|
52
54
|
|
|
53
55
|
<!-- 文件列表 -->
|
|
54
|
-
<view
|
|
55
|
-
<view v-for="(file, index) in fileList" :key="file.uid"
|
|
56
|
-
:class="`im-upload__item--${listType}`">
|
|
56
|
+
<view class="im-upload__list">
|
|
57
|
+
<view v-if="innerShowList && fileList.length > 0" v-for="(file, index) in fileList" :key="file.uid"
|
|
58
|
+
class="im-upload__item" :class="`im-upload__item--${listType}`">
|
|
57
59
|
<!-- 图片列表 -->
|
|
58
60
|
<template v-if="listType === 'picture'">
|
|
59
61
|
<view class="im-upload__item-preview">
|
|
@@ -121,6 +123,11 @@
|
|
|
121
123
|
</view>
|
|
122
124
|
</template>
|
|
123
125
|
</view>
|
|
126
|
+
|
|
127
|
+
<!-- 上传区域(默认类型) -->
|
|
128
|
+
<view v-if="!type && maxCount !== fileList.length" class="im-upload__default" @tap="handleUploadTap">
|
|
129
|
+
<im-icon customClass="im-upload__default-icon" :size="100" color="#dcdfe6" type="custom" name="+" />
|
|
130
|
+
</view>
|
|
124
131
|
</view>
|
|
125
132
|
|
|
126
133
|
<!-- 上传提示 -->
|
|
@@ -189,6 +196,8 @@ interface Props {
|
|
|
189
196
|
avatarText?: string
|
|
190
197
|
avatarSize?: number | string
|
|
191
198
|
avatarRadius?: string
|
|
199
|
+
showAvatarCamera?: boolean
|
|
200
|
+
avatarCameraColor?: string
|
|
192
201
|
|
|
193
202
|
// 拖拽配置
|
|
194
203
|
dragText?: string
|
|
@@ -235,21 +244,6 @@ interface Props {
|
|
|
235
244
|
customRequest?: (file: Object, onProgress: (percent: number) => void) => Promise<any>
|
|
236
245
|
}
|
|
237
246
|
|
|
238
|
-
// 定义 Emits
|
|
239
|
-
interface Emits {
|
|
240
|
-
(e: 'update:modelValue', files: string | UploadFile[]): void
|
|
241
|
-
(e: 'change', files: string | UploadFile[]): void
|
|
242
|
-
(e: 'select', file: Object): void
|
|
243
|
-
(e: 'success', file: UploadFile): void
|
|
244
|
-
(e: 'error', error: Error, file: UploadFile): void
|
|
245
|
-
(e: 'progress', percent: number, file: UploadFile): void
|
|
246
|
-
(e: 'remove', file: UploadFile, index: number): void
|
|
247
|
-
(e: 'preview', file: UploadFile): void
|
|
248
|
-
(e: 'exceed', files: Object[]): void
|
|
249
|
-
(e: 'uploading', file: UploadFile): void
|
|
250
|
-
(e: 'uploaded', file: UploadFile): void
|
|
251
|
-
}
|
|
252
|
-
|
|
253
247
|
// 定义 Props 默认值
|
|
254
248
|
const props = withDefaults(defineProps<Props>(), {
|
|
255
249
|
modelValue: () => [],
|
|
@@ -262,9 +256,11 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
262
256
|
|
|
263
257
|
cardText: '点击上传',
|
|
264
258
|
|
|
265
|
-
avatarText: '
|
|
259
|
+
avatarText: '',
|
|
266
260
|
avatarSize: 120,
|
|
267
261
|
avatarRadius: '50%',
|
|
262
|
+
showAvatarCamera: true,
|
|
263
|
+
avatarCameraColor: 'rgb(208 208 208)',
|
|
268
264
|
|
|
269
265
|
dragText: '将文件拖到此处,或点击上传',
|
|
270
266
|
|
|
@@ -297,7 +293,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
297
293
|
}
|
|
298
294
|
},
|
|
299
295
|
|
|
300
|
-
showList:
|
|
296
|
+
showList: true,
|
|
301
297
|
listType: 'picture',
|
|
302
298
|
removable: true,
|
|
303
299
|
previewable: true,
|
|
@@ -306,6 +302,21 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
306
302
|
readonly: false
|
|
307
303
|
})
|
|
308
304
|
|
|
305
|
+
// 定义 Emits
|
|
306
|
+
interface Emits {
|
|
307
|
+
(e: 'update:modelValue', files: string | UploadFile[]): void
|
|
308
|
+
(e: 'change', files: string | UploadFile[]): void
|
|
309
|
+
(e: 'select', file: Object): void
|
|
310
|
+
(e: 'success', file: UploadFile): void
|
|
311
|
+
(e: 'error', error: Error, file: UploadFile): void
|
|
312
|
+
(e: 'progress', percent: number, file: UploadFile): void
|
|
313
|
+
(e: 'remove', file: UploadFile, index: number): void
|
|
314
|
+
(e: 'preview', file: UploadFile): void
|
|
315
|
+
(e: 'exceed', files: Object[]): void
|
|
316
|
+
(e: 'uploading', file: UploadFile): void
|
|
317
|
+
(e: 'uploaded', file: UploadFile): void
|
|
318
|
+
}
|
|
319
|
+
|
|
309
320
|
const emit = defineEmits<Emits>()
|
|
310
321
|
|
|
311
322
|
// 响应式状态
|
|
@@ -335,6 +346,13 @@ watch(() => props.modelValue, (val) => {
|
|
|
335
346
|
}, { deep: true })
|
|
336
347
|
|
|
337
348
|
// 计算属性
|
|
349
|
+
const innerShowList = computed(() => {
|
|
350
|
+
if (props.type === 'avatar') {
|
|
351
|
+
return false
|
|
352
|
+
}
|
|
353
|
+
return props.showList
|
|
354
|
+
})
|
|
355
|
+
|
|
338
356
|
const uploading = computed(() => {
|
|
339
357
|
return fileList.value.some(file => file.status === 'uploading')
|
|
340
358
|
})
|
|
@@ -383,6 +401,7 @@ const handleUploadTap = async () => {
|
|
|
383
401
|
if (props.type === 'avatar') {
|
|
384
402
|
accept = 'image'
|
|
385
403
|
maxSelectable = 1
|
|
404
|
+
|
|
386
405
|
}
|
|
387
406
|
|
|
388
407
|
if (maxSelectable <= 0) {
|
|
@@ -751,6 +770,23 @@ defineExpose({
|
|
|
751
770
|
font-size: 28rpx;
|
|
752
771
|
}
|
|
753
772
|
|
|
773
|
+
.im-upload__default {
|
|
774
|
+
margin-top: 20rpx;
|
|
775
|
+
display: flex;
|
|
776
|
+
align-items: center;
|
|
777
|
+
justify-content: center;
|
|
778
|
+
width: 180rpx;
|
|
779
|
+
height: 180rpx;
|
|
780
|
+
border: 4rpx dashed #dcdfe6;
|
|
781
|
+
border-radius: 20rpx;
|
|
782
|
+
background-color: #fafafa;
|
|
783
|
+
transition: all 0.3s;
|
|
784
|
+
|
|
785
|
+
&-icon {
|
|
786
|
+
color: inherit;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
|
|
754
790
|
.im-upload__card {
|
|
755
791
|
display: flex;
|
|
756
792
|
flex-direction: column;
|
|
@@ -856,8 +892,8 @@ defineExpose({
|
|
|
856
892
|
|
|
857
893
|
.im-upload__item-preview {
|
|
858
894
|
position: relative;
|
|
859
|
-
width:
|
|
860
|
-
height:
|
|
895
|
+
width: 184rpx;
|
|
896
|
+
height: 184rpx;
|
|
861
897
|
border-radius: 8rpx;
|
|
862
898
|
overflow: hidden;
|
|
863
899
|
border: 1rpx solid #ebeef5;
|
package/package.json
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ import * as url from "./utils/url.d.ts";
|
|
|
13
13
|
import { useDynamicRefs } from "./utils/useDynamicRefs.d.ts";
|
|
14
14
|
import { webSocket, type WebSocket } from "./utils/websocket.d.ts";
|
|
15
15
|
import type {
|
|
16
|
-
// 类型常量
|
|
17
16
|
RtcMode,
|
|
18
17
|
RtcInfo,
|
|
19
18
|
Chat,
|
|
@@ -50,6 +49,13 @@ import validator, {
|
|
|
50
49
|
} from './utils/validator.d.ts'
|
|
51
50
|
import { EmojiType, EmojiCategoryType } from './components/emoji-picker'
|
|
52
51
|
import * as base64 from "./utils/base64.d.ts"
|
|
52
|
+
import {
|
|
53
|
+
Upload,
|
|
54
|
+
UploadFile,
|
|
55
|
+
UploadFileStatus,
|
|
56
|
+
UploadProps,
|
|
57
|
+
UploadMethods
|
|
58
|
+
} from './components/upload'
|
|
53
59
|
|
|
54
60
|
declare module 'im-ui-mobile' {
|
|
55
61
|
export function install(): void
|
|
@@ -90,7 +96,13 @@ declare module 'im-ui-mobile' {
|
|
|
90
96
|
RecorderFile,
|
|
91
97
|
UserInfo,
|
|
92
98
|
Response,
|
|
93
|
-
WebSocket
|
|
99
|
+
WebSocket,
|
|
100
|
+
|
|
101
|
+
Upload,
|
|
102
|
+
UploadFile,
|
|
103
|
+
UploadFileStatus,
|
|
104
|
+
UploadProps,
|
|
105
|
+
UploadMethods
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
// 导出函数/实例
|
|
@@ -124,6 +136,5 @@ declare module 'im-ui-mobile' {
|
|
|
124
136
|
MESSAGE_STATUS,
|
|
125
137
|
}
|
|
126
138
|
|
|
127
|
-
|
|
128
|
-
|
|
139
|
+
|
|
129
140
|
}
|