feat: add method to get core info.

This commit is contained in:
Rintim 2023-11-15 22:22:23 +08:00
parent 4fa9579c7d
commit 72e6f7e076
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 17 additions and 0 deletions

View File

@ -58445,6 +58445,23 @@
},
};
const get={
/**
* 获取当前内核版本信息
*
* 目前仅考虑`chrome`, `firefox``safari`三种浏览器的信息其余均归于其他范畴
*
* > 其他后续或许会增加`IE`永无可能
*
* @returns {["firefox" | "chrome" | "safari" | "other", number]}
*/
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])];
},
/**
* 返回 VCard[] 形式的所有牌用于印卡将遍历
* @param {Function} filter