@steedos/service-core-objects 3.0.0-beta.45 → 3.0.0-beta.47
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,16 +1,48 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
2
|
+
const SocketCommands = {
|
|
3
|
+
subscribe: "subscribe",
|
|
4
|
+
unsubscribe:"unsubscribe"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
const SocketEvents = {
|
|
8
|
+
metadataChange: 's:metadata:change',
|
|
9
|
+
notificationChange: 's:notification-change'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SocketRoomParts = {
|
|
13
|
+
space: 'space',
|
|
14
|
+
me: 'me',
|
|
15
|
+
notificationChange: 'notification-change'
|
|
16
|
+
}
|
|
17
|
+
|
|
1
18
|
// 连接到服务器
|
|
2
|
-
const socket = window.io("
|
|
19
|
+
const socket = window.io("/", {
|
|
3
20
|
path: "/socket.io"
|
|
4
21
|
});
|
|
5
22
|
|
|
6
23
|
// 监听连接事件
|
|
7
|
-
socket.on("connect", () => {
|
|
8
|
-
|
|
9
|
-
|
|
24
|
+
socket.on("connect", () => {});
|
|
25
|
+
|
|
26
|
+
socket.on("connection-init", ()=>{
|
|
27
|
+
console.log('emit', SocketCommands.subscribe, SocketRoomParts.space);
|
|
28
|
+
socket.emit(SocketCommands.subscribe, {
|
|
29
|
+
roomParts: SocketRoomParts.space
|
|
30
|
+
});
|
|
31
|
+
console.log('emit', SocketCommands.subscribe, SocketRoomParts.me);
|
|
32
|
+
socket.emit(SocketCommands.subscribe, {
|
|
33
|
+
roomParts: SocketRoomParts.me,
|
|
34
|
+
individual: true
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log('emit', SocketCommands.subscribe, SocketRoomParts.notificationChange);
|
|
38
|
+
socket.emit(SocketCommands.subscribe, {
|
|
39
|
+
roomParts: SocketRoomParts.notificationChange,
|
|
40
|
+
individual: true
|
|
41
|
+
});
|
|
42
|
+
})
|
|
10
43
|
|
|
11
44
|
// 监听自定义事件(根据服务器提供的接口)
|
|
12
|
-
socket.on(
|
|
13
|
-
console.log("Received:", data);
|
|
45
|
+
socket.on(SocketEvents.metadataChange, (data) => {
|
|
14
46
|
if(data.type === 'apps'){
|
|
15
47
|
window.$(`.btn-reload-global-header-${data.name}`).trigger('click');
|
|
16
48
|
window.$(`.btn-reload-app-menu-${data.name}`).trigger('click');
|
|
@@ -32,8 +64,19 @@ socket.on("metadata:change", (data) => {
|
|
|
32
64
|
}
|
|
33
65
|
});
|
|
34
66
|
|
|
35
|
-
|
|
36
|
-
|
|
67
|
+
socket.on(SocketEvents.notificationChange, (data)=>{
|
|
68
|
+
if(data.message){
|
|
69
|
+
window.SteedosUI.notification.info({
|
|
70
|
+
message: data.message.name,
|
|
71
|
+
description: data.message.body
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
window.$('.btn-reload-global-header-notifications').trigger('click');
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
socket.on("connect_error", (err) => {
|
|
78
|
+
console.log("连接错误:", err);
|
|
79
|
+
});
|
|
37
80
|
|
|
38
81
|
// 断开连接时
|
|
39
82
|
socket.on("disconnect", () => {
|
|
@@ -105,8 +105,9 @@ module.exports = {
|
|
|
105
105
|
this.broker.emit(`notifications.hasBeenSent`, {
|
|
106
106
|
ids: notifications_ids
|
|
107
107
|
});
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
await ctx.broker.call('b6-microservice.broadcast', {name: '$notification.users', data: {tenantId: message.space, users: to, message: {name: message.name, body: message.body}}})
|
|
109
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
110
|
+
} catch (e) { console.log(e) }
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@steedos/service-core-objects",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.47",
|
|
4
4
|
"main": "package.service.js",
|
|
5
5
|
"private": false,
|
|
6
6
|
"publishConfig": {
|
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
"steedos"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@steedos/service-package-loader": "3.0.0-beta.
|
|
13
|
+
"@steedos/service-package-loader": "3.0.0-beta.47",
|
|
14
14
|
"json2xls": "^0.1.2",
|
|
15
15
|
"lodash": "^4.17.21"
|
|
16
16
|
},
|
|
17
17
|
"description": "steedos package",
|
|
18
18
|
"repository": {},
|
|
19
19
|
"license": "MIT",
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "629459cbc678e85aee272ce6df56b22c37e01b38"
|
|
21
21
|
}
|