Selaa lähdekoodia

浏览器版本要求

Michael Wang 4 vuotta sitten
vanhempi
commit
39b0923ca5
2 muutettua tiedostoa jossa 20 lisäystä ja 2 poistoa
  1. 7 1
      src/main.ts
  2. 13 1
      src/utils/ua.ts

+ 7 - 1
src/main.ts

@@ -1,4 +1,10 @@
-import "@/utils/ua.ts";
+import validUA from "@/utils/ua.ts";
+if (!validUA) {
+  alert(
+    "请选择Chrome内核版本大于80的浏览器,最新版的Chrome浏览器、360浏览器、QQ浏览器满足要求。"
+  );
+  location.href = "about:blank";
+}
 import "./styles/global.css";
 import { createApp } from "vue";
 import App from "./App.vue";

+ 13 - 1
src/utils/ua.ts

@@ -2,7 +2,7 @@ import UAParser from "ua-parser-js";
 
 const ua = new UAParser();
 
-export function printUA() {
+function printUA() {
   console.log(
     `浏览器名称:${ua.getBrowser().name}   浏览器版本:${
       ua.getBrowser().version
@@ -13,3 +13,15 @@ export function printUA() {
 }
 
 printUA();
+
+export default function () {
+  console.log(parseInt(ua.getBrowser().version || "", 10));
+  if (
+    ua.getBrowser().name !== "Blink" ||
+    parseInt(ua.getBrowser().version || "", 10) <= 80
+  ) {
+    return false;
+  } else {
+    return true;
+  }
+}