creditdaddy 0.9.2 → 0.9.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "creditdaddy",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "CreditDaddy — Qoder / WorkBuddy / ZCode 多账号本地管理与每日积分自动签到助手",
5
5
  "homepage": "https://github.com/techysy/CreditDaddy",
6
6
  "repository": {
package/src/daemon.js CHANGED
@@ -49,7 +49,7 @@ import {
49
49
  import { addAccount, importAccounts, refreshContext } from './accounts.js';
50
50
  import { productImpl } from './providers.js';
51
51
  import { readWorkbuddySessions, writeWorkbuddySession, workbuddyAuthDir, currentWorkbuddyUid } from './workbuddyLocal.js';
52
- import { liveToAccount as zcodeLiveAccount, switchTo as zcodeSwitchTo, currentZcodeUid, currentZcodeIdentity, detectZcode, ensureVirtualDeviceMid, terminateZcode } from './zcodeLocal.js';
52
+ import { liveToAccount as zcodeLiveAccount, switchTo as zcodeSwitchTo, currentZcodeUid, currentZcodeIdentity, detectZcode, ensureVirtualDeviceMid, terminateZcode, zcodeRunning } from './zcodeLocal.js';
53
53
  import { fetchClaimPlans, claimPlan, fetchCaptchaConfig, proxyFirst, setProxyFirst, proxyUrl, setProxyUrl, autoClaimEnabled, setAutoClaimEnabled } from './zcodeClient.js';
54
54
  import { exportAccounts, parseImport, TransferError } from './transfer.js';
55
55
  import { runCheckinTick, getSchedulerInfo, dayKey } from './checkin.js';
@@ -494,6 +494,7 @@ async function handleApi(req, res, url) {
494
494
  workbuddyCurrentUid: currentWorkbuddyUid(),
495
495
  zcodeCurrentUid: currentZcodeUid(),
496
496
  zcodeCurrentIdentity: currentZcodeIdentity(),
497
+ zcodeClient: (() => { const d = detectZcode(); return { installed: d.exists, signedIn: d.signedIn, running: zcodeRunning() }; })(),
497
498
  keyRequired: Boolean(PANEL_KEY),
498
499
  });
499
500
  }
package/src/panel.html CHANGED
@@ -660,9 +660,12 @@ function creditHtml(a) {
660
660
  return base + (x.expiresAt ? '(' + fmtTime(x.expiresAt).slice(5, 16) + (x.recurring ? ' 重置)' : ' 到期)') : '');
661
661
  }).join(' · ');
662
662
  const pct = q.total > 0 ? Math.min(1, q.remaining / q.total) : 0;
663
+ // 满额(100%)不再渲染灰色「已使用」尾段——它只占 0 宽也会造成几像素的灰边
663
664
  return '<div class="credit-line"><span class="credit"><span class="lbl">剩余</span><b>' + fmtNum(q.remaining) + '</b>' + esc(unit) + '</span>'
664
665
  + '<span class="credit dim" title="' + items + '">' + (q.plan ? esc(q.plan) + ' · ' : '') + items + '</span></div>'
665
- + '<div class="bar"><span class="seg" style="flex:' + pct.toFixed(4) + ' 1 0"></span><span class="seg used" style="flex:' + (1 - pct).toFixed(4) + ' 1 0"></span></div>';
666
+ + '<div class="bar"><span class="seg" style="flex:' + pct.toFixed(4) + ' 1 0"></span>'
667
+ + (pct < 0.9999 ? '<span class="seg used" style="flex:' + (1 - pct).toFixed(4) + ' 1 0"></span>' : '')
668
+ + '</div>';
666
669
  }
667
670
  const total = q.total || 0;
668
671
  let bar = '';
@@ -931,7 +934,8 @@ function renderStatus() {
931
934
  n.innerHTML = 'ZCode 没有每日签到,积分靠「活动领取」。打开「自动领取」后,每轮签到结束会轮询可领活动并尝试领取(桌面版静默过验证码,需要人工时弹验证码窗口);平时保持关闭即可,活动期前再开。也可点卡片上的礼物图标手动领取。'
932
935
  + ' <button class="btn" id="btn-zac" style="margin-left:6px" title="ZCode 活动自动轮询领取(每轮签到后执行一次)">' + (ac ? '自动领取:开' : '自动领取:关') + '</button>'
933
936
  + ' <button class="btn" id="btn-znet" style="margin-left:4px" title="ZCode 上游接口的访问顺序:失败 / 被拦时自动回退另一条">出口:' + (pf ? '代理优先' : '直连优先') + '</button>'
934
- + ' <button class="btn" id="btn-zproxy" style="margin-left:4px" title="设置 ZCode 出口用的 http 代理(留空则清除;不设置时使用 HTTPS_PROXY 环境变量)">代理:' + esc(pu || (state.zHasEnvProxy ? '环境变量' : '未设置')) + '</button>';
937
+ + ' <button class="btn" id="btn-zproxy" style="margin-left:4px" title="设置 ZCode 出口用的 http 代理(留空则清除;不设置时使用 HTTPS_PROXY 环境变量)">代理:' + esc(pu || (state.zHasEnvProxy ? '环境变量' : '未设置')) + '</button>'
938
+ + zcodeClientChip(s);
935
939
  } else if (hasIntl && !s.riskIdentity && umidOffer(s)) {
936
940
  n.style.display = '';
937
941
  const busy = s.umid.installing || umidBusy;
@@ -950,6 +954,15 @@ function renderStatus() {
950
954
  }
951
955
  }
952
956
 
957
+ // ZCode 客户端状态芯片 + 「打开客户端」按钮(仅桌面版:面板里有 Electron 桥才显示按钮)
958
+ function zcodeClientChip(s) {
959
+ const c = s.zcodeClient || {};
960
+ if (!c.installed) return ' <span class="dim">客户端:未安装</span>';
961
+ const canOpen = window.creditdaddy && typeof window.creditdaddy.openZcodeClient === 'function';
962
+ return ' <span class="dim">客户端:' + (c.running ? '运行中' : '未运行') + '</span>'
963
+ + (canOpen ? ' <button class="btn" id="btn-zopen" style="margin-left:4px" title="打开本机 ZCode 客户端">打开客户端</button>' : '');
964
+ }
965
+
953
966
  // Qoder 设备身份组件(Linux / fnOS)
954
967
  const umidOffer = (s) => Boolean(s && s.umid && s.umid.supported && !s.umid.installed);
955
968
  let umidBusy = false;
@@ -964,6 +977,14 @@ async function installUmid() {
964
977
  }
965
978
  $('notice').addEventListener('click', (e) => { if (e.target.closest('#btn-umid')) installUmid(); });
966
979
  $('notice').addEventListener('click', async (e) => {
980
+ if (e.target.closest('#btn-zopen')) {
981
+ try {
982
+ const r = await window.creditdaddy.openZcodeClient();
983
+ if (r && r.ok) toast('已启动 ZCode 客户端');
984
+ else toast((r && r.error) || '无法打开 ZCode 客户端', false);
985
+ } catch (err) { toast(String(err && err.message || err), false); }
986
+ return;
987
+ }
967
988
  if (e.target.closest('#btn-zac')) {
968
989
  try {
969
990
  const r = await api('/api/zcode/net', { method: 'PUT', json: { autoClaim: state.zAutoClaim !== true } });