HOFO-GYG/dsh-balance-watch

HOFO-GYG★ 1JavaScript最后同步: 2026-08-14

在 GitHub 打开

DSH Web 插件:模型选择器旁显示 DeepSeek 账户余额徽章(点击查看明细)。DSH web plugin: DeepSeek account balance badge next to the model picker.

README 摘要

dsh-balance-watch DSH Web 插件:在 模型选择器旁 显示 DeepSeek 账户余额徽章。 A DSH web plugin that puts a DeepSeek account-balance badge right next to the model picker. 功能 / Features - 徽章常显 Balance ,点击后 向上 弹出明细面板:总余额 / 赠送余额 / 充值余额、多币种、更新时间、手动刷新 - 数据经插件自带的本地路由 GET /api/dsh-balance 获取: 服务端 解析 DEEPSEEK API KEY 并缓存(60 秒),API key 永不进入浏览器 - 每 2 分钟自动轮询,打开面板时即时刷新;provider 故障时降级显示 5 分钟内的最近数据并标注错误 - 余额低于 ¥5 时徽章变红,悬停提示"余额偏低" - 排版与官方模型选择器一致(字号/字重/颜色层级) 架构 / Architecture 文件 说明 lib/index.js host 半部 (Node,ESM,零依赖): ctx.webServer.register 挂载 /api/dsh-balance 路由, ctx.credentials.resolve('DEEPSEEK API KEY') 在服务端取密钥;单飞(single-flight)缓存 + 失败降级;仅接受回环 Host 与 GET/HEAD lib/client.js 浏览器半部 (DSH client-bundle 格式):注册 conversation.input.right 槽位(模型选择器左侧),React 徽章 + 弹窗,zh/en 双语 test-host.mjs host 半部单元测试(mock ctx / fetch / 时钟,15 项断言), node test-host.mjs 运行 数据流:浏览器 fetch('/api/dsh-balance') → 本地 dsh web 服务(插件路由)→ 服务端用密钥查询 DeepSeek /user/balance → 只把余额 JSON 返回浏览器。 安装 / Install(无需 pnpm / no pnpm required) 1. 把本仓库复制到 /profiles/web/node modules/dsh-balance-watch (Windows 默认 C:\Users\ \.dsh\profiles\web\node modules\ ;注意是 web profile 自己的 node modules,不是上一级 profiles\node modules —— 后者在全新启动时 host 半部可能不被加载): 2. 在 /profiles/web/cordis.patc…

在 GitHub 查看完整 README →
工具/开发dsh-plugin

分类