im-ui-mobile 0.0.13 → 0.0.15

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/index.ts CHANGED
@@ -1,20 +1,20 @@
1
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'
2
+ import ImChat from './components/im-chat/im-chat.vue'
3
+ // import ImChatMessageItem from './components/im-chat-message-item/im-chat-message-item.vue'
4
+ // import ImChatBox from './components/im-chat-box/im-chat-box.vue'
5
5
 
6
6
  export * from './libs'
7
7
  export * from './utils'
8
8
 
9
9
  // 重要:为组件添加名称,以支持开发环境
10
- ImChatItem.name = 'ImChatItem'
11
- ImChatMessageItem.name = 'ImChatMessageItem'
12
- ImChatBox.name = 'ImChatBox'
10
+ ImChat.name = 'ImChatItem'
11
+ // ImChatMessageItem.name = 'ImChatMessageItem'
12
+ // ImChatBox.name = 'ImChatBox'
13
13
 
14
14
  const components = [
15
- ImChatItem,
16
- ImChatMessageItem,
17
- ImChatBox
15
+ ImChat,
16
+ // ImChatMessageItem,
17
+ // ImChatBox
18
18
  ]
19
19
 
20
20
  const install = (app: App): void => {
@@ -25,9 +25,9 @@ const install = (app: App): void => {
25
25
 
26
26
  // 导出组件
27
27
  export {
28
- ImChatItem,
29
- ImChatMessageItem,
30
- ImChatBox,
28
+ ImChat as ImChatItem,
29
+ // ImChatMessageItem,
30
+ // ImChatBox,
31
31
  install
32
32
  }
33
33
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "im-ui-mobile",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -13,7 +13,7 @@
13
13
  "index.ts"
14
14
  ],
15
15
  "scripts": {
16
- "dev": "cd examples && npm run dev:h5",
16
+ "dev": "cd examples && npm run dev:mp-weixin",
17
17
  "build": "npm run build:types",
18
18
  "build:types": "vue-tsc -p tsconfig.build.json",
19
19
  "clean:types": "rmdir /s /q src/types 2>nul # '删除 types 目录'",
@@ -0,0 +1,18 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ $emit: (event: "click", ...args: any[]) => void;
3
+ name: string;
4
+ type: string;
5
+ avatar: string;
6
+ time: string;
7
+ lastMessage: string;
8
+ unreadCount: number;
9
+ $props: {
10
+ readonly name?: string | undefined;
11
+ readonly type?: string | undefined;
12
+ readonly avatar?: string | undefined;
13
+ readonly time?: string | undefined;
14
+ readonly lastMessage?: string | undefined;
15
+ readonly unreadCount?: number | undefined;
16
+ };
17
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
+ export default _default;
package/types/index.d.ts CHANGED
@@ -1,11 +1,9 @@
1
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';
2
+ import ImChat from './components/im-chat/im-chat.vue';
5
3
  export * from './libs';
6
4
  export * from './utils';
7
5
  declare const install: (app: App) => void;
8
- export { ImChatItem, ImChatMessageItem, ImChatBox, install };
6
+ export { ImChat as ImChatItem, install };
9
7
  declare const _default: {
10
8
  install: (app: App<any>) => void;
11
9
  };
@@ -1,203 +0,0 @@
1
- <template>
2
- <view class="u-im-chat-box">
3
- <view class="u-im-chat-box__header">
4
- <view class="u-im-chat-box__title">{{ title }}</view>
5
- <view class="u-im-chat-box__actions">
6
- <slot name="header-actions"></slot>
7
- </view>
8
- </view>
9
-
10
- <view class="u-im-chat-box__messages" ref="messagesRef">
11
- <view class="u-im-chat-box__loading" v-if="loading">
12
- <!-- 替换 uview 组件 -->
13
- <view class="loading-icon">加载中...</view>
14
- </view>
15
- <im-chat-message-item
16
- v-for="(message, index) in messages"
17
- :key="message.id || index"
18
- :position="message.position"
19
- :type="message.type"
20
- :content="message.content"
21
- :avatar="message.avatar"
22
- :show-avatar="shouldShowAvatar(message, index)"
23
- :status="message.status"
24
- :duration="message.duration"
25
- />
26
- </view>
27
-
28
- <view class="u-im-chat-box__input">
29
- <view class="u-im-chat-box__tools">
30
- <slot name="input-tools"></slot>
31
- </view>
32
- <view class="u-im-chat-box__textarea">
33
- <!-- 替换 u-textarea -->
34
- <textarea
35
- v-model="inputText"
36
- :placeholder="placeholder"
37
- :maxlength="maxlength"
38
- :auto-height="true"
39
- @confirm="handleSend"
40
- class="chat-textarea"
41
- />
42
- </view>
43
- <view class="u-im-chat-box__send">
44
- <!-- 替换 u-button -->
45
- <button type="primary" size="mini" @click="handleSend" class="send-button">发送</button>
46
- </view>
47
- </view>
48
- </view>
49
- </template>
50
-
51
- <script>
52
- import ImChatMessageItem from '../im-chat-message-item/index.vue'
53
-
54
- export default {
55
- name: 'ImChatBox',
56
- components: {
57
- ImChatMessageItem
58
- },
59
- props: {
60
- title: {
61
- type: String,
62
- default: '聊天'
63
- },
64
- messages: {
65
- type: Array,
66
- default: () => []
67
- },
68
- placeholder: {
69
- type: String,
70
- default: '请输入消息...'
71
- },
72
- maxlength: {
73
- type: Number,
74
- default: 1000
75
- },
76
- loading: {
77
- type: Boolean,
78
- default: false
79
- }
80
- },
81
- data() {
82
- return {
83
- inputText: ''
84
- }
85
- },
86
- watch: {
87
- messages: {
88
- handler() {
89
- this.scrollToBottom()
90
- },
91
- deep: true
92
- }
93
- },
94
- mounted() {
95
- this.scrollToBottom()
96
- },
97
- methods: {
98
- handleSend() {
99
- if (this.inputText.trim()) {
100
- this.$emit('send', this.inputText.trim())
101
- this.inputText = ''
102
- }
103
- },
104
- shouldShowAvatar(message, index) {
105
- if (index === 0) return true
106
- const prevMessage = this.messages[index - 1]
107
- return prevMessage.position !== message.position ||
108
- prevMessage.avatar !== message.avatar ||
109
- (message.timestamp && prevMessage.timestamp &&
110
- message.timestamp - prevMessage.timestamp > 300000) // 5分钟
111
- },
112
- scrollToBottom() {
113
- this.$nextTick(() => {
114
- if (this.$refs.messagesRef) {
115
- this.$refs.messagesRef.scrollTop = this.$refs.messagesRef.scrollHeight
116
- }
117
- })
118
- }
119
- }
120
- }
121
- </script>
122
-
123
- <style scoped>
124
- .u-im-chat-box {
125
- display: flex;
126
- flex-direction: column;
127
- height: 1200rpx;
128
- border: 2rpx solid #e4e7ed;
129
- border-radius: 16rpx;
130
- overflow: hidden;
131
- }
132
-
133
- .u-im-chat-box__header {
134
- display: flex;
135
- justify-content: space-between;
136
- align-items: center;
137
- padding: 24rpx 32rpx;
138
- background-color: #f5f7fa;
139
- border-bottom: 2rpx solid #e4e7ed;
140
- }
141
-
142
- .u-im-chat-box__title {
143
- font-size: 32rpx;
144
- font-weight: 500;
145
- color: #303133;
146
- }
147
-
148
- .u-im-chat-box__messages {
149
- flex: 1;
150
- padding: 32rpx;
151
- overflow-y: auto;
152
- background-color: #fafafa;
153
- }
154
-
155
- .u-im-chat-box__loading {
156
- display: flex;
157
- justify-content: center;
158
- padding: 32rpx;
159
- }
160
-
161
- .loading-icon {
162
- font-size: 28rpx;
163
- color: #909399;
164
- }
165
-
166
- .u-im-chat-box__input {
167
- border-top: 2rpx solid #e4e7ed;
168
- background-color: #fff;
169
- }
170
-
171
- .u-im-chat-box__tools {
172
- padding: 16rpx 32rpx;
173
- border-bottom: 2rpx solid #e4e7ed;
174
- }
175
-
176
- .u-im-chat-box__textarea {
177
- padding: 24rpx 32rpx;
178
- }
179
-
180
- .chat-textarea {
181
- width: 100%;
182
- min-height: 80rpx;
183
- padding: 16rpx;
184
- border: 2rpx solid #dcdfe6;
185
- border-radius: 8rpx;
186
- font-size: 28rpx;
187
- background-color: #fff;
188
- }
189
-
190
- .u-im-chat-box__send {
191
- padding: 0 32rpx 24rpx;
192
- text-align: right;
193
- }
194
-
195
- .send-button {
196
- background-color: #409EFF;
197
- color: #fff;
198
- border: none;
199
- border-radius: 8rpx;
200
- padding: 16rpx 32rpx;
201
- font-size: 28rpx;
202
- }
203
- </style>
@@ -1,205 +0,0 @@
1
- <template>
2
- <view class="u-im-message-item" :class="[`u-im-message-item--${position}`]">
3
- <view class="u-im-message-item__avatar" v-if="showAvatar">
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">U</text>
8
- </view>
9
- </view>
10
- <view class="u-im-message-item__content">
11
- <view class="u-im-message-item__bubble" :class="[`u-im-message-item__bubble--${type}`]">
12
- <text v-if="type === 'text'" class="u-im-message-item__text">
13
- {{ content }}
14
- </text>
15
- <view v-else-if="type === 'image'" class="u-im-message-item__image">
16
- <!-- 替换 u-image -->
17
- <image :src="content" class="image-fallback" mode="aspectFill" />
18
- </view>
19
- <view v-else-if="type === 'voice'" class="u-im-message-item__voice">
20
- <!-- 替换 u-icon -->
21
- <text class="voice-icon">▶</text>
22
- <text class="u-im-message-item__duration">{{ duration }}''</text>
23
- </view>
24
- </view>
25
- <view class="u-im-message-item__status" v-if="position === 'right'">
26
- <!-- 替换 u-icon -->
27
- <text v-if="status === 'sending'" class="status-icon sending">⏳</text>
28
- <text v-else-if="status === 'success'" class="status-icon success">✓</text>
29
- <text v-else-if="status === 'failed'" class="status-icon failed">✗</text>
30
- </view>
31
- </view>
32
- </view>
33
- </template>
34
-
35
- <script>
36
- export default {
37
- name: 'ImChatMessageItem',
38
- props: {
39
- position: {
40
- type: String,
41
- default: 'left',
42
- validator: function (value) {
43
- return ['left', 'right'].includes(value)
44
- }
45
- },
46
- type: {
47
- type: String,
48
- default: 'text',
49
- validator: function (value) {
50
- return ['text', 'image', 'voice', 'file'].includes(value)
51
- }
52
- },
53
- content: {
54
- type: String,
55
- required: true
56
- },
57
- avatar: {
58
- type: String,
59
- default: ''
60
- },
61
- showAvatar: {
62
- type: Boolean,
63
- default: true
64
- },
65
- status: {
66
- type: String,
67
- default: 'success',
68
- validator: function (value) {
69
- return ['sending', 'success', 'failed'].includes(value)
70
- }
71
- },
72
- duration: {
73
- type: Number,
74
- default: 0
75
- }
76
- }
77
- }
78
- </script>
79
-
80
- <style scoped>
81
- .u-im-message-item {
82
- display: flex;
83
- margin-bottom: 32rpx;
84
- }
85
-
86
- .u-im-message-item--left {
87
- justify-content: flex-start;
88
- }
89
-
90
- .u-im-message-item--right {
91
- justify-content: flex-end;
92
- }
93
-
94
- .u-im-message-item--right .u-im-message-item__content {
95
- flex-direction: row-reverse;
96
- }
97
-
98
- .u-im-message-item__avatar {
99
- margin: 0 16rpx;
100
- align-self: flex-end;
101
- }
102
-
103
- .avatar-fallback {
104
- width: 64rpx;
105
- height: 64rpx;
106
- border-radius: 50%;
107
- background-color: #67C23A;
108
- display: flex;
109
- align-items: center;
110
- justify-content: center;
111
- overflow: hidden;
112
- }
113
-
114
- .avatar-image {
115
- width: 100%;
116
- height: 100%;
117
- }
118
-
119
- .avatar-text {
120
- color: white;
121
- font-size: 24rpx;
122
- }
123
-
124
- .u-im-message-item__content {
125
- display: flex;
126
- align-items: flex-end;
127
- max-width: 70%;
128
- }
129
-
130
- .u-im-message-item__bubble {
131
- padding: 16rpx 24rpx;
132
- border-radius: 16rpx;
133
- position: relative;
134
- max-width: 100%;
135
- }
136
-
137
- .u-im-message-item__bubble--text {
138
- background-color: #f0f2f5;
139
- color: #303133;
140
- }
141
-
142
- .u-im-message-item--right .u-im-message-item__bubble--text {
143
- background-color: #409eff;
144
- color: #fff;
145
- }
146
-
147
- .u-im-message-item__image {
148
- border-radius: 8rpx;
149
- overflow: hidden;
150
- }
151
-
152
- .image-fallback {
153
- width: 400rpx;
154
- height: 300rpx;
155
- }
156
-
157
- .u-im-message-item__voice {
158
- display: flex;
159
- align-items: center;
160
- gap: 16rpx;
161
- padding: 16rpx 32rpx;
162
- background-color: #f0f2f5;
163
- border-radius: 32rpx;
164
- }
165
-
166
- .u-im-message-item--right .u-im-message-item__voice {
167
- background-color: #409eff;
168
- color: #fff;
169
- }
170
-
171
- .u-im-message-item__text {
172
- word-break: break-word;
173
- line-height: 1.4;
174
- }
175
-
176
- .voice-icon {
177
- font-size: 32rpx;
178
- }
179
-
180
- .u-im-message-item__duration {
181
- font-size: 24rpx;
182
- }
183
-
184
- .u-im-message-item__status {
185
- margin: 0 8rpx;
186
- display: flex;
187
- align-items: center;
188
- }
189
-
190
- .status-icon {
191
- font-size: 28rpx;
192
- }
193
-
194
- .status-icon.sending {
195
- color: #909399;
196
- }
197
-
198
- .status-icon.success {
199
- color: #67C23A;
200
- }
201
-
202
- .status-icon.failed {
203
- color: #F56C6C;
204
- }
205
- </style>
@@ -1,129 +0,0 @@
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
- ChatMessageItem: 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;
@@ -1,43 +0,0 @@
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
- } & {};
@@ -1,73 +0,0 @@
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;