Kaynağa Gözat

登录页面加载慢,可关闭应用

Michael Wang 3 yıl önce
ebeveyn
işleme
e108ab4cc4
2 değiştirilmiş dosya ile 46 ekleme ve 1 silme
  1. 43 1
      index.html
  2. 3 0
      src/main.ts

+ 43 - 1
index.html

@@ -1,15 +1,57 @@
 <!DOCTYPE html>
-<html lang="en">
+<html>
 
 <head>
   <meta charset="UTF-8" />
   <link rel="icon" href="/favicon.ico" />
+  <meta name="Description" content="考试云平台 -- 由武汉启明泰和软件服务有限公司提供" />
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
   <title>网考学生端</title>
+  <script>
+    // 重命名 Electron 提供的 require 详细请参考:https://www.w3cschool.cn/electronmanual/electronmanual-electron-faq.html
+    if (typeof require != "undefined") {
+      window.nodeRequire = require;
+      delete window.require;
+      delete window.exports;
+      delete window.module;
+    }
+  </script>
   <script src="https://static.geetest.com/static/tools/gt.js"></script>
+  <style>
+    #app-placeholder {
+      position: absolute;
+      top: 0;
+      left: 0;
+    }
+  </style>
 </head>
 
 <body>
+  <div id="app-placeholder">
+    <div style="
+        height: 120px;
+        font-size: 40px;
+        text-align: center;
+        width: 100vw;
+      ">
+      程序加载中...
+    </div>
+    <div class="js-close" style="display: none; justify-content: center;">
+      加载太慢?
+      <button>关闭</button>
+    </div>
+    <script>
+      //加载超过30秒还没有加载完JS,就显示关闭按钮,可退出应用
+      setTimeout(() => {
+        const closeBtn = document.querySelector('#app-placeholder .js-close');
+        if (closeBtn) {
+          closeBtn.style.display = "flex";
+          closeBtn.addEventListener('click', () => window.close());
+        }
+      }, 30 * 1000);
+    </script>
+  </div>
+
   <div id="app"></div>
 
   <!-- baidu tongji -->

+ 3 - 0
src/main.ts

@@ -21,3 +21,6 @@ meta.name = "naive-ui-style";
 document.head.appendChild(meta);
 
 app.mount("#app");
+
+if (document.getElementById("app-placeholder"))
+  document.getElementById("app-placeholder")?.remove();