sirius-common-utils 1.0.15 → 1.0.17

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.
@@ -6,6 +6,8 @@ const CfgUtils = {
6
6
  appInfo: {
7
7
  appName: "XMS",
8
8
  //application name
9
+ frontEndValueEncodeFlag: false,
10
+ //need to encode for LocalStorage values
9
11
  needFrontEndExceptionStatisticsFlag: true
10
12
  //need trace front-end logs
11
13
  },
@@ -48,24 +50,23 @@ function removeLocalStorageItem(key, obj) {
48
50
  function setLocalStorageStringItem(key, obj) {
49
51
  let realKey = CfgUtils.appInfo.appName + "_" + key;
50
52
  let realValue = obj;
51
- localStorage.setItem(realKey, realValue);
53
+ localStorage.setItem(realKey, encode(realValue));
52
54
  }
53
55
  function getLocalStorageStringItem(key) {
54
56
  let realKey = CfgUtils.appInfo.appName + "_" + key;
55
- let obj = localStorage.getItem(realKey);
57
+ let obj = decode(localStorage.getItem(realKey));
56
58
  return obj;
57
59
  }
58
60
  function setLocalStorageObjItem(key, obj) {
59
61
  let realKey = CfgUtils.appInfo.appName + "_" + key;
60
- let realValue = Base64.encode(JSON.stringify(obj));
61
- localStorage.setItem(realKey, realValue);
62
+ localStorage.setItem(realKey, encode(JSON.stringify(obj)));
62
63
  }
63
64
  function getLocalStorageObjItem(key) {
64
65
  let realKey = CfgUtils.appInfo.appName + "_" + key;
65
66
  let obj = null;
66
67
  try {
67
68
  let jsonVal = localStorage.getItem(realKey);
68
- obj = JSON.parse(Base64.decode(jsonVal));
69
+ obj = JSON.parse(decode(jsonVal));
69
70
  } catch (e) {
70
71
  }
71
72
  return obj;
@@ -96,19 +97,36 @@ function atomGetSessionStorageObjItem(key) {
96
97
  }
97
98
  function setSessionStorageObjItem(key, obj) {
98
99
  let realKey = CfgUtils.appInfo.appName + "_" + key;
99
- let realValue = Base64.encode(JSON.stringify(obj));
100
- sessionStorage.setItem(realKey, realValue);
100
+ sessionStorage.setItem(realKey, encode(JSON.stringify(obj)));
101
101
  }
102
102
  function getSessionStorageObjItem(key) {
103
103
  let realKey = CfgUtils.appInfo.appName + "_" + key;
104
104
  let obj = null;
105
105
  try {
106
106
  let jsonVal = sessionStorage.getItem(realKey);
107
- obj = JSON.parse(Base64.decode(jsonVal));
107
+ obj = JSON.parse(decode(jsonVal));
108
108
  } catch (e) {
109
109
  }
110
110
  return obj;
111
111
  }
112
+ function encode(originalValue) {
113
+ if (!originalValue) {
114
+ return originalValue;
115
+ }
116
+ if (!CfgUtils.appInfo.frontEndValueEncodeFlag) {
117
+ return originalValue;
118
+ }
119
+ return Base64.encode(originalValue);
120
+ }
121
+ function decode(encodeValue) {
122
+ if (!encodeValue) {
123
+ return encodeValue;
124
+ }
125
+ if (!CfgUtils.appInfo.frontEndValueEncodeFlag) {
126
+ return encodeValue;
127
+ }
128
+ return Base64.decode(encodeValue);
129
+ }
112
130
  const AppUtils = {
113
131
  setAppVersion,
114
132
  getAppVersion,
@@ -230,6 +248,9 @@ function init$1(pAxios, pSpinHandlerInstance, pDialogUtilsInstance, pLoginServic
230
248
  globalSpinHandlerInstance = pSpinHandlerInstance;
231
249
  loginServiceInstance = pLoginServiceInstance;
232
250
  }
251
+ function getHostName() {
252
+ return window.location.hostname;
253
+ }
233
254
  function loadParamFromLocationSearch(paramKey) {
234
255
  var paramsStr = window.location.search;
235
256
  if (paramsStr.indexOf("?") === 0) {
@@ -514,6 +535,7 @@ async function appSessionExit(resultCode, forceCloseFlag) {
514
535
  }
515
536
  const AxiosUtils = {
516
537
  init: init$1,
538
+ getHostName,
517
539
  loadParamFromLocationSearch,
518
540
  getPath,
519
541
  getUrlParam,
@@ -7,6 +7,8 @@
7
7
  appInfo: {
8
8
  appName: "XMS",
9
9
  //application name
10
+ frontEndValueEncodeFlag: false,
11
+ //need to encode for LocalStorage values
10
12
  needFrontEndExceptionStatisticsFlag: true
11
13
  //need trace front-end logs
12
14
  },
@@ -49,24 +51,23 @@
49
51
  function setLocalStorageStringItem(key, obj) {
50
52
  let realKey = CfgUtils.appInfo.appName + "_" + key;
51
53
  let realValue = obj;
52
- localStorage.setItem(realKey, realValue);
54
+ localStorage.setItem(realKey, encode(realValue));
53
55
  }
54
56
  function getLocalStorageStringItem(key) {
55
57
  let realKey = CfgUtils.appInfo.appName + "_" + key;
56
- let obj = localStorage.getItem(realKey);
58
+ let obj = decode(localStorage.getItem(realKey));
57
59
  return obj;
58
60
  }
59
61
  function setLocalStorageObjItem(key, obj) {
60
62
  let realKey = CfgUtils.appInfo.appName + "_" + key;
61
- let realValue = jsBase64.Base64.encode(JSON.stringify(obj));
62
- localStorage.setItem(realKey, realValue);
63
+ localStorage.setItem(realKey, encode(JSON.stringify(obj)));
63
64
  }
64
65
  function getLocalStorageObjItem(key) {
65
66
  let realKey = CfgUtils.appInfo.appName + "_" + key;
66
67
  let obj = null;
67
68
  try {
68
69
  let jsonVal = localStorage.getItem(realKey);
69
- obj = JSON.parse(jsBase64.Base64.decode(jsonVal));
70
+ obj = JSON.parse(decode(jsonVal));
70
71
  } catch (e) {
71
72
  }
72
73
  return obj;
@@ -97,19 +98,36 @@
97
98
  }
98
99
  function setSessionStorageObjItem(key, obj) {
99
100
  let realKey = CfgUtils.appInfo.appName + "_" + key;
100
- let realValue = jsBase64.Base64.encode(JSON.stringify(obj));
101
- sessionStorage.setItem(realKey, realValue);
101
+ sessionStorage.setItem(realKey, encode(JSON.stringify(obj)));
102
102
  }
103
103
  function getSessionStorageObjItem(key) {
104
104
  let realKey = CfgUtils.appInfo.appName + "_" + key;
105
105
  let obj = null;
106
106
  try {
107
107
  let jsonVal = sessionStorage.getItem(realKey);
108
- obj = JSON.parse(jsBase64.Base64.decode(jsonVal));
108
+ obj = JSON.parse(decode(jsonVal));
109
109
  } catch (e) {
110
110
  }
111
111
  return obj;
112
112
  }
113
+ function encode(originalValue) {
114
+ if (!originalValue) {
115
+ return originalValue;
116
+ }
117
+ if (!CfgUtils.appInfo.frontEndValueEncodeFlag) {
118
+ return originalValue;
119
+ }
120
+ return jsBase64.Base64.encode(originalValue);
121
+ }
122
+ function decode(encodeValue) {
123
+ if (!encodeValue) {
124
+ return encodeValue;
125
+ }
126
+ if (!CfgUtils.appInfo.frontEndValueEncodeFlag) {
127
+ return encodeValue;
128
+ }
129
+ return jsBase64.Base64.decode(encodeValue);
130
+ }
113
131
  const AppUtils = {
114
132
  setAppVersion,
115
133
  getAppVersion,
@@ -231,6 +249,9 @@
231
249
  globalSpinHandlerInstance = pSpinHandlerInstance;
232
250
  loginServiceInstance = pLoginServiceInstance;
233
251
  }
252
+ function getHostName() {
253
+ return window.location.hostname;
254
+ }
234
255
  function loadParamFromLocationSearch(paramKey) {
235
256
  var paramsStr = window.location.search;
236
257
  if (paramsStr.indexOf("?") === 0) {
@@ -515,6 +536,7 @@
515
536
  }
516
537
  const AxiosUtils = {
517
538
  init: init$1,
539
+ getHostName,
518
540
  loadParamFromLocationSearch,
519
541
  getPath,
520
542
  getUrlParam,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sirius-common-utils",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "",
5
5
  "main": "./dist/sirius-common-utils.umd.cjs",
6
6
  "module": "./dist/sirius-common-utils.js",