@@ -10,36 +10,38 @@ export interface IBrowser {
10
10
}
11
11
12
12
/**
13
- * Checks if the current browser meets minimum version requirements
13
+ * 检查当前浏览器是否满足最低版本要求
14
14
*
15
- * @category Environment Detection
15
+ * @category 环境检测
16
16
* @description
17
- * A utility function that validates whether the current browser satisfies specified minimum version
18
- * requirements. The function accepts an array of browser specifications and performs version
19
- * comparison checks.
17
+ * 该函数会检查当前浏览器的版本是否大于或等于指定的最低版本要求。
18
+ * 如果当前浏览器不在指定的浏览器列表中,将返回 false。
20
19
*
21
- * @param {IBrowser[] } browsers - An array of browser specifications, where each specification contains:
22
- * - `name`: Browser name (e.g., 'chrome', 'firefox', 'safari')
23
- * - `version`: Minimum required version number
24
- * @returns {boolean } Returns `true` if current browser meets version requirements, `false` otherwise
20
+ * @param {IBrowser[] } browsers - 浏览器最低版本配置数组
21
+ * - `name`: 浏览器名称,不区分大小写(如:'chrome'、'firefox'、'safari'等)
22
+ * - `version`: 最低版本号要求,支持字符串或数字格式(如:'80'、75、'13.0.1'等)
23
+ * @returns {boolean } 返回检查结果
24
+ * - 当前浏览器版本满足要求时,返回 `true`
25
+ * - 当前浏览器版本不满足要求或浏览器类型不匹配时,返回 `false`
26
+ * - 传入空数组时,返回 `false`
25
27
*
26
28
* @example
27
29
* ```typescript
28
30
* import { checkBrowserSupport } from 'dt-utils';
29
31
*
30
- * // Single browser check
32
+ * // 检查单个浏览器版本要求
31
33
* checkBrowserSupport([
32
34
* { name: 'chrome', version: '80' }
33
35
* ]);
34
36
*
35
- * // Multiple browser support
37
+ * // 检查多个浏览器版本要求(满足其中之一即可)
36
38
* checkBrowserSupport([
37
39
* { name: 'chrome', version: '80' },
38
40
* { name: 'firefox', version: '75' },
39
41
* { name: 'safari', version: '13' }
40
42
* ]);
41
43
*
42
- * // Version can be string or number
44
+ * // 版本号支持字符串或数字格式
43
45
* checkBrowserSupport([
44
46
* { name: 'chrome', version: 80 },
45
47
* { name: 'firefox', version: '75.0.1' }
0 commit comments