feat: 新增 DeepSeek 余额查询显示 - #19
Merged
Merged
Conversation
侧边栏新增单行余额显示,支持: - /cache-balance-key 配置 DeepSeek API Key(脱敏预填,空清除/含*保留原key/新key实时刷新) - 5 分钟轮询 + key 变更强制重新查询 - 错误状态区分(401/403/无数据/其他) - 跟随 /cache-currency 多币种切换(CNY/USD 直显,其余按汇率换算) - /cache-section 新增 DS Balance 开关, /cache-config 展示状态 - 余额区块上方分割线与开关联动
Hotakus
reviewed
Aug 8, 2026
Comment on lines
+544
to
+547
| createEffect(() => { | ||
| void balanceRefresh() | ||
| pollBalance() | ||
| }) |
Owner
There was a problem hiding this comment.
感谢你提交的新功能添加,但是我注意到,在 pollBalance() 中,引用了 balanceState(),balanceState() 的状态变化是否会导致 effect 被循环请求?
Contributor
Author
There was a problem hiding this comment.
感谢指出问题!已自查修复并推送。
根因:createEffect 直接调用 async 的 pollBalance(),而 async 函数 await 前的同步段读取并写入了 balanceState 信号,被 effect 追踪后与 setBalanceState 形成无限循环,且每轮重跑都发起新请求。
本次修复:
- 用 untrack 包裹 pollBalance,使 effect 仅追踪 balanceRefresh(key 变更时才重新查询),循环消除
- 移除 onMount 中重复的首次请求
- 增加请求序号,防止定时轮询与手动刷新并发时旧请求覆盖新结果
- 失败时清空旧数据,避免显示过期余额
- AbortController 10s 超时,超时显示"查询超时"
麻烦再次 review ,谢谢!
- untrack 包裹 pollBalance,避免 effect 追踪 balanceState 形成无限循环 - 移除 onMount 重复的首次请求 - 请求序号防止旧请求覆盖新结果 - 失败时清空旧数据 - AbortController 10s 超时并显示'查询超时'
Owner
|
感谢你的新功能,代码合并后,我会尽快推送更新,感谢你的支持 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
功能
侧边栏新增单行余额显示,支持:
说明
总余额就没做折叠项,用分割线隔开,个人觉得比较美观截图