dsh-go-workbuddy 1.0.1 → 1.0.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/lib/index.js +26 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -277,25 +277,36 @@ async function setAutoEnabled(on) {
|
|
|
277
277
|
} catch {}
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
-
// 自动签到:引擎在线时每 30
|
|
281
|
-
|
|
280
|
+
// 自动签到:引擎在线时每 30 分钟检查一次,遍历本区域所有账号逐个签到(全账号)。
|
|
281
|
+
// 去重 key = 日期 + 账号,互不影响;服务端也按天去重,重载后重复检查不会重复领取。
|
|
282
|
+
const autoCheckinDays = new Set()
|
|
282
283
|
async function autoCheckin() {
|
|
283
284
|
if (!(await autoEnabled())) return
|
|
284
285
|
const d = new Date()
|
|
285
|
-
const
|
|
286
|
-
|
|
286
|
+
const dayKey = `${d.getFullYear()}-${d.getMonth() + 1}-${d.getDate()}`
|
|
287
|
+
// 拉本区域所有账号;拿不到列表时退回只签当前账号
|
|
288
|
+
let accounts = []
|
|
287
289
|
try {
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
autoCheckinDay = key
|
|
291
|
-
return
|
|
292
|
-
}
|
|
293
|
-
const answer = await api(`/api/checkin?region=${region}${accountQuery()}`, { method: 'POST', body: '{}' })
|
|
294
|
-
if (answer?.claim !== undefined || before?.todayCheckedIn === true) {
|
|
295
|
-
autoCheckinDay = key
|
|
296
|
-
await pushStrip()
|
|
297
|
-
}
|
|
290
|
+
const snap = await api(`/api/accounts?region=${region}`)
|
|
291
|
+
accounts = Array.isArray(snap?.accounts) ? snap.accounts : []
|
|
298
292
|
} catch {}
|
|
293
|
+
if (accounts.length === 0 && accountId !== '') accounts = [{ id: accountId }]
|
|
294
|
+
for (const acc of accounts) {
|
|
295
|
+
const aid = String(acc?.id ?? '')
|
|
296
|
+
if (aid === '') continue
|
|
297
|
+
const key = `${region}-${dayKey}-${aid}`
|
|
298
|
+
if (autoCheckinDays.has(key)) continue
|
|
299
|
+
try {
|
|
300
|
+
const q = `&account=${encodeURIComponent(aid)}`
|
|
301
|
+
const before = await api(`/api/checkin?region=${region}${q}`)
|
|
302
|
+
if (before?.todayCheckedIn === true) { autoCheckinDays.add(key); continue }
|
|
303
|
+
const answer = await api(`/api/checkin?region=${region}${q}`, { method: 'POST', body: '{}' })
|
|
304
|
+
if (answer?.claim !== undefined || before?.todayCheckedIn === true) {
|
|
305
|
+
autoCheckinDays.add(key)
|
|
306
|
+
await pushStrip()
|
|
307
|
+
}
|
|
308
|
+
} catch {}
|
|
309
|
+
}
|
|
299
310
|
}
|
|
300
311
|
|
|
301
312
|
function noteOf(error, zh) {
|
|
@@ -327,6 +338,7 @@ async function buildPatch(zh) {
|
|
|
327
338
|
totalText: credits === null ? '—' : fmt(total),
|
|
328
339
|
totalTone: credits === null ? 'warn' : total <= 0 ? 'bad' : 'good',
|
|
329
340
|
totalCaption: credits === null ? (zh ? '还没读到' : 'not read') : zh ? `共 ${packages.length} 个积分包` : `${packages.length} packages`,
|
|
341
|
+
regionText: region === 'cn' ? (zh ? '国内版' : 'CN') : (zh ? '国际版' : 'Global'),
|
|
330
342
|
accountText: sel === undefined ? '—' : clip(String(sel.accountName || sel.id || '—'), 18),
|
|
331
343
|
checkinText: checkin === null ? '—' : checkin.todayCheckedIn === true ? (zh ? '已签' : 'done') : (zh ? '未签' : 'pending'),
|
|
332
344
|
streakText: checkin === null ? '—' : `${Number(checkin.streakDays ?? 0)} 天`,
|