SJTUMalPan/dsh-usage-dashboard ↗★ 0

dsh-usage-dashboard

将用量报表挂载至Web端并复用登录态鉴权 适合需要免密、安全地在浏览器中直接查看DSH用量统计报的用户。

套件
dsh-usage-dashboard
相容性
待驗證
版本
0.1.0
授權
MIT
最近更新
2026年9月27日

同名套件的其他儲存庫

安裝

$npx -p @deepseek-ai/dsh dsh plugin --profile web add github:SJTUMalPan/dsh-usage-dashboard

dsh-usage-dashboard

把 dsh-usage-stats 生成的用量报表挂到 DSH 宿主 Web 服务器的 /usage。

宿主插件,纯 ESM,零依赖,不修改任何其它工程。

为什么是插件

报表属于 dsh-usage-stats 自己。DSH 宿主已经提供了两件正好够用的东西:

用途接口
挂一条自己的 HTTP 路由ctx.webServer.register({kind, path, handler})
复用宿主登录态做鉴权ctx.connection.requestRejection(req) → 401 / 403 / undefined

requestRejection 的文档原话是「Apply Connection's Host/Origin checks and browser authentication to another Web route」——它存在的意义就是给插件自挂的路由复用宿主的 Host/Origin 围栏与会话 Cookie。所以本插件没有自己的令牌体系:能打开 DSH GUI 的浏览器, 同一 origin 下就能打开 /usage(会话 Cookie 是 Path=/; SameSite=Strict)。

安装

本插件是独立仓库(仓库根目录就是插件包,插件市场里可直接 dsh plugin --profile web add github:SJTUMalPan/dsh-usage-dashboard)。 它原先住在 dsh-usage-stats 仓库的 dsh-plugin/ 子目录,拆出来时保留了提交历史。


## 配置

`cordis.patch.yml` 里那一行的 `config`,两项都可省略:

```yaml
- insert:
    - id: usage-dashboard
      name: dsh-usage-dashboard
      config:
        path: /usage        # 挂载路径,默认 /usage
        reportPath: /abs/path/to/report.html
        # 默认 /report/usage-dashboard.html(放这里即可零配置)

path 必须是以 / 开头、非根、无尾斜杠且不含查询串/片段的绝对路径——非法值在装载期 就抛错,而不是留到请求时才 404。

reportPath 可以是绝对路径,也可以相对本包根目录。