@zgfe/business-lib 1.1.29-visual.12 → 1.1.29-visual.14
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/es/socket/demo/demo.js +2 -1
- package/es/socket/index.d.ts +6 -6
- package/es/socket/index.js +8 -0
- package/es/socket/types.d.ts +0 -1
- package/package.json +2 -2
package/es/socket/demo/demo.js
CHANGED
|
@@ -33,7 +33,8 @@ var ChatPanel = function ChatPanel(_ref) {
|
|
|
33
33
|
var _useContext = useContext(BizGlobalDataContext),
|
|
34
34
|
currentApp = _useContext.currentApp;
|
|
35
35
|
useEffect(function () {
|
|
36
|
-
|
|
36
|
+
var socket = new SocketClient('wss://rt2.zhugeio.com/eventtracking/ws', currentApp === null || currentApp === void 0 ? void 0 : currentApp.appKey, param);
|
|
37
|
+
setClient(socket);
|
|
37
38
|
return function () {
|
|
38
39
|
console.log('销毁chat', param);
|
|
39
40
|
if (!client) return;
|
package/es/socket/index.d.ts
CHANGED
|
@@ -9,18 +9,18 @@ declare class SocketClient {
|
|
|
9
9
|
private pingTimer?;
|
|
10
10
|
private appkey?;
|
|
11
11
|
constructor(url: string, appkey: string, params?: Record<string, any>);
|
|
12
|
-
emit(event: string, payload
|
|
13
|
-
on(type: SocketClientTypes.EventType | string, handle:
|
|
14
|
-
onConnected(handle:
|
|
15
|
-
onDisconnected(handle:
|
|
16
|
-
onError(handle:
|
|
12
|
+
emit(event: string, payload?: SocketClientTypes.Message['data']['payload']): void;
|
|
13
|
+
on<T>(type: SocketClientTypes.EventType | string, handle: (data?: T) => void): void;
|
|
14
|
+
onConnected(handle: () => void): void;
|
|
15
|
+
onDisconnected(handle: () => void): void;
|
|
16
|
+
onError(handle: (data?: Error) => void): void;
|
|
17
17
|
private _onError;
|
|
18
18
|
private _onClose;
|
|
19
19
|
private _onOpen;
|
|
20
20
|
private onMessage;
|
|
21
21
|
private ping;
|
|
22
22
|
removeAllListeners(): void;
|
|
23
|
-
removeListener(event: string, handle?:
|
|
23
|
+
removeListener(event: string, handle?: (data?: any) => void): void;
|
|
24
24
|
private getToken;
|
|
25
25
|
open(url?: string, params?: Record<string, any>): void;
|
|
26
26
|
close(): void;
|
package/es/socket/index.js
CHANGED
|
@@ -38,6 +38,12 @@ var SocketClient = /*#__PURE__*/function () {
|
|
|
38
38
|
key: "emit",
|
|
39
39
|
value: function emit(event, payload) {
|
|
40
40
|
var _this$client, _this$client2;
|
|
41
|
+
this.log('info', 'emit message', [event, payload]);
|
|
42
|
+
if (!this.client) {
|
|
43
|
+
this.log('info', '缓存消息', [event, payload]);
|
|
44
|
+
this.catch.push([event, payload]);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
41
47
|
switch ((_this$client = this.client) === null || _this$client === void 0 ? void 0 : _this$client.readyState) {
|
|
42
48
|
case WebSocket.CLOSED:
|
|
43
49
|
notification.warn({
|
|
@@ -53,6 +59,7 @@ var SocketClient = /*#__PURE__*/function () {
|
|
|
53
59
|
notification.warn({
|
|
54
60
|
message: '连接中'
|
|
55
61
|
});
|
|
62
|
+
this.log('info', '缓存消息', [event, payload]);
|
|
56
63
|
this.catch.push([event, payload]);
|
|
57
64
|
break;
|
|
58
65
|
case WebSocket.OPEN:
|
|
@@ -117,6 +124,7 @@ var SocketClient = /*#__PURE__*/function () {
|
|
|
117
124
|
(_this$listeners$conne = this.listeners['connected']) === null || _this$listeners$conne === void 0 ? void 0 : _this$listeners$conne.forEach(function (handle) {
|
|
118
125
|
handle.call(undefined);
|
|
119
126
|
});
|
|
127
|
+
this.log('info', 'clear catch', this.catch);
|
|
120
128
|
this.catch.forEach(function (_ref) {
|
|
121
129
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
122
130
|
event = _ref2[0],
|
package/es/socket/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zgfe/business-lib",
|
|
3
|
-
"version": "1.1.29-visual.
|
|
3
|
+
"version": "1.1.29-visual.14",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "dumi dev",
|
|
6
6
|
"docs:build": "dumi build",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"react": "^16.12.0 || ^17.0.0",
|
|
60
60
|
"yorkie": "^2.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "40a1fa79b213e69d9564f0fa845f4fae01f2db77"
|
|
63
63
|
}
|