add
This commit is contained in:
parent
91abd4cdac
commit
1174815e4e
|
@ -1,9 +1,24 @@
|
||||||
// browserCheck.js
|
// 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() {
|
function checkBrowserVersion() {
|
||||||
const userAgent = navigator.userAgent;
|
const userAgent = navigator.userAgent;
|
||||||
const chromeMatch = userAgent.match(/Chrome\/(\d+)/);
|
const chromeMatch = userAgent.match(/Chrome\/(\d+)/);
|
||||||
|
const firefoxMatch = userAgent.match(/Firefox\/(\d+)/);
|
||||||
|
|
||||||
if (chromeMatch) {
|
if (chromeMatch) {
|
||||||
const chromeVersion = parseInt(chromeMatch[1], 10);
|
const chromeVersion = parseInt(chromeMatch[1], 10);
|
||||||
|
@ -12,6 +27,15 @@ function checkBrowserVersion() {
|
||||||
} else if (chromeVersion < 100) {
|
} else if (chromeVersion < 100) {
|
||||||
showUpdatePrompt();
|
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/")) {
|
} else if (userAgent.includes("MSIE") || userAgent.includes("Trident/")) {
|
||||||
showUpdatePrompt();
|
showUpdatePrompt();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue