creditdaddy 1.5.0 → 1.5.1
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 +38 -3
- package/build.json +3 -3
- package/package.json +1 -1
- package/src/daemon.js +106 -7
- package/src/externalQuota.js +37 -7
- package/src/i18n/en.json +13 -2
- package/src/i18n/ja.json +13 -2
- package/src/i18n/ko.json +13 -2
- package/src/i18n/zh-TW.json +13 -2
- package/src/logger.js +56 -52
- package/src/panel.html +30 -3
- package/src/traeClient.js +294 -266
- package/src/workbuddyClient.js +87 -0
- package/src/zcodeClient.js +13 -3
package/src/panel.html
CHANGED
|
@@ -615,6 +615,9 @@
|
|
|
615
615
|
<button class="btn" id="mt-gw"></button>
|
|
616
616
|
<button class="btn" id="mt-open" style="display:none"></button>
|
|
617
617
|
</span>
|
|
618
|
+
<span id="w-actions" style="display:none">
|
|
619
|
+
<button class="btn" id="wt-act" title="领取临时活动(额外补偿 / 首月赠礼),用已存凭据批量领,免逐个网页点击"></button>
|
|
620
|
+
</span>
|
|
618
621
|
<button class="btn" id="btn-add"></button>
|
|
619
622
|
<button class="btn" id="btn-import"></button>
|
|
620
623
|
<button class="btn" id="btn-export"></button>
|
|
@@ -1717,6 +1720,7 @@ function render() {
|
|
|
1717
1720
|
$('z-actions').style.display = 'none'; // 兜底:切到仪表盘 / 10Router / 免费额度池 时 renderProd 不跑,先藏起来
|
|
1718
1721
|
$('t-actions').style.display = 'none';
|
|
1719
1722
|
$('m-actions').style.display = 'none';
|
|
1723
|
+
$('w-actions').style.display = 'none';
|
|
1720
1724
|
for (const p of PRODUCTS) $('cnt-' + p.id).textContent = ofProduct(p.id).length;
|
|
1721
1725
|
$('cnt-tenrouter').textContent = tr.quotas ? tr.quotas.connections.length : tr.config && tr.config.configured ? '…' : '–';
|
|
1722
1726
|
const freeAccounts = (state.cookieSites || []).reduce((n, s) => n + (s.accounts ? s.accounts.length : 0), 0);
|
|
@@ -1816,6 +1820,11 @@ function renderProd() {
|
|
|
1816
1820
|
$('mt-open').title = mc.running ? T('MiniMax Code 客户端运行中,点我唤到前台') : T('MiniMax Code 客户端未运行,点我启动');
|
|
1817
1821
|
}
|
|
1818
1822
|
}
|
|
1823
|
+
// WorkBuddy 临时活动(额外补偿 / 首月赠礼)批量领取入口——用已存凭据,免逐个网页点击
|
|
1824
|
+
$('w-actions').style.display = prod === 'workbuddy' ? 'contents' : 'none';
|
|
1825
|
+
if (prod === 'workbuddy') {
|
|
1826
|
+
$('wt-act').innerHTML = I.gift + T('领取活动');
|
|
1827
|
+
}
|
|
1819
1828
|
}
|
|
1820
1829
|
|
|
1821
1830
|
function kpi(label, value, sub, labelTitle) {
|
|
@@ -3057,7 +3066,8 @@ async function refreshAccountList() {
|
|
|
3057
3066
|
}
|
|
3058
3067
|
let quotaRun = 0;
|
|
3059
3068
|
let quotaLoadedAt = 0;
|
|
3060
|
-
async function loadQuotas(ids) {
|
|
3069
|
+
async function loadQuotas(ids, opts) {
|
|
3070
|
+
const live = !!(opts && opts.live);
|
|
3061
3071
|
const run = ++quotaRun;
|
|
3062
3072
|
quotaLoadedAt = Date.now();
|
|
3063
3073
|
const queue = (ids || state.accounts.map((a) => a.id)).slice();
|
|
@@ -3065,7 +3075,7 @@ async function loadQuotas(ids) {
|
|
|
3065
3075
|
const worker = async () => {
|
|
3066
3076
|
while (queue.length && run === quotaRun) {
|
|
3067
3077
|
const id = queue.shift();
|
|
3068
|
-
try { state.quotas[id] = (await api('/api/accounts/' + encodeURIComponent(id) + '/quota')).quota; }
|
|
3078
|
+
try { state.quotas[id] = (await api('/api/accounts/' + encodeURIComponent(id) + '/quota' + (live ? '?live=1' : ''))).quota; }
|
|
3069
3079
|
catch (e) { state.quotas[id] = { error: e.message }; }
|
|
3070
3080
|
render();
|
|
3071
3081
|
}
|
|
@@ -3166,6 +3176,22 @@ async function checkinAll(btn, product) {
|
|
|
3166
3176
|
btn.disabled = false; btn.innerHTML = label;
|
|
3167
3177
|
await loadStatus(); await loadAccounts(); loadLogs();
|
|
3168
3178
|
}
|
|
3179
|
+
// WorkBuddy 临时活动批量领取:用已存 Bearer 凭据领「额外补偿 / 首月赠礼」,免逐个网页点击
|
|
3180
|
+
async function claimWbActivities(btn) {
|
|
3181
|
+
const label = btn.innerHTML;
|
|
3182
|
+
btn.disabled = true; btn.innerHTML = I.refresh + T('领取中…');
|
|
3183
|
+
try {
|
|
3184
|
+
const d = await api('/api/workbuddy/claim-activities', { method: 'POST', json: {} });
|
|
3185
|
+
const s = d.summary || {};
|
|
3186
|
+
const claimed = (d.results || []).flatMap((r) => r.claimed || []).filter((x) => x.status === 'checked-in');
|
|
3187
|
+
const amount = claimed.reduce((sum, x) => sum + (Number(x.claimedAmount) || 0), 0);
|
|
3188
|
+
if (s.total === 0) toast(T('没有可领取的临时活动(都领过或未开启)'));
|
|
3189
|
+
else if (s.claimed > 0) toast(T('领取成功 {n} 项,+{amt} 积分', { n: s.claimed, amt: amount }) + (s.already ? T('({n} 项已领)', { n: s.already }) : '') + (s.failed ? T('({n} 项失败)', { n: s.failed }) : ''));
|
|
3190
|
+
else toast(T('已领 {n} 项,无可领活动', { n: s.already }) + (s.failed ? T('({n} 项失败)', { n: s.failed }) : ''), !s.failed);
|
|
3191
|
+
} catch (e) { toast(e.message, false); }
|
|
3192
|
+
btn.disabled = false; btn.innerHTML = label;
|
|
3193
|
+
await loadStatus(); await loadAccounts(); loadLogs();
|
|
3194
|
+
}
|
|
3169
3195
|
async function onCardClick(e) {
|
|
3170
3196
|
const btn = e.target.closest('[data-act]');
|
|
3171
3197
|
if (!btn) return;
|
|
@@ -3182,7 +3208,7 @@ async function onCardClick(e) {
|
|
|
3182
3208
|
if ([...sel.options].some((o) => o.value === a.provider && !o.hidden)) sel.value = a.provider;
|
|
3183
3209
|
return deviceLogin();
|
|
3184
3210
|
}
|
|
3185
|
-
if (act === 'quota') { loadQuotas([id]); return; }
|
|
3211
|
+
if (act === 'quota') { loadQuotas([id], { live: true }); return; }
|
|
3186
3212
|
if (act === 'claim') return openClaim(id);
|
|
3187
3213
|
if (act === 'switch') {
|
|
3188
3214
|
const a = state.accounts.find((x) => x.id === id);
|
|
@@ -4391,6 +4417,7 @@ for (const id of ['btn-import', 'btn-import-dash']) { $(id).innerHTML = I.upload
|
|
|
4391
4417
|
for (const id of ['btn-export', 'btn-export-dash']) $(id).innerHTML = I.download + T('导出');
|
|
4392
4418
|
$('btn-checkin-all').onclick = () => checkinAll($('btn-checkin-all'));
|
|
4393
4419
|
$('btn-checkin').onclick = () => checkinAll($('btn-checkin'), state.view);
|
|
4420
|
+
$('wt-act').onclick = () => claimWbActivities($('wt-act'));
|
|
4394
4421
|
$('btn-add-dash').onclick = () => openAdd('');
|
|
4395
4422
|
$('btn-add').onclick = () => openAdd(state.view);
|
|
4396
4423
|
$('btn-export-dash').onclick = () => { $('ex-provider').value = ''; refreshExportNote(); openModal('m-export'); };
|