{"record":{"id":"5b5a36368facf608","repo":"yikart/AiToEarn","slug":"error-5b5a36","errorCode":null,"errorMessage":"获取三方平台数据失败","messagePattern":"获取三方平台数据失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-electron/electron/main/plat/platforms/douyin/index.ts","lineNumber":123,"sourceCode":"  async getStatistics(account: AccountModel) {\n    const cookie: CookiesType = JSON.parse(account.loginCookie);\n\n    const accountInfo = await douyinService.getUserInfo(cookie);\n    return {\n      fansCount: accountInfo.fansCount,\n      workCount: 0, // TODO: 作品数量\n    };\n  }\n\n  async getDashboard(account: AccountModel, time: string[] = []) {\n    const res: DashboardData[] = [];\n    try {\n      const ret = await douyinService.getDashboardFunc(\n        account.loginCookie,\n        time[0],\n        time[1],\n      );\n      if (!ret.success) throw new Error('获取三方平台数据失败');\n      // console.log('@@@ret.data', ret.data)\n      for (const item of ret.data) {\n        res.push({\n          time: item.date,\n          fans: item.zhangfen,\n          read: item.bofang,\n          comment: item.pinglun,\n          like: item.dianzan,\n          forward: item.fenxiang,\n          collect: 0,\n        });\n      }\n    } catch (error) {\n      console.log('------ getDashboard wxSph ---', error);\n    }\n\n    return res.reverse();\n  }","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/electron/main/plat/platforms/douyin/index.ts#L105-L141","documentation":"getDashboard fetches douyin (抖音) platform dashboard data through douyinService.getDashboardFunc. If the service response reports success:false (third-party API failure, expired login cookie, or upstream error), the code throws a plain Error with the Chinese message '获取三方平台数据失败' (failed to get third-party platform data).","triggerScenarios":"douyinService returns { success: false } — typically because account.loginCookie is expired/invalid, the douyin open API rejected or rate-limited the request, or the time range parameters are invalid.","commonSituations":"User's douyin session cookie expired and needs re-login; douyin changed its API response shape; network/proxy failure reaching douyin; querying a time range with no data.","solutions":["Re-authenticate the douyin account to refresh loginCookie","Log ret payload on failure to see douyin's actual error and handle rate limits","Validate/normalize the time range before calling getDashboardFunc","Add a fallback/empty-result path so the dashboard UI degrades gracefully instead of throwing"],"exampleFix":"// before\nif (!ret.success) throw new Error('获取三方平台数据失败');\n// after\nif (!ret.success || !Array.isArray(ret.data)) {\n  logger.warn('douyin dashboard failed', ret?.message);\n  return []; // graceful fallback\n}","handlingStrategy":"fallback","validationCode":"if (!account.loginCookie || isCookieExpired(account.loginCookie)) {\n  throw new Error('Douyin login expired, please re-authenticate');\n}\nif (!Array.isArray(time) || time.length !== 2) {\n  throw new Error('Invalid dashboard time range');\n}","typeGuard":"function isDashboardResponse(r: unknown): r is { success: true; data: { date: string; zhangfen: number; bofang: number }[] } {\n  return !!r && typeof r === 'object' && (r as any).success === true && Array.isArray((r as any).data);\n}","tryCatchPattern":"try {\n  const data = await getDashboard(account, time);\n} catch (e) {\n  if (e.message === '获取三方平台数据失败') {\n    logger.warn('Douyin dashboard unavailable, returning cached/empty data');\n    return cachedDashboard ?? [];\n  }\n  throw e;\n}","preventionTips":["Refresh douyin loginCookie proactively and detect 401/cookie-expiry responses","Log the third-party failure payload for diagnosis instead of a generic message","Validate the time range before calling the upstream API","Return empty/cached results so the dashboard degrades gracefully"],"tags":["douyin","third-party-api","network","cookie-expired"],"backgroundTag":"third-party-api-request-failed","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}