@anthonyhan/token-pilot 0.4.9 → 0.4.10
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/dist/cli/index.js +6 -1
- package/package.json +1 -1
- package/web/dashboard.html +27 -16
package/dist/cli/index.js
CHANGED
|
@@ -292,6 +292,10 @@ async function main() {
|
|
|
292
292
|
// 参数从 stdin 读 {keys, customs},避免把 key 放进命令行参数——
|
|
293
293
|
// 那样会出现在 ps 输出和历史里。
|
|
294
294
|
if (cmd === 'quota-test') {
|
|
295
|
+
// 版本自检:这个子命令是 0.4.9 加的,旧版 CLI(比如 0.4.2)没有它。
|
|
296
|
+
// 旧版会走到用法提示输出「用法:...」,第一个字符是「用」,
|
|
297
|
+
// 前端 JSON.parse 直接崩成「Unrecognized token '用'」。
|
|
298
|
+
// 这里主动校验 stdin 能解析,解析不了立刻返回结构化错误,绝不混进非 JSON 输出。
|
|
295
299
|
const chunks = [];
|
|
296
300
|
for await (const c of process.stdin)
|
|
297
301
|
chunks.push(c);
|
|
@@ -300,7 +304,8 @@ async function main() {
|
|
|
300
304
|
payload = JSON.parse(Buffer.concat(chunks).toString('utf8') || '{}');
|
|
301
305
|
}
|
|
302
306
|
catch {
|
|
303
|
-
|
|
307
|
+
console.log(JSON.stringify({ results: [], error: 'invalid-payload' }));
|
|
308
|
+
return;
|
|
304
309
|
}
|
|
305
310
|
const { testEndpoints } = await import('../core/quota/providers/declarative.js');
|
|
306
311
|
const results = await testEndpoints(payload.keys ?? {}, Array.isArray(payload.customs) ? payload.customs : []);
|
package/package.json
CHANGED
package/web/dashboard.html
CHANGED
|
@@ -409,8 +409,11 @@ footer .notes{max-width:560px}
|
|
|
409
409
|
.opt-unit{font-size:11.5px;color:var(--muted)}
|
|
410
410
|
.delrow{color:var(--muted);border:0;background:none;cursor:pointer;font-size:14px;line-height:1;padding:2px}
|
|
411
411
|
.modal-foot{display:flex;justify-content:flex-end;align-items:center;gap:12px;padding:12px 18px;border-top:1px solid var(--gridln)}
|
|
412
|
-
.saved-hint{
|
|
412
|
+
.saved-hint{font-size:12px;font-weight:700;opacity:0;transition:opacity .2s var(--ease)}
|
|
413
413
|
.saved-hint.on{opacity:1}
|
|
414
|
+
.saved-hint.ok{color:var(--pos-text)}
|
|
415
|
+
.saved-hint.err{color:var(--warn)}
|
|
416
|
+
.saved-hint.err{color:var(--danger,var(--warn))}
|
|
414
417
|
|
|
415
418
|
@media (max-width:1020px){
|
|
416
419
|
.stat-grid{grid-template-columns:repeat(2,1fr)}
|
|
@@ -727,9 +730,9 @@ footer .notes{max-width:560px}
|
|
|
727
730
|
<div class="modal-head"><h2>数据设置</h2><button class="theme-btn" id="modalClose" type="button" aria-label="关闭设置"><svg viewBox="0 0 24 24"><path d="M6 6l12 12M18 6L6 18"/></svg></button></div>
|
|
728
731
|
<div class="modal-body">
|
|
729
732
|
<div class="m-sec">
|
|
730
|
-
<div class="m-lab">API Key
|
|
733
|
+
<div class="m-lab">API Key 管理 <span>余额与订阅共用:选平台、填 key、测试、保存;只存本机,不上传</span></div>
|
|
731
734
|
<div class="key-empty-note">
|
|
732
|
-
没填也能用:装了 CC Switch
|
|
735
|
+
没填也能用:装了 CC Switch 会自动读取(标「CC Switch 读取」)。<b>不装 CC Switch 时,这里是唯一入口。</b>
|
|
733
736
|
</div>
|
|
734
737
|
<div id="mKeys"></div>
|
|
735
738
|
<div class="key-actions">
|
|
@@ -751,7 +754,6 @@ footer .notes{max-width:560px}
|
|
|
751
754
|
</div>
|
|
752
755
|
<div id="mSubs" data-set="subs"></div>
|
|
753
756
|
<div class="key-actions">
|
|
754
|
-
<button class="addrow" type="button" id="mAddSubPlatform">+ 添加订阅平台</button>
|
|
755
757
|
<button class="addrow" type="button" data-add="subs">+ 手动填一条</button>
|
|
756
758
|
</div>
|
|
757
759
|
<div id="mSubResult" class="key-result"></div>
|
|
@@ -1456,10 +1458,14 @@ modal.addEventListener("click",function(e){
|
|
|
1456
1458
|
var clr=e.target.closest("[data-keyclear]");
|
|
1457
1459
|
if(clr){
|
|
1458
1460
|
var i=+clr.dataset.keyclear;
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1461
|
+
var k=settings.keys[i];
|
|
1462
|
+
// 从列表移除,而不是清空字段。
|
|
1463
|
+
// 之前是清 masked/value 但留在列表里,导致「点了没反应」——行还在。
|
|
1464
|
+
// 现在把它从列表拿掉;已存的 key 由保存逻辑写入空值完成删除。
|
|
1465
|
+
if(k.masked)k._clear=true; // 有已存 key:标待删,保存时写空值真正删掉
|
|
1466
|
+
k.added=false; // 从界面列表移除
|
|
1467
|
+
k.masked=null; // 去掉已配置标记——否则过滤条件仍认为它该显示
|
|
1468
|
+
k.value="";
|
|
1463
1469
|
renderKeyRows();
|
|
1464
1470
|
return;
|
|
1465
1471
|
}
|
|
@@ -1468,7 +1474,6 @@ modal.addEventListener("click",function(e){
|
|
|
1468
1474
|
});
|
|
1469
1475
|
$("#mAddCustom").addEventListener("click",showAddPlatform);
|
|
1470
1476
|
$("#mTestKeys").addEventListener("click",testKeys);
|
|
1471
|
-
$("#mAddSubPlatform").addEventListener("click",showAddSubPlatform);
|
|
1472
1477
|
$$(".addrow").forEach(function(b){
|
|
1473
1478
|
// 只处理带 data-add 的行内「+ 添加」按钮。
|
|
1474
1479
|
// 没有这层判断的话,同样用 .addrow 样式的「添加自定义平台」「测试连接」
|
|
@@ -1512,9 +1517,15 @@ $("#settingsSave").addEventListener("click",function(){
|
|
|
1512
1517
|
settings.keys.forEach(function(k){if(k._custom)customs.push(k._custom)});
|
|
1513
1518
|
if(customs.length)payload.customEndpoints=customs;
|
|
1514
1519
|
var h=$("#saveHint");
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1520
|
+
// duration=0 表示常驻:不再一闪而过。
|
|
1521
|
+
// 用户反馈保存提示一闪就消失,根本来不及看,分不清是存上了还是没存上。
|
|
1522
|
+
function showHint(msg, ok, duration){
|
|
1523
|
+
h.textContent=msg;
|
|
1524
|
+
h.classList.add("on");
|
|
1525
|
+
h.classList.remove("ok","err");
|
|
1526
|
+
h.classList.add(ok===false?"err":"ok");
|
|
1527
|
+
clearTimeout(h._t);
|
|
1528
|
+
if(duration>0)h._t=setTimeout(function(){h.classList.remove("on")},duration);
|
|
1518
1529
|
}
|
|
1519
1530
|
var saved;
|
|
1520
1531
|
if (inTauri()) {
|
|
@@ -1530,14 +1541,14 @@ $("#settingsSave").addEventListener("click",function(){
|
|
|
1530
1541
|
saved.then(function(j){
|
|
1531
1542
|
// RTK 装卸结果如实反馈:失败时显示真实原因(含冲突提示),不吞成「已保存」
|
|
1532
1543
|
if(j&&j.rtk){
|
|
1533
|
-
if(j.rtk.ok){showHint("已保存 · "+(j.rtk.message||"RTK 就绪"),2600)}
|
|
1534
|
-
else{showHint("RTK 未安装:"+(j.rtk.message||"未知原因"),6000);try{loadSettingsFromD()}catch(e){}}
|
|
1544
|
+
if(j.rtk.ok){showHint("已保存 · "+(j.rtk.message||"RTK 就绪"),true,2600)}
|
|
1545
|
+
else{showHint("RTK 未安装:"+(j.rtk.message||"未知原因"),false,6000);try{loadSettingsFromD()}catch(e){}}
|
|
1535
1546
|
}else{
|
|
1536
|
-
showHint("已保存");
|
|
1547
|
+
showHint("✓ 已保存",true,0);
|
|
1537
1548
|
}
|
|
1538
1549
|
}).catch(function(e){
|
|
1539
1550
|
try{localStorage.setItem("tp-settings",JSON.stringify(payload))}catch(e2){}
|
|
1540
|
-
showHint("保存失败:"+((e&&e.message)||"未知错误")+"(仅本地预览生效)",
|
|
1551
|
+
showHint("✗ 保存失败:"+((e&&e.message)||"未知错误")+"(仅本地预览生效)",false,0);
|
|
1541
1552
|
});
|
|
1542
1553
|
});
|
|
1543
1554
|
|