Browse Source

🐞 fix: 修复跑步记录已存在的问题

Pchen0 1 month ago
parent
commit
653cf05b97
1 changed files with 15 additions and 0 deletions
  1. 15 0
      lib/Lepao/Worker.js

+ 15 - 0
lib/Lepao/Worker.js

@@ -185,6 +185,21 @@ class Worker {
 
     isRunSuccess(bindResponse) {
         const payload = bindResponse?.data
+        const info = String(bindResponse?.info || '')
+        const idempotentExists =
+            info.includes('跑步记录已存在') ||
+            info.includes('记录已存在')
+
+        // 幂等兜底:首包可能已成功落库,但响应在代理链路丢失,重发后会返回“记录已存在”。
+        // 该场景应按成功处理,避免误判失败后返还次数。
+        if (idempotentExists) {
+            return {
+                ok: true,
+                reason: info || '跑步记录已存在',
+                payload
+            }
+        }
+
         if (!bindResponse || bindResponse.status !== 1 || !payload) {
             return {
                 ok: false,