Ver Fonte

百度统计:添加网络请求的统计

Michael Wang há 6 anos atrás
pai
commit
2cd4c3da99
2 ficheiros alterados com 6 adições e 1 exclusões
  1. 2 1
      src/plugins/axios.js
  2. 4 0
      src/router.js

+ 2 - 1
src/plugins/axios.js

@@ -128,6 +128,7 @@ _$http.interceptors.request.use(
 // Add a response interceptor
 _$httpWith500Msg.interceptors.response.use(
   response => {
+    window._hmt.push(["_trackEvent", "网络请求-响应", response.config.url]);
     return response;
   },
   error => {
@@ -204,6 +205,7 @@ _$httpWith500Msg.interceptors.response.use(
 _$http.interceptors.response.use(
   // no auto 500 error UI
   response => {
+    window._hmt.push(["_trackEvent", "网络请求-响应", response.config.url]);
     return response;
   },
   error => {
@@ -288,5 +290,4 @@ loadProgressBar({}, Vue.$httpWithMsg);
 loadProgressBar({}, Vue.$httpWithoutAuth);
 
 import "axios-progress-bar/dist/nprogress.css";
-
 export default Plugin;

+ 4 - 0
src/router.js

@@ -26,6 +26,10 @@ let router = new Router({
 });
 
 router.beforeEach((to, from, next) => {
+  if (to.path) {
+    window._hmt.push(["_trackPageview", "/admin" + to.fullPath]);
+  }
+
   if (to.path.includes("/preview_paper/")) {
     next();
     return;