Răsfoiți Sursa

检测窗口大小变化,并上报日志

Michael Wang 3 ani în urmă
părinte
comite
fb32c6ca61
2 a modificat fișierele cu 25 adăugiri și 1 ștergeri
  1. 2 1
      src/features/Login/Login.vue
  2. 23 0
      src/utils/util.js

+ 2 - 1
src/features/Login/Login.vue

@@ -146,7 +146,7 @@ import {
   createUserDetailLog,
   createEncryptLog,
 } from "@/utils/logger";
-import { isElectron } from "@/utils/util";
+import { isElectron, registerOnResize } from "@/utils/util";
 import GeeTest from "./GeeTest";
 import GlobalNotice from "./GlobalNotice";
 import { tryLimit } from "@/utils/tryLimit";
@@ -445,6 +445,7 @@ export default {
         duration: 2 * 24 * 60 * 60,
       });
     }
+    registerOnResize();
 
     if (
       [

+ 23 - 0
src/utils/util.js

@@ -1,3 +1,6 @@
+import { throttle } from "lodash";
+import { createLog } from "./logger";
+
 export function toChineseNumber(num) {
   let ret;
   if (num < 10) {
@@ -35,6 +38,26 @@ export function isElectron() {
   return typeof nodeRequire != "undefined";
 }
 
+export function registerOnResize() {
+  const throttledResizeLog = throttle(() => {
+    createLog({
+      page: window.location.pathname,
+      action: "registerOnResize",
+      width: window.screen.width,
+      height: window.screen.height,
+      screenX: window.screen.availWidth,
+      screenY: window.screen.availHeight,
+      clientWidth: document.documentElement.clientWidth,
+      clientHeight: document.documentElement.clientHeight,
+      windowInnerWidth: window.innerWidth,
+      windowInnerHeight: window.innerHeight,
+      windowOuterWidth: window.outerWidth,
+      windowOuterHeight: window.outerHeight,
+    });
+  }, 3000);
+  window.onresize = throttledResizeLog;
+}
+
 // 下载文件
 export async function downloadFileURL(url, name) {
   const link = document.createElement("a");