gant-core 0.1.30 → 0.1.32
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/lib/cli/index.js +40 -30
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/template/index.html +0 -1
- package/lib/index.d.ts +6 -4
- package/lib/index.js +27 -27
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.ts
CHANGED
|
@@ -1700,6 +1700,7 @@ interface GantUserConfig extends Configuration, GantCustomConfig {
|
|
|
1700
1700
|
devServer?: Configuration$1;
|
|
1701
1701
|
}
|
|
1702
1702
|
type CONFIG_TYPE = {
|
|
1703
|
+
IP2_BASE_CONFIG?: BASE_CONFIG_TYPE;
|
|
1703
1704
|
BASE_CONFIG?: BASE_CONFIG_TYPE;
|
|
1704
1705
|
MAIN_CONFIG?: MAIN_CONFIG_TYPE;
|
|
1705
1706
|
SYSMGMT_CONFIG?: SYSMGMT_CONFIG_TYPE;
|
|
@@ -1728,8 +1729,9 @@ type LOGIN_CONFIG = {
|
|
|
1728
1729
|
type MAIN_CONFIG_TYPE = {
|
|
1729
1730
|
requestTimeout?: number;
|
|
1730
1731
|
siderMenuCollapsed?: boolean;
|
|
1732
|
+
searchMenu?: boolean;
|
|
1731
1733
|
headerMenu?: boolean;
|
|
1732
|
-
navType?: "breadcrumb" | "tabs";
|
|
1734
|
+
navType?: "breadcrumb" | "tabs" | 'none';
|
|
1733
1735
|
menuHistory?: boolean;
|
|
1734
1736
|
initialDashboardLayout?: any[];
|
|
1735
1737
|
homePath?: string;
|
|
@@ -2149,7 +2151,7 @@ interface WEBSOCKETRECROD {
|
|
|
2149
2151
|
recipientType: string;
|
|
2150
2152
|
recipientCode: string;
|
|
2151
2153
|
title?: string;
|
|
2152
|
-
status?:
|
|
2154
|
+
status?: "01" | "00";
|
|
2153
2155
|
senderName?: string;
|
|
2154
2156
|
senderTime?: string;
|
|
2155
2157
|
content: string;
|
|
@@ -2302,8 +2304,8 @@ declare const codeListStore: {
|
|
|
2302
2304
|
declare const parameterStore: {
|
|
2303
2305
|
parameterList: ParameterList;
|
|
2304
2306
|
parameterMap: ParameterMaps;
|
|
2305
|
-
findAllParameters()
|
|
2306
|
-
getSystemParameterByName(name: string | string[])
|
|
2307
|
+
findAllParameters: () => Promise<void>;
|
|
2308
|
+
getSystemParameterByName: (name: string | string[]) => ParameterItem | Pick<ParameterMaps, string>;
|
|
2307
2309
|
};
|
|
2308
2310
|
declare const userStore: UserStore;
|
|
2309
2311
|
declare const loginStore: LoginStore;
|
package/lib/index.js
CHANGED
|
@@ -215,59 +215,59 @@ function findSystemParameterApi() {
|
|
|
215
215
|
class ParameterStoreClass {
|
|
216
216
|
parameterList = [];
|
|
217
217
|
parameterMap = {};
|
|
218
|
-
async
|
|
218
|
+
findAllParameters = async () => {
|
|
219
219
|
const res = await findSystemParameterApi();
|
|
220
220
|
const data = res || [];
|
|
221
221
|
const dataMap = groupBy(data, 'name');
|
|
222
222
|
this.parameterList = data;
|
|
223
223
|
this.parameterMap = dataMap;
|
|
224
|
-
}
|
|
224
|
+
};
|
|
225
225
|
/**
|
|
226
226
|
* 获取系统参数,可以一次指定获取多个参数(传入数组)
|
|
227
227
|
* @param name {string | string[]} 需要获取到的参数的key
|
|
228
228
|
* @returns 返回根据key查询到一个参数对象
|
|
229
229
|
*/
|
|
230
|
-
getSystemParameterByName(name) {
|
|
230
|
+
getSystemParameterByName = (name) => {
|
|
231
231
|
if (typeof name === 'string')
|
|
232
232
|
return this.parameterMap[name];
|
|
233
233
|
return pick(this.parameterMap, name);
|
|
234
|
-
}
|
|
234
|
+
};
|
|
235
235
|
}
|
|
236
236
|
const parameterStoreInstance = new ParameterStoreClass();
|
|
237
237
|
|
|
238
238
|
//计算最终的WebSocketUrl
|
|
239
|
-
const pingMsg =
|
|
240
|
-
const pongMsg =
|
|
239
|
+
const pingMsg = "ping"; //客户端心跳信息
|
|
240
|
+
const pongMsg = "pong"; //服务端心跳信息
|
|
241
241
|
const reconnectTimeout = 10000;
|
|
242
242
|
const pingPongTimeout = 10000; //发送的心跳的间隔时间
|
|
243
|
-
const WS_CONTENT_SUCCESS =
|
|
244
|
-
const WS_CONTENT_ERROR =
|
|
245
|
-
const WS_CONTENT_CLOSE =
|
|
243
|
+
const WS_CONTENT_SUCCESS = "WS_CONTENT_SUCCESS";
|
|
244
|
+
const WS_CONTENT_ERROR = "WS_CONTENT_ERROR";
|
|
245
|
+
const WS_CONTENT_CLOSE = "WS_CONTENT_CLOSE";
|
|
246
246
|
const getWebSocketUrl = (userLoginName) => {
|
|
247
|
-
const suffix =
|
|
247
|
+
const suffix = "notification-ws";
|
|
248
248
|
const paramStr = `userLoginName=${userLoginName}`;
|
|
249
249
|
const { host, protocol, port, hostname } = window.location;
|
|
250
250
|
//是否是https
|
|
251
|
-
const isHttps = protocol.includes(
|
|
251
|
+
const isHttps = protocol.includes("https");
|
|
252
252
|
//ws协议
|
|
253
|
-
let wsProtocol = isHttps ?
|
|
253
|
+
let wsProtocol = isHttps ? "wss" : "ws";
|
|
254
254
|
//默认是host
|
|
255
255
|
let wsHost = host;
|
|
256
256
|
//如果不是是https并且有端口号时,ws端口就是web端口+1
|
|
257
257
|
if (!isHttps && port) {
|
|
258
|
-
let newhost = parseInt(port)
|
|
258
|
+
let newhost = parseInt(port);
|
|
259
259
|
wsHost = `${hostname}:${newhost}`;
|
|
260
260
|
}
|
|
261
261
|
const wsAddress = `${wsProtocol}://${wsHost}/${suffix}?${paramStr}`;
|
|
262
262
|
return wsAddress;
|
|
263
263
|
};
|
|
264
264
|
class GantWebSocket {
|
|
265
|
-
RECIPIENT_TYPE_ALL =
|
|
266
|
-
RECIPIENT_TYPE_USER =
|
|
267
|
-
RECIPIENT_TYPE_OBSERVER =
|
|
268
|
-
RECIPIENT_TYPE_CONNECTION =
|
|
265
|
+
RECIPIENT_TYPE_ALL = "all"; // 所有用户均可收到的消息类型【公告等消息】
|
|
266
|
+
RECIPIENT_TYPE_USER = "user"; // 某个用户可以收到【用户通知】
|
|
267
|
+
RECIPIENT_TYPE_OBSERVER = "obsvr"; // 某个观察者可以收到【接口处理进度】
|
|
268
|
+
RECIPIENT_TYPE_CONNECTION = "conn"; // 某个连接成功接收到【ws连接专用】
|
|
269
269
|
//链接地址
|
|
270
|
-
webSocketUrl =
|
|
270
|
+
webSocketUrl = "";
|
|
271
271
|
// WebSocket
|
|
272
272
|
ws = null;
|
|
273
273
|
//重链次数
|
|
@@ -280,17 +280,17 @@ class GantWebSocket {
|
|
|
280
280
|
pongTimeoutFn = null;
|
|
281
281
|
reconnectFn = null;
|
|
282
282
|
//是否限制次数
|
|
283
|
-
repeatLimit =
|
|
283
|
+
repeatLimit = 2;
|
|
284
284
|
//链接标识
|
|
285
|
-
connectionId =
|
|
286
|
-
userLoginName =
|
|
285
|
+
connectionId = "";
|
|
286
|
+
userLoginName = "";
|
|
287
287
|
eventStack = {};
|
|
288
288
|
constructor() { }
|
|
289
289
|
init = (userLoginName, options) => {
|
|
290
290
|
this.userLoginName = userLoginName;
|
|
291
291
|
this.webSocketUrl = getWebSocketUrl(userLoginName);
|
|
292
|
-
this.disReconnect = get$1(options,
|
|
293
|
-
this.repeatLimit = get$1(options,
|
|
292
|
+
this.disReconnect = get$1(options, "disReconnect", false);
|
|
293
|
+
this.repeatLimit = get$1(options, "repeatLimit", 20);
|
|
294
294
|
this.createWebSocket();
|
|
295
295
|
};
|
|
296
296
|
createWebSocket = () => {
|
|
@@ -385,7 +385,7 @@ class GantWebSocket {
|
|
|
385
385
|
}
|
|
386
386
|
}
|
|
387
387
|
catch (err) {
|
|
388
|
-
console.warn(
|
|
388
|
+
console.warn("received error!!!", err);
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
this.ws.onerror = () => {
|
|
@@ -394,7 +394,7 @@ class GantWebSocket {
|
|
|
394
394
|
emitter.emit(WS_CONTENT_ERROR);
|
|
395
395
|
};
|
|
396
396
|
this.ws.onclose = () => {
|
|
397
|
-
console.warn(
|
|
397
|
+
console.warn("webSocket close");
|
|
398
398
|
this.ws = null;
|
|
399
399
|
this.heartReset();
|
|
400
400
|
this.reconnect();
|
|
@@ -406,7 +406,7 @@ class GantWebSocket {
|
|
|
406
406
|
const id = uniqueId();
|
|
407
407
|
this.eventStack[id] = {
|
|
408
408
|
recipientType: eventType,
|
|
409
|
-
type:
|
|
409
|
+
type: "recipientType",
|
|
410
410
|
event,
|
|
411
411
|
};
|
|
412
412
|
return id;
|
|
@@ -694,7 +694,7 @@ class UserStore {
|
|
|
694
694
|
if (!!this.userSetting[key]) {
|
|
695
695
|
return this.userSetting[key];
|
|
696
696
|
}
|
|
697
|
-
const res = await getUserDataApi({ dataType, dataId: userId });
|
|
697
|
+
const res = await getUserDataApi({ dataType, dataId: userId + dataType });
|
|
698
698
|
const bigData = res?.bigData ? JSON.parse(res.bigData) : undefined;
|
|
699
699
|
this.userSetting[key] = bigData;
|
|
700
700
|
return bigData;
|