Quellcode durchsuchen

统计限流接口调用次数

Michael Wang vor 4 Jahren
Ursprung
Commit
03ccfc2c7a
2 geänderte Dateien mit 18 neuen und 1 gelöschten Zeilen
  1. 8 0
      src/features/Login/Login.vue
  2. 10 1
      src/features/OnlineExam/OnlineExamList.vue

+ 8 - 0
src/features/Login/Login.vue

@@ -493,6 +493,10 @@ export default {
       this.loginBtnLoading = true;
 
       const limitResult = await tryLimit({ action: "login", limit: 500 });
+      this.logger({
+        action: "登录页面--login clicked",
+        logId: "登录限流API call",
+      });
       if (!limitResult) {
         createLog({
           currentPage: "登录页面--login clicked",
@@ -506,6 +510,10 @@ export default {
         this.loginBtnLoading = false;
         return;
       }
+      createLog({
+        currentPage: "登录页面--login clicked",
+        action: "登录未限流",
+      });
 
       const before = Date.now();
 

+ 10 - 1
src/features/OnlineExam/OnlineExamList.vue

@@ -173,18 +173,26 @@ export default {
       );
     },
     async raceEnter(course) {
+      this.spinShow = true;
+      this.processingMessage = "正在请求...";
       const minutesAfterCourseStart = Math.floor(
         moment(this.now).diff(moment(course.startTime), "seconds") / 60
       );
 
       this.enterButtonClicked = true;
       const limitResult = await tryLimit({ action: "startExam", limit: 100 });
+      this.logger({
+        action: "在线考试列表页面",
+        logId: "开考限流API call",
+      });
       this.enterButtonClicked = false;
+      this.spinShow = false;
 
       if (limitResult) {
         window._hmt.push(["_trackEvent", "在线考试列表页面", "摇号进入考试"]);
         this.logger({
           action: "在线考试列表页面",
+          logId: "开考未限流",
           detail: "限流-" + minutesAfterCourseStart + "分进入",
         });
 
@@ -198,6 +206,7 @@ export default {
         ]);
         this.logger({
           action: "在线考试列表页面",
+          logId: "开考被限流",
           detail: "限流-" + minutesAfterCourseStart + "分被限流",
         });
         this.$Modal.warning({
@@ -205,7 +214,7 @@ export default {
           content: "网络繁忙,请稍后再试。",
           onOk: () => {
             clearInterval(this.countdownInterval);
-            this.countdown = 10;
+            this.countdown = 3;
             this.countdownInterval = setInterval(() => {
               this.countdown--;
             }, 1 * 1000);