im-ui-mobile 0.0.98 → 0.1.0
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-avatar/im-avatar.vue +121 -121
- package/components/im-button/im-button.vue +630 -626
- package/components/im-cell/im-cell.vue +10 -15
- package/components/im-cell-group/im-cell-group.vue +16 -16
- package/components/im-chat-item/im-chat-item.vue +213 -213
- package/components/im-context-menu/im-context-menu.vue +138 -138
- package/components/im-file-upload/im-file-upload.vue +309 -309
- package/components/im-friend-item/im-friend-item.vue +82 -75
- package/components/im-group-item/im-group-item.vue +62 -62
- package/components/im-group-member-selector/im-group-member-selector.vue +202 -202
- package/components/im-group-rtc-join/im-group-rtc-join.vue +112 -112
- package/components/im-image-upload/im-image-upload.vue +94 -94
- package/components/im-loading/im-loading.vue +64 -64
- package/components/im-mention-picker/im-mention-picker.vue +191 -191
- package/components/im-message-item/im-message-item.vue +555 -555
- package/components/im-nav-bar/im-nav-bar.vue +98 -98
- package/components/im-read-receipt/im-read-receipt.vue +174 -174
- package/components/im-virtual-list/im-virtual-list.vue +52 -51
- package/components/im-voice-input/im-voice-input.vue +305 -305
- package/libs/index.ts +2 -3
- package/package.json +58 -58
- package/styles/button.scss +1 -1
- package/theme.scss +61 -62
- package/types/components.d.ts +0 -1
- package/types/index.d.ts +94 -94
- package/types/libs/index.d.ts +206 -204
- package/types/utils/datetime.d.ts +9 -9
- package/types/utils/dom.d.ts +11 -11
- package/types/utils/emoji.d.ts +8 -8
- package/types/utils/enums.d.ts +73 -73
- package/types/utils/messageType.d.ts +35 -35
- package/types/utils/recorderApp.d.ts +9 -9
- package/types/utils/recorderH5.d.ts +9 -9
- package/types/utils/requester.d.ts +15 -15
- package/types/utils/url.d.ts +5 -5
- package/types/utils/useDynamicRefs.d.ts +9 -9
- package/types/utils/websocket.d.ts +34 -34
- package/utils/enums.js +1 -1
- package/components/im-virtual-scroller/im-virtual-scroller.vue +0 -54
- package/types/components/virtual-scroller.d.ts +0 -20
|
@@ -1,122 +1,122 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="avatar none-pointer-events" @click="showUserInfo" :title="name">
|
|
3
|
-
<image v-if="url" class="avatar-image" :src="url" :style="avatarImageStyle" lazy-load="true"
|
|
4
|
-
mode="aspectFill" />
|
|
5
|
-
<view v-else class="avatar-text" :style="avatarTextStyle">
|
|
6
|
-
{{ name?.substring(0, 1).toUpperCase() }}
|
|
7
|
-
</view>
|
|
8
|
-
<view v-if="online" class="online" title="用户当前在线" />
|
|
9
|
-
</view>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup lang="ts">
|
|
13
|
-
import { computed } from 'vue';
|
|
14
|
-
|
|
15
|
-
interface Props {
|
|
16
|
-
id?: number;
|
|
17
|
-
size?: number | string;
|
|
18
|
-
url?: string;
|
|
19
|
-
name?: string;
|
|
20
|
-
radius?: string;
|
|
21
|
-
online?: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
25
|
-
size: 'default',
|
|
26
|
-
name: '',
|
|
27
|
-
radius: "50%",
|
|
28
|
-
online: false
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
interface Emits {
|
|
32
|
-
(e: 'click', id: number): void
|
|
33
|
-
}
|
|
34
|
-
const emit = defineEmits<Emits>()
|
|
35
|
-
|
|
36
|
-
const colors = [
|
|
37
|
-
"#5daa31", "#c7515a", "#e03697", "#85029b",
|
|
38
|
-
"#c9b455", "#326eb6"
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
const showUserInfo = () => {
|
|
42
|
-
if (props.id && props.id > 0) {
|
|
43
|
-
// TODO:组件化
|
|
44
|
-
// uni.navigateTo({ url: "/pages/common/user-info?id=" + props.id });
|
|
45
|
-
emit('click', props.id)
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const _size = computed(() => {
|
|
50
|
-
if (typeof props.size === 'number') {
|
|
51
|
-
return props.size;
|
|
52
|
-
} else if (typeof props.size === 'string') {
|
|
53
|
-
const sizeMap: Record<string, number> = {
|
|
54
|
-
'default': 96,
|
|
55
|
-
'small': 84,
|
|
56
|
-
'smaller': 72,
|
|
57
|
-
'mini': 60,
|
|
58
|
-
'minier': 48,
|
|
59
|
-
'lage': 108,
|
|
60
|
-
'lager': 120,
|
|
61
|
-
};
|
|
62
|
-
return sizeMap[props.size] || 96;
|
|
63
|
-
}
|
|
64
|
-
return 96;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const avatarImageStyle = computed(() => {
|
|
68
|
-
return `width:${_size.value}rpx;height:${_size.value}rpx;`;
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const avatarTextStyle = computed(() => {
|
|
72
|
-
return `width: ${_size.value}rpx;
|
|
73
|
-
height:${_size.value}rpx;
|
|
74
|
-
background: linear-gradient(145deg,#ffffff20 25%,#00000060),${textColor.value};
|
|
75
|
-
font-size:${_size.value * 0.45}rpx;
|
|
76
|
-
border-radius: ${props.radius};`;
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
const textColor = computed(() => {
|
|
80
|
-
if (!props.name) {
|
|
81
|
-
return '#fff';
|
|
82
|
-
}
|
|
83
|
-
let hash = 0;
|
|
84
|
-
for (let i = 0; i < props.name.length; i++) {
|
|
85
|
-
hash += props.name.charCodeAt(i);
|
|
86
|
-
}
|
|
87
|
-
return colors[hash % colors.length];
|
|
88
|
-
});
|
|
89
|
-
</script>
|
|
90
|
-
|
|
91
|
-
<style scoped lang="scss">
|
|
92
|
-
.avatar {
|
|
93
|
-
position: relative;
|
|
94
|
-
cursor: pointer;
|
|
95
|
-
|
|
96
|
-
.avatar-image {
|
|
97
|
-
position: relative;
|
|
98
|
-
overflow: hidden;
|
|
99
|
-
border-radius: 50%;
|
|
100
|
-
vertical-align: bottom;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
.avatar-text {
|
|
104
|
-
color: white;
|
|
105
|
-
border-radius: 50%;
|
|
106
|
-
display: flex;
|
|
107
|
-
align-items: center;
|
|
108
|
-
justify-content: center;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
.online {
|
|
112
|
-
position: absolute;
|
|
113
|
-
right: -10%;
|
|
114
|
-
bottom: 0;
|
|
115
|
-
width: 24rpx;
|
|
116
|
-
height: 24rpx;
|
|
117
|
-
background: limegreen;
|
|
118
|
-
border-radius: 50%;
|
|
119
|
-
border: 6rpx solid white;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<view class="avatar none-pointer-events" @click="showUserInfo" :title="name">
|
|
3
|
+
<image v-if="url" class="avatar-image" :src="url" :style="avatarImageStyle" lazy-load="true"
|
|
4
|
+
mode="aspectFill" />
|
|
5
|
+
<view v-else class="avatar-text" :style="avatarTextStyle">
|
|
6
|
+
{{ name?.substring(0, 1).toUpperCase() }}
|
|
7
|
+
</view>
|
|
8
|
+
<view v-if="online" class="online" title="用户当前在线" />
|
|
9
|
+
</view>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
id?: number;
|
|
17
|
+
size?: number | string;
|
|
18
|
+
url?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
radius?: string;
|
|
21
|
+
online?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
25
|
+
size: 'default',
|
|
26
|
+
name: '',
|
|
27
|
+
radius: "50%",
|
|
28
|
+
online: false
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
interface Emits {
|
|
32
|
+
(e: 'click', id: number): void
|
|
33
|
+
}
|
|
34
|
+
const emit = defineEmits<Emits>()
|
|
35
|
+
|
|
36
|
+
const colors = [
|
|
37
|
+
"#5daa31", "#c7515a", "#e03697", "#85029b",
|
|
38
|
+
"#c9b455", "#326eb6"
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const showUserInfo = () => {
|
|
42
|
+
if (props.id && props.id > 0) {
|
|
43
|
+
// TODO:组件化
|
|
44
|
+
// uni.navigateTo({ url: "/pages/common/user-info?id=" + props.id });
|
|
45
|
+
emit('click', props.id)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const _size = computed(() => {
|
|
50
|
+
if (typeof props.size === 'number') {
|
|
51
|
+
return props.size;
|
|
52
|
+
} else if (typeof props.size === 'string') {
|
|
53
|
+
const sizeMap: Record<string, number> = {
|
|
54
|
+
'default': 96,
|
|
55
|
+
'small': 84,
|
|
56
|
+
'smaller': 72,
|
|
57
|
+
'mini': 60,
|
|
58
|
+
'minier': 48,
|
|
59
|
+
'lage': 108,
|
|
60
|
+
'lager': 120,
|
|
61
|
+
};
|
|
62
|
+
return sizeMap[props.size] || 96;
|
|
63
|
+
}
|
|
64
|
+
return 96;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const avatarImageStyle = computed(() => {
|
|
68
|
+
return `width:${_size.value}rpx;height:${_size.value}rpx;`;
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const avatarTextStyle = computed(() => {
|
|
72
|
+
return `width: ${_size.value}rpx;
|
|
73
|
+
height:${_size.value}rpx;
|
|
74
|
+
background: linear-gradient(145deg,#ffffff20 25%,#00000060),${textColor.value};
|
|
75
|
+
font-size:${_size.value * 0.45}rpx;
|
|
76
|
+
border-radius: ${props.radius};`;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const textColor = computed(() => {
|
|
80
|
+
if (!props.name) {
|
|
81
|
+
return '#fff';
|
|
82
|
+
}
|
|
83
|
+
let hash = 0;
|
|
84
|
+
for (let i = 0; i < props.name.length; i++) {
|
|
85
|
+
hash += props.name.charCodeAt(i);
|
|
86
|
+
}
|
|
87
|
+
return colors[hash % colors.length];
|
|
88
|
+
});
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<style scoped lang="scss">
|
|
92
|
+
.avatar {
|
|
93
|
+
position: relative;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
|
|
96
|
+
.avatar-image {
|
|
97
|
+
position: relative;
|
|
98
|
+
overflow: hidden;
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
vertical-align: bottom;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.avatar-text {
|
|
104
|
+
color: white;
|
|
105
|
+
border-radius: 50%;
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
justify-content: center;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.online {
|
|
112
|
+
position: absolute;
|
|
113
|
+
right: -10%;
|
|
114
|
+
bottom: 0;
|
|
115
|
+
width: 24rpx;
|
|
116
|
+
height: 24rpx;
|
|
117
|
+
background: limegreen;
|
|
118
|
+
border-radius: 50%;
|
|
119
|
+
border: 6rpx solid white;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
122
|
</style>
|