feat(credit-stats): 积分统计三模块账号联动,请求明细支持排序与分页 - #104
Open
magicapple123 wants to merge 1 commit into
Open
magicapple123 wants to merge 1 commit into
magicapple123 wants to merge 1 commit into
Conversation
- 趋势 / 按模型分类 / 积分明细三处的账号选择提升为页面级共享状态, 任一处切换,三处同步(changexbc#98 建议一) - 请求用量明细表头「请求时间」「消耗」可点击切换升降序,默认时间倒序(changexbc#98 建议二) - 明细超过 100 条时分页展示,显示区间与页码 - 后端每账号明细上限 100 → 1000:官方接口本来就全量扫回, 100 条截不住排查高消耗请求所需的更早记录 closes changexbc#98
Contributor
Author
This branch has not been deployed
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.
背景
#98 提了两点:三个模块各自一个账号下拉框,看一个账号要点三次;请求用量明细既不能按消耗排序,又只能看到最近 100 条。
做了什么
1. 账号选择联动(建议一)
趋势 / 按模型分类 / 积分明细三处的账号选择提升为页面级共享状态,任一处切换,三处同步。
2. 请求用量明细排序(建议二)
表头「请求时间」「消耗」可点击切换升序 / 降序,默认时间倒序(与改动前一致)。切到「消耗」列默认降序,直接看最高消耗的请求。
3. 明细分页 + 提高后端上限(建议二)
OFFICIAL_USAGE_DETAIL_LIMIT100 → 1000实现说明
sharedAccountFilter提到CreditStatsPage,三个子组件由内部 state 改为受控 props。AccountFilterMenu各自的allowAll语义不变 —— 积分明细只允许单账号,共享值为「所有账号」时仍回退到第一个账号,行为与改动前一致requestTime是「YYYY-MM-DD HH:mm:ss」文本,字典序即时间序;同值时用requestId兜底保证稳定collectedAt变化)都会回到第一页,避免停在空页OFFICIAL_USAGE_PAGE_SIZE(3000)分页全量扫回的 —— 每日聚合、模型聚合用的都是全量rows,只有明细输出被take(100)截断。100 条截不住「排查哪笔请求最费积分」所需的更早记录;同时不设上限会把重度账号的明细撑到几万条,缓存文件与前端渲染一起变慢,所以取有界的 1000没做的
建议一里提到的「页面顶部增加全局账号选择器」没做:做成三处联动已经解决「点三次」和「上下不一致」,再加一个入口反而多一处要维护的状态。
验证
node node_modules/typescript/bin/tsc --noEmit:通过cargo test -p wb-switch-core:607 passed / 0 failedAccountsPage.tsx/account-card.tsx/api.ts/types.ts/switch.rs,与在途的 feat: 清理旧会话——本地软删 + 云端同删 + 对账 #62 / feat: 账号发现——识别本机未入册账号并一键补录 #65 / feat: 切号带走定时任务 #66 / feat: 切号同步设置与文件 #68 / feat: 切号前预览——按当前勾选统计将发生的数据变更 #69 无文件交集closes #98