gant-core 0.1.29 → 0.1.31
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 -31
- package/lib/cli/index.js.map +1 -1
- package/lib/cli/template/index.html +0 -1
- package/lib/index.d.ts +6 -3
- package/lib/index.js +44 -39
- 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;
|
|
@@ -1984,6 +1985,7 @@ interface GlobalOptions {
|
|
|
1984
1985
|
base?: string;
|
|
1985
1986
|
menuData?: ServerMenuData | ((res: UserAggregateInfo) => ServerMenuData);
|
|
1986
1987
|
loginSuccessCallback?: () => void;
|
|
1988
|
+
ssoCallback?: () => boolean;
|
|
1987
1989
|
}
|
|
1988
1990
|
|
|
1989
1991
|
declare const MENU_HISTORY_UPDATE = "MENU_HISTORY_UPDATE";
|
|
@@ -2065,7 +2067,7 @@ declare class BaseLogin {
|
|
|
2065
2067
|
declare class SSOLogin {
|
|
2066
2068
|
init(ssoConfig?: SSOConfigType): void;
|
|
2067
2069
|
private ssoConfig;
|
|
2068
|
-
isSso: () => Promise<boolean>;
|
|
2070
|
+
isSso: (ssoCallback?: () => boolean) => Promise<boolean>;
|
|
2069
2071
|
ssoLogin: () => boolean;
|
|
2070
2072
|
ssoLoginOut: () => void;
|
|
2071
2073
|
}
|
|
@@ -2080,8 +2082,9 @@ declare class LoginStore extends BaseLogin {
|
|
|
2080
2082
|
ssoLogin: SSOLogin;
|
|
2081
2083
|
validate: ValidateLogin;
|
|
2082
2084
|
noCheckPermissionsPath?: string[];
|
|
2085
|
+
ssoCallback?: () => boolean;
|
|
2083
2086
|
constructor();
|
|
2084
|
-
init: (loginConfig?: LOGIN_CONFIG, base?: string) => void;
|
|
2087
|
+
init: (loginConfig?: LOGIN_CONFIG, base?: string, ssoCallback?: () => boolean) => void;
|
|
2085
2088
|
isNoLoginRequiredPage: () => boolean;
|
|
2086
2089
|
loginOut: () => Promise<void>;
|
|
2087
2090
|
loginAuthentication: (params: BeforeLoginCheckCodeParams) => Promise<void>;
|
|
@@ -2147,7 +2150,7 @@ interface WEBSOCKETRECROD {
|
|
|
2147
2150
|
recipientType: string;
|
|
2148
2151
|
recipientCode: string;
|
|
2149
2152
|
title?: string;
|
|
2150
|
-
status?:
|
|
2153
|
+
status?: "01" | "00";
|
|
2151
2154
|
senderName?: string;
|
|
2152
2155
|
senderTime?: string;
|
|
2153
2156
|
content: string;
|
package/lib/index.js
CHANGED
|
@@ -236,38 +236,38 @@ class ParameterStoreClass {
|
|
|
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;
|
|
@@ -1045,28 +1045,31 @@ class BaseLogin {
|
|
|
1045
1045
|
|
|
1046
1046
|
const defaultSsoConfig = {
|
|
1047
1047
|
sso: false,
|
|
1048
|
-
ssoUrlSearchParams: [
|
|
1049
|
-
ssoCheckTokenUrl:
|
|
1050
|
-
ssoSuccessUrlkey:
|
|
1051
|
-
ssoLoginUrl: window.location.origin +
|
|
1052
|
-
ssologinOutUrl: window.location.origin +
|
|
1048
|
+
ssoUrlSearchParams: ["ticket"],
|
|
1049
|
+
ssoCheckTokenUrl: "",
|
|
1050
|
+
ssoSuccessUrlkey: "successUrl",
|
|
1051
|
+
ssoLoginUrl: window.location.origin + "/fwSecurity/ssoAuth/login.api",
|
|
1052
|
+
ssologinOutUrl: window.location.origin + "fwSecurity/ssoAuth/logout.api",
|
|
1053
1053
|
};
|
|
1054
1054
|
class SSOLogin {
|
|
1055
1055
|
init(ssoConfig) {
|
|
1056
1056
|
this.ssoConfig = { ...this.ssoConfig, ...ssoConfig };
|
|
1057
1057
|
}
|
|
1058
1058
|
ssoConfig = defaultSsoConfig;
|
|
1059
|
-
isSso = async () => {
|
|
1059
|
+
isSso = async (ssoCallback) => {
|
|
1060
1060
|
if (!this.ssoConfig.sso)
|
|
1061
|
-
return;
|
|
1061
|
+
return false;
|
|
1062
|
+
let sso = false;
|
|
1062
1063
|
try {
|
|
1063
|
-
|
|
1064
|
-
return !!onlyRedirect;
|
|
1064
|
+
sso = await checkAuthConfigApi();
|
|
1065
1065
|
}
|
|
1066
1066
|
catch (error) {
|
|
1067
|
-
console.error(
|
|
1067
|
+
console.error("sso", error);
|
|
1068
1068
|
}
|
|
1069
|
-
|
|
1069
|
+
if (ssoCallback) {
|
|
1070
|
+
sso = await ssoCallback();
|
|
1071
|
+
}
|
|
1072
|
+
return !!sso;
|
|
1070
1073
|
};
|
|
1071
1074
|
ssoLogin = () => {
|
|
1072
1075
|
//在检测cookie中是否包含userIdentity信息
|
|
@@ -1105,16 +1108,18 @@ class LoginStore extends BaseLogin {
|
|
|
1105
1108
|
ssoLogin;
|
|
1106
1109
|
validate;
|
|
1107
1110
|
noCheckPermissionsPath = [];
|
|
1111
|
+
ssoCallback;
|
|
1108
1112
|
constructor() {
|
|
1109
1113
|
super();
|
|
1110
1114
|
this.ssoLogin = new SSOLogin();
|
|
1111
1115
|
this.validate = new ValidateLogin();
|
|
1112
1116
|
}
|
|
1113
|
-
init = (loginConfig, base =
|
|
1117
|
+
init = (loginConfig, base = "/", ssoCallback) => {
|
|
1114
1118
|
this.BASE = base;
|
|
1119
|
+
this.ssoCallback = ssoCallback;
|
|
1115
1120
|
this.noCheckPermissionsPath = loginConfig?.noCheckPermissionsPath;
|
|
1116
1121
|
this.ssoLogin.init(loginConfig);
|
|
1117
|
-
this.loginPathname = loginConfig?.loginPathname ||
|
|
1122
|
+
this.loginPathname = loginConfig?.loginPathname || "/login";
|
|
1118
1123
|
};
|
|
1119
1124
|
isNoLoginRequiredPage = () => {
|
|
1120
1125
|
const pathname = window.location.pathname;
|
|
@@ -1124,7 +1129,7 @@ class LoginStore extends BaseLogin {
|
|
|
1124
1129
|
return isNoLogin;
|
|
1125
1130
|
};
|
|
1126
1131
|
loginOut = async () => {
|
|
1127
|
-
const isSSO = await this.ssoLogin.isSso();
|
|
1132
|
+
const isSSO = await this.ssoLogin.isSso(this.ssoCallback);
|
|
1128
1133
|
if (isSSO)
|
|
1129
1134
|
this.ssoLogin.ssoLoginOut();
|
|
1130
1135
|
await this.baseLoginOut();
|
|
@@ -1137,7 +1142,7 @@ class LoginStore extends BaseLogin {
|
|
|
1137
1142
|
redirectLogin = async () => {
|
|
1138
1143
|
if (this.isNoLoginRequiredPage())
|
|
1139
1144
|
return true;
|
|
1140
|
-
const isSSO = await this.ssoLogin.isSso();
|
|
1145
|
+
const isSSO = await this.ssoLogin.isSso(this.ssoCallback);
|
|
1141
1146
|
if (isSSO) {
|
|
1142
1147
|
this.ssoLogin.ssoLogin();
|
|
1143
1148
|
return false;
|
|
@@ -1188,8 +1193,8 @@ class GlobalStoreClass {
|
|
|
1188
1193
|
this.menuStore.init(isEmpty(localeMenus) ? startMenus : localeMenus, currentUser.id);
|
|
1189
1194
|
};
|
|
1190
1195
|
init = async (options) => {
|
|
1191
|
-
const { base = "/", menuData, loginSuccessCallback } = options;
|
|
1192
|
-
this.loginStore.init(options?.loginConfig, base);
|
|
1196
|
+
const { base = "/", menuData, loginSuccessCallback, ssoCallback } = options;
|
|
1197
|
+
this.loginStore.init(options?.loginConfig, base, ssoCallback);
|
|
1193
1198
|
try {
|
|
1194
1199
|
//检查token
|
|
1195
1200
|
const res = await this.loginStore.chekToken();
|