浏览代码

限流:timeout 5 => 10 秒

Michael Wang 4 年之前
父节点
当前提交
d2d19b6263
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      src/utils/tryLimit.js

+ 7 - 2
src/utils/tryLimit.js

@@ -7,10 +7,15 @@ export async function tryLimit({ action, limit = 100 }) {
   try {
     res = await axios.get(
       `https://tcc.qmth.com.cn/rate_limit/prod/${action}/${limit}`,
-      { timeout: 5 * 1000 }
+      { timeout: 10 * 1000 }
     );
     serverPass = res.data.pass;
 
+    createLog({
+      action: "第一次限流调用",
+      limitAction: action,
+      detail: serverPass ? "进入" : "限流",
+    });
     if (!serverPass) {
       // 休眠 1 ~ 5 秒 再试
       res = null; // 供外部判断
@@ -21,7 +26,7 @@ export async function tryLimit({ action, limit = 100 }) {
       console.log({ sleepTime, now: Date.now() });
       res = await axios.get(
         `https://tcc.qmth.com.cn/rate_limit/prod/${action}/${limit}`,
-        { timeout: 5 * 1000 }
+        { timeout: 10 * 1000 }
       );
       serverPass = res.data.pass;
       createLog({