Skip to content
dsh.fish
Bundle

dsh-piggy-bank

DSH web plugin: a draggable floating piggy-bank balance badge for the official DeepSeek API account balance, with per-conversation polling and a balance-deduction animation.

Source
outprintHelloLi
License
MIT
Updated
Updated 8 days ago

Readme

# dsh-piggy-bank

DeepSeek Harness (DSH) Web 插件:一个**可拖动的悬浮存钱罐**,实时显示 DeepSeek 账户余额,并在余额发生变化时弹出扣减 / 增加动画。

## 功能

- **悬浮存钱罐**:可拖动位置,支持 **卡通猪 / 蓝色鲸鱼 / 黑金龙纹 / 陶瓷** 4 种内置透明 PNG 样式,也可导入外部 `.svg` 作为自定义样式。
- **余额展示**:余额显示在存钱罐上方,带深色文字背景。
- **自动刷新**:页面打开、任务开始 / 结束时立即刷新;对话运行期间按设定间隔(默认 30 秒)自动查询,仅在页面可见时轮询。
- **余额动画**:查询时存钱罐摇晃;余额下降时抖动并显示 `-¥xx.xx`(淡入淡出 5 秒);余额增加时以金色显示 `+¥xx.xx`。
- **设置界面**:在 DSH 的**设置**侧边栏中,可调整「查询时间间隔(秒)」(5–600)、切换样式、添加自定义 SVG。

> 数据来源为 DeepSeek 官方接口 `GET https://api.deepseek.com/user/balance`。DeepSeek 开放平台未提供 token 用量 / 费用 / 账单接口,因此本插件只展示余额,不做本地用量记账或费用估算。

## 安装

本插件为纯 Node.js 实现,跨平台通用,一键安装:

```bash
node scripts/install.mjs
```

也可以使用各平台快捷脚本:

- **Windows(CMD)**:`scripts\install.cmd`
- **Windows(PowerShell)**:`scripts\install.ps1`
- **macOS / Linux**:`./scripts/install.sh`

安装脚本会自动:找到 dsh profile(默认 `web`)→ 复制插件 → 在 profile 的 `package.json` 中登记依赖和 bundle → 执行 `pnpm install`。

完成后再**重启 `dsh web` 并硬刷新页面**(Windows: `Ctrl+Shift+R`;macOS: `Cmd+Shift+R`)。

### 可选参数

```bash
node scripts/install.mjs --profile headless   # 安装到其它 profile
node scripts/install.mjs --no-install        # 只复制/登记,不运行 pnpm install
```

发布到 npm / GitHub 后,也可用 DSH 自带命令安装:

```bash
dsh plugin --profile web add dsh-piggy-bank
```

## 前置条件

- `~/.dsh/.credentials.yaml` 中已配置 `DEEPSEEK_API_KEY`。
- Node.js ≥ 20,pnpm 可用。
- DSH 已初始化 web profile(`~/.dsh/profiles/web`)。

## 结构

| 文件 | 作用 |
| --- | --- |
| `lib/index.js` | host 端:注册 `/dsh-piggy-bank/status` 与图标路由、监听 `turn/end`、注册设置命名空间。 |
| `lib/client.js` | client 端:悬浮存钱罐 + 余额动画 + 设置卡片 + 定时查询。 |
| `assets/` | 4 种内置存钱罐透明 PNG(卡通猪 / 蓝色鲸鱼 / 黑金龙纹 / 陶瓷)。 |
| `scripts/install.mjs` | 跨平台一键安装脚本。 |
| `cordis.patch.yml` | 把插件行插入 DSH host 组合。 |

## License

MIT

Install

dsh plugin --profile web add github:outprintHelloLi/dsh-piggy-bank

Profile: web

  • This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.
Source