im-ui-mobile 0.0.16 → 0.0.18

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.
@@ -1,18 +1,18 @@
1
1
  <template>
2
- <view class="im-chat-item" :class="[`im-chat-item--${type}`]" @click="handleClick">
3
- <view class="im-chat-item__avatar">
2
+ <view class="im-chat" :class="[`im-chat--${type}`]" @click="handleClick">
3
+ <view class="im-chat__avatar">
4
4
  <view class="avatar-fallback">
5
5
  <image v-if="avatar" :src="avatar" class="avatar-image" mode="aspectFill" />
6
6
  <text v-else class="avatar-text">{{ displayName }}</text>
7
7
  </view>
8
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>
9
+ <view class="im-chat__content">
10
+ <view class="im-chat__header">
11
+ <text class="im-chat__name">{{ name }}</text>
12
+ <text class="im-chat__time">{{ time }}</text>
13
13
  </view>
14
- <view class="im-chat-item__message">
15
- <text class="im-chat-item__text">{{ lastMessage }}</text>
14
+ <view class="im-chat__message">
15
+ <text class="im-chat__text">{{ lastMessage }}</text>
16
16
  <view v-if="unreadCount > 0" class="badge-fallback">
17
17
  <text class="badge-text">{{ displayUnreadCount }}</text>
18
18
  </view>
@@ -21,78 +21,80 @@
21
21
  </view>
22
22
  </template>
23
23
 
