@zjw-jszn/shared-imsdk 1.0.9 → 1.0.10
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 +18 -0
- package/dist/api/index.d.ts +4 -0
- package/dist/config/index.d.ts +44 -0
- package/dist/shared-imsdk.css +90 -90
- package/dist/shared-imsdk.es.js +260 -42
- package/dist/shared-imsdk.umd.cjs +260 -42
- package/dist/types/index.d.ts +21 -0
- package/dist/utils/websocket.d.ts +10 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,7 @@ const config: IMSDKConfig = {
|
|
|
51
51
|
siteId: '6',
|
|
52
52
|
},
|
|
53
53
|
ws: {
|
|
54
|
+
url: 'wss://aox.api.orchiport.asia',
|
|
54
55
|
controller: 'Site',
|
|
55
56
|
platform: 'site',
|
|
56
57
|
},
|
|
@@ -66,12 +67,27 @@ controls.show()
|
|
|
66
67
|
| --- | --- |
|
|
67
68
|
| `phone` | 首次鉴权必填(无 token 场景) |
|
|
68
69
|
| `api.baseURL` | HTTP 基础地址(默认 `https://aox.api.orchiport.asia`) |
|
|
70
|
+
| `api.resourceBaseURL` | 资源基础地址(默认 `https://resource.api.orchiport.asia`,用于补全上传图片相对路径) |
|
|
71
|
+
| `api.uploadURL` | 上传接口地址(默认 `https://resource.api.orchiport.asia/system/uploadImage`) |
|
|
69
72
|
| `api.prefix` | API 前缀,`shared` 模式下必须显式传入 |
|
|
70
73
|
| `api.siteId` | 站点 ID,用于鉴权后 WS 连接 |
|
|
74
|
+
| `ws.url` | WebSocket 地址(可选;未传时会基于 `api.baseURL` 自动推导) |
|
|
71
75
|
| `ws.controller` | WebSocket 控制器,必须显式传入 |
|
|
72
76
|
| `ws.platform` | 平台标识,必须为小写,且等于 `controller.toLowerCase()` |
|
|
77
|
+
| `ws.reconnectInterval` | 自动重连间隔(毫秒,默认 `3000`) |
|
|
78
|
+
| `ws.heartbeatInterval` | 心跳间隔(毫秒,默认 `3000`) |
|
|
79
|
+
| `ws.maxReconnectAttempts` | 最大自动重连次数(默认 `5`) |
|
|
80
|
+
| `ws.connectTimeout` | 连接超时(毫秒,默认 `30000`) |
|
|
81
|
+
| `ws.traceEnabled` | 是否输出 WS Trace 日志(默认 `false`) |
|
|
82
|
+
| `ws.protocol.controller` | 协议控制器(可选,默认跟随 `ws.controller`) |
|
|
83
|
+
| `ws.protocol.action.send` | 发送消息动作名映射(默认 `send`) |
|
|
84
|
+
| `ws.protocol.action.msgRead` | 已读动作名映射(默认 `msgRead`) |
|
|
85
|
+
| `ws.protocol.action.onConnect` | 上线动作名映射(默认 `onConnect`) |
|
|
86
|
+
| `ws.protocol.action.offLine` | 离线动作名映射(默认 `offLine`) |
|
|
87
|
+
| `ws.protocol.action.heartbeat` | 心跳动作名映射(默认 `heartbeat`) |
|
|
73
88
|
| `sound` | 消息提示音开关与地址 |
|
|
74
89
|
| `auth.authorizationPayload` | 鉴权扩展参数透传 |
|
|
90
|
+
| `chat.platformServicePhone` | 平台客服默认手机号 |
|
|
75
91
|
| `runtimeApi` | 运行时扩展接口(`getChatConfig/closeSession/getCustomerChatList`) |
|
|
76
92
|
|
|
77
93
|
## 常用导出
|
|
@@ -96,8 +112,10 @@ import {
|
|
|
96
112
|
- 缺少 `api.prefix` 会抛错。
|
|
97
113
|
- 缺少 `ws.controller` 或 `ws.platform` 会抛错。
|
|
98
114
|
- `ws.platform` 必须小写,且需与 `ws.controller.toLowerCase()` 一致。
|
|
115
|
+
- 未传 `ws.url` 时,SDK 会优先使用 `api.baseURL` 推导 WS 地址(`https -> wss`,`http -> ws`)。
|
|
99
116
|
- 首次初始化且无 token 时,必须传 `phone`。
|
|
100
117
|
- 已以某模式初始化后,不允许在同页面切换到另一模式。
|
|
118
|
+
- 调用 `getChatList` 且参数为 `friend_type=4` + `customeronly=1/true` 时,如未传 `phone`,会自动回落到 `chat.platformServicePhone`。
|
|
101
119
|
|
|
102
120
|
## 样式
|
|
103
121
|
|
package/dist/api/index.d.ts
CHANGED
|
@@ -152,6 +152,8 @@ export declare function getChatRewordBySession(data: {
|
|
|
152
152
|
* @param data.session_id - 会话ID
|
|
153
153
|
* @param data.user_type - 用户类型
|
|
154
154
|
* @param data.msg_type - 消息类型
|
|
155
|
+
* @param data.friend_type - 对话对象类型
|
|
156
|
+
* @param data.customeronly - 平台客服模式标记(1/true)
|
|
155
157
|
*/
|
|
156
158
|
export declare function getChatList(data: {
|
|
157
159
|
page: number;
|
|
@@ -161,4 +163,6 @@ export declare function getChatList(data: {
|
|
|
161
163
|
session_id?: string;
|
|
162
164
|
user_type?: number;
|
|
163
165
|
msg_type?: number;
|
|
166
|
+
friend_type?: number;
|
|
167
|
+
customeronly?: number | string | boolean;
|
|
164
168
|
}): Promise<PageResponse<Message>>;
|
package/dist/config/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
export interface SDKConfig {
|
|
5
5
|
api: {
|
|
6
6
|
baseURL: string;
|
|
7
|
+
resourceBaseURL: string;
|
|
7
8
|
prefix: string;
|
|
8
9
|
uploadURL: string;
|
|
9
10
|
signKey: string;
|
|
@@ -14,8 +15,25 @@ export interface SDKConfig {
|
|
|
14
15
|
userType?: number;
|
|
15
16
|
};
|
|
16
17
|
ws: {
|
|
18
|
+
url: string;
|
|
17
19
|
controller: string;
|
|
18
20
|
platform: string;
|
|
21
|
+
reconnectInterval: number;
|
|
22
|
+
heartbeatInterval: number;
|
|
23
|
+
maxReconnectAttempts: number;
|
|
24
|
+
connectTimeout: number;
|
|
25
|
+
traceEnabled: boolean;
|
|
26
|
+
protocol: {
|
|
27
|
+
controller: string;
|
|
28
|
+
action: {
|
|
29
|
+
send: string;
|
|
30
|
+
msgRead: string;
|
|
31
|
+
onConnect: string;
|
|
32
|
+
offLine: string;
|
|
33
|
+
heartbeat: string;
|
|
34
|
+
};
|
|
35
|
+
heartbeatSignals: string[];
|
|
36
|
+
};
|
|
19
37
|
};
|
|
20
38
|
sound?: {
|
|
21
39
|
enabled: boolean;
|
|
@@ -24,6 +42,9 @@ export interface SDKConfig {
|
|
|
24
42
|
auth: {
|
|
25
43
|
authorizationPayload?: Record<string, unknown>;
|
|
26
44
|
};
|
|
45
|
+
chat: {
|
|
46
|
+
platformServicePhone: string;
|
|
47
|
+
};
|
|
27
48
|
runtimeApi: {
|
|
28
49
|
getChatConfig?: () => Promise<{
|
|
29
50
|
quick_receive?: string[] | string;
|
|
@@ -69,6 +90,29 @@ export declare function getWSController(): string;
|
|
|
69
90
|
* 获取 WebSocket 平台标识
|
|
70
91
|
*/
|
|
71
92
|
export declare function getWSPlatform(): string;
|
|
93
|
+
/**
|
|
94
|
+
* 是否开启 WebSocket Trace 日志
|
|
95
|
+
*/
|
|
96
|
+
export declare function isWSTraceEnabled(): boolean;
|
|
97
|
+
/**
|
|
98
|
+
* 获取 WebSocket 协议控制器(优先 protocol.controller)
|
|
99
|
+
*/
|
|
100
|
+
export declare function getWSProtocolController(): string;
|
|
101
|
+
/**
|
|
102
|
+
* 获取 WebSocket 协议动作映射
|
|
103
|
+
*/
|
|
104
|
+
export declare function getWSProtocolAction(): {
|
|
105
|
+
send: string;
|
|
106
|
+
msgRead: string;
|
|
107
|
+
onConnect: string;
|
|
108
|
+
offLine: string;
|
|
109
|
+
heartbeat: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* 获取 WebSocket 基础地址
|
|
113
|
+
* 优先级:ws.url > api.baseURL 推导 > 默认地址
|
|
114
|
+
*/
|
|
115
|
+
export declare function getWSBaseURL(): string;
|
|
72
116
|
/**
|
|
73
117
|
* 获取鉴权扩展参数(平台默认为空,门店可注入 username/avatar)
|
|
74
118
|
*/
|