mdm-im-v3 1.4.1 → 1.4.3

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/CHANGELOG.md CHANGED
@@ -39,3 +39,10 @@
39
39
  ## V1.4.1 2026-08-11
40
40
  - 发布mdm-im-v3@1.4.1版本
41
41
  1. 修改核心文件的调用方式,避免打包后无法正常使用。
42
+
43
+ ## V1.4.3 2026-08-11
44
+ - 发布mdm-im-v3@1.4.3版本
45
+ 1. 修改核心文件的导出方法及对象,方便查询IM的登录状态及消息未读数。
46
+
47
+ ## V1.4.2 2026-08-11
48
+ - 发布mdm-im-v3@1.4.2版本(已废弃:打包遗漏)
package/README.md CHANGED
@@ -63,12 +63,11 @@ const handleLogin = () => {
63
63
 
64
64
  ```js
65
65
  // ========== 步骤1:core/index.js — 应用入口处登录 IM ==========
66
- import { useMessage, useChatStore } from 'mdm-im-v3/core'
67
-
68
- const chatStore = useChatStore()
66
+ import { watch } from 'vue'
67
+ import { useMessage } from 'mdm-im-v3/core'
69
68
 
70
- // 传入配置参数,自动保存到 store
71
- const { initIMSDK, getUnReadMessageCount } = useMessage({
69
+ // 传入配置参数,自动保存到 store;同时解构出 loginStatus 用于监控
70
+ const { initIMSDK, getUnReadMessageCount, loginStatus, messageStore } = useMessage({
72
71
  userID: 'your-account', // 用户 ID,必填
73
72
  nickname: 'your-name', // 用户昵称
74
73
  faceURL: '', // 用户头像
@@ -83,16 +82,13 @@ const { initIMSDK, getUnReadMessageCount } = useMessage({
83
82
  // 初始化并登录
84
83
  await initIMSDK()
85
84
 
86
- // 监听登录状态,登录成功后获取未读数
87
- watch(
88
- () => chatStore.getLoginStatus,
89
- status => {
90
- if (status === 3) {
91
- // 从服务端获取未读消息总数
92
- getUnReadMessageCount(true)
93
- }
85
+ // 监控 IM 登录状态,登录成功后获取未读数
86
+ watch(loginStatus, status => {
87
+ if (status === 3) {
88
+ // 从服务端获取未读消息总数
89
+ getUnReadMessageCount(true)
94
90
  }
95
- )
91
+ })
96
92
  ```
97
93
 
98
94
  ```vue
@@ -199,7 +195,7 @@ chatRef.value.inviteUser('group-id-xxx', ['user1', 'user2'])
199
195
 
200
196
  ## `useMessage` API
201
197
 
202
- 从 `mdm-im-v3/core` 导入,用于手动管理 IM 生命周期:
198
+ 从 `mdm-im-v3/core` 导入,用于手动管理 IM 生命周期。该模块同时导出 `useMessage` 和 `useChatStore`:
203
199
 
204
200
  ```js
205
201
  import { useMessage, useChatStore } from 'mdm-im-v3/core'
@@ -240,6 +236,8 @@ const { initIMSDK, clearInstance, getUnReadMessageCount, setConversationMsgAsRea
240
236
 
241
237
  | 方法/属性 | 说明 |
242
238
  |-----------|------|
239
+ | `messageStore` | Pinia store 实例(`useChatStore()`),可直接访问所有 state/getters/actions |
240
+ | `loginStatus` | IM 登录状态的 `computed` 引用,便于外部 `watch` 监控。值:1-未登录,2-登录中,3-已登录 |
243
241
  | `initIMSDK()` | 初始化 SDK → 绑定所有 OpenIM 事件 → 登录。需先在 store 中设置 userID、imToken、apiUrl 等。返回 `Promise<void>`。 |
244
242
  | `clearInstance(bool)` | 解绑事件 → 登出 → 清除 SDK 实例。传入 `true` 时同时清空会话列表和 `window.imInstance`。 |
245
243
  | `getUnReadMessageCount(fromServer?)` | 获取未读消息总数。`fromServer=true` 从服务端获取,默认从本地会话列表累计。 |
@@ -250,7 +248,12 @@ const { initIMSDK, clearInstance, getUnReadMessageCount, setConversationMsgAsRea
250
248
 
251
249
  ## ChatStore
252
250
 
253
- 通过 `useChatStore()` 获取,是 Pinia store(id: `'chatMessage'`),**已开启 localStorage 持久化**,持久化字段包括:`userID`、`nickname`、`faceURL`、`platformID`、`apiUrl`、`wsUrl`、`tenantID`(`imToken` 和 `satoken` 仅保存在 Pinia 内存中,不持久化到本地存储)。
251
+ 从 `mdm-im-v3/core` 导入 `useChatStore` 后调用获取,是 Pinia store(id: `'chatMessage'`),**已开启 localStorage 持久化**,持久化字段包括:`userID`、`nickname`、`faceURL`、`platformID`、`apiUrl`、`wsUrl`、`tenantID`(`imToken` 和 `satoken` 仅保存在 Pinia 内存中,不持久化到本地存储)。
252
+
253
+ ```js
254
+ import { useChatStore } from 'mdm-im-v3/core'
255
+ const chatStore = useChatStore()
256
+ ```
254
257
 
255
258
  ### 常用 State
256
259
 
package/dist/core.es.js CHANGED
@@ -1,4 +1,6 @@
1
- import { H as a } from "./index-CKBF2vQ0.js";
1
+ import "vue";
2
+ import { u as o, H as r } from "./index-CeZkCy7e.js";
2
3
  export {
3
- a as useMessage
4
+ o as useChatStore,
5
+ r as useMessage
4
6
  };