feat(widget): 侧栏紧凑 ¥ 按钮 + 可拖动费用窗口 + 今日花费仅统计官方 API - #1
Open
dragan2023 wants to merge 2 commits into
Open
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
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.
优化内容
1. 侧栏不再直接显示费用文字(解决与其他插件按钮重叠)
sidebar.footer.action插槽直接渲染「余额 ¥x · 今日花费 ¥y」内联文字,与同一插槽的其他插件按钮(如刷视频)挤在一起导致重叠。UsageWidget忽略宽/窄模式,统一渲染一个 28×28 的紧凑「¥」按钮,侧栏不再出现费用文字;余额/今日花费信息仅在悬停 tooltip 或点击弹出的窗口内展示。2. 费用详情改为可拖动的浮动窗口(解决面板越出浏览器底部)
position: fixed,以按钮底部rect.bottom + 6作为 top 定位;侧栏本身贴近视口底部,算出的位置直接越过浏览器底部,导致详细数据面板无法查看。left:50%; top:50%; translate(-50%,-50%)),不再依赖按钮锚点定位;calc(100vh - 24px),内容区可滚动;close文案。3. 今日花费估算按 provider 过滤,不再纳入非官方服务商
lib/index.js的估算逻辑:重放会话日志时读取每个请求的config.provider,默认排除opencode-go等非官方渠道(新增可配置项excludeProviders,默认["opencode-go"]),使「今日花费」只反映官方 DeepSeek API 的消耗;外部视觉调用(vision-fallback,opencode-go 渠道)同样排除。余额走官方接口、本身是正确的,不受影响。修改范围
lib/client.jsUsageWidget组件重写(约 -106/+120 行)、新增.ud-window系列浮动窗口样式、zh/en 字典各新增 1 个 keylib/index.jsexcludeProviders配置项(默认["opencode-go"]),computeUsage按config.provider过滤非官方 provider;会话日志循环与外部视觉用量处理各加一行排除判断(约 +20/-5 行)CHANGELOG.md## Unreleased条目(两项改动)/user/balance走官方接口)、计价表与峰谷价逻辑、统计看板UsageDashboardTab、会话投影、测试用例。验证
node --check lib/client.js与node --check lib/index.js语法检查通过;node --test test/*.test.mjs通过(1/1);