feat: add more info for `get.coreInfo`

This commit is contained in:
Rintim 2024-02-13 13:24:06 +08:00
parent 459df4e0a4
commit e181cd7f5c
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 11 additions and 7 deletions

View File

@ -18,15 +18,19 @@ export class Get extends Uninstantable {
*
* > 其他后续或许会增加`IE`永无可能
*
* @returns {["firefox" | "chrome" | "safari" | "other", number]}
* @returns {["firefox" | "chrome" | "safari" | "other", number, number, number]}
*/
static coreInfo() {
const regex = /(firefox|chrome|safari)\/([\d.]+)/;
let result;
if (!(result = userAgent.match(regex))) return ["other", NaN];
if (result[1] != "safari") return [result[1], parseInt(result[2])];
result = userAgent.match(/version\/([\d.]+).*safari/);
return ["safari", parseInt(result[1])];
const regex = /(firefox|chrome|safari)\/(\d+(?:\.\d+)+)/
let result
if (!(result = userAgent.match(regex))) return ["other", NaN, NaN, NaN]
if (result[1] != "safari") {
const [major, minor, patch] = result[2].split(".")
return [result[1], parseInt(major), parseInt(minor), parseInt(patch)]
}
result = userAgent.match(/version\/(\d+(?:\.\d+)+).*safari/)
const [major, minor, patch] = result[1].split(".")
return ["safari", parseInt(major), parseInt(minor), parseInt(patch)]
}
/**
* 返回 VCard[] 形式的所有牌用于印卡将遍历