zhangjianyu1006156/dsh-balance-display ↗★ 0
dsh-balance-display
DeepSeek API balance pill for the DSH Web GUI: shows remaining credit in the left sidebar footer with low-balance alerts, spend history, and a one-click top-up link. The API key never leaves the host process — the host half resolves it through the dsh credentials service and queries api.deepseek.com/user/balance; the browser half only fetches redacted balance JSON from a loopback route.
安装
$
npx -p @deepseek-ai/dsh dsh plugin --profile web add github:zhangjianyu1006156/dsh-balance-display说明文档
阅读完整 README ↗dsh-balance-display
DeepSeek API 余额显示插件 —— 在 DSH Web GUI 的左侧栏底部实时显示 API Key 剩余额度,支持低余额预警、余额消耗趋势、一键充值。
密钥全程只在主机端:主机端通过 dsh 凭据服务读取 key 并查询 api.deepseek.com/user/balance,浏览器端只从本机回环路由拉取脱敏后的余额 JSON,密钥绝不进入浏览器。
功能
- 左下角余额胶囊:显示
余额 ¥92.12,点击刷新,悬浮显示充值/赠送拆分 - 低余额预警:低于阈值(默认 ¥5,可调)圆点变红 + 悬浮警告 + 可选浏览器通知(跨过阈值只提醒一次)
- 小额精度自适应:余额 /client.js
服务、webServer 路由、credentials 服务)。插件零@deepseek-ai` 运行时依赖,所有接入点特性检测,一份代码两种形态通用。
开发
dsh-balance-display/
├── package.json # dsh.bundle.patch + dsh.client 清单
├── cordis.patch.yml # 插件挂载行
└── lib/
├── index.js # 主机端:余额路由 / config 路由 / 脱敏 / 缓存
└── client.js # 浏览器端:左下角胶囊 / 设置页 / i18n / 趋势图
测试(主机端 stub + 客户端 SSR 冒烟,无需启动 dsh):
node /tmp/test-balance-host.mjs # 主机端:脱敏/缓存/并发去重/凭据失效/config 路由
node /tmp/test-balance-client3.mjs # 客户端:精度/退避/消耗/历史/阈值
发布新版本:
npm version patch # 或 minor / major
npm publish # 需输 2FA 动态码
License
MIT