@ivujs/i-utils 2.1.4 → 2.1.6
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/dist/cjs/clipboard/index.cjs +3 -3
- package/dist/cjs/device/index.cjs +12 -12
- package/dist/cjs/file/index.cjs +9 -8
- package/dist/cjs/storage/localStorage.cjs +4 -4
- package/dist/cjs/storage/sessionStorage.cjs +4 -4
- package/dist/cjs/validate/index.cjs +1 -6
- package/dist/es/clipboard/index.mjs +3 -3
- package/dist/es/device/index.mjs +12 -12
- package/dist/es/file/index.mjs +9 -8
- package/dist/es/storage/localStorage.mjs +4 -4
- package/dist/es/storage/sessionStorage.mjs +4 -4
- package/dist/es/validate/index.mjs +1 -6
- package/dist/lib/index.full.umd.js +34 -38
- package/dist/lib/index.full.umd.min.js +2 -2
- package/dist/lib/index.full.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -44,7 +44,7 @@ function getClipboard() {
|
|
|
44
44
|
*/
|
|
45
45
|
function getClipboardText() {
|
|
46
46
|
return new Promise((resolve, reject) => {
|
|
47
|
-
if (window.navigator
|
|
47
|
+
if (window && window.navigator) {
|
|
48
48
|
window.navigator.clipboard
|
|
49
49
|
.readText()
|
|
50
50
|
.then((text) => {
|
|
@@ -68,7 +68,7 @@ function getClipboardText() {
|
|
|
68
68
|
function setClipboard(data) {
|
|
69
69
|
return new Promise((resolve, reject) => {
|
|
70
70
|
// 现代浏览器
|
|
71
|
-
if (window.navigator
|
|
71
|
+
if (window && window.navigator) {
|
|
72
72
|
let clipboardItem = null;
|
|
73
73
|
// 是文本类型
|
|
74
74
|
if (typeof data === "string") {
|
|
@@ -101,7 +101,7 @@ function setClipboard(data) {
|
|
|
101
101
|
function setClipboardText(text) {
|
|
102
102
|
return new Promise((resolve, reject) => {
|
|
103
103
|
// 现代浏览器
|
|
104
|
-
if (window.navigator
|
|
104
|
+
if (window && window.navigator) {
|
|
105
105
|
window.navigator.clipboard.writeText(text).then((success) => {
|
|
106
106
|
resolve(true);
|
|
107
107
|
}, (failed) => {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @returns {Object} 返回浏览器信息
|
|
11
11
|
*/
|
|
12
12
|
function getBrowserInfo() {
|
|
13
|
-
const ua = window.navigator.userAgent.toLowerCase();
|
|
13
|
+
const ua = window && window.navigator.userAgent.toLowerCase();
|
|
14
14
|
// ie
|
|
15
15
|
const ie = ua.match(/rv:([\d.]+)\) like gecko/) || ua.match(/msie ([\d\.]+)/);
|
|
16
16
|
// edge
|
|
@@ -53,7 +53,7 @@ function isPc() {
|
|
|
53
53
|
* @returns {boolean} 返回true和false
|
|
54
54
|
*/
|
|
55
55
|
function isPhone() {
|
|
56
|
-
const ua = window.navigator.userAgent;
|
|
56
|
+
const ua = window && window.navigator.userAgent;
|
|
57
57
|
return /Android|webOS|iPhone|iPod|BlackBerry|Windows Phone|IEMobile/i.test(ua);
|
|
58
58
|
}
|
|
59
59
|
/* 操作系统类型 */
|
|
@@ -62,7 +62,7 @@ function isPhone() {
|
|
|
62
62
|
* @returns {boolean} 返回true和false
|
|
63
63
|
*/
|
|
64
64
|
function isAndroid() {
|
|
65
|
-
const ua = window.navigator.userAgent;
|
|
65
|
+
const ua = window && window.navigator.userAgent;
|
|
66
66
|
return /Android|BlackBerry/i.test(ua);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
@@ -70,7 +70,7 @@ function isAndroid() {
|
|
|
70
70
|
* @returns {boolean} 返回true和false
|
|
71
71
|
*/
|
|
72
72
|
function isIos() {
|
|
73
|
-
const ua = window.navigator.userAgent;
|
|
73
|
+
const ua = window && window.navigator.userAgent;
|
|
74
74
|
return /iPhone|iPad|iPod|iOS/i.test(ua);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -78,7 +78,7 @@ function isIos() {
|
|
|
78
78
|
* @returns {boolean} 返回true和false
|
|
79
79
|
*/
|
|
80
80
|
function isWindowsPhone() {
|
|
81
|
-
const ua = window.navigator.userAgent;
|
|
81
|
+
const ua = window && window.navigator.userAgent;
|
|
82
82
|
return /Windows Phone/i.test(ua);
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -86,7 +86,7 @@ function isWindowsPhone() {
|
|
|
86
86
|
* @returns {boolean} 返回true和false
|
|
87
87
|
*/
|
|
88
88
|
function isWindows() {
|
|
89
|
-
const ua = window.navigator.userAgent;
|
|
89
|
+
const ua = window && window.navigator.userAgent;
|
|
90
90
|
return /win/i.test(ua);
|
|
91
91
|
}
|
|
92
92
|
/**
|
|
@@ -94,7 +94,7 @@ function isWindows() {
|
|
|
94
94
|
* @returns {boolean} 返回true和false
|
|
95
95
|
*/
|
|
96
96
|
function isLinux() {
|
|
97
|
-
const ua = window.navigator.userAgent;
|
|
97
|
+
const ua = window && window.navigator.userAgent;
|
|
98
98
|
return /linux/i.test(ua);
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
@@ -102,7 +102,7 @@ function isLinux() {
|
|
|
102
102
|
* @returns {boolean} 返回true和false
|
|
103
103
|
*/
|
|
104
104
|
function isMac() {
|
|
105
|
-
const ua = window.navigator.userAgent;
|
|
105
|
+
const ua = window && window.navigator.userAgent;
|
|
106
106
|
return /mac/i.test(ua);
|
|
107
107
|
}
|
|
108
108
|
/* 苹果设备类型 */
|
|
@@ -111,7 +111,7 @@ function isMac() {
|
|
|
111
111
|
*@returns {boolean} 返回true和false
|
|
112
112
|
*/
|
|
113
113
|
function isIphone() {
|
|
114
|
-
const ua = window.navigator.userAgent;
|
|
114
|
+
const ua = window && window.navigator.userAgent;
|
|
115
115
|
return /iPhone/i.test(ua);
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
@@ -119,7 +119,7 @@ function isIphone() {
|
|
|
119
119
|
*@return {boolean} 返回true和false
|
|
120
120
|
*/
|
|
121
121
|
function isIpad() {
|
|
122
|
-
const ua = window.navigator.userAgent;
|
|
122
|
+
const ua = window && window.navigator.userAgent;
|
|
123
123
|
return /iPod/i.test(ua);
|
|
124
124
|
}
|
|
125
125
|
/* 手机浏览器类型 */
|
|
@@ -128,7 +128,7 @@ function isIpad() {
|
|
|
128
128
|
* @returns {boolean} 返回true和false
|
|
129
129
|
*/
|
|
130
130
|
function isWeixin() {
|
|
131
|
-
const ua = window.navigator.userAgent;
|
|
131
|
+
const ua = window && window.navigator.userAgent;
|
|
132
132
|
return /MicroMessenger/i.test(ua);
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
@@ -136,7 +136,7 @@ function isWeixin() {
|
|
|
136
136
|
* @returns {boolean} 返回true和false
|
|
137
137
|
*/
|
|
138
138
|
function isQQ() {
|
|
139
|
-
const ua = window.navigator.userAgent;
|
|
139
|
+
const ua = window && window.navigator.userAgent;
|
|
140
140
|
return /QQ/i.test(ua);
|
|
141
141
|
}
|
|
142
142
|
|
package/dist/cjs/file/index.cjs
CHANGED
|
@@ -120,15 +120,16 @@ function fileToUrl(file) {
|
|
|
120
120
|
function urlToFile(url) {
|
|
121
121
|
return new Promise((resolve, reject) => {
|
|
122
122
|
try {
|
|
123
|
-
window
|
|
124
|
-
|
|
125
|
-
res.
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
window &&
|
|
124
|
+
window.fetch(url).then((res) => {
|
|
125
|
+
if (res.status === 200) {
|
|
126
|
+
res.blob().then((blob) => {
|
|
127
|
+
blobToFile(blob).then((file) => {
|
|
128
|
+
resolve(file);
|
|
129
|
+
});
|
|
128
130
|
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
});
|
|
131
|
+
}
|
|
132
|
+
});
|
|
132
133
|
}
|
|
133
134
|
catch (err) {
|
|
134
135
|
console.error(err);
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns {string} 返回数据
|
|
8
8
|
*/
|
|
9
9
|
function getLocalStorage(key) {
|
|
10
|
-
return window.localStorage.getItem(key) || undefined;
|
|
10
|
+
return (window && window.localStorage.getItem(key)) || undefined;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* 设置localStorage缓存数据
|
|
@@ -15,20 +15,20 @@ function getLocalStorage(key) {
|
|
|
15
15
|
* @param {string} value value值
|
|
16
16
|
*/
|
|
17
17
|
function setLocalStorage(key, value) {
|
|
18
|
-
window.localStorage.setItem(key, value);
|
|
18
|
+
window && window.localStorage.setItem(key, value);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* 通过key从localStorage缓存中删除数据
|
|
22
22
|
* @param {string} key key值
|
|
23
23
|
*/
|
|
24
24
|
function removeLocalStorage(key) {
|
|
25
|
-
window.localStorage.removeItem(key);
|
|
25
|
+
window && window.localStorage.removeItem(key);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* 清空localStorage缓存中所有数据
|
|
29
29
|
*/
|
|
30
30
|
function clearLocalStorage() {
|
|
31
|
-
window.localStorage.clear();
|
|
31
|
+
window && window.localStorage.clear();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
exports.clearLocalStorage = clearLocalStorage;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* @returns {string} 返回数据
|
|
8
8
|
*/
|
|
9
9
|
function getSessionStorage(key) {
|
|
10
|
-
return window.sessionStorage.getItem(key) || undefined;
|
|
10
|
+
return (window && window.sessionStorage.getItem(key)) || undefined;
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
13
13
|
* 设置sessionStorage缓存数据
|
|
@@ -15,20 +15,20 @@ function getSessionStorage(key) {
|
|
|
15
15
|
* @param {string} value value值
|
|
16
16
|
*/
|
|
17
17
|
function setSessionStorage(key, value) {
|
|
18
|
-
window.sessionStorage.setItem(key, value);
|
|
18
|
+
window && window.sessionStorage.setItem(key, value);
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* 通过key从sessionStorage缓存中删除数据
|
|
22
22
|
* @param {string} key key值
|
|
23
23
|
*/
|
|
24
24
|
function removeSessionStorage(key) {
|
|
25
|
-
window.sessionStorage.removeItem(key);
|
|
25
|
+
window && window.sessionStorage.removeItem(key);
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* 清空sessionStorage缓存中所有数据
|
|
29
29
|
*/
|
|
30
30
|
function clearSessionStorage() {
|
|
31
|
-
window.sessionStorage.clear();
|
|
31
|
+
window && window.sessionStorage.clear();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
exports.clearSessionStorage = clearSessionStorage;
|
|
@@ -219,12 +219,7 @@ function isFalse(value) {
|
|
|
219
219
|
* @returns {boolean} 返回结果
|
|
220
220
|
*/
|
|
221
221
|
function isNaN(value) {
|
|
222
|
-
return (value == null ||
|
|
223
|
-
typeof value === "boolean" || // 布尔值视为非数字
|
|
224
|
-
Array.isArray(value) || // 数组视为非数字
|
|
225
|
-
value === "" || // 空字符串视为非数字
|
|
226
|
-
window.isNaN(Number(value)) // 原生isNaN判断(转数字后是否为NaN)
|
|
227
|
-
);
|
|
222
|
+
return (value == null || typeof value === "boolean" || Array.isArray(value) || value === "" || Number.isNaN(Number(value)));
|
|
228
223
|
}
|
|
229
224
|
/**
|
|
230
225
|
* 判断是数字
|
|
@@ -42,7 +42,7 @@ function getClipboard() {
|
|
|
42
42
|
*/
|
|
43
43
|
function getClipboardText() {
|
|
44
44
|
return new Promise((resolve, reject) => {
|
|
45
|
-
if (window.navigator
|
|
45
|
+
if (window && window.navigator) {
|
|
46
46
|
window.navigator.clipboard
|
|
47
47
|
.readText()
|
|
48
48
|
.then((text) => {
|
|
@@ -66,7 +66,7 @@ function getClipboardText() {
|
|
|
66
66
|
function setClipboard(data) {
|
|
67
67
|
return new Promise((resolve, reject) => {
|
|
68
68
|
// 现代浏览器
|
|
69
|
-
if (window.navigator
|
|
69
|
+
if (window && window.navigator) {
|
|
70
70
|
let clipboardItem = null;
|
|
71
71
|
// 是文本类型
|
|
72
72
|
if (typeof data === "string") {
|
|
@@ -99,7 +99,7 @@ function setClipboard(data) {
|
|
|
99
99
|
function setClipboardText(text) {
|
|
100
100
|
return new Promise((resolve, reject) => {
|
|
101
101
|
// 现代浏览器
|
|
102
|
-
if (window.navigator
|
|
102
|
+
if (window && window.navigator) {
|
|
103
103
|
window.navigator.clipboard.writeText(text).then((success) => {
|
|
104
104
|
resolve(true);
|
|
105
105
|
}, (failed) => {
|
package/dist/es/device/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @returns {Object} 返回浏览器信息
|
|
9
9
|
*/
|
|
10
10
|
function getBrowserInfo() {
|
|
11
|
-
const ua = window.navigator.userAgent.toLowerCase();
|
|
11
|
+
const ua = window && window.navigator.userAgent.toLowerCase();
|
|
12
12
|
// ie
|
|
13
13
|
const ie = ua.match(/rv:([\d.]+)\) like gecko/) || ua.match(/msie ([\d\.]+)/);
|
|
14
14
|
// edge
|
|
@@ -51,7 +51,7 @@ function isPc() {
|
|
|
51
51
|
* @returns {boolean} 返回true和false
|
|
52
52
|
*/
|
|
53
53
|
function isPhone() {
|
|
54
|
-
const ua = window.navigator.userAgent;
|
|
54
|
+
const ua = window && window.navigator.userAgent;
|
|
55
55
|
return /Android|webOS|iPhone|iPod|BlackBerry|Windows Phone|IEMobile/i.test(ua);
|
|
56
56
|
}
|
|
57
57
|
/* 操作系统类型 */
|
|
@@ -60,7 +60,7 @@ function isPhone() {
|
|
|
60
60
|
* @returns {boolean} 返回true和false
|
|
61
61
|
*/
|
|
62
62
|
function isAndroid() {
|
|
63
|
-
const ua = window.navigator.userAgent;
|
|
63
|
+
const ua = window && window.navigator.userAgent;
|
|
64
64
|
return /Android|BlackBerry/i.test(ua);
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
@@ -68,7 +68,7 @@ function isAndroid() {
|
|
|
68
68
|
* @returns {boolean} 返回true和false
|
|
69
69
|
*/
|
|
70
70
|
function isIos() {
|
|
71
|
-
const ua = window.navigator.userAgent;
|
|
71
|
+
const ua = window && window.navigator.userAgent;
|
|
72
72
|
return /iPhone|iPad|iPod|iOS/i.test(ua);
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
@@ -76,7 +76,7 @@ function isIos() {
|
|
|
76
76
|
* @returns {boolean} 返回true和false
|
|
77
77
|
*/
|
|
78
78
|
function isWindowsPhone() {
|
|
79
|
-
const ua = window.navigator.userAgent;
|
|
79
|
+
const ua = window && window.navigator.userAgent;
|
|
80
80
|
return /Windows Phone/i.test(ua);
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
@@ -84,7 +84,7 @@ function isWindowsPhone() {
|
|
|
84
84
|
* @returns {boolean} 返回true和false
|
|
85
85
|
*/
|
|
86
86
|
function isWindows() {
|
|
87
|
-
const ua = window.navigator.userAgent;
|
|
87
|
+
const ua = window && window.navigator.userAgent;
|
|
88
88
|
return /win/i.test(ua);
|
|
89
89
|
}
|
|
90
90
|
/**
|
|
@@ -92,7 +92,7 @@ function isWindows() {
|
|
|
92
92
|
* @returns {boolean} 返回true和false
|
|
93
93
|
*/
|
|
94
94
|
function isLinux() {
|
|
95
|
-
const ua = window.navigator.userAgent;
|
|
95
|
+
const ua = window && window.navigator.userAgent;
|
|
96
96
|
return /linux/i.test(ua);
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
@@ -100,7 +100,7 @@ function isLinux() {
|
|
|
100
100
|
* @returns {boolean} 返回true和false
|
|
101
101
|
*/
|
|
102
102
|
function isMac() {
|
|
103
|
-
const ua = window.navigator.userAgent;
|
|
103
|
+
const ua = window && window.navigator.userAgent;
|
|
104
104
|
return /mac/i.test(ua);
|
|
105
105
|
}
|
|
106
106
|
/* 苹果设备类型 */
|
|
@@ -109,7 +109,7 @@ function isMac() {
|
|
|
109
109
|
*@returns {boolean} 返回true和false
|
|
110
110
|
*/
|
|
111
111
|
function isIphone() {
|
|
112
|
-
const ua = window.navigator.userAgent;
|
|
112
|
+
const ua = window && window.navigator.userAgent;
|
|
113
113
|
return /iPhone/i.test(ua);
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
@@ -117,7 +117,7 @@ function isIphone() {
|
|
|
117
117
|
*@return {boolean} 返回true和false
|
|
118
118
|
*/
|
|
119
119
|
function isIpad() {
|
|
120
|
-
const ua = window.navigator.userAgent;
|
|
120
|
+
const ua = window && window.navigator.userAgent;
|
|
121
121
|
return /iPod/i.test(ua);
|
|
122
122
|
}
|
|
123
123
|
/* 手机浏览器类型 */
|
|
@@ -126,7 +126,7 @@ function isIpad() {
|
|
|
126
126
|
* @returns {boolean} 返回true和false
|
|
127
127
|
*/
|
|
128
128
|
function isWeixin() {
|
|
129
|
-
const ua = window.navigator.userAgent;
|
|
129
|
+
const ua = window && window.navigator.userAgent;
|
|
130
130
|
return /MicroMessenger/i.test(ua);
|
|
131
131
|
}
|
|
132
132
|
/**
|
|
@@ -134,7 +134,7 @@ function isWeixin() {
|
|
|
134
134
|
* @returns {boolean} 返回true和false
|
|
135
135
|
*/
|
|
136
136
|
function isQQ() {
|
|
137
|
-
const ua = window.navigator.userAgent;
|
|
137
|
+
const ua = window && window.navigator.userAgent;
|
|
138
138
|
return /QQ/i.test(ua);
|
|
139
139
|
}
|
|
140
140
|
|
package/dist/es/file/index.mjs
CHANGED
|
@@ -118,15 +118,16 @@ function fileToUrl(file) {
|
|
|
118
118
|
function urlToFile(url) {
|
|
119
119
|
return new Promise((resolve, reject) => {
|
|
120
120
|
try {
|
|
121
|
-
window
|
|
122
|
-
|
|
123
|
-
res.
|
|
124
|
-
|
|
125
|
-
|
|
121
|
+
window &&
|
|
122
|
+
window.fetch(url).then((res) => {
|
|
123
|
+
if (res.status === 200) {
|
|
124
|
+
res.blob().then((blob) => {
|
|
125
|
+
blobToFile(blob).then((file) => {
|
|
126
|
+
resolve(file);
|
|
127
|
+
});
|
|
126
128
|
});
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
});
|
|
129
|
+
}
|
|
130
|
+
});
|
|
130
131
|
}
|
|
131
132
|
catch (err) {
|
|
132
133
|
console.error(err);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @returns {string} 返回数据
|
|
6
6
|
*/
|
|
7
7
|
function getLocalStorage(key) {
|
|
8
|
-
return window.localStorage.getItem(key) || undefined;
|
|
8
|
+
return (window && window.localStorage.getItem(key)) || undefined;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 设置localStorage缓存数据
|
|
@@ -13,20 +13,20 @@ function getLocalStorage(key) {
|
|
|
13
13
|
* @param {string} value value值
|
|
14
14
|
*/
|
|
15
15
|
function setLocalStorage(key, value) {
|
|
16
|
-
window.localStorage.setItem(key, value);
|
|
16
|
+
window && window.localStorage.setItem(key, value);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* 通过key从localStorage缓存中删除数据
|
|
20
20
|
* @param {string} key key值
|
|
21
21
|
*/
|
|
22
22
|
function removeLocalStorage(key) {
|
|
23
|
-
window.localStorage.removeItem(key);
|
|
23
|
+
window && window.localStorage.removeItem(key);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* 清空localStorage缓存中所有数据
|
|
27
27
|
*/
|
|
28
28
|
function clearLocalStorage() {
|
|
29
|
-
window.localStorage.clear();
|
|
29
|
+
window && window.localStorage.clear();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export { clearLocalStorage, getLocalStorage, removeLocalStorage, setLocalStorage };
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @returns {string} 返回数据
|
|
6
6
|
*/
|
|
7
7
|
function getSessionStorage(key) {
|
|
8
|
-
return window.sessionStorage.getItem(key) || undefined;
|
|
8
|
+
return (window && window.sessionStorage.getItem(key)) || undefined;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* 设置sessionStorage缓存数据
|
|
@@ -13,20 +13,20 @@ function getSessionStorage(key) {
|
|
|
13
13
|
* @param {string} value value值
|
|
14
14
|
*/
|
|
15
15
|
function setSessionStorage(key, value) {
|
|
16
|
-
window.sessionStorage.setItem(key, value);
|
|
16
|
+
window && window.sessionStorage.setItem(key, value);
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* 通过key从sessionStorage缓存中删除数据
|
|
20
20
|
* @param {string} key key值
|
|
21
21
|
*/
|
|
22
22
|
function removeSessionStorage(key) {
|
|
23
|
-
window.sessionStorage.removeItem(key);
|
|
23
|
+
window && window.sessionStorage.removeItem(key);
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* 清空sessionStorage缓存中所有数据
|
|
27
27
|
*/
|
|
28
28
|
function clearSessionStorage() {
|
|
29
|
-
window.sessionStorage.clear();
|
|
29
|
+
window && window.sessionStorage.clear();
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export { clearSessionStorage, getSessionStorage, removeSessionStorage, setSessionStorage };
|
|
@@ -217,12 +217,7 @@ function isFalse(value) {
|
|
|
217
217
|
* @returns {boolean} 返回结果
|
|
218
218
|
*/
|
|
219
219
|
function isNaN(value) {
|
|
220
|
-
return (value == null ||
|
|
221
|
-
typeof value === "boolean" || // 布尔值视为非数字
|
|
222
|
-
Array.isArray(value) || // 数组视为非数字
|
|
223
|
-
value === "" || // 空字符串视为非数字
|
|
224
|
-
window.isNaN(Number(value)) // 原生isNaN判断(转数字后是否为NaN)
|
|
225
|
-
);
|
|
220
|
+
return (value == null || typeof value === "boolean" || Array.isArray(value) || value === "" || Number.isNaN(Number(value)));
|
|
226
221
|
}
|
|
227
222
|
/**
|
|
228
223
|
* 判断是数字
|