sirius-common-utils 1.0.14 → 1.0.16
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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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,
|
|
@@ -1007,7 +1025,6 @@ const DomUtils = {
|
|
|
1007
1025
|
forbidBodyScroll,
|
|
1008
1026
|
syncDomAnimation,
|
|
1009
1027
|
closetByClassName,
|
|
1010
|
-
getDomElemMouseRelativePosition,
|
|
1011
1028
|
offset
|
|
1012
1029
|
};
|
|
1013
1030
|
function isIOS() {
|
|
@@ -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
|
-
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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,
|
|
@@ -1008,7 +1026,6 @@
|
|
|
1008
1026
|
forbidBodyScroll,
|
|
1009
1027
|
syncDomAnimation,
|
|
1010
1028
|
closetByClassName,
|
|
1011
|
-
getDomElemMouseRelativePosition,
|
|
1012
1029
|
offset
|
|
1013
1030
|
};
|
|
1014
1031
|
function isIOS() {
|