@zjw-jszn/platform-imsdk 1.0.2 → 1.0.4
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/README.md +89 -16
- package/index.js +2 -0
- package/package.json +7 -12
package/README.md
CHANGED
|
@@ -1,30 +1,103 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zjw-jszn/platform-imsdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@zjw-jszn/platform-imsdk` 是平台侧接入包,在 `shared` 内核上固化平台模式并内置平台扩展 API。
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
- WebSocket controller:`Site`
|
|
7
|
-
- WebSocket platform:`site`
|
|
8
|
-
- 能力范围:基础会话能力 + 平台扩展接口(结束会话、客服会话、会话配置、AI 配置)
|
|
9
|
-
平台 API 文档:`docs/API/平台.md`
|
|
10
|
-
|
|
11
|
-
安装:
|
|
5
|
+
## 安装
|
|
12
6
|
|
|
13
7
|
```bash
|
|
14
8
|
pnpm add @zjw-jszn/platform-imsdk
|
|
15
9
|
```
|
|
16
10
|
|
|
17
|
-
|
|
11
|
+
## 导入
|
|
18
12
|
|
|
19
13
|
```ts
|
|
20
14
|
import { IMSDK } from '@zjw-jszn/platform-imsdk'
|
|
15
|
+
import type {
|
|
16
|
+
IMSDKConfig,
|
|
17
|
+
PlatformChatConfig,
|
|
18
|
+
PlatformCloseSessionParams,
|
|
19
|
+
PlatformPageResponse,
|
|
20
|
+
PlatformSession,
|
|
21
|
+
} from '@zjw-jszn/platform-imsdk'
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 平台模式默认值(自动注入)
|
|
25
|
+
|
|
26
|
+
| 配置项 | 固定值 |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| `api.prefix` | `/site/IM` |
|
|
29
|
+
| `api.userType` | `4` |
|
|
30
|
+
| `ws.controller` | `Site` |
|
|
31
|
+
| `ws.platform` | `site` |
|
|
32
|
+
|
|
33
|
+
> 以上字段以平台模式为准;外部覆盖会被忽略并打印告警。
|
|
34
|
+
|
|
35
|
+
## 初始化
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
type Controls = {
|
|
39
|
+
show: () => void
|
|
40
|
+
hide: () => void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
declare function init(config: IMSDKConfig): Promise<Controls>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 最小接入示例
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { IMSDK } from '@zjw-jszn/platform-imsdk'
|
|
50
|
+
import type { IMSDKConfig } from '@zjw-jszn/platform-imsdk'
|
|
51
|
+
|
|
52
|
+
const config: IMSDKConfig = {
|
|
53
|
+
phone: '18888888888',
|
|
54
|
+
api: {
|
|
55
|
+
baseURL: 'https://aox.api.orchiport.asia',
|
|
56
|
+
siteId: '6',
|
|
57
|
+
},
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const controls = await IMSDK.init(config)
|
|
61
|
+
controls.show()
|
|
62
|
+
```
|
|
21
63
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
64
|
+
## 平台扩展 API
|
|
65
|
+
|
|
66
|
+
### `getChatConfig`
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
declare function getChatConfig(): Promise<PlatformChatConfig>
|
|
25
70
|
```
|
|
26
71
|
|
|
27
|
-
|
|
72
|
+
### `closeSession`
|
|
28
73
|
|
|
29
|
-
|
|
30
|
-
|
|
74
|
+
```ts
|
|
75
|
+
declare function closeSession(data: PlatformCloseSessionParams): Promise<boolean>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
约束:`uid` 与 `session_id` 至少传一个。
|
|
79
|
+
|
|
80
|
+
### `getCustomerChatList`
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
declare function getCustomerChatList(data: {
|
|
84
|
+
page: number
|
|
85
|
+
limit: number
|
|
86
|
+
phone?: string
|
|
87
|
+
}): Promise<PlatformPageResponse<PlatformSession>>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## 配置约束
|
|
91
|
+
|
|
92
|
+
- 可配置 shared 通用项:`api.baseURL`、`api.siteId`、`sound`、`auth` 等。
|
|
93
|
+
- 外部传入 `runtimeApi.getChatConfig/closeSession/getCustomerChatList` 会被忽略(平台内置实现优先)。
|
|
94
|
+
- 已初始化后若尝试切换到门店模式,会抛错并提示刷新页面。
|
|
95
|
+
|
|
96
|
+
## 样式
|
|
97
|
+
|
|
98
|
+
样式由依赖链中的 shared 包自动注入,通常不需要手动引入。
|
|
99
|
+
如需手动控制加载时机:
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
import '@zjw-jszn/platform-imsdk/style.css'
|
|
103
|
+
```
|
package/index.js
ADDED
package/package.json
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zjw-jszn/platform-imsdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
5
|
-
"main": "./dist/platform-imsdk.umd.js",
|
|
6
|
-
"module": "./dist/platform-imsdk.es.js",
|
|
4
|
+
"version": "1.0.4",
|
|
7
5
|
"exports": {
|
|
8
6
|
".": {
|
|
9
|
-
"types":
|
|
10
|
-
|
|
11
|
-
"default": "./dist/index.d.ts"
|
|
12
|
-
},
|
|
13
|
-
"import": {
|
|
14
|
-
"development": "./src/index.ts",
|
|
15
|
-
"default": "./dist/platform-imsdk.es.js"
|
|
16
|
-
}
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./index.js"
|
|
17
9
|
},
|
|
18
10
|
"./style.css": "./style.css"
|
|
19
11
|
},
|
|
12
|
+
"main": "./dist/platform-imsdk.umd.js",
|
|
13
|
+
"module": "./index.js",
|
|
20
14
|
"types": "./dist/index.d.ts",
|
|
21
15
|
"files": [
|
|
22
16
|
"dist",
|
|
17
|
+
"index.js",
|
|
23
18
|
"style.css"
|
|
24
19
|
],
|
|
25
20
|
"publishConfig": {
|
|
@@ -27,7 +22,7 @@
|
|
|
27
22
|
"registry": "https://registry.npmjs.org/"
|
|
28
23
|
},
|
|
29
24
|
"dependencies": {
|
|
30
|
-
"@zjw-jszn/shared-imsdk": "1.0.
|
|
25
|
+
"@zjw-jszn/shared-imsdk": "1.0.4"
|
|
31
26
|
},
|
|
32
27
|
"devDependencies": {
|
|
33
28
|
"typescript": "~5.9.3",
|