feat(account): 侧栏账户卡接 alpha-platform B 余额/会员/用量(+14天 sparkline) - #11
Merged
Merged
Conversation
alpha-code 持 stored JWT 读 GET /v1/account/summary(境内 account.tidelabs.click),
填上侧栏账户弹层:会员订阅、可用余额、5h/7d 额度窗口、近 14 天用量 sparkline——
替换原「待接入」占位。
- shared/alpha-config:+ account host(ALPHA_ENDPOINTS.account)+ 路径
(accountSummary /v1/account/summary、transactions /v1/billing/transactions)
- main:alpha-account.ts client(Bearer JWT,401/network → typed error)、
account-ipc.ts 注册、alpha-auth 加 getAccessToken()(main-only,token 不出 renderer)
- preload:account.{summary,transactions} 命名空间 + 跨 bundle AccountSummary 类型
- renderer:账户卡接真实数据,带 loading/error/未订阅(按量计费)分支 + 内联 Sparkline(无图表库)
env 覆盖:ALPHA_ACCOUNT_URL(与 ALPHA_WEB_URL/ALPHA_PLATFORM_URL 一致)。
验证:tsgo -b green;真实端点冒烟 —— 无 token GET .../v1/account/summary 返回 401
unauthorized(域名/路径正确、服务在线、鉴权生效)。**尚未**用已登录 token 做像素核验
(需 DEV_PLATFORM_TOKEN 或 OAuth 登录)。usageSeries 空时 sparkline 显示「暂无数据」。
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
让顶部 chip、底部 sub、升级/管理 CTA 都优先用 fetch 到的 summary plan(权威), 而非只看 JWT 的粗粒度 claim——截图核验时发现卡片显示「Pro」但顶部却是「免费版」。 summary 未到时回退到 JWT claim,所以两处永不矛盾。 端到端核验(本地 dev account-server,dev 租户):弹层 Pro / ¥499.97 / 45·30 / 45·100.0K / 14 天 sparkline;header+footer 现读 PRO;CTA 显示 充值/管理订阅。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jinjunnn
pushed a commit
that referenced
this pull request
Jun 24, 2026
PR #11 账户集成后核实:接口与 B 侧计量链均通,但默认 BYOK 直连绕过 B; 走 gateway 的 alpha provider 模型还是占位 alpha-default(alpha-models.ts:60 TODO)。 要让用量出数需平台模式 + 接真实模型 id。详见 docs/platform-integration.md。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
为什么
让 alpha-code 真正显示账户用量/会员/余额。按
alpha-platform/docs/alpha-code-account-integration.md:登录拿 C 签发的 JWT → 直读 B 的境内 account-serveraccount.tidelabs.click的GET /v1/account/summary。B 已实现并部署。改了什么
ALPHA_ENDPOINTS.account+ 路径ALPHA_PATHS.{accountSummary,transactions}。alpha-account.ts(Bearer JWT,401/network→ typed error);account-ipc.ts(自包含 IPC,镜像 ext-ipc);alpha-auth.ts加getAccessToken()——main-only,token 不出 renderer。account.{summary,transactions}+ 跨 bundleAccountSummary类型。env 覆盖
ALPHA_ACCOUNT_URL,与ALPHA_WEB_URL/ALPHA_PLATFORM_URL一致。零改 upstream。安全
JWT 仅 main 持有(
getAccessToken不经 IPC 暴露);renderer 只拿已解析 summary。账户读走境内 account-server(PII/金融驻留境内),不打模型 gateway。测试(端到端,自验)
tsgo -bgreen。curl account.tidelabs.click/v1/account/summary(无 token)→401 unauthorized(域名/路径/鉴权正确)。alpha-platform/packages/gateway(dev 租户),alpha-code 以ALPHA_ACCOUNT_URL=localhost:8787+DEV_PLATFORM_TOKEN起 → CDP 截图核验账户弹层:AccountSummary类型(balanceFen/plan{window5h,window7d,renewsAt,daysLeft}/usage/usageSeries[14])。备注
usageSeries已返 14 天数组(dev 租户 tokens 全 0 → sparkline 平线);真实用量累积后自动点亮。🤖 Generated with Claude Code