im-ui-mobile 0.1.20 → 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
|
<!-- 拖拽区域类型 -->
|
|
@@ -52,7 +54,7 @@
|
|
|
52
54
|
|
|
53
55
|
<!-- 文件列表 -->
|
|
54
56
|
<view class="im-upload__list">
|
|
55
|
-
<view v-if="
|
|
57
|
+
<view v-if="innerShowList && fileList.length > 0" v-for="(file, index) in fileList" :key="file.uid"
|
|
56
58
|
class="im-upload__item" :class="`im-upload__item--${listType}`">
|
|
57
59
|
<!-- 图片列表 -->
|
|
58
60
|
<template v-if="listType === 'picture'">
|
|
@@ -122,8 +124,9 @@
|
|
|
122
124
|
</template>
|
|
123
125
|
</view>
|
|
124
126
|
|
|
125
|
-
|
|
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="+" />
|
|
127
130
|
</view>
|
|
128
131
|
</view>
|
|
129
132
|
|
|
@@ -193,6 +196,8 @@ interface Props {
|
|
|
193
196
|
avatarText?: string
|
|
194
197
|
avatarSize?: number | string
|
|
195
198
|
avatarRadius?: string
|
|
199
|
+
showAvatarCamera?: boolean
|
|
200
|
+
avatarCameraColor?: string
|
|
196
201
|
|
|
197
202
|
// 拖拽配置
|
|
198
203
|
dragText?: string
|
|
@@ -239,21 +244,6 @@ interface Props {
|
|
|
239
244
|
customRequest?: (file: Object, onProgress: (percent: number) => void) => Promise<any>
|
|
240
245
|
}
|
|
241
246
|
|
|
242
|
-
// 定义 Emits
|
|
243
|
-
interface Emits {
|
|
244
|
-
(e: 'update:modelValue', files: string | UploadFile[]): void
|
|
245
|
-
(e: 'change', files: string | UploadFile[]): void
|
|
246
|
-
(e: 'select', file: Object): void
|
|
247
|
-
(e: 'success', file: UploadFile): void
|
|
248
|
-
(e: 'error', error: Error, file: UploadFile): void
|
|
249
|
-
(e: 'progress', percent: number, file: UploadFile): void
|
|
250
|
-
(e: 'remove', file: UploadFile, index: number): void
|
|
251
|
-
(e: 'preview', file: UploadFile): void
|
|
252
|
-
(e: 'exceed', files: Object[]): void
|
|
253
|
-
(e: 'uploading', file: UploadFile): void
|
|
254
|
-
(e: 'uploaded', file: UploadFile): void
|
|
255
|
-
}
|
|
256
|
-
|
|
257
247
|
// 定义 Props 默认值
|
|
258
248
|
const props = withDefaults(defineProps<Props>(), {
|
|
259
249
|
modelValue: () => [],
|
|
@@ -266,9 +256,11 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
266
256
|
|
|
267
257
|
cardText: '点击上传',
|
|
268
258
|
|
|
269
|
-
avatarText: '
|
|
259
|
+
avatarText: '',
|
|
270
260
|
avatarSize: 120,
|
|
271
261
|
avatarRadius: '50%',
|
|
262
|
+
showAvatarCamera: true,
|
|
263
|
+
avatarCameraColor: 'rgb(208 208 208)',
|
|
272
264
|
|
|
273
265
|
dragText: '将文件拖到此处,或点击上传',
|
|
274
266
|
|
|
@@ -310,6 +302,21 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
310
302
|
readonly: false
|
|
311
303
|
})
|
|
312
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
|
+
|
|
313
320
|
const emit = defineEmits<Emits>()
|
|
314
321
|
|
|
315
322
|
// 响应式状态
|
|
@@ -339,6 +346,13 @@ watch(() => props.modelValue, (val) => {
|
|
|
339
346
|
}, { deep: true })
|
|
340
347
|
|
|
341
348
|
// 计算属性
|
|
349
|
+
const innerShowList = computed(() => {
|
|
350
|
+
if (props.type === 'avatar') {
|
|
351
|
+
return false
|
|
352
|
+
}
|
|
353
|
+
return props.showList
|
|
354
|
+
})
|
|
355
|
+
|
|
342
356
|
const uploading = computed(() => {
|
|
343
357
|
return fileList.value.some(file => file.status === 'uploading')
|
|
344
358
|
})
|
|
@@ -387,6 +401,7 @@ const handleUploadTap = async () => {
|
|
|
387
401
|
if (props.type === 'avatar') {
|
|
388
402
|
accept = 'image'
|
|
389
403
|
maxSelectable = 1
|
|
404
|
+
|
|
390
405
|
}
|
|
391
406
|
|
|
392
407
|
if (maxSelectable <= 0) {
|
|
@@ -768,13 +783,10 @@ defineExpose({
|
|
|
768
783
|
transition: all 0.3s;
|
|
769
784
|
|
|
770
785
|
&-icon {
|
|
771
|
-
color:
|
|
772
|
-
font-size: 200rpx;
|
|
773
|
-
margin-top: -20rpx;
|
|
786
|
+
color: inherit;
|
|
774
787
|
}
|
|
775
788
|
}
|
|
776
789
|
|
|
777
|
-
|
|
778
790
|
.im-upload__card {
|
|
779
791
|
display: flex;
|
|
780
792
|
flex-direction: column;
|
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
|
}
|