@fish-under-sea/magpie-dragonapi 0.1.4 → 0.1.5
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.md +2 -2
- package/package.json +1 -1
- package/ui/app.js +24 -13
- package/ui/index.html +27 -11
- package/ui/style.css +27 -3
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
把 [DragonAPI](https://newapi.dragon3api.com/) 接进 magpie:模型广场、余额、用量,外加一个能按分组建钥匙的本地界面。
|
|
4
4
|
|
|
5
|
-
> 当前版本 **0.1.
|
|
5
|
+
> 当前版本 **0.1.5**。只做供应商插件 + 只读看板 + 密钥管理,不做「页面里点充值」。
|
|
6
6
|
|
|
7
7
|
## 它是什么
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
| **命令行** | `magpie plugin add @fish-under-sea/magpie-dragonapi` |
|
|
26
26
|
|
|
27
27
|
npm 拉不到时(内网、镜像抽风):到 [Releases](https://github.com/Fish-under-sea/magpie-dragonapi/releases) 下
|
|
28
|
-
`fish-under-sea-magpie-dragonapi-0.1.
|
|
28
|
+
`fish-under-sea-magpie-dragonapi-0.1.5.tgz`,解包成目录,再 `magpie plugin add <那个目录>` ——
|
|
29
29
|
`plugin add` 认 `path`,和从文件夹加插件是同一条路。
|
|
30
30
|
|
|
31
31
|
装好后:Settings → Plugins 里出现 **DragonAPI** 行(带一张页面),供应商列表里出现 **DragonAPI**。
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fish-under-sea/magpie-dragonapi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "DragonAPI for magpie: a provider plugin whose models, groups and prices come from the site's public /api/pricing, with balance and per-call usage from an sk- key, plus a local page that lists the market (read-only), shows usage and can mint new keys for a group.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.mjs",
|
package/ui/app.js
CHANGED
|
@@ -792,19 +792,30 @@ function renderAccounts() {
|
|
|
792
792
|
return;
|
|
793
793
|
}
|
|
794
794
|
|
|
795
|
-
box.replaceChildren(...accounts.map((a) =>
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
795
|
+
box.replaceChildren(...accounts.map((a) => {
|
|
796
|
+
const mask = a.masked || '';
|
|
797
|
+
// 服务端的 label 本身就是「分组 · 打码钥匙」,再单列一次打码就是重复。
|
|
798
|
+
// 只在 label 里没有它时才单独显示。
|
|
799
|
+
const showMask = mask && !String(a.label || '').includes(mask);
|
|
800
|
+
// 余额是「—」不是因为没有余额,而是插件进程还没拿到这把钥匙的明文
|
|
801
|
+
// (冷启动后要等宿主调一次 models/usage 才会填)。说清楚,别让人以为没钱了。
|
|
802
|
+
const noKeyHint = a.balance === '—'
|
|
803
|
+
? '插件还没拿到这把钥匙的明文:在 magpie 里发一次请求、或点右上角「刷新」即可'
|
|
804
|
+
: '';
|
|
805
|
+
return h('div', { class: 'acct' },
|
|
806
|
+
h('div', { class: 'acct-top' },
|
|
807
|
+
h('span', { class: 'acct-label', text: a.label || a.tokenName || '未命名账号' }),
|
|
808
|
+
a.group ? h('span', { class: 'tag', text: a.group }) : null,
|
|
809
|
+
showMask ? h('span', { class: 'acct-mask', text: mask }) : null,
|
|
810
|
+
),
|
|
811
|
+
h('div', { class: 'acct-figs' },
|
|
812
|
+
fig('余额', a.balance ?? '—', 'big pos', noKeyHint || (Number.isFinite(a.balanceRaw) ? `${fmtInt(a.balanceRaw)} quota` : '')),
|
|
813
|
+
fig('已用', a.used ?? '—', '', Number.isFinite(a.usedRaw) ? `${fmtInt(a.usedRaw)} quota` : ''),
|
|
814
|
+
fig('模型数', Number.isFinite(a.models) ? fmtInt(a.models) : '—'),
|
|
815
|
+
fig('绑定于', fmtAt(a.boundAt)),
|
|
816
|
+
),
|
|
817
|
+
);
|
|
818
|
+
}));
|
|
808
819
|
}
|
|
809
820
|
|
|
810
821
|
function fig(k, v, cls = '', title = '') {
|
package/ui/index.html
CHANGED
|
@@ -57,15 +57,19 @@
|
|
|
57
57
|
|
|
58
58
|
<!-- 1. 模型广场:纯展示。这里刻意没有任何勾选框、开关或「已选」状态。 -->
|
|
59
59
|
<section class="panel" id="panel-catalog" role="tabpanel" aria-labelledby="tab-catalog" data-panel="catalog">
|
|
60
|
+
<header class="page-head">
|
|
61
|
+
<h2>模型广场</h2>
|
|
62
|
+
<p class="page-sub">站点公开目录:分组、倍率与价格。只读展示,不改站点任何设置。</p>
|
|
63
|
+
</header>
|
|
60
64
|
<div class="market-body">
|
|
61
65
|
<aside class="market-aside" aria-label="筛选">
|
|
62
66
|
<div class="ma-head">
|
|
63
|
-
<
|
|
67
|
+
<h3>筛选</h3>
|
|
64
68
|
<button class="link" id="catalog-reset" type="button">重置</button>
|
|
65
69
|
</div>
|
|
66
70
|
<p class="ma-note">按分组与类型细化。分组决定倍率,也决定你需要哪把钥匙。</p>
|
|
67
71
|
|
|
68
|
-
<
|
|
72
|
+
<h4 id="aside-group-head">分组</h4>
|
|
69
73
|
<div class="market-chips" id="group-chips" role="group" aria-labelledby="aside-group-head"></div>
|
|
70
74
|
</aside>
|
|
71
75
|
|
|
@@ -90,10 +94,14 @@
|
|
|
90
94
|
|
|
91
95
|
<!-- 2. 余额与用量 -->
|
|
92
96
|
<section class="panel" id="panel-wallet" role="tabpanel" aria-labelledby="tab-wallet" data-panel="wallet" hidden>
|
|
97
|
+
<header class="page-head">
|
|
98
|
+
<h2>余额与用量</h2>
|
|
99
|
+
<p class="page-sub">每个账号的余额、按日周月汇总,以及逐条调用流水。金额按站点币种显示。</p>
|
|
100
|
+
</header>
|
|
93
101
|
<div class="grid-2">
|
|
94
102
|
<div class="card">
|
|
95
103
|
<header class="card-head">
|
|
96
|
-
<
|
|
104
|
+
<h3>账户余额</h3>
|
|
97
105
|
<span class="card-sub" id="account-sub"></span>
|
|
98
106
|
</header>
|
|
99
107
|
<div id="account-body"><p class="loading">正在读取…</p></div>
|
|
@@ -101,7 +109,7 @@
|
|
|
101
109
|
|
|
102
110
|
<div class="card">
|
|
103
111
|
<header class="card-head">
|
|
104
|
-
<
|
|
112
|
+
<h3>用量汇总</h3>
|
|
105
113
|
<div class="segmented" role="group" aria-label="统计区间">
|
|
106
114
|
<button type="button" data-range="day" aria-pressed="true">日</button>
|
|
107
115
|
<button type="button" data-range="week" aria-pressed="false">周</button>
|
|
@@ -114,7 +122,7 @@
|
|
|
114
122
|
|
|
115
123
|
<div class="card">
|
|
116
124
|
<header class="card-head">
|
|
117
|
-
<
|
|
125
|
+
<h3>用量流水</h3>
|
|
118
126
|
<div class="card-tools">
|
|
119
127
|
<label class="sr-only" for="flow-account">按账号查看</label>
|
|
120
128
|
<select id="flow-account"></select>
|
|
@@ -127,9 +135,13 @@
|
|
|
127
135
|
|
|
128
136
|
<!-- 3. 密钥 -->
|
|
129
137
|
<section class="panel" id="panel-keys" role="tabpanel" aria-labelledby="tab-keys" data-panel="keys" hidden>
|
|
138
|
+
<header class="page-head">
|
|
139
|
+
<h2>密钥</h2>
|
|
140
|
+
<p class="page-sub">按分组建钥匙、看一次性明文、删掉不再用的。一把钥匙只属于一个分组。</p>
|
|
141
|
+
</header>
|
|
130
142
|
<div class="grid-2 keys-grid">
|
|
131
143
|
<div class="card">
|
|
132
|
-
<header class="card-head"><
|
|
144
|
+
<header class="card-head"><h3>新建钥匙</h3></header>
|
|
133
145
|
<form id="key-form" class="form" novalidate>
|
|
134
146
|
<div class="field">
|
|
135
147
|
<label for="key-group">分组</label>
|
|
@@ -159,7 +171,7 @@
|
|
|
159
171
|
</div>
|
|
160
172
|
|
|
161
173
|
<div class="card">
|
|
162
|
-
<header class="card-head"><
|
|
174
|
+
<header class="card-head"><h3>怎么绑进 magpie</h3></header>
|
|
163
175
|
<div id="bind-info-body"><p class="loading">正在读取绑定说明…</p></div>
|
|
164
176
|
</div>
|
|
165
177
|
</div>
|
|
@@ -168,7 +180,7 @@
|
|
|
168
180
|
|
|
169
181
|
<div class="card">
|
|
170
182
|
<header class="card-head">
|
|
171
|
-
<
|
|
183
|
+
<h3>已有钥匙</h3>
|
|
172
184
|
<span class="card-sub" id="keys-count"></span>
|
|
173
185
|
</header>
|
|
174
186
|
<div id="keys-body"><p class="loading">正在读取…</p></div>
|
|
@@ -177,10 +189,14 @@
|
|
|
177
189
|
|
|
178
190
|
<!-- 4. 访问令牌(PAT) -->
|
|
179
191
|
<section class="panel" id="panel-pat" role="tabpanel" aria-labelledby="tab-pat" data-panel="pat" hidden>
|
|
192
|
+
<header class="page-head">
|
|
193
|
+
<h2>访问令牌</h2>
|
|
194
|
+
<p class="page-sub">PAT 用来读账户、建密钥、看余额。它只能由你在浏览器里创建,插件无法代登录。</p>
|
|
195
|
+
</header>
|
|
180
196
|
<div class="grid-2">
|
|
181
197
|
<div class="card">
|
|
182
198
|
<header class="card-head">
|
|
183
|
-
<
|
|
199
|
+
<h3>访问令牌 PAT</h3>
|
|
184
200
|
<span class="card-sub" id="pat-badge"></span>
|
|
185
201
|
</header>
|
|
186
202
|
<div id="pat-state" class="pat-state"><p class="loading">正在读取…</p></div>
|
|
@@ -200,7 +216,7 @@
|
|
|
200
216
|
</div>
|
|
201
217
|
|
|
202
218
|
<div class="card">
|
|
203
|
-
<header class="card-head"><
|
|
219
|
+
<header class="card-head"><h3>需要哪些权限</h3></header>
|
|
204
220
|
<div class="table-wrap">
|
|
205
221
|
<table class="data-table scope-table">
|
|
206
222
|
<caption class="sr-only">PAT scope 与对应能力</caption>
|
|
@@ -225,7 +241,7 @@
|
|
|
225
241
|
</div>
|
|
226
242
|
|
|
227
243
|
<div class="card">
|
|
228
|
-
<header class="card-head"><
|
|
244
|
+
<header class="card-head"><h3>健康与诊断</h3></header>
|
|
229
245
|
<div id="diag-body"><p class="loading">正在读取…</p></div>
|
|
230
246
|
</div>
|
|
231
247
|
</section>
|
package/ui/style.css
CHANGED
|
@@ -405,6 +405,30 @@ input[type="search"] { -webkit-appearance: none; appearance: none; }
|
|
|
405
405
|
}
|
|
406
406
|
.card.flush { padding: 0; overflow: hidden; }
|
|
407
407
|
|
|
408
|
+
/* 页面级标题:四个标签页共用一套节奏。
|
|
409
|
+
没有它的时候每页都是「一堆卡片」,卡片标题还跟标签名重复;有了它,
|
|
410
|
+
标签是导航、页头是身份、卡片标题是分区,三层才分得开。 */
|
|
411
|
+
.page-head {
|
|
412
|
+
display: flex;
|
|
413
|
+
align-items: baseline;
|
|
414
|
+
gap: 10px;
|
|
415
|
+
flex-wrap: wrap;
|
|
416
|
+
margin: 0 0 14px;
|
|
417
|
+
}
|
|
418
|
+
.page-head h2 {
|
|
419
|
+
margin: 0;
|
|
420
|
+
font-size: 17px;
|
|
421
|
+
font-weight: 650;
|
|
422
|
+
letter-spacing: -.01em;
|
|
423
|
+
}
|
|
424
|
+
.page-sub {
|
|
425
|
+
margin: 0;
|
|
426
|
+
max-width: 72ch;
|
|
427
|
+
font-size: 11.5px;
|
|
428
|
+
line-height: 1.5;
|
|
429
|
+
color: var(--muted);
|
|
430
|
+
}
|
|
431
|
+
|
|
408
432
|
.card-head {
|
|
409
433
|
display: flex;
|
|
410
434
|
align-items: center;
|
|
@@ -414,7 +438,7 @@ input[type="search"] { -webkit-appearance: none; appearance: none; }
|
|
|
414
438
|
}
|
|
415
439
|
.card.flush > .card-head { margin: 0; padding: 12px 14px; border-bottom: 1px solid var(--line); }
|
|
416
440
|
|
|
417
|
-
.card-head h2 {
|
|
441
|
+
.card-head :is(h2, h3) {
|
|
418
442
|
margin: 0;
|
|
419
443
|
font-size: 13.5px;
|
|
420
444
|
font-weight: 650;
|
|
@@ -1041,9 +1065,9 @@ input[type="search"] { -webkit-appearance: none; appearance: none; }
|
|
|
1041
1065
|
background: var(--sunken);
|
|
1042
1066
|
}
|
|
1043
1067
|
.ma-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
|
|
1044
|
-
.ma-head h2 { margin: 0; font-size:
|
|
1068
|
+
.ma-head :is(h2, h3) { margin: 0; font-size: 12.5px; font-weight: 600; }
|
|
1045
1069
|
.ma-note { margin: 4px 0 10px; font-size: 11px; line-height: 1.5; color: var(--muted); }
|
|
1046
|
-
.market-aside h3 {
|
|
1070
|
+
.market-aside :is(h3, h4) {
|
|
1047
1071
|
margin: 12px 0 7px;
|
|
1048
1072
|
font-size: 11px;
|
|
1049
1073
|
font-weight: 600;
|