im-ui-mobile 0.0.10 → 0.0.12
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/{chat-box → im-chat-box}/index.vue +4 -4
- package/components/im-chat-item/index.vue +189 -0
- package/components/{chat-message-item → im-chat-message-item}/index.vue +1 -1
- package/index.ts +36 -0
- package/package.json +4 -3
- package/types/components/chat-item/index.vue.d.ts +38 -58
- package/types/components/im-chat-box/index.vue.d.ts +129 -0
- package/types/components/im-chat-item/index.vue.d.ts +43 -0
- package/types/components/im-chat-message-item/index.vue.d.ts +73 -0
- package/types/index.d.ts +11 -8
- package/components/chat-item/index.vue +0 -189
- package/index.js +0 -31
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- 替换 uview 组件 -->
|
|
13
13
|
<view class="loading-icon">加载中...</view>
|
|
14
14
|
</view>
|
|
15
|
-
<chat-message-item
|
|
15
|
+
<im-chat-message-item
|
|
16
16
|
v-for="(message, index) in messages"
|
|
17
17
|
:key="message.id || index"
|
|
18
18
|
:position="message.position"
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
</template>
|
|
50
50
|
|
|
51
51
|
<script>
|
|
52
|
-
import
|
|
52
|
+
import ImChatMessageItem from '../im-chat-message-item/index.vue'
|
|
53
53
|
|
|
54
54
|
export default {
|
|
55
|
-
name: '
|
|
55
|
+
name: 'ImChatBox',
|
|
56
56
|
components: {
|
|
57
|
-
|
|
57
|
+
ImChatMessageItem
|
|
58
58
|
},
|
|
59
59
|
props: {
|
|
60
60
|
title: {
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="im-chat-item" :class="[`im-chat-item--${type}`]" @click="handleClick">
|
|
3
|
+
<view class="im-chat-item__avatar">
|
|
4
|
+
<view class="avatar-fallback">
|
|
5
|
+
<image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill" />
|
|
6
|
+
<text v-else class="avatar-text">{{ displayName }}</text>
|
|
7
|
+
</view>
|
|
8
|
+
</view>
|
|
9
|
+
<view class="im-chat-item__content">
|
|
10
|
+
<view class="im-chat-item__header">
|
|
11
|
+
<text class="im-chat-item__name">{{ name }}</text>
|
|
12
|
+
<text class="im-chat-item__time">{{ time }}</text>
|
|
13
|
+
</view>
|
|
14
|
+
<view class="im-chat-item__message">
|
|
15
|
+
<text class="im-chat-item__text">{{ lastMessage }}</text>
|
|
16
|
+
<view v-if="unreadCount > 0" class="badge-fallback">
|
|
17
|
+
<text class="badge-text">{{ displayUnreadCount }}</text>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</view>
|
|
21
|
+
</view>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup lang="ts">
|
|
25
|
+
import { computed } from 'vue'
|
|
26
|
+
|
|
27
|
+
// 设置组件名称(重要!)
|
|
28
|
+
defineOptions({
|
|
29
|
+
name: 'ImChatItem'
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
type?: 'default' | 'group'
|
|
34
|
+
avatar?: string
|
|
35
|
+
name: string
|
|
36
|
+
time: string
|
|
37
|
+
lastMessage: string
|
|
38
|
+
unreadCount?: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
42
|
+
type: 'default',
|
|
43
|
+
avatar: '',
|
|
44
|
+
unreadCount: 0
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
const emit = defineEmits<{
|
|
48
|
+
click: [event: any]
|
|
49
|
+
}>()
|
|
50
|
+
|
|
51
|
+
const displayName = computed(() => props.name.charAt(0))
|
|
52
|
+
const displayUnreadCount = computed(() =>
|
|
53
|
+
props.unreadCount > 99 ? '99+' : props.unreadCount
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const handleClick = (event: any) => {
|
|
57
|
+
console.log('🔍 uni 对象检查:', {
|
|
58
|
+
hasUni: typeof uni !== 'undefined',
|
|
59
|
+
hasShowToast: typeof uni?.showToast === 'function',
|
|
60
|
+
hasShowModal: typeof uni?.showModal === 'function'
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
try {
|
|
64
|
+
// 使用 showModal 替代 showToast 进行测试
|
|
65
|
+
uni.showModal({
|
|
66
|
+
title: '提示',
|
|
67
|
+
content: `点击了 ${props.name}`,
|
|
68
|
+
showCancel: false,
|
|
69
|
+
confirmText: '知道了'
|
|
70
|
+
})
|
|
71
|
+
console.log('✅ uni.showModal 调用成功')
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error('❌ uni API 调用失败:', error)
|
|
74
|
+
|
|
75
|
+
// 备用方案:在开发环境显示提示
|
|
76
|
+
if (typeof document !== 'undefined') {
|
|
77
|
+
alert(`点击了 ${props.name}`)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
emit('click', event)
|
|
82
|
+
}
|
|
83
|
+
</script>
|
|
84
|
+
|
|
85
|
+
<style lang="scss" scoped>
|
|
86
|
+
.im-chat-item {
|
|
87
|
+
display: flex;
|
|
88
|
+
padding: 24rpx 32rpx;
|
|
89
|
+
transition: background-color 0.3s;
|
|
90
|
+
border-bottom: 2rpx solid #f5f7fa;
|
|
91
|
+
|
|
92
|
+
&:active {
|
|
93
|
+
background-color: #f5f7fa;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
&__avatar {
|
|
97
|
+
margin-right: 24rpx;
|
|
98
|
+
|
|
99
|
+
.avatar-fallback {
|
|
100
|
+
width: 80rpx;
|
|
101
|
+
height: 80rpx;
|
|
102
|
+
border-radius: 50%;
|
|
103
|
+
background: linear-gradient(135deg, #409EFF, #67C23A);
|
|
104
|
+
display: flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
justify-content: center;
|
|
107
|
+
overflow: hidden;
|
|
108
|
+
|
|
109
|
+
.avatar-image {
|
|
110
|
+
width: 100%;
|
|
111
|
+
height: 100%;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.avatar-text {
|
|
115
|
+
color: white;
|
|
116
|
+
font-size: 32rpx;
|
|
117
|
+
font-weight: bold;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__content {
|
|
123
|
+
flex: 1;
|
|
124
|
+
min-width: 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
&__header {
|
|
128
|
+
display: flex;
|
|
129
|
+
justify-content: space-between;
|
|
130
|
+
align-items: center;
|
|
131
|
+
margin-bottom: 8rpx;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&__name {
|
|
135
|
+
font-size: 32rpx;
|
|
136
|
+
font-weight: 500;
|
|
137
|
+
color: #303133;
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
text-overflow: ellipsis;
|
|
140
|
+
white-space: nowrap;
|
|
141
|
+
flex: 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
&__time {
|
|
145
|
+
font-size: 24rpx;
|
|
146
|
+
color: #909399;
|
|
147
|
+
flex-shrink: 0;
|
|
148
|
+
margin-left: 16rpx;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&__message {
|
|
152
|
+
display: flex;
|
|
153
|
+
justify-content: space-between;
|
|
154
|
+
align-items: center;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
&__text {
|
|
158
|
+
font-size: 28rpx;
|
|
159
|
+
color: #606266;
|
|
160
|
+
overflow: hidden;
|
|
161
|
+
text-overflow: ellipsis;
|
|
162
|
+
white-space: nowrap;
|
|
163
|
+
flex: 1;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.badge-fallback {
|
|
167
|
+
background-color: #FA3534;
|
|
168
|
+
border-radius: 40rpx;
|
|
169
|
+
min-width: 36rpx;
|
|
170
|
+
height: 36rpx;
|
|
171
|
+
display: flex;
|
|
172
|
+
align-items: center;
|
|
173
|
+
justify-content: center;
|
|
174
|
+
margin-left: 16rpx;
|
|
175
|
+
|
|
176
|
+
.badge-text {
|
|
177
|
+
color: white;
|
|
178
|
+
font-size: 20rpx;
|
|
179
|
+
font-weight: bold;
|
|
180
|
+
padding: 0 8rpx;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/* 群聊样式 */
|
|
185
|
+
&--group &__name::before {
|
|
186
|
+
content: "👥 ";
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
</style>
|
package/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { App } from 'vue'
|
|
2
|
+
import ImChatItem from './components/im-chat-item/index.vue'
|
|
3
|
+
import ImChatMessageItem from './components/im-chat-message-item/index.vue'
|
|
4
|
+
import ImChatBox from './components/im-chat-box/index.vue'
|
|
5
|
+
|
|
6
|
+
export * from './libs'
|
|
7
|
+
export * from './utils'
|
|
8
|
+
|
|
9
|
+
// 重要:为组件添加名称,以支持开发环境
|
|
10
|
+
ImChatItem.name = 'ImChatItem'
|
|
11
|
+
ImChatMessageItem.name = 'ImChatMessageItem'
|
|
12
|
+
ImChatBox.name = 'ImChatBox'
|
|
13
|
+
|
|
14
|
+
const components = [
|
|
15
|
+
ImChatItem,
|
|
16
|
+
ImChatMessageItem,
|
|
17
|
+
ImChatBox
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
const install = (app: App): void => {
|
|
21
|
+
components.forEach(component => {
|
|
22
|
+
app.component(component.name!, component)
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// 导出组件
|
|
27
|
+
export {
|
|
28
|
+
ImChatItem,
|
|
29
|
+
ImChatMessageItem,
|
|
30
|
+
ImChatBox,
|
|
31
|
+
install
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default {
|
|
35
|
+
install
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "im-ui-mobile",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.ts",
|
|
6
7
|
"types": "types/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"components",
|
|
9
10
|
"libs",
|
|
10
11
|
"types",
|
|
11
12
|
"utils",
|
|
12
|
-
"index.
|
|
13
|
+
"index.ts"
|
|
13
14
|
],
|
|
14
15
|
"scripts": {
|
|
15
16
|
"dev": "cd examples && npm run dev:h5",
|
|
@@ -1,63 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
type: StringConstructor;
|
|
17
|
-
required: true;
|
|
18
|
-
};
|
|
19
|
-
lastMessage: {
|
|
20
|
-
type: StringConstructor;
|
|
21
|
-
required: true;
|
|
22
|
-
};
|
|
23
|
-
unreadCount: {
|
|
24
|
-
type: NumberConstructor;
|
|
25
|
-
default: number;
|
|
26
|
-
};
|
|
27
|
-
}>, {}, {}, {
|
|
28
|
-
displayName(): string;
|
|
29
|
-
displayUnreadCount(): number | "99+";
|
|
30
|
-
}, {
|
|
31
|
-
handleClick(): void;
|
|
32
|
-
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
|
-
type: {
|
|
34
|
-
type: StringConstructor;
|
|
35
|
-
default: string;
|
|
36
|
-
validator: (value: unknown) => boolean;
|
|
37
|
-
};
|
|
38
|
-
avatar: {
|
|
39
|
-
type: StringConstructor;
|
|
40
|
-
default: string;
|
|
41
|
-
};
|
|
42
|
-
name: {
|
|
43
|
-
type: StringConstructor;
|
|
44
|
-
required: true;
|
|
45
|
-
};
|
|
46
|
-
time: {
|
|
47
|
-
type: StringConstructor;
|
|
48
|
-
required: true;
|
|
49
|
-
};
|
|
50
|
-
lastMessage: {
|
|
51
|
-
type: StringConstructor;
|
|
52
|
-
required: true;
|
|
53
|
-
};
|
|
54
|
-
unreadCount: {
|
|
55
|
-
type: NumberConstructor;
|
|
56
|
-
default: number;
|
|
57
|
-
};
|
|
58
|
-
}>> & Readonly<{}>, {
|
|
1
|
+
interface Props {
|
|
2
|
+
type?: 'default' | 'group';
|
|
3
|
+
avatar?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
time: string;
|
|
6
|
+
lastMessage: string;
|
|
7
|
+
unreadCount?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
10
|
+
type: string;
|
|
11
|
+
avatar: string;
|
|
12
|
+
unreadCount: number;
|
|
13
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
click: (event: any) => void;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
59
16
|
type: string;
|
|
60
17
|
avatar: string;
|
|
61
18
|
unreadCount: number;
|
|
19
|
+
}>>> & Readonly<{
|
|
20
|
+
onClick?: ((event: any) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
type: "default" | "group";
|
|
23
|
+
avatar: string;
|
|
24
|
+
unreadCount: number;
|
|
62
25
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
63
26
|
export default _default;
|
|
27
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
28
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
30
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
31
|
+
} : {
|
|
32
|
+
type: import('vue').PropType<T[K]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type __VLS_WithDefaults<P, D> = {
|
|
37
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
38
|
+
default: D[K];
|
|
39
|
+
}> : P[K];
|
|
40
|
+
};
|
|
41
|
+
type __VLS_Prettify<T> = {
|
|
42
|
+
[K in keyof T]: T[K];
|
|
43
|
+
} & {};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
title: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
};
|
|
6
|
+
messages: {
|
|
7
|
+
type: ArrayConstructor;
|
|
8
|
+
default: () => never[];
|
|
9
|
+
};
|
|
10
|
+
placeholder: {
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
default: string;
|
|
13
|
+
};
|
|
14
|
+
maxlength: {
|
|
15
|
+
type: NumberConstructor;
|
|
16
|
+
default: number;
|
|
17
|
+
};
|
|
18
|
+
loading: {
|
|
19
|
+
type: BooleanConstructor;
|
|
20
|
+
default: boolean;
|
|
21
|
+
};
|
|
22
|
+
}>, {}, {
|
|
23
|
+
inputText: string;
|
|
24
|
+
}, {}, {
|
|
25
|
+
handleSend(): void;
|
|
26
|
+
shouldShowAvatar(message: any, index: any): any;
|
|
27
|
+
scrollToBottom(): void;
|
|
28
|
+
}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
29
|
+
title: {
|
|
30
|
+
type: StringConstructor;
|
|
31
|
+
default: string;
|
|
32
|
+
};
|
|
33
|
+
messages: {
|
|
34
|
+
type: ArrayConstructor;
|
|
35
|
+
default: () => never[];
|
|
36
|
+
};
|
|
37
|
+
placeholder: {
|
|
38
|
+
type: StringConstructor;
|
|
39
|
+
default: string;
|
|
40
|
+
};
|
|
41
|
+
maxlength: {
|
|
42
|
+
type: NumberConstructor;
|
|
43
|
+
default: number;
|
|
44
|
+
};
|
|
45
|
+
loading: {
|
|
46
|
+
type: BooleanConstructor;
|
|
47
|
+
default: boolean;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {
|
|
50
|
+
title: string;
|
|
51
|
+
messages: unknown[];
|
|
52
|
+
placeholder: string;
|
|
53
|
+
maxlength: number;
|
|
54
|
+
loading: boolean;
|
|
55
|
+
}, {}, {
|
|
56
|
+
ImChatMessageItem: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
57
|
+
position: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: string;
|
|
60
|
+
validator: (value: unknown) => boolean;
|
|
61
|
+
};
|
|
62
|
+
type: {
|
|
63
|
+
type: StringConstructor;
|
|
64
|
+
default: string;
|
|
65
|
+
validator: (value: unknown) => boolean;
|
|
66
|
+
};
|
|
67
|
+
content: {
|
|
68
|
+
type: StringConstructor;
|
|
69
|
+
required: true;
|
|
70
|
+
};
|
|
71
|
+
avatar: {
|
|
72
|
+
type: StringConstructor;
|
|
73
|
+
default: string;
|
|
74
|
+
};
|
|
75
|
+
showAvatar: {
|
|
76
|
+
type: BooleanConstructor;
|
|
77
|
+
default: boolean;
|
|
78
|
+
};
|
|
79
|
+
status: {
|
|
80
|
+
type: StringConstructor;
|
|
81
|
+
default: string;
|
|
82
|
+
validator: (value: unknown) => boolean;
|
|
83
|
+
};
|
|
84
|
+
duration: {
|
|
85
|
+
type: NumberConstructor;
|
|
86
|
+
default: number;
|
|
87
|
+
};
|
|
88
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
89
|
+
position: {
|
|
90
|
+
type: StringConstructor;
|
|
91
|
+
default: string;
|
|
92
|
+
validator: (value: unknown) => boolean;
|
|
93
|
+
};
|
|
94
|
+
type: {
|
|
95
|
+
type: StringConstructor;
|
|
96
|
+
default: string;
|
|
97
|
+
validator: (value: unknown) => boolean;
|
|
98
|
+
};
|
|
99
|
+
content: {
|
|
100
|
+
type: StringConstructor;
|
|
101
|
+
required: true;
|
|
102
|
+
};
|
|
103
|
+
avatar: {
|
|
104
|
+
type: StringConstructor;
|
|
105
|
+
default: string;
|
|
106
|
+
};
|
|
107
|
+
showAvatar: {
|
|
108
|
+
type: BooleanConstructor;
|
|
109
|
+
default: boolean;
|
|
110
|
+
};
|
|
111
|
+
status: {
|
|
112
|
+
type: StringConstructor;
|
|
113
|
+
default: string;
|
|
114
|
+
validator: (value: unknown) => boolean;
|
|
115
|
+
};
|
|
116
|
+
duration: {
|
|
117
|
+
type: NumberConstructor;
|
|
118
|
+
default: number;
|
|
119
|
+
};
|
|
120
|
+
}>> & Readonly<{}>, {
|
|
121
|
+
position: string;
|
|
122
|
+
type: string;
|
|
123
|
+
avatar: string;
|
|
124
|
+
showAvatar: boolean;
|
|
125
|
+
status: string;
|
|
126
|
+
duration: number;
|
|
127
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
128
|
+
}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
129
|
+
export default _default;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
type?: 'default' | 'group';
|
|
3
|
+
avatar?: string;
|
|
4
|
+
name: string;
|
|
5
|
+
time: string;
|
|
6
|
+
lastMessage: string;
|
|
7
|
+
unreadCount?: number;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
10
|
+
type: string;
|
|
11
|
+
avatar: string;
|
|
12
|
+
unreadCount: number;
|
|
13
|
+
}>>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
14
|
+
click: (event: any) => void;
|
|
15
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
16
|
+
type: string;
|
|
17
|
+
avatar: string;
|
|
18
|
+
unreadCount: number;
|
|
19
|
+
}>>> & Readonly<{
|
|
20
|
+
onClick?: ((event: any) => any) | undefined;
|
|
21
|
+
}>, {
|
|
22
|
+
type: "default" | "group";
|
|
23
|
+
avatar: string;
|
|
24
|
+
unreadCount: number;
|
|
25
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
export default _default;
|
|
27
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
28
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
29
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
30
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
31
|
+
} : {
|
|
32
|
+
type: import('vue').PropType<T[K]>;
|
|
33
|
+
required: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
type __VLS_WithDefaults<P, D> = {
|
|
37
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
38
|
+
default: D[K];
|
|
39
|
+
}> : P[K];
|
|
40
|
+
};
|
|
41
|
+
type __VLS_Prettify<T> = {
|
|
42
|
+
[K in keyof T]: T[K];
|
|
43
|
+
} & {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
2
|
+
position: {
|
|
3
|
+
type: StringConstructor;
|
|
4
|
+
default: string;
|
|
5
|
+
validator: (value: unknown) => boolean;
|
|
6
|
+
};
|
|
7
|
+
type: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: string;
|
|
10
|
+
validator: (value: unknown) => boolean;
|
|
11
|
+
};
|
|
12
|
+
content: {
|
|
13
|
+
type: StringConstructor;
|
|
14
|
+
required: true;
|
|
15
|
+
};
|
|
16
|
+
avatar: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
showAvatar: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
status: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: string;
|
|
27
|
+
validator: (value: unknown) => boolean;
|
|
28
|
+
};
|
|
29
|
+
duration: {
|
|
30
|
+
type: NumberConstructor;
|
|
31
|
+
default: number;
|
|
32
|
+
};
|
|
33
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
34
|
+
position: {
|
|
35
|
+
type: StringConstructor;
|
|
36
|
+
default: string;
|
|
37
|
+
validator: (value: unknown) => boolean;
|
|
38
|
+
};
|
|
39
|
+
type: {
|
|
40
|
+
type: StringConstructor;
|
|
41
|
+
default: string;
|
|
42
|
+
validator: (value: unknown) => boolean;
|
|
43
|
+
};
|
|
44
|
+
content: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
required: true;
|
|
47
|
+
};
|
|
48
|
+
avatar: {
|
|
49
|
+
type: StringConstructor;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
showAvatar: {
|
|
53
|
+
type: BooleanConstructor;
|
|
54
|
+
default: boolean;
|
|
55
|
+
};
|
|
56
|
+
status: {
|
|
57
|
+
type: StringConstructor;
|
|
58
|
+
default: string;
|
|
59
|
+
validator: (value: unknown) => boolean;
|
|
60
|
+
};
|
|
61
|
+
duration: {
|
|
62
|
+
type: NumberConstructor;
|
|
63
|
+
default: number;
|
|
64
|
+
};
|
|
65
|
+
}>> & Readonly<{}>, {
|
|
66
|
+
position: string;
|
|
67
|
+
type: string;
|
|
68
|
+
avatar: string;
|
|
69
|
+
showAvatar: boolean;
|
|
70
|
+
status: string;
|
|
71
|
+
duration: number;
|
|
72
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
73
|
+
export default _default;
|
package/types/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import ImChatItem from './components/im-chat-item/index.vue';
|
|
3
|
+
import ImChatMessageItem from './components/im-chat-message-item/index.vue';
|
|
4
|
+
import ImChatBox from './components/im-chat-box/index.vue';
|
|
5
|
+
export * from './libs';
|
|
6
|
+
export * from './utils';
|
|
7
|
+
declare const install: (app: App) => void;
|
|
8
|
+
export { ImChatItem, ImChatMessageItem, ImChatBox, install };
|
|
9
|
+
declare const _default: {
|
|
10
|
+
install: (app: App<any>) => void;
|
|
11
|
+
};
|
|
4
12
|
export default _default;
|
|
5
|
-
import ChatItem from './components/chat-item/index.vue';
|
|
6
|
-
import ChatMessageItem from './components/chat-message-item/index.vue';
|
|
7
|
-
import ChatBox from './components/chat-box/index.vue';
|
|
8
|
-
export function install(app: any): void;
|
|
9
|
-
export { ChatItem, ChatMessageItem, ChatBox };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="u-im-chat-item" :class="[`u-im-chat-item--${type}`]" @click="handleClick">
|
|
3
|
-
<view class="u-im-chat-item__avatar">
|
|
4
|
-
<!-- 替换 u-avatar -->
|
|
5
|
-
<view class="avatar-fallback">
|
|
6
|
-
<image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill" />
|
|
7
|
-
<text v-else class="avatar-text">{{ displayName }}</text>
|
|
8
|
-
</view>
|
|
9
|
-
</view>
|
|
10
|
-
<view class="u-im-chat-item__content">
|
|
11
|
-
<view class="u-im-chat-item__header">
|
|
12
|
-
<text class="u-im-chat-item__name">{{ name }}</text>
|
|
13
|
-
<text class="u-im-chat-item__time">{{ time }}</text>
|
|
14
|
-
</view>
|
|
15
|
-
<view class="u-im-chat-item__message">
|
|
16
|
-
<text class="u-im-chat-item__text">{{ lastMessage }}</text>
|
|
17
|
-
<!-- 替换 u-badge -->
|
|
18
|
-
<view v-if="unreadCount > 0" class="badge-fallback">
|
|
19
|
-
<text class="badge-text">{{ displayUnreadCount }}</text>
|
|
20
|
-
</view>
|
|
21
|
-
</view>
|
|
22
|
-
</view>
|
|
23
|
-
</view>
|
|
24
|
-
</template>
|
|
25
|
-
|
|
26
|
-
<script>
|
|
27
|
-
export default {
|
|
28
|
-
name: 'ChatItem',
|
|
29
|
-
props: {
|
|
30
|
-
type: {
|
|
31
|
-
type: String,
|
|
32
|
-
default: 'default',
|
|
33
|
-
validator: function (value) {
|
|
34
|
-
return ['default', 'group'].includes(value)
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
avatar: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: ''
|
|
40
|
-
},
|
|
41
|
-
name: {
|
|
42
|
-
type: String,
|
|
43
|
-
required: true
|
|
44
|
-
},
|
|
45
|
-
time: {
|
|
46
|
-
type: String,
|
|
47
|
-
required: true
|
|
48
|
-
},
|
|
49
|
-
lastMessage: {
|
|
50
|
-
type: String,
|
|
51
|
-
required: true
|
|
52
|
-
},
|
|
53
|
-
unreadCount: {
|
|
54
|
-
type: Number,
|
|
55
|
-
default: 0
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
computed: {
|
|
59
|
-
displayName() {
|
|
60
|
-
return this.name ? this.name.charAt(0) : ''
|
|
61
|
-
},
|
|
62
|
-
displayUnreadCount() {
|
|
63
|
-
return this.unreadCount > 99 ? '99+' : this.unreadCount
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
methods: {
|
|
67
|
-
handleClick() {
|
|
68
|
-
// 添加更多调试信息
|
|
69
|
-
try {
|
|
70
|
-
uni.showModal({
|
|
71
|
-
title: `点击了 ${this.name}`,
|
|
72
|
-
icon: 'none',
|
|
73
|
-
duration: 2000
|
|
74
|
-
})
|
|
75
|
-
console.log('✅ uni.showToast 调用成功')
|
|
76
|
-
} catch (error) {
|
|
77
|
-
console.error('❌ uni.showToast 调用失败:', error)
|
|
78
|
-
}
|
|
79
|
-
this.$emit('click')
|
|
80
|
-
},
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<style scoped>
|
|
86
|
-
.u-im-chat-item {
|
|
87
|
-
display: flex;
|
|
88
|
-
padding: 24rpx 32rpx;
|
|
89
|
-
transition: background-color 0.3s;
|
|
90
|
-
border-bottom: 2rpx solid #f5f7fa;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.u-im-chat-item:active {
|
|
94
|
-
background-color: #f5f7fa;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.u-im-chat-item__avatar {
|
|
98
|
-
margin-right: 24rpx;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.avatar-fallback {
|
|
102
|
-
width: 80rpx;
|
|
103
|
-
height: 80rpx;
|
|
104
|
-
border-radius: 50%;
|
|
105
|
-
background-color: #409EFF;
|
|
106
|
-
display: flex;
|
|
107
|
-
align-items: center;
|
|
108
|
-
justify-content: center;
|
|
109
|
-
overflow: hidden;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
.avatar-image {
|
|
113
|
-
width: 100%;
|
|
114
|
-
height: 100%;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
.avatar-text {
|
|
118
|
-
color: white;
|
|
119
|
-
font-size: 32rpx;
|
|
120
|
-
font-weight: bold;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.u-im-chat-item__content {
|
|
124
|
-
flex: 1;
|
|
125
|
-
min-width: 0;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
.u-im-chat-item__header {
|
|
129
|
-
display: flex;
|
|
130
|
-
justify-content: space-between;
|
|
131
|
-
align-items: center;
|
|
132
|
-
margin-bottom: 8rpx;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.u-im-chat-item__name {
|
|
136
|
-
font-size: 32rpx;
|
|
137
|
-
font-weight: 500;
|
|
138
|
-
color: #303133;
|
|
139
|
-
overflow: hidden;
|
|
140
|
-
text-overflow: ellipsis;
|
|
141
|
-
white-space: nowrap;
|
|
142
|
-
flex: 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
.u-im-chat-item__time {
|
|
146
|
-
font-size: 24rpx;
|
|
147
|
-
color: #909399;
|
|
148
|
-
flex-shrink: 0;
|
|
149
|
-
margin-left: 16rpx;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
.u-im-chat-item__message {
|
|
153
|
-
display: flex;
|
|
154
|
-
justify-content: space-between;
|
|
155
|
-
align-items: center;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
.u-im-chat-item__text {
|
|
159
|
-
font-size: 28rpx;
|
|
160
|
-
color: #606266;
|
|
161
|
-
overflow: hidden;
|
|
162
|
-
text-overflow: ellipsis;
|
|
163
|
-
white-space: nowrap;
|
|
164
|
-
flex: 1;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.badge-fallback {
|
|
168
|
-
background-color: #FA3534;
|
|
169
|
-
border-radius: 40rpx;
|
|
170
|
-
min-width: 36rpx;
|
|
171
|
-
height: 36rpx;
|
|
172
|
-
display: flex;
|
|
173
|
-
align-items: center;
|
|
174
|
-
justify-content: center;
|
|
175
|
-
margin-left: 16rpx;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
.badge-text {
|
|
179
|
-
color: white;
|
|
180
|
-
font-size: 20rpx;
|
|
181
|
-
font-weight: bold;
|
|
182
|
-
padding: 0 8rpx;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/* 群聊样式 */
|
|
186
|
-
.u-im-chat-item--group .u-im-chat-item__name::before {
|
|
187
|
-
content: "👥 ";
|
|
188
|
-
}
|
|
189
|
-
</style>
|
package/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import ChatItem from './components/chat-item/index.vue'
|
|
2
|
-
import ChatMessageItem from './components/chat-message-item/index.vue'
|
|
3
|
-
import ChatBox from './components/chat-box/index.vue'
|
|
4
|
-
|
|
5
|
-
// 重要:为组件添加名称,以支持开发环境
|
|
6
|
-
ChatItem.name = 'ChatItem'
|
|
7
|
-
ChatMessageItem.name = 'ChatMessageItem'
|
|
8
|
-
ChatBox.name = 'ChatBox'
|
|
9
|
-
|
|
10
|
-
const components = [
|
|
11
|
-
ChatItem,
|
|
12
|
-
ChatMessageItem,
|
|
13
|
-
ChatBox
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
const install = (app) => {
|
|
17
|
-
components.forEach(component => {
|
|
18
|
-
app.component(component.name || '', component)
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
ChatItem,
|
|
24
|
-
ChatMessageItem,
|
|
25
|
-
ChatBox,
|
|
26
|
-
install
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default {
|
|
30
|
-
install
|
|
31
|
-
}
|