Skip to content

[Feature] #123

@wnfilm

Description

@wnfilm

想要什么功能 / What feature?

建议:额度刷新成功但部分账号「日额度」为空,希望 UI / API 能明确区分

当前版本:v2.0.74

我们在使用 Dashboard 的「刷新余额 / refresh credits」时发现:部分账号刷新接口返回成功,但页面里的「日额度」显示不出来,容易让运维误以为账号或代理有问题。

现象

我们有 20 个账号,刷新余额后:

  • 12 个账号有 dailyPercent
  • 8 个账号 dailyPercent 为 null
  • 这 8 个账号 weeklyPercent 是有值的,约 45% - 49%
  • refresh 接口返回 ok=true,没有 lastError

示例:

f182ab4d daily=NULL weekly=45
51b10b0b daily=NULL weekly=49
78990c8a daily=NULL weekly=49
62888d6f daily=NULL weekly=49
310267ce daily=NULL weekly=49
bc3ea65a daily=NULL weekly=49
3718287a daily=NULL weekly=48
78c36754 daily=NULL weekly=49

单独刷新其中一个账号时,返回类似:

{
"ok": true,
"credits": {
"planName": "Trial",
"dailyPercent": null,
"weeklyPercent": 45,
"prompt": {
"limit": 100,
"remaining": 100
},
"percent": 100
}
}

初步判断

看起来不是刷新失败,也不是账号不可用,而是上游 GetUserStatus 对部分 Trial 账号没有返回 dailyQuotaRemainingPercent,但返回了 weeklyQuotaRemainingPercent。

目前代码里 daily 字段只有在上游返回数字时才写入:

dailyPercent: typeof ps.dailyQuotaRemainingPercent === 'number'
? ps.dailyQuotaRemainingPercent
: null

这个逻辑本身没问题,但 Dashboard 上用户很难判断这是:

  1. 刷新失败
  2. 账号异常
  3. 上游没有返回日额度字段

建议

希望可以优化一下显示和 API 语义:

  1. 当 dailyPercent=null 但 weeklyPercent 有值时,UI 显示为:

    • 日:上游未返回
    • 或 日:N/A
    • 不要让用户误以为刷新失败
  2. refresh-credits 返回里可以加一个字段,例如:

{
"dailyQuotaAvailable": false,
"dailyQuotaReason": "upstream_missing",
"weeklyQuotaAvailable": true
}

  1. 当前 percent 在 daily 缺失时会 fallback 到 prompt credits,可能出现 daily=null, weekly=45, percent=100,这个对运维判断有点误导。建议:

    • 如果 weeklyPercent 有值,可以优先用 weeklyPercent 作为兜底展示
    • 或者明确区分 promptPercent 和 quotaPercent
  2. 如果可行,可以增加一个 GetPlanStatus 兜底,用来补齐 GetUserStatus 没返回的 daily quota。

期望效果

刷新成功但上游没给 daily quota 时,Dashboard 能明确告诉用户「不是失败,是上游未返回日额度」,同时仍展示 weekly quota,方便判断账号真实剩余额度。

替代方案 / Alternatives considered

No response

是否愿意提 PR / Willing to submit a PR?

  • 我想自己实现 / I'd like to implement this myself

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfixed已修复 等待确认

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions