dsh-ollama-usage 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +147 -0
- package/README.md +50 -18
- package/lib/client.js +152 -87
- package/package.json +9 -3
package/README.en.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# ⚡ dsh-ollama-usage
|
|
4
|
+
|
|
5
|
+
**Ollama Cloud usage & remaining-quota visualization · a DeepSeek Harness plugin**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
8
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](package.json)
|
|
11
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage/releases)
|
|
12
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage)
|
|
13
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
14
|
+
[](https://awesome-dsh-plugin.com)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
17
|
+
|
|
18
|
+
Ollama Cloud usage & remaining-quota visualization for DeepSeek Harness —
|
|
19
|
+
5-hour session + weekly quota, always-visible sidebar bars, a full panel on the
|
|
20
|
+
plugin's own detail page, persisted credentials & snapshots, auto-refresh.
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## ✨ 功能特性 / Features
|
|
25
|
+
|
|
26
|
+
| Capability | Description |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| 🎯 **Session usage (per 5 hours)** | Ollama Cloud's 5-hour session quota, pinned at the top showing "used X% · remaining Y%" |
|
|
29
|
+
| 📅 **Weekly usage** | This week's quota progress, shown next to the session usage |
|
|
30
|
+
| 🎨 **Sidebar dual bars** | Minimal, transparent style: session 5h in **light purple** + weekly in **deep purple**, each with a percentage, details on hover, refreshed every 60 seconds (auto-hidden on narrow layouts) |
|
|
31
|
+
| 🖥️ **Full panel on the plugin detail page** | Rendered between the description and component rows of the "Plugin list → dsh-ollama-usage" page: session/week usage bars, session and weekly reset countdowns, and the last 5 session-usage history entries; card-based sections with loading / error / success states |
|
|
32
|
+
| 💾 **Persistence** | The API Key and usage snapshot are written to `$DSH_HOME/storages/ollama-usage/usage.json` (mode 600, 24 history entries kept), restored automatically across conversations / restarts |
|
|
33
|
+
| 🔄 **Auto-refresh** | The host queries every 10 minutes (even when the page is closed); an invalidated Key (401) is cleared automatically with a prompt |
|
|
34
|
+
| 🔑 **Login guidance** | When not signed in, one click opens [ollama.com/settings](https://ollama.com/settings) to sign in and [settings/keys](https://ollama.com/settings/keys) to create an API Key; compatible with the legacy CLI's `~/.ollama/auth.json` |
|
|
35
|
+
|
|
36
|
+
The quota progress data comes from Ollama's official endpoint `GET https://ollama.com/api/balance`
|
|
37
|
+
(the `remaining_percent` and `resets_at` of `included.session` / `included.weekly`), matching the
|
|
38
|
+
[ollama.com/settings](https://ollama.com/settings) page.
|
|
39
|
+
|
|
40
|
+
> **v0.1.11 fix**: in 2026-10 Ollama changed `GET /api/usage` to return only hourly/daily
|
|
41
|
+
> request-volume buckets and no longer include `limits.session` / `limits.weekly`, so older
|
|
42
|
+
> versions parsed both percentages as `null` — the panel showed "no data" and the sidebar bars
|
|
43
|
+
> showed "—". Quota progress now comes from `/api/balance` (`used = 100 - remaining_percent`),
|
|
44
|
+
> and the reset countdown uses the real `resets_at` sent by the endpoint.
|
|
45
|
+
|
|
46
|
+
## 📦 安装 / Install
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
dsh plugin --profile web add dsh-ollama-usage
|
|
50
|
+
dsh --profile web
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
> Alternatively, add `dsh-ollama-usage` to the profile `package.json`'s
|
|
54
|
+
> `dsh.profile.bundles` manually and restart.
|
|
55
|
+
|
|
56
|
+
## 🚀 使用 / Usage
|
|
57
|
+
|
|
58
|
+
1. Open **Plugin list → dsh-ollama-usage** (the panel is rendered between the description and component rows of that page);
|
|
59
|
+
2. When not signed in, follow the panel guidance: sign in at [ollama.com](https://ollama.com/settings) →
|
|
60
|
+
create an API Key at [settings/keys](https://ollama.com/settings/keys) →
|
|
61
|
+
paste it and click **Check** (or run `ollama signin` in a terminal and click **Re-check local credentials**);
|
|
62
|
+
3. On success it is persisted; expand the sidebar to see the dual bars at the bottom, and the panel shows details and history at any time;
|
|
63
|
+
4. When no longer needed, click **Clear stored Key** to remove the local credential (history is kept).
|
|
64
|
+
|
|
65
|
+
## 🖼️ 界面预览 / Screenshots
|
|
66
|
+
|
|
67
|
+
The screenshots below come from a throwaway local preview instance; the example data is for demonstration only:
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+

|
|
72
|
+
|
|
73
|
+

|
|
74
|
+
|
|
75
|
+
## 🔒 数据与隐私 / Privacy
|
|
76
|
+
|
|
77
|
+
- Only a Bearer-carrying query request is sent to `https://ollama.com/api/balance`;
|
|
78
|
+
- The Key is stored in plaintext locally in `$DSH_HOME/storages/ollama-usage/usage.json` (mode 600,
|
|
79
|
+
a trust level equal to `~/.ollama/auth.json`), and can be cleared at any time.
|
|
80
|
+
|
|
81
|
+
## 🏗️ 架构 / Architecture
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
┌──────────────────────────┐ ┌─────────────────────────────┐
|
|
85
|
+
│ browser (client bundle) │ RPC │ host (lib/index.js) │
|
|
86
|
+
│ lib/client.js │◄──────►│ webServer /ollama-usage │
|
|
87
|
+
│ · sidebar dual bars │ 信封协议 │ · fetch api/balance(Bearer)│
|
|
88
|
+
│ · settings panel │ │ · $DSH_HOME 持久化(0600) │
|
|
89
|
+
│ · login guidance │ │ · 10min auto-refresh │
|
|
90
|
+
└──────────────────────────┘ └─────────────────────────────┘
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
- Host entry `lib/index.js`: ESM, exports `name` + the default plugin; `webServer` prefix route +
|
|
94
|
+
the Connection RPC envelope protocol (`check` / `snapshot` / `forget` / `auth-state`).
|
|
95
|
+
- Client entry `lib/client.js`: a `window.__ModuleLoader__.load` bundle that talks to the host via
|
|
96
|
+
`connection.rpc.call('/ollama-usage', endpoint, payload)`.
|
|
97
|
+
- Wiring: `cordis.patch.yml` (Loader row) + the `dsh.bundle.patch` / `dsh.client` declarations in
|
|
98
|
+
`package.json`.
|
|
99
|
+
|
|
100
|
+
## 🧩 兼容性 / Compatibility
|
|
101
|
+
|
|
102
|
+
Since DSH 0.2.1 the compatibility gate prefers `engines.dsh`. This plugin declares **`engines.dsh: ">=0.1.7-rc.1"`** (no upper bound), keeps the `@deepseek-ai/dsh-home-paths` peer at `>=0.1.7-rc.1`, and has been checked on:
|
|
103
|
+
|
|
104
|
+
| DSH version | Status |
|
|
105
|
+
| --- | --- |
|
|
106
|
+
| 0.1.5-rc.1 | ✅ Tested |
|
|
107
|
+
| 0.1.5-rc.2 | ✅ Tested |
|
|
108
|
+
| 0.1.6-alpha.2 | ✅ Tested |
|
|
109
|
+
| 0.1.7-rc.1 | ✅ Tested |
|
|
110
|
+
| 0.1.7-rc.2 | ✅ Tested |
|
|
111
|
+
| 0.2.0-rc.1 | ✅ Tested |
|
|
112
|
+
| 0.2.1-rc.1 | ✅ Gate + probes |
|
|
113
|
+
| 0.2.1-rc.2 | ✅ Gate |
|
|
114
|
+
|
|
115
|
+
> Only versions that were **actually run** are listed; untested versions are omitted.
|
|
116
|
+
|
|
117
|
+
v0.1.13 targets DSH **≥0.1.5-rc.1** (the `@deepseek-ai/dsh-*` peer was relaxed to `>=0.1.7-rc.1`), verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** (all RPC envelope probes pass; on 0.1.7-rc.2 the `/ollama-usage/snapshot` endpoint returns as measured; on 0.2.0-rc.1 it passes the new compatibility gate and loads normally; on 0.2.1-rc.1 the gate and RPC envelope probes pass, and 0.2.1-rc.2 passes the gate); for older DSH (0.1.0-rc.5 ~ rc.8) use the last compatible npm version, **0.1.5**.
|
|
118
|
+
|
|
119
|
+
## 🛠️ 开发 / Develop
|
|
120
|
+
|
|
121
|
+
### 测试 / Tests
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
- `test/bridge-smoke.mjs` (17 checks): route registration, the no-token / 401 branches, persistence
|
|
128
|
+
read/write and cleanup, snapshot / forget / auth-state, and validation of malformed envelopes and
|
|
129
|
+
request methods.
|
|
130
|
+
- `test/balance-parse.mjs`: a `/api/balance` parsing regression (no network, a fetch stub). It drives
|
|
131
|
+
`check` with real response bodies and asserts the 5h / weekly percentage conversion, `resets_at`
|
|
132
|
+
passthrough, persistence and history appending, plus the unlimited-plan / non-JSON / 401 / 403 /
|
|
133
|
+
network-error branches.
|
|
134
|
+
- `test/rpc-envelope-alpha4.mjs`: every endpoint passes alpha.4's Connection RPC envelope validator.
|
|
135
|
+
|
|
136
|
+
### 构建与发布 / Build & Publish
|
|
137
|
+
|
|
138
|
+
```bash
|
|
139
|
+
npm install # 安装依赖(@deepseek-ai/dsh-home-paths)
|
|
140
|
+
npm test # 冒烟测试(见上)
|
|
141
|
+
npm pack # 本地打包检查
|
|
142
|
+
npm publish # 发布到 npm
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## 📄 许可证 / License
|
|
146
|
+
|
|
147
|
+
[MIT](LICENSE) © 2026 dsh-ollama-usage contributors
|
package/README.md
CHANGED
|
@@ -4,10 +4,16 @@
|
|
|
4
4
|
|
|
5
5
|
**Ollama Cloud 用量余量可视化 · DeepSeek Harness 插件**
|
|
6
6
|
|
|
7
|
-
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
8
|
+
[](https://www.npmjs.com/package/dsh-ollama-usage)
|
|
9
|
+
[](LICENSE)
|
|
10
|
+
[](package.json)
|
|
11
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage/releases)
|
|
12
|
+
[](https://github.com/SeverusZh/dsh-ollama-usage)
|
|
13
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
14
|
+
[](https://awesome-dsh-plugin.com)
|
|
15
|
+
|
|
16
|
+
</div>
|
|
11
17
|
|
|
12
18
|
可视化你的 **Ollama Cloud** 用量余量 —— 每 5 小时会话用量 + 周用量,
|
|
13
19
|
侧边栏极简双横条常驻显示,插件详情页完整面板,Key 与快照持久化,自动刷新。
|
|
@@ -16,21 +22,16 @@
|
|
|
16
22
|
5-hour session + weekly quota, always-visible sidebar bars, a full panel on the
|
|
17
23
|
plugin's own detail page, persisted credentials & snapshots, auto-refresh.*
|
|
18
24
|
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
25
|
---
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
> v0.1.11 targets DSH **≥0.1.5-rc.1**, verified on **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1**; for older DSH releases use the last compatible npm version **0.1.5**.
|
|
25
|
-
|
|
26
|
-
## ✨ 功能特性 Features
|
|
27
|
+
## ✨ 功能特性 / Features
|
|
27
28
|
|
|
28
29
|
| 能力 | 说明 |
|
|
29
30
|
| --- | --- |
|
|
30
31
|
| 🎯 **会话用量(每 5 小时)** | Ollama Cloud 的 5 小时会话配额,置顶展示「已用 X% · 剩余 Y%」 |
|
|
31
32
|
| 📅 **周用量(Weekly)** | 本周配额进度,与会话用量并排展示 |
|
|
32
33
|
| 🎨 **侧边栏双横条** | 极简透明风格:会话 5h **淡紫** + 周用量**深紫**,各带百分比数字,悬停显示详情,每 60 秒自动更新(窄栏自动隐藏) |
|
|
33
|
-
| 🖥️ **插件详情页完整面板** | 渲染在「插件列表 → dsh-ollama-usage」页面的描述与组件行之间:会话/周用量进度条、会话与周重置倒计时、最近 5
|
|
34
|
+
| 🖥️ **插件详情页完整面板** | 渲染在「插件列表 → dsh-ollama-usage」页面的描述与组件行之间:会话/周用量进度条、会话与周重置倒计时、最近 5 条会话用量历史;卡片化分区,带加载 / 错误 / 成功状态提示 |
|
|
34
35
|
| 💾 **持久化** | API Key 与用量快照写入 `$DSH_HOME/storages/ollama-usage/usage.json`(权限 600,保留 24 条历史),跨对话 / 重启自动恢复 |
|
|
35
36
|
| 🔄 **自动刷新** | Host 每 10 分钟自动查询(页面关闭也持续);Key 失效(401)自动清除并提示 |
|
|
36
37
|
| 🔑 **登录引导** | 未登录时一键打开 [ollama.com/settings](https://ollama.com/settings) 登录、到 [settings/keys](https://ollama.com/settings/keys) 创建 API Key;兼容旧版 CLI 的 `~/.ollama/auth.json` |
|
|
@@ -45,7 +46,7 @@ plugin's own detail page, persisted credentials & snapshots, auto-refresh.*
|
|
|
45
46
|
> 现在限额进度改由 `/api/balance` 提供(`已用 = 100 - remaining_percent`),
|
|
46
47
|
> 重置倒计时也直接使用接口下发的真实 `resets_at`。
|
|
47
48
|
|
|
48
|
-
## 📦 安装 Install
|
|
49
|
+
## 📦 安装 / Install
|
|
49
50
|
|
|
50
51
|
```bash
|
|
51
52
|
dsh plugin --profile web add dsh-ollama-usage
|
|
@@ -55,7 +56,7 @@ dsh --profile web
|
|
|
55
56
|
> 也可手动把 `dsh-ollama-usage` 加入 profile `package.json` 的
|
|
56
57
|
> `dsh.profile.bundles` 后重启。
|
|
57
58
|
|
|
58
|
-
## 🚀 使用 Usage
|
|
59
|
+
## 🚀 使用 / Usage
|
|
59
60
|
|
|
60
61
|
1. 打开 **插件列表 → dsh-ollama-usage**(面板渲染在该页面的描述与组件行之间);
|
|
61
62
|
2. 未登录时按面板指引:登录 [ollama.com](https://ollama.com/settings) →
|
|
@@ -64,13 +65,23 @@ dsh --profile web
|
|
|
64
65
|
3. 检测成功后即持久化,展开侧边栏即可看到底部双横条,面板可随时查看详情与历史;
|
|
65
66
|
4. 不再需要时点 **清除已存 Key** 移除本地凭证(历史保留)。
|
|
66
67
|
|
|
67
|
-
##
|
|
68
|
+
## 🖼️ 界面预览 / Screenshots
|
|
69
|
+
|
|
70
|
+
以下截图来自本地一次性预览实例,示例数据仅用于演示:
|
|
71
|
+
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
## 🔒 数据与隐私 / Privacy
|
|
68
79
|
|
|
69
80
|
- 仅向 `https://ollama.com/api/balance` 发送带 Bearer 的查询请求;
|
|
70
81
|
- Key 以明文保存在本机 `$DSH_HOME/storages/ollama-usage/usage.json`(权限 600,
|
|
71
82
|
与 `~/.ollama/auth.json` 同等级信任),随时可清除。
|
|
72
83
|
|
|
73
|
-
## 🏗️ 架构 Architecture
|
|
84
|
+
## 🏗️ 架构 / Architecture
|
|
74
85
|
|
|
75
86
|
```
|
|
76
87
|
┌──────────────────────────┐ ┌─────────────────────────────┐
|
|
@@ -89,7 +100,28 @@ dsh --profile web
|
|
|
89
100
|
- 接线:`cordis.patch.yml`(Loader 行)+ `package.json` 的
|
|
90
101
|
`dsh.bundle.patch` / `dsh.client` 声明。
|
|
91
102
|
|
|
92
|
-
##
|
|
103
|
+
## 🧩 兼容性 / Compatibility
|
|
104
|
+
|
|
105
|
+
DSH 0.2.1 起兼容门禁优先读取 `engines.dsh`。本插件声明 **`engines.dsh: ">=0.1.7-rc.1"`**(无上限),`@deepseek-ai/dsh-home-paths` peer 保持 `>=0.1.7-rc.1`,并已核对:
|
|
106
|
+
|
|
107
|
+
| DSH 版本 | 状态 |
|
|
108
|
+
| --- | --- |
|
|
109
|
+
| 0.1.5-rc.1 | ✅ 实测通过 |
|
|
110
|
+
| 0.1.5-rc.2 | ✅ 实测通过 |
|
|
111
|
+
| 0.1.6-alpha.2 | ✅ 实测通过 |
|
|
112
|
+
| 0.1.7-rc.1 | ✅ 实测通过 |
|
|
113
|
+
| 0.1.7-rc.2 | ✅ 实测通过 |
|
|
114
|
+
| 0.2.0-rc.1 | ✅ 实测通过 |
|
|
115
|
+
| 0.2.1-rc.1 | ✅ 兼容门禁 + 探针通过 |
|
|
116
|
+
| 0.2.1-rc.2 | ✅ 兼容门禁通过 |
|
|
117
|
+
|
|
118
|
+
> 只列出**实际跑过**的版本;未实测的不列。
|
|
119
|
+
|
|
120
|
+
v0.1.13 支持 DSH **≥0.1.5-rc.1**(`@deepseek-ai/dsh-*` peer 放宽为 `>=0.1.7-rc.1`),已在 **0.1.5-rc.1 / 0.1.5-rc.2 / 0.1.6-alpha.2 / 0.1.7-rc.1 / 0.1.7-rc.2 / 0.2.0-rc.1** 实测(RPC envelope 探针全过;0.1.7-rc.2 上 `/ollama-usage/snapshot` 实测返回;0.2.0-rc.1 上通过新的兼容性门禁并正常加载;0.2.1-rc.1 上兼容门禁与 RPC envelope 探针通过,0.2.1-rc.2 门禁通过);旧版 DSH(0.1.0-rc.5 ~ rc.8)请使用最后兼容的 npm 版本 **0.1.5**。
|
|
121
|
+
|
|
122
|
+
## 🛠️ 开发 / Develop
|
|
123
|
+
|
|
124
|
+
### 测试 / Tests
|
|
93
125
|
|
|
94
126
|
```bash
|
|
95
127
|
npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
@@ -102,7 +134,7 @@ npm test # bridge-smoke → balance-parse → rpc-envelope-alpha4
|
|
|
102
134
|
以及无限额套餐 / 非 JSON / 401 / 403 / 网络异常各分支。
|
|
103
135
|
- `test/rpc-envelope-alpha4.mjs`:逐端点通过 alpha.4 的 Connection RPC 信封校验器。
|
|
104
136
|
|
|
105
|
-
|
|
137
|
+
### 构建与发布 / Build & Publish
|
|
106
138
|
|
|
107
139
|
```bash
|
|
108
140
|
npm install # 安装依赖(@deepseek-ai/dsh-home-paths)
|
|
@@ -111,6 +143,6 @@ npm pack # 本地打包检查
|
|
|
111
143
|
npm publish # 发布到 npm
|
|
112
144
|
```
|
|
113
145
|
|
|
114
|
-
## 📄 License
|
|
146
|
+
## 📄 许可证 / License
|
|
115
147
|
|
|
116
148
|
[MIT](LICENSE) © 2026 dsh-ollama-usage contributors
|
package/lib/client.js
CHANGED
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* 进度条、会话与周用量重置倒计时、历史记录、API Key 配置、清除 Key)。
|
|
7
7
|
* 渲染在「插件列表 → dsh-ollama-usage」页面的描述与组件行之间 ——
|
|
8
8
|
* 配置不再位于设置面板(settings.section 已退役);
|
|
9
|
-
* - sidebar.footer.action:极简双横条(会话 5h
|
|
9
|
+
* - sidebar.footer.action:极简双横条(会话 5h / 周用量,紫为主的数据可视化强调色);
|
|
10
10
|
* - tool.view.cordis:Run 卡片内的同款面板。
|
|
11
11
|
*
|
|
12
12
|
* 数据通道:Host 在 webServer 注册的 /ollama-usage 前缀路由,经 Connection
|
|
13
|
-
* RPC 信封协议调用(check / snapshot / forget)
|
|
14
|
-
*
|
|
13
|
+
* RPC 信封协议调用(check / snapshot / forget)。
|
|
14
|
+
*
|
|
15
|
+
* 呈现层:手写 <style> 注入,颜色/字体/圆角/阴影/焦点环全部来自官方 --dsw-*
|
|
16
|
+
* 主题变量,亮暗主题自动成立。唯一保留的硬编码颜色是双横条的两档紫色,按规范
|
|
17
|
+
* 只作为「数据可视化强调色」用于横条填充,不扩散到任何通用控件。
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
window.__ModuleLoader__.load({
|
|
@@ -25,52 +28,87 @@ window.__ModuleLoader__.load({
|
|
|
25
28
|
|
|
26
29
|
const RPC_CHANNEL = '/ollama-usage'
|
|
27
30
|
const CSS_TAG_ID = 'dsh-ollama-usage/client.css'
|
|
31
|
+
// 数据可视化强调色:仅用于侧栏双横条的填充(会话 5h 淡紫 / 周用量深紫),
|
|
32
|
+
// 属于插件品牌识别,不用于按钮、边框、文字等通用控件。
|
|
28
33
|
const SESSION_COLOR = '#b39df7'
|
|
29
34
|
const WEEKLY_COLOR = '#7c66e8'
|
|
30
35
|
|
|
31
36
|
const CSS = [
|
|
32
|
-
|
|
33
|
-
'.olusa-
|
|
34
|
-
'.olusa-
|
|
35
|
-
'.olusa-
|
|
36
|
-
'.olusa-
|
|
37
|
-
'.olusa-
|
|
38
|
-
'.olusa-
|
|
39
|
-
'.olusa-
|
|
40
|
-
'.olusa-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
'.olusa-
|
|
44
|
-
'.olusa-
|
|
45
|
-
'.olusa-
|
|
46
|
-
'.olusa-
|
|
47
|
-
'.olusa-
|
|
48
|
-
'.olusa-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
'.olusa-
|
|
52
|
-
'.olusa-
|
|
53
|
-
'.olusa-
|
|
54
|
-
'.olusa-
|
|
55
|
-
'.olusa-
|
|
56
|
-
'.olusa-
|
|
57
|
-
'.olusa-
|
|
58
|
-
'.olusa-
|
|
59
|
-
'.olusa-
|
|
60
|
-
'.olusa-
|
|
61
|
-
'.olusa-
|
|
62
|
-
'.olusa-
|
|
37
|
+
// ── 面板骨架 ────────────────────────────────────────────────
|
|
38
|
+
'.olusa-panel{display:flex;flex-direction:column;gap:12px;padding:14px 16px;border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:var(--dsw-font-xs-13);box-sizing:border-box}',
|
|
39
|
+
'.olusa-panel *{box-sizing:border-box}',
|
|
40
|
+
'.olusa-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;min-width:0}',
|
|
41
|
+
'.olusa-head-main{display:flex;flex-direction:column;gap:2px;min-width:0}',
|
|
42
|
+
'.olusa-title{font:var(--dsw-font-s-14);font-weight:600;color:var(--dsw-alias-label-primary);white-space:nowrap}',
|
|
43
|
+
'.olusa-sub{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary)}',
|
|
44
|
+
'.olusa-block{display:flex;flex-direction:column;gap:12px;min-width:0}',
|
|
45
|
+
'.olusa-ver{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-caption)}',
|
|
46
|
+
|
|
47
|
+
// ── 用量进度条 ──────────────────────────────────────────────
|
|
48
|
+
'.olusa-barblock{display:flex;flex-direction:column;gap:6px;min-width:0}',
|
|
49
|
+
'.olusa-barhead{display:flex;align-items:baseline;justify-content:space-between;gap:8px;min-width:0}',
|
|
50
|
+
'.olusa-barlabel{font:var(--dsw-font-xxs-strong-12);font-weight:500;color:var(--dsw-alias-label-primary)}',
|
|
51
|
+
'.olusa-barval{font:var(--dsw-font-xxxs-strong-11);font-weight:500;color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;white-space:nowrap}',
|
|
52
|
+
'.olusa-bar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 10%,var(--dsw-alias-bg-layer-2));overflow:hidden}',
|
|
53
|
+
'.olusa-barfill{height:100%;border-radius:999px;transition:width .2s ease}',
|
|
54
|
+
|
|
55
|
+
// ── 说明 / 分区 / 列表 ──────────────────────────────────────
|
|
56
|
+
'.olusa-hint{margin:0;font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-tertiary);line-height:16px}',
|
|
57
|
+
'.olusa-sec{display:flex;flex-direction:column;gap:2px;min-width:0}',
|
|
58
|
+
'.olusa-sec-title{margin:0 0 2px;font:var(--dsw-font-xxxs-strong-11);font-weight:600;color:var(--dsw-alias-label-secondary);letter-spacing:.02em}',
|
|
59
|
+
'.olusa-list{display:flex;flex-direction:column;min-width:0}',
|
|
60
|
+
'.olusa-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;padding:6px 0;border-bottom:1px solid var(--dsw-alias-border-l1);min-width:0;font:var(--dsw-font-xxs-12)}',
|
|
61
|
+
'.olusa-row:last-child{border-bottom:none}',
|
|
62
|
+
'.olusa-rowname{color:var(--dsw-alias-label-secondary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}',
|
|
63
|
+
'.olusa-rowval{color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums;white-space:nowrap}',
|
|
64
|
+
'.olusa-link{color:var(--dsw-alias-link);text-decoration:none;border-radius:var(--dsw-radius-xs)}',
|
|
65
|
+
'.olusa-link:hover{text-decoration:underline}',
|
|
66
|
+
'.olusa-link:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}',
|
|
67
|
+
'.olusa-steps{margin:0;padding-left:16px;display:flex;flex-direction:column;gap:4px;font:var(--dsw-font-xxs-12);color:var(--dsw-alias-label-secondary);line-height:18px}',
|
|
68
|
+
|
|
69
|
+
// ── 输入 / 按钮 / 状态 ──────────────────────────────────────
|
|
70
|
+
'.olusa-input{flex:1;min-width:0;height:30px;padding:0 10px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);font:var(--dsw-font-xs-13);transition:border-color .15s ease}',
|
|
71
|
+
'.olusa-input:hover{border-color:var(--dsw-alias-border-l3)}',
|
|
72
|
+
'.olusa-input:focus{outline:none;border-color:var(--dsw-alias-brand-primary)}',
|
|
73
|
+
'.olusa-input:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}',
|
|
74
|
+
'.olusa-input::placeholder{color:var(--dsw-alias-label-tertiary)}',
|
|
75
|
+
'.olusa-login-title{font:var(--dsw-font-xs-strong-13);font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
76
|
+
'.olusa-rowbtns{display:flex;gap:8px;flex-wrap:wrap;align-items:center;margin-top:2px}',
|
|
77
|
+
'.olusa-btn{display:inline-flex;align-items:center;justify-content:center;height:28px;padding:0 12px;color:var(--dsw-alias-label-primary);background:transparent;border:1px solid var(--dsw-alias-border-l2);border-radius:var(--dsw-radius-sm);font:var(--dsw-font-xxs-strong-12);font-weight:500;cursor:pointer;white-space:nowrap;transition:background-color .15s ease,border-color .15s ease,color .15s ease,opacity .15s ease}',
|
|
78
|
+
'.olusa-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}',
|
|
79
|
+
'.olusa-btn:active:not(:disabled){background:var(--dsw-alias-interactive-bg-active)}',
|
|
80
|
+
'.olusa-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}',
|
|
81
|
+
'.olusa-btn:disabled{opacity:.5;cursor:not-allowed}',
|
|
82
|
+
'.olusa-btn-primary{background:var(--dsw-alias-button-primary-fill);border-color:transparent;color:var(--dsw-alias-label-primary-foreground)}',
|
|
83
|
+
'.olusa-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}',
|
|
84
|
+
'.olusa-btn-primary:active:not(:disabled){background:var(--dsw-alias-button-primary-hover)}',
|
|
85
|
+
'.olusa-btn-danger{color:var(--dsw-alias-state-error-primary)}',
|
|
86
|
+
'.olusa-btn-danger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover-danger)}',
|
|
87
|
+
'.olusa-error{margin:0;font:var(--dsw-font-xxs-12);color:var(--dsw-alias-state-error-primary);line-height:18px;word-break:break-word}',
|
|
88
|
+
'.olusa-state{display:inline-flex;align-items:center;align-self:flex-start;padding:2px 8px;border-radius:999px;font:var(--dsw-font-xxxs-strong-11);font-weight:500;max-width:100%}',
|
|
89
|
+
'.olusa-state[data-tone=ok]{background:var(--dsw-alias-state-success-tertiary);color:var(--dsw-alias-state-success-primary);border:1px solid color-mix(in srgb,var(--dsw-alias-state-success-primary) 20%,transparent)}',
|
|
90
|
+
'.olusa-state[data-tone=err]{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent);color:var(--dsw-alias-state-error-primary);border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 20%,transparent)}',
|
|
91
|
+
'.olusa-loading{display:flex;flex-direction:column;gap:8px}',
|
|
92
|
+
'.olusa-skeleton{height:10px;border-radius:var(--dsw-radius-xs);background:var(--dsw-alias-bg-skeleton)}',
|
|
93
|
+
'.olusa-skeleton.is-wide{width:56%}',
|
|
94
|
+
|
|
95
|
+
// ── 侧栏双横条 ──────────────────────────────────────────────
|
|
96
|
+
'.olusa-bars{display:flex;flex-direction:column;gap:8px;padding:6px 8px;width:120px;min-width:120px;flex-shrink:0;box-sizing:border-box;background:transparent;border:none}',
|
|
97
|
+
'.olusa-barsrow{display:flex;flex-direction:column;gap:2px;min-width:0}',
|
|
63
98
|
'.olusa-barshead{display:flex;justify-content:space-between;align-items:baseline;gap:6px}',
|
|
64
|
-
'.olusa-barslabel{font-
|
|
65
|
-
'.olusa-barsval{font-
|
|
66
|
-
'.olusa-minibar{height:
|
|
67
|
-
'.olusa-minibarfill{height:100%;border-radius:
|
|
99
|
+
'.olusa-barslabel{font:var(--dsw-font-xxxs-11);color:var(--dsw-alias-label-secondary);white-space:nowrap}',
|
|
100
|
+
'.olusa-barsval{font:var(--dsw-font-xxxs-strong-11);font-weight:600;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-primary);white-space:nowrap}',
|
|
101
|
+
'.olusa-minibar{height:6px;border-radius:999px;background:color-mix(in srgb,var(--dsw-alias-label-primary) 12%,transparent);overflow:hidden}',
|
|
102
|
+
'.olusa-minibarfill{height:100%;border-radius:999px;transition:width .2s ease}',
|
|
103
|
+
|
|
104
|
+
'@media (prefers-reduced-motion:reduce){.olusa-barfill,.olusa-minibarfill{transition:none}}',
|
|
68
105
|
].join('\n')
|
|
69
106
|
|
|
70
107
|
function injectCss() {
|
|
71
108
|
if (typeof document === 'undefined') return
|
|
72
109
|
if (document.querySelector('style[data-plugin-css="' + CSS_TAG_ID + '"]') !== null) return
|
|
73
110
|
const tag = document.createElement('style')
|
|
111
|
+
tag.dataset.plugin = 'dsh-ollama-usage'
|
|
74
112
|
tag.dataset.pluginCss = CSS_TAG_ID
|
|
75
113
|
tag.textContent = CSS
|
|
76
114
|
;(document.head || document.documentElement).appendChild(tag)
|
|
@@ -78,10 +116,10 @@ window.__ModuleLoader__.load({
|
|
|
78
116
|
|
|
79
117
|
const pct = (v) => (typeof v === 'number' && Number.isFinite(v) ? Math.round(v * 10) / 10 : null)
|
|
80
118
|
const colorFor = (p) => {
|
|
81
|
-
if (p === null) return 'var(--dsw-alias-label-secondary
|
|
82
|
-
if (p < 70) return 'var(--dsw-alias-state-success-primary
|
|
83
|
-
if (p < 90) return 'var(--dsw-alias-state-warn-primary
|
|
84
|
-
return 'var(--dsw-alias-state-error-primary
|
|
119
|
+
if (p === null) return 'var(--dsw-alias-label-secondary)'
|
|
120
|
+
if (p < 70) return 'var(--dsw-alias-state-success-primary)'
|
|
121
|
+
if (p < 90) return 'var(--dsw-alias-state-warn-primary)'
|
|
122
|
+
return 'var(--dsw-alias-state-error-primary)'
|
|
85
123
|
}
|
|
86
124
|
const fmtTime = (iso) => { try {
|
|
87
125
|
const d = new Date(iso)
|
|
@@ -137,7 +175,7 @@ window.__ModuleLoader__.load({
|
|
|
137
175
|
const p = pct(props.percent)
|
|
138
176
|
const width = p === null ? 0 : Math.min(100, Math.max(0, p))
|
|
139
177
|
const remaining = p === null ? null : Math.round((100 - p) * 10) / 10
|
|
140
|
-
return React.createElement('div', { className: 'olusa-
|
|
178
|
+
return React.createElement('div', { className: 'olusa-barblock' },
|
|
141
179
|
React.createElement('div', { className: 'olusa-barhead' },
|
|
142
180
|
React.createElement('span', { className: 'olusa-barlabel' }, props.label),
|
|
143
181
|
React.createElement('span', { className: 'olusa-barval' }, p === null ? '暂无数据' : ('已用 ' + p + '% · 剩余 ' + remaining + '%'))
|
|
@@ -154,7 +192,8 @@ window.__ModuleLoader__.load({
|
|
|
154
192
|
React.createElement('div', { className: 'olusa-login-title' }, '尚未登录 Ollama 账号'),
|
|
155
193
|
React.createElement('ol', { className: 'olusa-steps' },
|
|
156
194
|
React.createElement('li', null,
|
|
157
|
-
|
|
195
|
+
'打开 ',
|
|
196
|
+
React.createElement('a', { className: 'olusa-link', href: 'https://ollama.com/settings', target: '_blank', rel: 'noreferrer' }, 'ollama.com/settings'),
|
|
158
197
|
' 并登录(或注册)Ollama 账号'
|
|
159
198
|
),
|
|
160
199
|
React.createElement('li', null,
|
|
@@ -162,14 +201,14 @@ window.__ModuleLoader__.load({
|
|
|
162
201
|
React.createElement('a', { className: 'olusa-link', href: 'https://ollama.com/settings/keys', target: '_blank', rel: 'noreferrer' }, 'settings/keys'),
|
|
163
202
|
' 创建一个 API Key'
|
|
164
203
|
),
|
|
165
|
-
React.createElement('li', null, '把 Key
|
|
204
|
+
React.createElement('li', null, '把 Key 粘贴到下方点击「检测」;或先在终端运行 ollama signin / ollama login,再点「重新检测本地凭证」')
|
|
166
205
|
),
|
|
167
206
|
React.createElement('input', { className: 'olusa-input', placeholder: '粘贴 API Key', value: props.tokenInput, onChange: (e) => props.onInput(e.target.value), spellCheck: false }),
|
|
168
207
|
React.createElement('div', { className: 'olusa-rowbtns' },
|
|
169
208
|
React.createElement('button', { className: 'olusa-btn olusa-btn-primary', disabled: props.busy || !props.tokenInput.trim(), onClick: () => props.onCheck(props.tokenInput.trim()) }, props.busy ? '检测中…' : '检测'),
|
|
170
209
|
React.createElement('button', { className: 'olusa-btn', disabled: props.busy, onClick: () => props.onRetryLocal() }, '重新检测本地凭证')
|
|
171
210
|
),
|
|
172
|
-
React.createElement('div', { className: 'olusa-hint' }, '
|
|
211
|
+
React.createElement('div', { className: 'olusa-hint' }, '检测成功后,Key 与用量快照会保存到 $DSH_HOME/storages/ollama-usage/usage.json(权限 600),跨对话 / 重启自动恢复并每 10 分钟自动刷新。')
|
|
173
212
|
)
|
|
174
213
|
}
|
|
175
214
|
|
|
@@ -180,34 +219,49 @@ window.__ModuleLoader__.load({
|
|
|
180
219
|
const models = Array.isArray(d.models) ? d.models.slice(0, 5) : []
|
|
181
220
|
const history = Array.isArray(props.history) ? props.history.slice(-5).reverse() : []
|
|
182
221
|
return React.createElement('div', { className: 'olusa-block' },
|
|
183
|
-
React.createElement(BarRow, { label: '会话用量(每 5 小时)', percent: d.sessionPercent,
|
|
222
|
+
React.createElement(BarRow, { label: '会话用量(每 5 小时)', percent: d.sessionPercent, resetText: sessionResetText ? '还有 ' + sessionResetText + ' 重置' : null }),
|
|
184
223
|
React.createElement(BarRow, { label: '本周用量(Weekly)', percent: d.weeklyPercent, resetText: weeklyResetText ? '还有 ' + weeklyResetText + ' 重置' : null }),
|
|
185
224
|
(models.length > 0
|
|
186
|
-
? React.createElement('div', { className: 'olusa-
|
|
187
|
-
React.createElement('div', { className: 'olusa-
|
|
188
|
-
|
|
189
|
-
React.createElement('
|
|
190
|
-
|
|
191
|
-
|
|
225
|
+
? React.createElement('div', { className: 'olusa-sec' },
|
|
226
|
+
React.createElement('div', { className: 'olusa-sec-title' }, '模型请求数(本周)'),
|
|
227
|
+
React.createElement('div', { className: 'olusa-list' },
|
|
228
|
+
models.map((m) => React.createElement('div', { className: 'olusa-row', key: m.name },
|
|
229
|
+
React.createElement('span', { className: 'olusa-rowname', title: m.name }, m.name),
|
|
230
|
+
React.createElement('span', { className: 'olusa-rowval' }, String(m.requestCount) + ' 次')
|
|
231
|
+
)))
|
|
232
|
+
)
|
|
192
233
|
: null),
|
|
193
234
|
(history.length > 0
|
|
194
|
-
? React.createElement('div', { className: 'olusa-
|
|
195
|
-
React.createElement('div', { className: 'olusa-
|
|
196
|
-
|
|
197
|
-
React.createElement('
|
|
198
|
-
|
|
199
|
-
|
|
235
|
+
? React.createElement('div', { className: 'olusa-sec' },
|
|
236
|
+
React.createElement('div', { className: 'olusa-sec-title' }, '最近记录(会话用量)'),
|
|
237
|
+
React.createElement('div', { className: 'olusa-list' },
|
|
238
|
+
history.map((h, i) => React.createElement('div', { className: 'olusa-row', key: String(i) },
|
|
239
|
+
React.createElement('span', { className: 'olusa-rowname' }, fmtTime(h.at)),
|
|
240
|
+
React.createElement('span', { className: 'olusa-rowval' }, (h.sessionPercent === null || h.sessionPercent === undefined) ? '—' : (h.sessionPercent + '%'))
|
|
241
|
+
)))
|
|
242
|
+
)
|
|
200
243
|
: null),
|
|
201
244
|
(props.updatedAt
|
|
202
245
|
? React.createElement('div', { className: 'olusa-hint' }, '上次更新:' + fmtTime(props.updatedAt) + '(每 10 分钟自动刷新)')
|
|
203
246
|
: null),
|
|
204
|
-
React.createElement('div', {
|
|
205
|
-
|
|
247
|
+
React.createElement('div', {
|
|
248
|
+
className: 'olusa-state',
|
|
249
|
+
'data-tone': props.persisted ? 'ok' : 'err',
|
|
250
|
+
title: props.persisted ? '$DSH_HOME/storages/ollama-usage/usage.json' : undefined,
|
|
251
|
+
}, props.persisted ? '✓ 已持久化到本地' : '⚠ 未能写入本地文件')
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** 加载骨架:首屏 snapshot 落定前占位,避免登录表单闪现。 */
|
|
256
|
+
function LoadingBody() {
|
|
257
|
+
return React.createElement('div', { className: 'olusa-loading', role: 'status', 'aria-live': 'polite' },
|
|
258
|
+
React.createElement('div', { className: 'olusa-skeleton is-wide' }),
|
|
259
|
+
React.createElement('div', { className: 'olusa-skeleton' })
|
|
206
260
|
)
|
|
207
261
|
}
|
|
208
262
|
|
|
209
263
|
function OllamaUsagePanel() {
|
|
210
|
-
const [phase, setPhase] = React.useState('
|
|
264
|
+
const [phase, setPhase] = React.useState('loading')
|
|
211
265
|
const [data, setData] = React.useState(null)
|
|
212
266
|
const [history, setHistory] = React.useState(null)
|
|
213
267
|
const [updatedAt, setUpdatedAt] = React.useState(null)
|
|
@@ -224,7 +278,8 @@ window.__ModuleLoader__.load({
|
|
|
224
278
|
setUpdatedAt(v.updatedAt || null)
|
|
225
279
|
if (typeof v.persisted === 'boolean') setPersisted(v.persisted)
|
|
226
280
|
setError('')
|
|
227
|
-
|
|
281
|
+
// 无 usage 快照时留在登录引导,避免“无错误却显示查询失败”的 usage/error 分支。
|
|
282
|
+
setPhase(v.usage ? 'usage' : 'login')
|
|
228
283
|
} else if (res && res.error && (res.error.code === 'no-token' || res.error.code === 'no-data')) {
|
|
229
284
|
setError('')
|
|
230
285
|
setPhase('login')
|
|
@@ -258,44 +313,54 @@ window.__ModuleLoader__.load({
|
|
|
258
313
|
setData(res.value.usage); setHistory(res.value.history || null); setUpdatedAt(res.value.updatedAt || null); setError(''); setPhase('usage')
|
|
259
314
|
// snapshot 数据读自磁盘文件(插件无内存缓存),必然已持久化;服务端字段优先,缺省按不变式置 true
|
|
260
315
|
setPersisted(typeof res.value.persisted === 'boolean' ? res.value.persisted : true)
|
|
316
|
+
} else {
|
|
317
|
+
// 首屏无数据(未登录 / 无快照)落到登录引导;已有数据时保持当前视图。
|
|
318
|
+
setPhase((current) => (current === 'loading' ? 'login' : current))
|
|
261
319
|
}
|
|
262
|
-
}).catch(() => {
|
|
320
|
+
}).catch(() => {
|
|
321
|
+
if (!disposed) setPhase((current) => (current === 'loading' ? 'login' : current))
|
|
322
|
+
})
|
|
263
323
|
refresh()
|
|
264
324
|
const dispose = ctx.interval(refresh, 60000)
|
|
265
325
|
return () => { disposed = true; dispose() }
|
|
266
326
|
}, [])
|
|
267
327
|
|
|
268
|
-
const body = phase === '
|
|
269
|
-
? React.createElement(
|
|
270
|
-
: phase === '
|
|
271
|
-
? React.createElement(
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
React.createElement('
|
|
328
|
+
const body = phase === 'loading'
|
|
329
|
+
? React.createElement(LoadingBody)
|
|
330
|
+
: phase === 'login'
|
|
331
|
+
? React.createElement(LoginBody, { tokenInput: tokenInput, onInput: setTokenInput, onCheck: doCheck, onRetryLocal: () => doCheck(''), busy: busy })
|
|
332
|
+
: phase === 'usage' && data
|
|
333
|
+
? React.createElement('div', { className: 'olusa-block' },
|
|
334
|
+
React.createElement(UsageBody, { data: data, history: history, updatedAt: updatedAt, persisted: persisted }),
|
|
335
|
+
(error ? React.createElement('div', { className: 'olusa-error' }, String(error)) : null),
|
|
336
|
+
React.createElement('div', { className: 'olusa-rowbtns' },
|
|
337
|
+
React.createElement('button', { className: 'olusa-btn olusa-btn-danger', disabled: busy, onClick: () => doForget() }, '清除已存 Key')
|
|
338
|
+
)
|
|
276
339
|
)
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
340
|
+
: React.createElement('div', { className: 'olusa-block' },
|
|
341
|
+
React.createElement('div', { className: 'olusa-error' }, String(error || '查询失败')),
|
|
342
|
+
React.createElement('div', { className: 'olusa-hint' },
|
|
343
|
+
'请确认已登录:',
|
|
344
|
+
React.createElement('a', { className: 'olusa-link', href: 'https://ollama.com/settings', target: '_blank', rel: 'noreferrer' }, 'ollama.com/settings'),
|
|
345
|
+
',或粘贴 API Key 重试。'
|
|
346
|
+
),
|
|
347
|
+
React.createElement('input', { className: 'olusa-input', placeholder: '粘贴 API Key', value: tokenInput, onChange: (e) => setTokenInput(e.target.value), spellCheck: false }),
|
|
348
|
+
React.createElement('div', { className: 'olusa-rowbtns' },
|
|
349
|
+
React.createElement('button', { className: 'olusa-btn olusa-btn-primary', disabled: busy || !tokenInput.trim(), onClick: () => doCheck(tokenInput.trim()) }, busy ? '检测中…' : '检测'),
|
|
350
|
+
React.createElement('button', { className: 'olusa-btn', disabled: busy, onClick: () => doCheck('') }, '重试')
|
|
351
|
+
)
|
|
289
352
|
)
|
|
290
|
-
)
|
|
291
353
|
|
|
292
354
|
return React.createElement('div', { className: 'olusa-panel' },
|
|
293
355
|
React.createElement('div', { className: 'olusa-head' },
|
|
294
|
-
React.createElement('
|
|
356
|
+
React.createElement('div', { className: 'olusa-head-main' },
|
|
357
|
+
React.createElement('span', { className: 'olusa-title' }, '⚡ Ollama 用量'),
|
|
358
|
+
React.createElement('span', { className: 'olusa-sub' }, '会话 5h · 周用量 · 每 10 分钟自动刷新')
|
|
359
|
+
),
|
|
295
360
|
React.createElement('button', { className: 'olusa-btn', disabled: busy, onClick: () => doCheck('') }, busy ? '查询中…' : '刷新')
|
|
296
361
|
),
|
|
297
362
|
body,
|
|
298
|
-
React.createElement('div', { className: 'olusa-ver' }, 'dsh-ollama-usage · v0.1.
|
|
363
|
+
React.createElement('div', { className: 'olusa-ver' }, 'dsh-ollama-usage · v0.1.13')
|
|
299
364
|
)
|
|
300
365
|
}
|
|
301
366
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ollama-usage",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "DeepSeek Harness 插件:可视化 Ollama Cloud 账号用量余量(每 5 小时会话用量 + 周用量),支持侧边栏双横条、插件详情页完整面板、API Key 与用量快照持久化、自动刷新与登录引导。Ollama Pro usage & remaining-quota visualization for DeepSeek Harness: 5-hour session + weekly quota bars in the sidebar footer, a full panel on the plugin's own detail page, persisted API key and usage snapshots, auto-refresh and login guidance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
"0.1.6-alpha.2": "compatible",
|
|
33
33
|
"0.1.7-rc.1": "compatible",
|
|
34
34
|
"0.1.7-rc.2": "compatible",
|
|
35
|
-
"0.2.0-rc.1": "compatible"
|
|
35
|
+
"0.2.0-rc.1": "compatible",
|
|
36
|
+
"0.2.1-rc.1": "compatible",
|
|
37
|
+
"0.2.1-rc.2": "compatible"
|
|
36
38
|
},
|
|
37
39
|
"node": ">=20"
|
|
38
40
|
}
|
|
@@ -95,5 +97,9 @@
|
|
|
95
97
|
"license": "MIT",
|
|
96
98
|
"scripts": {
|
|
97
99
|
"test": "DSH_HOME=.tmp-dsh-home HOME=.tmp-home node test/bridge-smoke.mjs && DSH_HOME=.tmp-balance-dsh-home HOME=.tmp-balance-home node test/balance-parse.mjs && DSH_HOME=.tmp-env-dsh-home HOME=.tmp-env-home node test/rpc-envelope-alpha4.mjs"
|
|
100
|
+
},
|
|
101
|
+
"engines": {
|
|
102
|
+
"node": ">=20",
|
|
103
|
+
"dsh": ">=0.1.7-rc.1"
|
|
98
104
|
}
|
|
99
|
-
}
|
|
105
|
+
}
|