24
- <script setup>
25
- import { computed } from 'vue'
26
-
27
- // 设置组件名称(重要!)
28
- defineOptions({
29
- name: 'ImChatItem'
30
- })
31
-
32
- const props = defineProps({
33
- type: {
34
- type: String,
35
- default: 'default',
36
- validator: (value) => ['default', 'group'].includes(value)
37
- },
38
- avatar: {
39
- type: String,
40
- default: ''
41
- },
42
- name: {
43
- type: String,
44
- required: true
45
- },
46
- time: {
47
- type: String,
48
- required: true
24
+ <script>
25
+ export default {
26
+ name: 'ImChat',
27
+ props: {
28
+ type: {
29
+ type: String,
30
+ default: 'default',
31
+ validator: function (value) {
32
+ return ['default', 'group'].includes(value)
33
+ }
34
+ },
35
+ avatar: {
36
+ type: String,
37
+ default: ''
38
+ },
39
+ name: {
40
+ type: String,
41
+ required: true
42
+ },
43
+ time: {
44
+ type: String,
45
+ required: true
46
+ },
47
+ lastMessage: {
48
+ type: String,
49
+ required: true
50
+ },
51
+ unreadCount: {
52
+ type: Number,
53
+ default: 0
54
+ }
49
55
  },
50
- lastMessage: {
51
- type: String,
52
- required: true
56
+ computed: {
57
+ displayName() {
58
+ return this.name ? this.name.charAt(0) : ''
59
+ },
60
+ displayUnreadCount() {
61
+ return this.unreadCount > 99 ? '99+' : this.unreadCount
62
+ }
53
63
  },
54
- unreadCount: {
55
- type: Number,
56
- default: 0
57
- }
58
- })
59
-
60
- const emit = defineEmits(['click'])
61
-
62
- const displayName = computed(() => props.name.charAt(0))
63
- const displayUnreadCount = computed(() => props.unreadCount > 99 ? '99+' : props.unreadCount)
64
-
65
- const handleClick = (event) => {
66
- console.log('🔍 uni 对象检查:', {
67
- hasUni: typeof uni !== 'undefined',
68
- hasShowToast: typeof uni?.showToast === 'function',
69
- hasShowModal: typeof uni?.showModal === 'function'
70
- })
71
-
72
- try {
73
- // 使用 showModal 替代 showToast 进行测试
74
- uni.showModal({
75
- title: '提示',
76
- content: `点击了 ${props.name}`,
77
- showCancel: false,
78
- confirmText: '知道了'
79
- })
80
- console.log(' uni.showModal 调用成功')
81
- } catch (error) {
82
- console.error('❌ uni API 调用失败:', error)
83
-
84
- // 备用方案:在开发环境显示提示
85
- if (typeof document !== 'undefined') {
86
- alert(`点击了 ${props.name}`)
64
+ methods: {
65
+ handleClick(event) {
66
+ console.log('🔍 uni 对象检查:', {
67
+ hasUni: typeof uni !== 'undefined',
68
+ hasShowToast: typeof uni?.showToast === 'function',
69
+ hasShowModal: typeof uni?.showModal === 'function'
70
+ })
71
+
72
+ try {
73
+ // 使用 showModal 替代 showToast 进行测试
74
+ uni.showModal({
75
+ title: '提示',
76
+ content: `点击了 ${this.name}`,
77
+ showCancel: false,
78
+ confirmText: '知道了'
79
+ })
80
+ console.log('✅ uni.showModal 调用成功')
81
+ } catch (error) {
82
+ console.error('❌ uni API 调用失败:', error)
83
+
84
+ // 备用方案:在开发环境显示提示
85
+ if (typeof document !== 'undefined') {
86
+ alert(`点击了 ${this.name}`)
87
+ }
88
+ }
89
+
90
+ this.$emit('click', event)
87
91
  }
88
92
  }
89
-
90
- emit('click', event)
91
93
  }
92
94
  </script>
93
95
 
94
96
  <style lang="scss" scoped>
95
- .im-chat-item {
97
+ .im-chat {
96
98
  display: flex;
97
99
  padding: 24rpx 32rpx;
98
100
  transition: background-color 0.3s;
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ import ImChat from './components/im-chat/im-chat.vue'
2
+
3
+ // 重要:为组件添加名称,以支持开发环境
4
+ ImChat.name = 'ImChat'
5
+
6
+ const components = [
7
+ ImChat
8
+ ]
9
+
10
+ const install = (app) => {
11
+ components.forEach(component => {
12
+ app.component(component.name || '', component)
13
+ })
14
+ }
15
+
16
+ export default {
17
+ install
18
+ }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "im-ui-mobile",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
5
  "type": "module",
6
- "main": "index.ts",
6
+ "main": "index.js",
7
7
  "types": "types/index.d.ts",
8
8
  "files": [
9
9
  "components",
10
10
  "libs",
11
11
  "types",
12
12
  "utils",
13
- "index.ts"
13
+ "index.js"
14
14
  ],
15
15
  "scripts": {
16
- "dev": "cd examples && npm run dev:mp-weixin",
16
+ "wx": "cd examples && npm run dev:mp-weixin",
17
17
  "h5": "cd examples && npm run dev:h5",
18
18
  "build": "npm run build:types",
19
19
  "build:types": "vue-tsc -p tsconfig.build.json",
@@ -0,0 +1,9 @@
1
+ export interface AllowedComponentProps {
2
+ class?: unknown;
3
+ style?: unknown;
4
+ }
5
+
6
+ export interface VNodeProps {
7
+ key?: string | number | symbol;
8
+ ref?: unknown;
9
+ }
@@ -0,0 +1,104 @@
1
+ import { AllowedComponentProps, VNodeProps } from './_common'
2
+
3
+ declare interface ChatProps {
4
+ type: {
5
+ type: StringConstructor;
6
+ default: string;
7
+ validator: (value: unknown) => boolean;
8
+ };
9
+ avatar: {
10
+ type: StringConstructor;
11
+ default: string;
12
+ };
13
+ name: {
14
+ type: StringConstructor;
15
+ required: true;
16
+ };
17
+ time: {
18
+ type: StringConstructor;
19
+ required: true;
20
+ };
21
+ lastMessage: {
22
+ type: StringConstructor;
23
+ required: true;
24
+ };
25
+ unreadCount: {
26
+ type: NumberConstructor;
27
+ default: number;
28
+ };
29
+ }
30
+
31
+ declare interface _Chat {
32
+ new(): {
33
+ $props: AllowedComponentProps &
34
+ VNodeProps &
35
+ ChatProps
36
+ }
37
+ }
38
+
39
+ export declare const Chat: _Chat
40
+
41
+
42
+ // declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
43
+ // type: {
44
+ // type: StringConstructor;
45
+ // default: string;
46
+ // validator: (value: unknown) => boolean;
47
+ // };
48
+ // avatar: {
49
+ // type: StringConstructor;
50
+ // default: string;
51
+ // };
52
+ // name: {
53
+ // type: StringConstructor;
54
+ // required: true;
55
+ // };
56
+ // time: {
57
+ // type: StringConstructor;
58
+ // required: true;
59
+ // };
60
+ // lastMessage: {
61
+ // type: StringConstructor;
62
+ // required: true;
63
+ // };
64
+ // unreadCount: {
65
+ // type: NumberConstructor;
66
+ // default: number;
67
+ // };
68
+ // }>, {}, {}, {
69
+ // displayName(): string;
70
+ // displayUnreadCount(): number | "99+";
71
+ // }, {
72
+ // handleClick(event: any): void;
73
+ // }, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
74
+ // type: {
75
+ // type: StringConstructor;
76
+ // default: string;
77
+ // validator: (value: unknown) => boolean;
78
+ // };
79
+ // avatar: {
80
+ // type: StringConstructor;
81
+ // default: string;
82
+ // };
83
+ // name: {
84
+ // type: StringConstructor;
85
+ // required: true;
86
+ // };
87
+ // time: {
88
+ // type: StringConstructor;
89
+ // required: true;
90
+ // };
91
+ // lastMessage: {
92
+ // type: StringConstructor;
93
+ // required: true;
94
+ // };
95
+ // unreadCount: {
96
+ // type: NumberConstructor;
97
+ // default: number;
98
+ // };
99
+ // }>> & Readonly<{}>, {
100
+ // type: string;
101
+ // avatar: string;
102
+ // unreadCount: number;
103
+ // }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
104
+ // export default _default;
@@ -1,18 +1,63 @@
1
- declare const _default: import("vue").DefineComponent<{}, {
2
- $emit: (event: "click", ...args: any[]) => void;
3
- name: string;
1
+ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ type: {
3
+ type: StringConstructor;
4
+ default: string;
5
+ validator: (value: unknown) => boolean;
6
+ };
7
+ avatar: {
8
+ type: StringConstructor;
9
+ default: string;
10
+ };
11
+ name: {
12
+ type: StringConstructor;
13
+ required: true;
14
+ };
15
+ time: {
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(event: any): 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<{}>, {
4
59
  type: string;
5
60
  avatar: string;
6
- time: string;
7
- lastMessage: string;
8
61
  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>;
62
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
18
63
  export default _default;
@@ -0,0 +1,7 @@
1
+ declare module 'vue' {
2
+ export interface GlobalComponents {
3
+ ['im-chat']: typeof import('./components/chat')['Chat']
4
+ }
5
+ }
6
+
7
+ export { }
package/types/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- import { App } from 'vue';
2
- import ImChat from './components/im-chat/im-chat.vue';
3
- export * from './libs';
4
- export * from './utils';
5
- declare const install: (app: App) => void;
6
- export { ImChat, install };
7
- declare const _default: {
8
- install: (app: App<any>) => void;
9
- };
1
+ declare namespace _default {
2
+ export { install };
3
+ }
10
4
  export default _default;
5
+ declare function install(app: any): void;
@@ -0,0 +1,20 @@
1
+ {
2
+ "name": "@im-ui-mobile/types",
3
+ "version": "0.0.18",
4
+ "description": "A Vue3.0 + typescript instant messaging component library for Uniapp",
5
+ "main": "index.d.ts",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": ""
12
+ },
13
+ "keywords": [
14
+ "im-ui-mobile"
15
+ ],
16
+ "types": "./index.d.ts",
17
+ "publishConfig": {
18
+ "registry": "https://registry.npmjs.org/"
19
+ }
20
+ }
package/index.ts DELETED
@@ -1,36 +0,0 @@
1
- import { App } from '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
-
6
- export * from './libs'
7
- export * from './utils'
8
-
9
- // 重要:为组件添加名称,以支持开发环境
10
- ImChat.name = 'ImChat'
11
- // ImChatMessageItem.name = 'ImChatMessageItem'
12
- // ImChatBox.name = 'ImChatBox'
13
-
14
- const components = [
15
- ImChat,
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
- ImChat,
29
- // ImChatMessageItem,
30
- // ImChatBox,
31
- install
32
- }
33
-
34
- export default {
35
- install
36
- }
@@ -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
- 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;
@@ -1,18 +0,0 @@
1
- declare const _default: import("vue").DefineComponent<{}, {
2
- $emit: (event: "click", ...args: any[]) => void;
3
- type: string;
4
- avatar: string;
5
- name: string;
6
- time: string;
7
- lastMessage: string;
8
- unreadCount: number;
9
- $props: {
10
- readonly type?: string | undefined;
11
- readonly avatar?: string | undefined;
12
- readonly name?: 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;
@@ -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;