Pārlūkot izejas kodu

添加百度统计

Michael Wang 3 gadi atpakaļ
vecāks
revīzija
5923cf6c3a
3 mainītis faili ar 32 papildinājumiem un 15 dzēšanām
  1. 27 11
      index.html
  2. 3 3
      src/router/index.ts
  3. 2 1
      src/types/global.d.ts

+ 27 - 11
index.html

@@ -1,13 +1,29 @@
 <!DOCTYPE html>
 <html lang="en">
-  <head>
-    <meta charset="UTF-8" />
-    <link rel="icon" href="/favicon.ico" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>网考学生端</title>
-  </head>
-  <body>
-    <div id="app"></div>
-    <script type="module" src="/src/main.ts"></script>
-  </body>
-</html>
+
+<head>
+  <meta charset="UTF-8" />
+  <link rel="icon" href="/favicon.ico" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <title>网考学生端</title>
+</head>
+
+<body>
+  <div id="app"></div>
+
+  <!-- baidu tongji -->
+  <script>
+    var _hmt = _hmt || [];
+    // TODO: 开发过程中注释掉
+    // (function () {
+    //   var hm = document.createElement("script");
+    //   hm.src = "https://hm.baidu.com/hm.js?d00b10467bcf422aeadda1f7074f32d3";
+    //   var s = document.getElementsByTagName("script")[0];
+    //   s.parentNode.insertBefore(hm, s);
+    // })();
+  </script>
+
+  <script type="module" src="/src/main.ts"></script>
+</body>
+
+</html>

+ 3 - 3
src/router/index.ts

@@ -36,9 +36,9 @@ const router = createRouter({
 router.beforeEach((to, from, next) => {
   const loginPath = "/login/";
 
-  // if (to.path) {
-  //   window._hmt.push(["_trackPageview", "/oe-web" + to.fullPath]);
-  // }
+  if (to.path) {
+    _hmt.push(["_trackPageview", "/oe-web" + to.fullPath]);
+  }
 
   if (to.path.match(/^\/?/) || to.path.match(/^\/login\/.?$/)) {
     resetStore();

+ 2 - 1
src/types/global.d.ts

@@ -12,7 +12,8 @@ export {};
 // }
 
 declare global {
-  let $message: MessageApiInjection;
+  const $message: MessageApiInjection;
+  const _hmt: string[][];
 }
 
 declare module "axios/index" {