add
This commit is contained in:
parent
13fe284752
commit
0f6e9fdb37
|
@ -1,9 +1,24 @@
|
|||
// browserCheck.js
|
||||
// 检测浏览器是否支持 ES6
|
||||
function supportsES6() {
|
||||
try {
|
||||
// 尝试使用一些 ES6 特性
|
||||
new Function("(a = 0) => a");
|
||||
let test = 0;
|
||||
const testConst = 0;
|
||||
class TestClass {}
|
||||
Promise.resolve();
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// 检查浏览器版本的函数
|
||||
function checkBrowserVersion() {
|
||||
const userAgent = navigator.userAgent;
|
||||
const chromeMatch = userAgent.match(/Chrome\/(\d+)/);
|
||||
const firefoxMatch = userAgent.match(/Firefox\/(\d+)/);
|
||||
|
||||
if (chromeMatch) {
|
||||
const chromeVersion = parseInt(chromeMatch[1], 10);
|
||||
|
@ -12,6 +27,15 @@ function checkBrowserVersion() {
|
|||
} else if (chromeVersion < 100) {
|
||||
showUpdatePrompt();
|
||||
}
|
||||
} else if (firefoxMatch) {
|
||||
const firefoxVersion = parseInt(firefoxMatch[1], 10);
|
||||
if (firefoxVersion < 70) {
|
||||
showMustDownloadPrompt();
|
||||
} else if (firefoxVersion < 90) {
|
||||
showUpdatePrompt();
|
||||
}
|
||||
} else if (!supportsES6()) {
|
||||
showMustDownloadPrompt();
|
||||
} else if (userAgent.includes("MSIE") || userAgent.includes("Trident/")) {
|
||||
showUpdatePrompt();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue