dsh-go-workbuddy 1.1.1 → 1.1.2

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/cordis.patch.yml CHANGED
@@ -4,5 +4,5 @@
4
4
  - insert:
5
5
  - id: dsh-connect-workbuddy
6
6
  name: dsh-connect-workbuddy
7
- - id: dsh-go-workbuddy
8
- name: dsh-go-workbuddy
7
+ - id: local-workbuddy
8
+ name: local-workbuddy
package/lib/index.js CHANGED
@@ -226,7 +226,7 @@ function pollLogin(loginId) {
226
226
  pendingLogins.delete(loginId)
227
227
  if (answer.error === undefined) {
228
228
  void pushStrip()
229
- try { dshGoRef?.refresh?.('main', {}) } catch {}
229
+ try { dshGoRef?.refresh?.('wb-main', {}) } catch {}
230
230
  }
231
231
  } catch {}
232
232
  }, 3000)
@@ -238,7 +238,7 @@ async function startLogin(zh, force = false) {
238
238
  try {
239
239
  const snapshot = await api(`/api/accounts?region=${region}`)
240
240
  const n = Array.isArray(snapshot?.accounts) ? snapshot.accounts.length : 0
241
- if (n > 0) return { open: 'panel:main', toast: clip(zh ? `已登录 ${n} 个账号` : `${n} accounts`, 40) }
241
+ if (n > 0) return { open: 'panel:wb-main', toast: clip(zh ? `已登录 ${n} 个账号` : `${n} accounts`, 40) }
242
242
  } catch {}
243
243
  }
244
244
  try {
@@ -259,12 +259,12 @@ async function doCheckin(zh) {
259
259
  try {
260
260
  const before = await api(`/api/checkin?region=${region}${accountQuery()}`)
261
261
  if (before?.todayCheckedIn === true) {
262
- return { refresh: 'main', toast: clip(zh ? `今天已经签过了,连续 ${Number(before.streakDays ?? 0)} 天` : 'Already checked in today', 40) }
262
+ return { refresh: 'wb-main', toast: clip(zh ? `今天已经签过了,连续 ${Number(before.streakDays ?? 0)} 天` : 'Already checked in today', 40) }
263
263
  }
264
264
  const answer = await api(`/api/checkin?region=${region}${accountQuery()}`, { method: 'POST', body: '{}' })
265
265
  const credit = Number(answer?.claim?.credit ?? 0)
266
266
  await pushStrip()
267
- return { refresh: 'main', toast: clip(zh ? `签到成功,+${fmt(credit)} 积分` : `Checked in +${fmt(credit)}`, 40) }
267
+ return { refresh: 'wb-main', toast: clip(zh ? `签到成功,+${fmt(credit)} 积分` : `Checked in +${fmt(credit)}`, 40) }
268
268
  } catch (error) {
269
269
  if (error?.code === 'not_logged_in') return { toast: clip(zh ? '还没登录 WorkBuddy' : 'Not signed in', 40) }
270
270
  return { toast: clip(zh ? `签到失败:${error?.code ?? '网络'}` : 'Check-in failed', 40) }
@@ -383,7 +383,7 @@ async function buildPatch(zh) {
383
383
  }
384
384
 
385
385
  function mainPanel(ctx) {
386
- ctx.dshGo.panel('main', {
386
+ ctx.dshGo.panel('wb-main', {
387
387
  view: (scope, caps) => {
388
388
  const zh = isZh(caps)
389
389
  return {
@@ -438,7 +438,7 @@ function mainPanel(ctx) {
438
438
  const zh = isZh(event)
439
439
  await pushStrip()
440
440
  try { return { patch: await buildPatch(zh), toast: clip(zh ? '已刷新' : 'Refreshed', 40) } }
441
- catch { return { refresh: 'main' } }
441
+ catch { return { refresh: 'wb-main' } }
442
442
  },
443
443
  checkin: (scope, event) => doCheckin(isZh(event)),
444
444
  autoToggle: async (scope, event) => {
@@ -446,7 +446,7 @@ function mainPanel(ctx) {
446
446
  const raw = event?.value?.value
447
447
  const on = Array.isArray(raw) ? raw.includes('on') : raw === 'on'
448
448
  await setAutoEnabled(on)
449
- return { refresh: 'main', toast: clip(zh ? (on ? '已开启自动签到' : '已关闭自动签到') : (on ? 'Auto check-in on' : 'Auto check-in off'), 40) }
449
+ return { refresh: 'wb-main', toast: clip(zh ? (on ? '已开启自动签到' : '已关闭自动签到') : (on ? 'Auto check-in on' : 'Auto check-in off'), 40) }
450
450
  },
451
451
  'switch-account': async (scope, event) => {
452
452
  const zh = isZh(event)
@@ -458,7 +458,7 @@ function mainPanel(ctx) {
458
458
  try {
459
459
  return { patch: await buildPatch(zh), toast: clip(zh ? '已切换账号' : 'Switched', 40) }
460
460
  } catch {
461
- return { refresh: 'main', toast: clip(zh ? '切换中…' : 'Switching…', 40) }
461
+ return { refresh: 'wb-main', toast: clip(zh ? '切换中…' : 'Switching…', 40) }
462
462
  }
463
463
  },
464
464
  logout: async (scope, event) => {
@@ -497,7 +497,7 @@ function mainPanel(ctx) {
497
497
  saveAccount('')
498
498
  try {
499
499
  return { patch: await buildPatch(zh), toast: clip(zh ? `已切到${region === 'cn' ? '国内版' : '国际版'}` : `Switched to ${region}`, 40) }
500
- } catch { return { refresh: 'main' } }
500
+ } catch { return { refresh: 'wb-main' } }
501
501
  },
502
502
  },
503
503
  })
@@ -511,7 +511,7 @@ export function apply(ctx) {
511
511
  ctx.dshGo.on('login', (scope, event) => startLogin(isZh(event)))
512
512
 
513
513
 
514
- ctx.dshGo.strip('state', (scope, emit, caps) => {
514
+ ctx.dshGo.strip('wb-state', (scope, emit, caps) => {
515
515
  stripGen += 1
516
516
  stripEmit = typeof emit === 'function' ? emit : null
517
517
  stripLocale = String(caps?.locale ?? 'zh')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-go-workbuddy",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "type": "module",
5
5
  "main": "lib/index.js",
6
6
  "dsh": {
@@ -34,14 +34,14 @@
34
34
  ],
35
35
  "composer.strip": [
36
36
  {
37
- "id": "state",
37
+ "id": "wb-state",
38
38
  "icon": "coin",
39
- "panel": "main"
39
+ "panel": "wb-main"
40
40
  }
41
41
  ],
42
42
  "panels": [
43
43
  {
44
- "id": "main",
44
+ "id": "wb-main",
45
45
  "title": {
46
46
  "zh": "WorkBuddy 积分",
47
47
  "en": "WB credits"