dream-common 1.1.12 → 1.1.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.
- package/lib/storage.js +6 -43
- package/package.json +1 -1
package/lib/storage.js
CHANGED
|
@@ -67,50 +67,13 @@ export const sessionStorageRemove = (key) => {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function getObj(bool = true, value = null) {
|
|
70
|
-
|
|
71
|
-
if (value === null || value === undefined || value === 'null' || value === 'undefined' || value.length <= 0) {
|
|
70
|
+
if (value === null || value === undefined || value.length <= 0) {
|
|
72
71
|
return false
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
obj = {
|
|
80
|
-
type: 'array',
|
|
81
|
-
value: obj.value.split("@#&%")
|
|
82
|
-
}
|
|
83
|
-
} else if (obj.type === 'json') {
|
|
84
|
-
obj = {
|
|
85
|
-
type: 'json',
|
|
86
|
-
value: JSON.parse(obj.value)
|
|
87
|
-
}
|
|
88
|
-
} else if (obj.type === 'boolean') {
|
|
89
|
-
obj = {
|
|
90
|
-
type: 'boolean',
|
|
91
|
-
value: obj.value === 1
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
break;
|
|
95
|
-
case 'boolean':
|
|
96
|
-
obj.value = value ? 1 : 0;
|
|
97
|
-
break;
|
|
98
|
-
case 'object':
|
|
99
|
-
if (value instanceof Array) {
|
|
100
|
-
obj = {
|
|
101
|
-
type: 'array',
|
|
102
|
-
value: value.join("@#&%")
|
|
103
|
-
}
|
|
104
|
-
} else if (value instanceof Object) {
|
|
105
|
-
obj = {
|
|
106
|
-
type: 'json',
|
|
107
|
-
value: JSON.stringify(value)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
default:
|
|
112
|
-
obj.value = value;
|
|
113
|
-
break
|
|
73
|
+
if (bool) {
|
|
74
|
+
return aesEncrypt(key,JSON.stringify(value))
|
|
75
|
+
} else {
|
|
76
|
+
const data = aesDecrypt(key,value);
|
|
77
|
+
return JSON.parse(data)
|
|
114
78
|
}
|
|
115
|
-
return bool ? aesEncrypt(key,JSON.stringify(obj)) : obj.value;
|
|
116
79
|
}
|