dsh-notify-tray 0.1.7 → 0.1.8

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/client.js CHANGED
@@ -42,15 +42,14 @@ window.__ModuleLoader__.load({
42
42
  return true
43
43
  }
44
44
 
45
- // slots / locale / configForms carry the settings page; the poller only needs the first two.
45
+ // Settings mount independently once the layout and host namespace are ready.
46
46
  var inject = ['uiWorkspace', 'sessions', 'slots', 'locale', 'configForms']
47
47
 
48
48
  // ------------------------------------------------------------------------
49
- // Settings page: the plugin's own page inside DSH's Plugins screen, in the
50
- // same frame the official "子智能体 / Agent 循环" pages use — a SettingsForm
49
+ // Settings page: a sidebar entry opens a main panel containing a SettingsForm
51
50
  // over the `notify-tray` settings namespace (the `.volatile()` fields of
52
51
  // lib/index.js Config, served by @deepseek-ai/dsh-settings), grouped into
53
- // sections with toggles, segmented choices and number fields, one Save.
52
+ // sections with toggles, segmented choices and number fields, saved automatically.
54
53
  // Plain React.createElement, so no build step is needed.
55
54
  // ------------------------------------------------------------------------
56
55
  function mountSettingsPage(ctx, require) {
@@ -62,8 +61,8 @@ window.__ModuleLoader__.load({
62
61
  const NS = 'notify-tray'
63
62
  /** Dictionary namespace owned by this page. */
64
63
  const LOCALE_NS = 'notify-tray.settings'
65
- /** The package page (`plugins.bundle.config` is keyed by package name). */
66
- const PACKAGE_KEY = 'dsh-notify-tray'
64
+ /** The sidebar id and main slot key must match for layout navigation. */
65
+ const PANEL_ID = 'notify-tray'
67
66
  const CATALOG_ROUTE = 'notify-tray/catalog'
68
67
  const REFRESH_ROUTE = 'notify-tray/refresh'
69
68
  const TRAY_ROUTE = 'notify-tray/tray'
@@ -106,6 +105,33 @@ window.__ModuleLoader__.load({
106
105
  }
107
106
 
108
107
  const zh = {
108
+ title: '小鲸鱼通知站',
109
+ autoSave: '自动保存已开启',
110
+ saved: '设置已保存',
111
+ pendingSave: '等待保存…',
112
+ fixSettings: '请检查输入后自动保存',
113
+ retrySave: '重试保存',
114
+ updateTitle: '版本更新',
115
+ updateHint: '打开此页自动检查,发现兼容的正式版后可一键更新。',
116
+ checkUpdate: '检查更新',
117
+ installUpdate: '立即更新',
118
+ update_idle: '准备检查更新',
119
+ update_checking: '正在检查新版本…',
120
+ update_available: '发现可用的新版本',
121
+ update_current: '已是最新正式版',
122
+ update_blocked: '有新版本,但暂无适合当前 DSH 的正式版',
123
+ update_unavailable: '当前 DSH 未提供可用的插件更新权限或接口。',
124
+ update_updating: '正在更新,请稍候…',
125
+ update_updated: '更新已完成',
126
+ update_restart: '更新已安装,重启 DSH 后生效',
127
+ update_error: '检查或更新失败,可重新检查后再试',
128
+ update_unknown: '更新结果尚未确认,请到插件管理页查看,避免重复操作。',
129
+ update_restored: '更新失败,DSH 已恢复旧版本;如提示需要重启,请重启 DSH。',
130
+ update_broken: '更新与恢复均未完成,请到插件管理页处理。',
131
+ updateSaveFirst: '设置尚未保存,请先检查输入或重试保存。',
132
+ installedVersion: '当前版本',
133
+ newVersion: '新版本',
134
+
109
135
  summary: '任务做完或需要你时提醒你,状态栏里看进度和花费。',
110
136
  summary_win32: '任务做完或需要你时弹通知,顺便算算今天花了多少。Windows 没有状态栏,小鲸鱼只用通知来找你。',
111
137
  sectionNotify: '提醒我',
@@ -123,8 +149,8 @@ window.__ModuleLoader__.load({
123
149
 
124
150
  sectionTray: '状态栏小鲸鱼',
125
151
  tray: '显示小鲸鱼',
126
- trayHint: '保存后立即生效。',
127
- trayHint_linux: 'UOS / Deepin / 麒麟 / KDE 自带托盘;GNOME 要装 AppIndicator 扩展。保存后立即生效。',
152
+ trayHint: '更改后自动保存并生效。',
153
+ trayHint_linux: 'UOS / Deepin / 麒麟 / KDE 自带托盘;GNOME 要装 AppIndicator 扩展。更改后自动保存并生效。',
128
154
  trayHiddenNote: '状态栏图标已从它的菜单里隐藏。',
129
155
  trayShowAgain: '重新显示状态栏图标',
130
156
  trayShowing: '正在显示…',
@@ -254,12 +280,38 @@ window.__ModuleLoader__.load({
254
280
  reset: '恢复默认',
255
281
  readOnly: '本部署的设置为只读。',
256
282
  unavailable: '小鲸鱼还没加载好,暂时不能配置。',
257
- save: '保存',
258
283
  saving: '保存中…',
259
- saveFailed: '没保存成功,值还留着,改改再试。',
284
+ saveFailed: '设置未保存,修改已保留,请重试。',
260
285
  invalidNumber: '请填数字;留空表示用默认值。',
261
286
  }
262
287
  const en = {
288
+ title: 'Whale Notify Station',
289
+ autoSave: 'Autosave is on',
290
+ saved: 'Settings saved',
291
+ pendingSave: 'Waiting to save…',
292
+ fixSettings: 'Check your input to save automatically',
293
+ retrySave: 'Retry saving',
294
+ updateTitle: 'Updates',
295
+ updateHint: 'Checks when you open this page. Install a compatible stable release with one click.',
296
+ checkUpdate: 'Check for updates',
297
+ installUpdate: 'Update now',
298
+ update_idle: 'Ready to check for updates',
299
+ update_checking: 'Checking for updates…',
300
+ update_available: 'A new version is available',
301
+ update_current: 'You have the latest stable version',
302
+ update_blocked: 'Newer versions exist, but no compatible stable release is available',
303
+ update_unavailable: 'Plugin update access or APIs are unavailable in this DSH instance.',
304
+ update_updating: 'Updating, please wait…',
305
+ update_updated: 'Update complete',
306
+ update_restart: 'Update installed. Restart DSH to use it.',
307
+ update_error: 'Check or update failed. Check again to retry.',
308
+ update_unknown: 'The update outcome is unknown. Check plugin management before trying again.',
309
+ update_restored: 'Update failed; DSH restored the previous version. Restart DSH if requested.',
310
+ update_broken: 'Update and recovery did not complete. Open plugin management to resolve this.',
311
+ updateSaveFirst: 'Settings are not saved. Check your input or retry saving first.',
312
+ installedVersion: 'Installed',
313
+ newVersion: 'New version',
314
+
263
315
  summary: 'Notifies you when a task finishes or needs you; the status bar shows progress and spend.',
264
316
  summary_win32: 'Notifies you when a task finishes or needs you, and keeps count of today\'s spend. Windows has no status bar, so the whale reaches you through notifications only.',
265
317
  sectionNotify: 'Notify me',
@@ -277,8 +329,8 @@ window.__ModuleLoader__.load({
277
329
 
278
330
  sectionTray: 'Status-bar whale',
279
331
  tray: 'Show the whale',
280
- trayHint: 'Takes effect as soon as you save.',
281
- trayHint_linux: 'Built into UOS / Deepin / Kylin / KDE; GNOME needs the AppIndicator extension. Takes effect as soon as you save.',
332
+ trayHint: 'Changes are saved and applied automatically.',
333
+ trayHint_linux: 'Built into UOS / Deepin / Kylin / KDE; GNOME needs the AppIndicator extension. Changes are saved and applied automatically.',
282
334
  trayHiddenNote: 'The status-bar icon was hidden from its own menu.',
283
335
  trayShowAgain: 'Show the status-bar icon again',
284
336
  trayShowing: 'Showing…',
@@ -408,7 +460,6 @@ window.__ModuleLoader__.load({
408
460
  reset: 'Reset to default',
409
461
  readOnly: 'This deployment stores settings read-only.',
410
462
  unavailable: 'The whale is not loaded yet, so it cannot be configured right now.',
411
- save: 'Save',
412
463
  saving: 'Saving…',
413
464
  saveFailed: 'The deployment did not accept these values; they were left for you to correct.',
414
465
  invalidNumber: 'Enter a number, or leave blank to use the default.',
@@ -444,6 +495,8 @@ window.__ModuleLoader__.load({
444
495
  /** Plan fields a preset fills in; switching provider clears them. */
445
496
  const PRESET_FIELDS = ['planId', 'planName', 'planPrice', 'planCurrency', 'planPeriod', 'planQuota', 'planQuotaUrl']
446
497
 
498
+ // The form model clears staged edits when a save resolves. Keep edits made
499
+ // during that request and replay them before submitting the next batch.
447
500
  class Controller {
448
501
  constructor(scope) {
449
502
  this.form = new ui.SettingsFormModel(scope, [
@@ -452,21 +505,184 @@ window.__ModuleLoader__.load({
452
505
  ...NUMBERS.map(f => ui.settingsNumberField(f)),
453
506
  ...TEXTS.map(textField),
454
507
  ])
455
- this.store = this.form.bind(() => this.projection())
508
+ this.actions = this.form.actions()
509
+ this.listeners = new Set()
510
+ this.pending = new Map()
511
+ this.notice = null
512
+ this.noticeSeq = 0
513
+ this.disposed = false
514
+ this.inFlight = false
515
+ this.formStore = this.form.bind(() => this.projection())
516
+ this.unsubscribe = this.formStore.subscribe?.(() => this.publish())
517
+ this.store = {
518
+ getSnapshot: () => this.snapshot,
519
+ subscribe: listener => { this.listeners.add(listener); return () => this.listeners.delete(listener) },
520
+ }
521
+ this.publish()
456
522
  }
457
523
 
458
524
  projection() {
459
525
  const fields = {}
460
526
  for (const f of FIELDS) fields[f] = this.form.field(f)
461
- return { ...this.form.shell(), fields }
527
+ return { ...this.form.shell(), fields, notice: this.notice }
528
+ }
529
+
530
+ publish() {
531
+ if (this.disposed) return
532
+ this.snapshot = this.projection()
533
+ for (const listener of this.listeners) listener()
534
+ }
535
+
536
+ change(field, text, reset = false) {
537
+ if (this.disposed || !this.form.shell().writable) return
538
+ this.notice = null
539
+ if (this.inFlight) this.pending.set(field, { text, reset })
540
+ if (reset) this.actions.resetField(field)
541
+ else this.actions.edit(field, text)
542
+ this.publish()
543
+ this.schedule()
544
+ }
545
+
546
+ schedule() {
547
+ clearTimeout(this.timer)
548
+ this.timer = setTimeout(() => { this.flush() }, 500)
549
+ }
550
+
551
+ async flush() {
552
+ clearTimeout(this.timer)
553
+ if (this.disposed) return false
554
+ // Used by refresh/update actions to wait for every pending setting.
555
+ if (this.inFlight) {
556
+ await this.saving
557
+ return this.flush()
558
+ }
559
+ const state = this.form.shell()
560
+ if (!state.available || !state.writable || state.invalid) return false
561
+ if (!state.dirty) return true
562
+ this.inFlight = true
563
+ this.notice = null
564
+ this.pending.clear()
565
+ this.saving = (async () => {
566
+ try {
567
+ // actions().save() returns void in DSH; save() is the awaitable method.
568
+ await this.form.save()
569
+ if (this.disposed) return false
570
+ const failed = this.form.shell().failed
571
+ const pending = [...this.pending]
572
+ this.pending.clear()
573
+ for (const [field, change] of pending) {
574
+ if (change.reset) this.actions.resetField(field)
575
+ else this.actions.edit(field, change.text)
576
+ }
577
+ const after = this.form.shell()
578
+ this.notice = failed ? { id: ++this.noticeSeq, kind: 'saveFailed' }
579
+ : !after.dirty ? { id: ++this.noticeSeq, kind: 'saved' } : null
580
+ // Do not loop on a rejection. An explicit retry or a new edit retries.
581
+ if (!failed && after.dirty && !after.invalid) this.schedule()
582
+ return !failed && !after.dirty
583
+ } catch (error) {
584
+ if (!this.disposed) this.notice = { id: ++this.noticeSeq, kind: 'saveFailed' }
585
+ return false
586
+ } finally {
587
+ this.inFlight = false
588
+ this.publish()
589
+ }
590
+ })()
591
+ return this.saving
462
592
  }
463
593
 
464
594
  inject() {
465
- return { hooks: { notifyTray: this.store }, ...this.form.actions() }
595
+ return {
596
+ hooks: { notifyTray: this.store },
597
+ edit: (field, text) => this.change(field, text),
598
+ resetField: field => this.change(field, '', true),
599
+ flush: () => this.flush(),
600
+ retrySave: () => this.flush(),
601
+ dismissNotice: id => { if (this.notice?.id === id) { this.notice = null; this.publish() } },
602
+ }
603
+ }
604
+
605
+ dispose() {
606
+ this.disposed = true
607
+ clearTimeout(this.timer)
608
+ this.unsubscribe?.()
609
+ this.listeners.clear()
610
+ this.form.dispose()
611
+ }
612
+ }
613
+ exports.__SettingsController = Controller
614
+
615
+ // All update decisions and package mutations belong to DSH's plugin manager.
616
+ // The browser never runs a shell or chooses an unverified registry version.
617
+ class UpdateController {
618
+ constructor(getManager, flush) {
619
+ this.getManager = getManager
620
+ this.flush = flush
621
+ this.listeners = new Set()
622
+ this.snapshot = { phase: 'idle' }
623
+ this.disposed = false
624
+ this.store = {
625
+ getSnapshot: () => this.snapshot,
626
+ subscribe: listener => { this.listeners.add(listener); return () => this.listeners.delete(listener) },
627
+ }
628
+ }
629
+
630
+ patch(change) {
631
+ if (this.disposed) return
632
+ this.snapshot = { ...this.snapshot, ...change }
633
+ for (const listener of this.listeners) listener()
634
+ }
635
+
636
+ async check() {
637
+ if (this.disposed || ['checking', 'updating', 'restart'].includes(this.snapshot.phase)) return
638
+ const manager = this.getManager()
639
+ if (!manager?.listVersions || !manager?.updateBundle) return this.patch({ phase: 'unavailable' })
640
+ this.patch({ phase: 'checking', candidate: undefined, error: undefined })
641
+ try {
642
+ const inventory = await manager.listBundles()
643
+ if (!inventory.ok) throw new Error(inventory.error?.message || 'Plugin inventory unavailable')
644
+ const pkg = inventory.value.find(pkg => pkg.name === 'dsh-notify-tray')
645
+ if (!pkg) return this.patch({ phase: 'unavailable' })
646
+ this.patch({ installed: pkg.version })
647
+ if (!pkg.updatable) return this.patch({ phase: /^(?:link:|file:|git|https?:|\/)/u.test(pkg.source || '') ? 'local' : 'unavailable' })
648
+ const answer = await manager.listVersions('dsh-notify-tray', {})
649
+ if (!answer.ok) throw new Error(answer.error?.message || 'Version check failed')
650
+ const list = answer.value
651
+ if (list.status !== 'listed') throw new Error(list.reason || 'Version check refused')
652
+ const candidate = list.versions.find(v => v.bundle && !v.incompatible && !v.deprecated && !v.prerelease)
653
+ this.patch({ phase: candidate ? 'available' : list.versions.length ? 'blocked' : 'current', installed: list.installed, candidate: candidate?.version, registry: list.registry })
654
+ } catch (error) {
655
+ this.patch({ phase: 'error', error: String(error.message || error) })
656
+ }
657
+ }
658
+
659
+ async update() {
660
+ if (this.disposed || this.snapshot.phase !== 'available') return
661
+ const { candidate, registry } = this.snapshot
662
+ this.patch({ phase: 'updating', error: undefined })
663
+ try {
664
+ if (!await this.flush()) return this.patch({ phase: 'available', error: 'updateSaveFirst' })
665
+ if (this.disposed) return
666
+ const manager = this.getManager()
667
+ const answer = await manager.updateBundle('dsh-notify-tray', candidate, { registry })
668
+ if (!answer.ok) return this.patch({ phase: 'unknown', error: answer.error?.message })
669
+ const result = answer.value
670
+ const application = result.result?.application
671
+ if (application === 'applied' || application === 'restart-required') {
672
+ this.patch({ phase: application === 'restart-required' ? 'restart' : 'updated', installed: candidate, candidate: undefined })
673
+ } else {
674
+ const restored = result.restore?.application
675
+ this.patch({ phase: restored === 'applied' || restored === 'restart-required' ? 'restored' : restored ? 'broken' : 'error', error: result.result?.error?.diagnostic || result.result?.error?.code || application })
676
+ }
677
+ } catch (error) {
678
+ // A disconnected client cannot assume an update failed; the host may still finish it.
679
+ this.patch({ phase: 'unknown', error: String(error.message || error) })
680
+ }
466
681
  }
467
682
 
468
- dispose() { this.form.dispose() }
683
+ dispose() { this.disposed = true; this.listeners.clear() }
469
684
  }
685
+ exports.__UpdateController = UpdateController
470
686
 
471
687
  // ---- live data: catalog once, host state while the page is open ------------------
472
688
  const live = { catalog: undefined, state: undefined, listeners: new Set() }
@@ -513,7 +729,7 @@ window.__ModuleLoader__.load({
513
729
  const S = {
514
730
  section: { marginTop: 28 },
515
731
  sectionTitle: { fontSize: 15, fontWeight: 600, margin: '0 0 4px' },
516
- row: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: 16, padding: '10px 0', borderBottom: '1px solid color-mix(in srgb, currentColor 10%, transparent)' },
732
+ row: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: 16, padding: '10px 0', borderBottom: '1px solid color-mix(in srgb, currentColor 10%, transparent)' },
517
733
  rowText: { minWidth: 0 },
518
734
  label: { fontSize: 14 },
519
735
  hint: { margin: '2px 0 0', opacity: 0.6, fontSize: 12 },
@@ -523,7 +739,7 @@ window.__ModuleLoader__.load({
523
739
  grid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '8px 16px', marginTop: 12 },
524
740
  card: { border: '1px solid var(--dsw-alias-border-l3, color-mix(in srgb, currentColor 12%, transparent))', borderRadius: 'var(--dsw-radius-lg, 10px)', padding: '12px 14px', margin: '12px 0', fontSize: 13, lineHeight: '20px' },
525
741
  cardTitle: { fontSize: 12, fontWeight: 500, opacity: 0.65, marginBottom: 4 },
526
- mono: { fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)', fontSize: 13 },
742
+ mono: { overflowWrap: 'anywhere', fontFamily: 'var(--ds-font-family-code, ui-monospace, monospace)', fontSize: 13 },
527
743
  muted: { opacity: 0.65 },
528
744
  error: { color: 'var(--dsw-alias-state-error-primary, #d33)' },
529
745
  select: { boxSizing: 'border-box', border: '.5px solid var(--dsw-alias-border-l4, color-mix(in srgb, currentColor 25%, transparent))', borderRadius: 'var(--dsw-radius-md, 6px)', width: 180, maxWidth: '100%', height: 32, font: 'inherit', background: 'var(--dsw-alias-bg-layer-1, transparent)', color: 'var(--dsw-alias-label-primary, inherit)', padding: '0 10px', fontSize: 14, lineHeight: '22px', cursor: 'pointer' },
@@ -532,7 +748,7 @@ window.__ModuleLoader__.load({
532
748
  lines: { margin: '6px 0 0', paddingLeft: 18, fontSize: 12, opacity: 0.75 },
533
749
  checks: { display: 'flex', flexWrap: 'wrap', gap: '8px 18px', marginTop: 10 },
534
750
  check: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 13 },
535
- spendCard: { display: 'flex', alignItems: 'center', gap: 16, border: '1px solid var(--dsw-alias-border-l3, color-mix(in srgb, currentColor 12%, transparent))', borderRadius: 'var(--dsw-radius-lg, 10px)', padding: '12px 14px', margin: '4px 0' },
751
+ spendCard: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: 16, border: '1px solid var(--dsw-alias-border-l3, color-mix(in srgb, currentColor 12%, transparent))', borderRadius: 'var(--dsw-radius-lg, 10px)', padding: '12px 14px', margin: '4px 0' },
536
752
  spendValue: { fontSize: 22, fontWeight: 600, lineHeight: '28px' },
537
753
  keyRow: { display: 'flex', alignItems: 'flex-start', gap: 8, flexWrap: 'wrap' },
538
754
  disclosure: { display: 'flex', alignItems: 'center', gap: 6, width: '100%', font: 'inherit', fontSize: 13, color: 'inherit', background: 'none', border: 0, padding: '10px 0', cursor: 'pointer', textAlign: 'left' },
@@ -624,9 +840,9 @@ window.__ModuleLoader__.load({
624
840
  }, options.map(([value, label]) => h('option', { key: value, value }, label)))
625
841
  }
626
842
 
627
- function Section({ title, children }) {
628
- return h('section', { style: S.section },
629
- h('h4', { style: S.sectionTitle }, title),
843
+ function Section({ title, icon = 'settings', children }) {
844
+ return h('section', { className: 'dnt-card' },
845
+ h('h2', { className: 'dnt-card-title' }, h('span', { className: 'dnt-section-icon' }, h(Icon, { name: icon })), title),
630
846
  children)
631
847
  }
632
848
 
@@ -737,7 +953,7 @@ window.__ModuleLoader__.load({
737
953
  const [busy, setBusy] = React.useState(false)
738
954
  const refresh = () => {
739
955
  setBusy(true)
740
- fetchJson(REFRESH_ROUTE, { method: 'POST' }).then(() => loadState()).catch(() => {}).then(() => setBusy(false))
956
+ common.flush().then(saved => saved ? fetchJson(REFRESH_ROUTE, { method: 'POST' }).then(() => loadState()) : undefined).catch(() => {}).then(() => setBusy(false))
741
957
  }
742
958
  const choosePlan = id => {
743
959
  edit('planId', id)
@@ -853,36 +1069,139 @@ window.__ModuleLoader__.load({
853
1069
  h(TextField, { name: 'planQuotaUrl', field: f.planQuotaUrl, placeholder: quotaSpec?.url ?? 'https://…', ...common }))) : null))
854
1070
  }
855
1071
 
1072
+ const PAGE_CSS = `
1073
+ .dnt-page { --dnt-accent: #5085b2; --dnt-border: color-mix(in srgb, currentColor 11%, transparent); height: 100%; min-height: 0; overflow-y: auto; }
1074
+ .dnt-content { max-width: 1040px; margin: auto; padding: 30px 26px 48px; }
1075
+ .dnt-hero { display: flex; align-items: center; gap: 18px; padding: 22px; margin-bottom: 24px; border-radius: 20px; background: linear-gradient(115deg, color-mix(in srgb, var(--dnt-accent) 12%, transparent), color-mix(in srgb, var(--dnt-accent) 2%, transparent)); border: 1px solid var(--dnt-border); }
1076
+ .dnt-mascot { box-sizing: border-box; width: 80px; height: 80px; padding: 8px; flex: none; border-radius: 22px; border: 1px solid var(--dnt-border); background: var(--dsw-alias-bg-layer-1, #fff); box-shadow: 0 3px 10px #00000006; }
1077
+ .dnt-mascot-window { width: 100%; height: 100%; overflow: hidden; border-radius: 15px; background: #050505; }
1078
+ .dnt-mascot-sprite { display: block; width: 100%; height: 100%; object-fit: contain; transform-origin: center bottom; animation: dnt-peek 7s cubic-bezier(.22, 1, .36, 1) infinite; }
1079
+ .dnt-heading { margin: 0; font-size: 24px; font-weight: 650; letter-spacing: -.4px; }
1080
+ .dnt-subtitle { margin: 7px 0 10px; opacity: .62; font-size: 13px; line-height: 1.6; }
1081
+ .dnt-status { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; opacity: .8; }
1082
+ .dnt-status[data-busy=true] svg { animation: dnt-spin 1.4s linear infinite; }
1083
+ .dnt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 18px; margin-bottom: 18px; }
1084
+ .dnt-card { min-width: 0; border: 1px solid var(--dnt-border); border-radius: 16px; padding: 20px; margin-bottom: 18px; background: var(--dsw-alias-bg-layer-1, transparent); transition: border-color .2s, box-shadow .2s; }
1085
+ .dnt-grid > .dnt-card { margin-bottom: 0; }
1086
+ .dnt-card:hover { border-color: color-mix(in srgb, var(--dnt-accent) 36%, transparent); box-shadow: 0 4px 18px #00000004; }
1087
+ .dnt-card-title { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; margin: 0 0 16px; }
1088
+ .dnt-section-icon { display: inline-flex; color: var(--dnt-accent); padding: 7px; border-radius: 10px; background: color-mix(in srgb, var(--dnt-accent) 9%, transparent); }
1089
+ .dnt-page button { transition: background .15s, opacity .15s; }
1090
+ .dnt-page button:hover:not(:disabled) { filter: brightness(.94); }
1091
+ .dnt-page button:focus-visible, .dnt-page select:focus-visible { outline: 2px solid var(--dnt-accent); outline-offset: 3px; }
1092
+ .dnt-update-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
1093
+ .dnt-update-actions { display: flex; flex-wrap: wrap; gap: 8px; }
1094
+ .dnt-update-version { display: inline-flex; gap: 7px; font-size: 12px; font-weight: 500; margin-bottom: 8px; }
1095
+ .dnt-update-version span { padding: 3px 8px; border-radius: 6px; background: color-mix(in srgb, var(--dnt-accent) 9%, transparent); }
1096
+ .dnt-note { font-size: 12px; line-height: 1.6; opacity: .7; margin: 0; overflow-wrap: anywhere; }
1097
+ .dnt-alert { border-radius: 10px; padding: 10px 14px; margin-bottom: 16px; background: color-mix(in srgb, #d68036 10%, transparent); font-size: 13px; }
1098
+ @keyframes dnt-peek {
1099
+ 0%, 8% { transform: translateY(32%); }
1100
+ 13% { transform: translateY(0); }
1101
+ 18% { transform: translateY(2%); }
1102
+ 24%, 48% { transform: translateY(0); }
1103
+ 76%, 100% { transform: translateY(32%); }
1104
+ }
1105
+ @keyframes dnt-spin { to { transform: rotate(360deg); } }
1106
+ @media (max-width: 1000px) { .dnt-grid { grid-template-columns: 1fr; } }
1107
+ @media (max-width: 600px) { .dnt-content { padding: 16px 12px 28px; } .dnt-hero { padding: 16px; gap: 10px; } .dnt-heading { font-size: 20px; } .dnt-mascot { width: 60px; height: 60px; padding: 6px; border-radius: 18px; } .dnt-mascot-window { border-radius: 11px; } .dnt-card { padding: 16px; } }
1108
+ @media (prefers-reduced-motion: reduce) { .dnt-page *, .dnt-page *::before { animation: none !important; transition: none !important; } }
1109
+ `
1110
+
1111
+ function Icon({ name, size = 16 }) {
1112
+ const paths = {
1113
+ bell: 'M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9M10 21h4',
1114
+ chart: 'M4 3v17h17M8 15v-4m5 4V7m5 8V4',
1115
+ settings: 'M4 6h16M4 12h16M4 18h16M8 3v6m8 0v6m-6 0v6',
1116
+ update: 'M20 7v5h-5M4 17v-5h5M6 7a7 7 0 0 1 12-1l2 3M4 15l2 3a7 7 0 0 0 12-1',
1117
+ check: 'm5 12 4 4L19 6',
1118
+ }
1119
+ return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.7, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true }, h('path', { d: paths[name] || paths.settings }))
1120
+ }
1121
+
856
1122
  function Page(props) {
857
- if (props.view === 'summary') return platformT(props.t, currentPlatform())('summary')
858
- return h(FullPage, props)
1123
+ const liveData = useLive()
1124
+ const state = props.useNotifyTray(snapshot => snapshot)
1125
+ const busy = state.saving || state.dirty
1126
+ const status = !state.available ? 'unavailable' : !state.writable ? 'readOnly' : state.notice?.kind === 'saveFailed' ? 'saveFailed' : state.invalid ? 'fixSettings' : state.saving ? 'saving' : state.dirty ? 'pendingSave' : 'autoSave'
1127
+ return h('div', { className: 'dnt-page' },
1128
+ h('style', null, PAGE_CSS),
1129
+ h('div', { className: 'dnt-content' },
1130
+ h('header', { className: 'dnt-hero' },
1131
+ h(PeekingMascot),
1132
+ h('div', null,
1133
+ h('h1', { className: 'dnt-heading' }, props.t('title')),
1134
+ h('p', { className: 'dnt-subtitle' }, platformT(props.t, currentPlatform())('summary')),
1135
+ h('span', { className: 'dnt-status', role: 'status', 'data-busy': busy }, h(Icon, { name: busy ? 'update' : 'check', size: 13 }), props.t(status)))),
1136
+ h(FullPage, { ...props, liveData }),
1137
+ h(UpdatePanel, props)))
1138
+ }
1139
+
1140
+ function PeekingMascot() {
1141
+ const [ready, setReady] = React.useState(false)
1142
+ return h('div', { className: 'dnt-mascot', 'aria-hidden': true },
1143
+ h('div', { className: 'dnt-mascot-window' },
1144
+ h('img', {
1145
+ className: 'dnt-mascot-sprite',
1146
+ src: 'notify-tray/mascot?v=peeking-2',
1147
+ alt: '',
1148
+ draggable: false,
1149
+ style: { animationPlayState: ready ? 'running' : 'paused' },
1150
+ onLoad: () => setReady(true),
1151
+ })))
1152
+ }
1153
+
1154
+ function UpdatePanel(props) {
1155
+ const t = props.t
1156
+ const state = props.useNotifyUpdate(snapshot => snapshot)
1157
+ React.useEffect(() => { props.checkUpdate() }, [])
1158
+ const busy = state.phase === 'checking' || state.phase === 'updating'
1159
+ return h(Section, { title: t('updateTitle'), icon: 'update' },
1160
+ h('div', { className: 'dnt-update-row' },
1161
+ h('div', { style: { flex: '1 1 240px', minWidth: 0 } },
1162
+ state.installed ? h('div', { className: 'dnt-update-version' },
1163
+ h('span', null, `${t('installedVersion')} ${state.installed}`),
1164
+ state.candidate ? h('span', null, `${t('newVersion')} ${state.candidate}`) : null) : null,
1165
+ state.phase !== 'local' ? h('p', { className: 'dnt-note', role: 'status' }, t(`update_${state.phase}`)) : null,
1166
+ state.error ? h('p', { className: 'dnt-note', style: S.error, role: 'alert' }, state.error === 'updateSaveFirst' ? t(state.error) : state.error) : null),
1167
+ h('div', { className: 'dnt-update-actions' },
1168
+ h('button', { type: 'button', style: S.button, disabled: busy || state.phase === 'restart', onClick: props.checkUpdate }, t('checkUpdate')),
1169
+ state.phase === 'available' ? h('button', { type: 'button', style: { ...S.button, background: 'var(--dnt-accent)', color: '#fff', borderColor: 'transparent' }, onClick: props.installUpdate }, t('installUpdate')) : null)),
1170
+ h('p', { className: 'dnt-note', style: { marginTop: 12 } }, t('updateHint')))
1171
+ }
1172
+
1173
+ function WhaleIcon({ size = 16 }) {
1174
+ return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', 'aria-hidden': true },
1175
+ h('path', { d: 'M3 12c0-3.3 2.7-6 6-6s6 2.7 6 6h2c0-2 1.5-3.5 4-4v5c0 4-4 7-9 7s-9-3-9-8Z M8.5 11a1 1 0 1 0-2 0 1 1 0 0 0 2 0Z', fill: 'currentColor', fillRule: 'evenodd' }),
1176
+ h('path', { d: 'M10 5V2m0 3 3-2', stroke: 'currentColor', strokeWidth: 1.5, strokeLinecap: 'round' }))
859
1177
  }
860
1178
 
861
1179
  function FullPage(props) {
862
1180
  const state = props.useNotifyTray(snapshot => snapshot)
863
- const liveData = useLive()
1181
+ const liveData = props.liveData
864
1182
  const platform = currentPlatform()
865
1183
  const features = (platform && FEATURES[platform]) || ALL_FEATURES
866
1184
  const t = platformT(props.t, platform)
867
1185
  const disabled = !state.writable
868
- const common = { t, disabled, edit: props.edit, resetField: props.resetField }
1186
+ const common = { t, disabled, edit: props.edit, resetField: props.resetField, flush: props.flush }
869
1187
  const f = state.fields
870
1188
  const toggle = name => h(ToggleRow, { key: name, name, field: f[name], ...common })
871
1189
  const titleStyle = f.titleStyle.text || 'text'
872
- return h(ui.SettingsForm, {
873
- labels: { unavailable: t('unavailable'), readOnly: t('readOnly'), saveFailed: t('saveFailed'), save: t('save'), saving: t('saving') },
874
- state,
875
- onSave: props.save,
876
- onDiscard: props.discard,
877
- },
878
- h(Section, { title: t('sectionNotify') },
1190
+ if (!state.available) return h('p', { role: 'status', className: 'dnt-alert' }, t('unavailable'))
1191
+ return h('div', null,
1192
+ !state.writable ? h('p', { role: 'status', className: 'dnt-alert' }, t('readOnly')) : null,
1193
+ state.notice?.kind === 'saveFailed' ? h('div', { role: 'alert', className: 'dnt-alert' }, t('saveFailed'), ' ',
1194
+ h('button', { type: 'button', style: S.button, disabled: state.saving || !state.writable || state.invalid, onClick: props.retrySave }, t('retrySave'))) : null,
1195
+ state.notice ? h(ui.Toast, { key: state.notice.id, text: t(state.notice.kind), tone: state.notice.kind === 'saved' ? 'success' : undefined, holdMs: 2200, onDone: () => { if (state.notice.kind === 'saved') props.dismissNotice(state.notice.id) } }) : null,
1196
+ h('div', { className: 'dnt-grid' },
1197
+ h(Section, { title: t('sectionNotify'), icon: 'bell' },
879
1198
  h(CheckRow, { label: 'notifyWhen', names: NOTIFY_FIELDS, f, ...common }),
880
1199
  toggle('sound')),
881
- features.tray ? h(Section, { title: t('sectionTray') },
1200
+ features.tray ? h(Section, { title: t('sectionTray'), icon: 'settings' },
882
1201
  toggle('tray'),
883
1202
  h(TrayStatus, { t, state: liveData.state }),
884
- features.menuBarTitle ? h(ChoiceRow, { name: 'titleStyle', field: f.titleStyle, hint: `titleStyleHint_${titleStyle}`, ...common, options: [['text', 'titleText'], ['count', 'titleCount'], ['icon', 'titleIcon']] }) : null) : null,
885
- h(Section, { title: t('sectionMoney') },
1203
+ features.menuBarTitle ? h(ChoiceRow, { name: 'titleStyle', field: f.titleStyle, hint: `titleStyleHint_${titleStyle}`, ...common, options: [['text', 'titleText'], ['count', 'titleCount'], ['icon', 'titleIcon']] }) : null) : null),
1204
+ h(Section, { title: t('sectionMoney'), icon: 'chart' },
886
1205
  h(SpendCard, { t, state: liveData.state }),
887
1206
  h(PlanSection, { t, f, common, state: liveData.state, catalog: liveData.catalog })),
888
1207
  h(AdvancedSection, { t, f, common, features, state: liveData.state, catalog: liveData.catalog }))
@@ -892,18 +1211,31 @@ window.__ModuleLoader__.load({
892
1211
  const t = ctx.locale.bind(LOCALE_NS)
893
1212
  ctx.effect(() => ctx.locale.register(LOCALE_NS, { zh: { ...zh, CNY: '¥ 人民币', USD: '$ 美元' }, en: { ...en, CNY: '¥ CNY', USD: '$ USD' } }), 'notify-tray: settings dictionaries')
894
1213
  const card = new Controller(ctx.configForms.get(NS))
1214
+ const updater = new UpdateController(() => ctx.get?.('remote.pluginManager') || ctx.remote?.pluginManager, () => card.flush())
1215
+ ctx.effect(() => () => updater.dispose(), 'notify-tray: updates')
895
1216
  ctx.effect(() => () => card.dispose(), 'notify-tray: settings form')
896
- // One door only: the package page itself (what "插件 → 小鲸鱼通知站" opens,
897
- // keyed by package name). The component row deliberately gets no
898
- // `plugins.row.config` entry, so there is no second, identical page
899
- // behind the row's "›".
900
- ctx.effect(() => ctx.configForms.whileServed([NS], () => ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
901
- name: 'plugins.bundle.config',
902
- key: PACKAGE_KEY,
903
- locale: LOCALE_NS,
904
- inject: () => card.inject(),
905
- }, Page))), 'notify-tray: settings on the package page')
906
- void t
1217
+ // DSH owns sidebar navigation and README rendering on the plugin page.
1218
+ // Register no plugin-detail config/actions: settings have one entrance.
1219
+ ctx.inject(['layout'], pageCtx => {
1220
+ pageCtx.effect(() => pageCtx.configForms.whileServed([NS], () => {
1221
+ const stopMain = pageCtx.slots.inject('main', () => pageCtx.slots.register({
1222
+ name: 'main',
1223
+ key: PANEL_ID,
1224
+ locale: LOCALE_NS,
1225
+ inject: () => {
1226
+ const face = card.inject()
1227
+ return { ...face, hooks: { ...face.hooks, notifyUpdate: updater.store }, checkUpdate: () => updater.check(), installUpdate: () => updater.update() }
1228
+ },
1229
+ }, Page))
1230
+ const stopSidebar = pageCtx.slots.inject('sidebar.panellist', () => pageCtx.slots.register({
1231
+ name: 'sidebar.panellist',
1232
+ id: PANEL_ID,
1233
+ order: 11,
1234
+ label: () => t('title'),
1235
+ }, WhaleIcon))
1236
+ return () => { stopSidebar(); stopMain() }
1237
+ }), 'notify-tray: sidebar settings')
1238
+ })
907
1239
  }
908
1240
 
909
1241
 
@@ -9,6 +9,7 @@
9
9
  * snapshot again.
10
10
  */
11
11
  import { createHash } from 'node:crypto'
12
+ import { readFileSync } from 'node:fs'
12
13
  import { publicCatalog } from '../catalog.js'
13
14
  import { spendOf, TITLES } from '../format.js'
14
15
  import { desktopHosted } from '../system.js'
@@ -19,6 +20,7 @@ const CATALOG_PATH = '/notify-tray/catalog'
19
20
  const REFRESH_PATH = '/notify-tray/refresh'
20
21
  const TRAY_PATH = '/notify-tray/tray'
21
22
  const RAISE_PATH = '/notify-tray/raise'
23
+ const MASCOT_PATH = '/notify-tray/mascot'
22
24
  /**
23
25
  * A clicked Windows toast can only launch `dsh://open` (or the web GUI), so no
24
26
  * session travels with it: a window that comes forward within this long after
@@ -56,6 +58,19 @@ export function setupRoutes(ctx, host) {
56
58
  res.setHeader('cache-control', 'no-store')
57
59
  res.end(JSON.stringify(body))
58
60
  }
61
+ // The peeking sprite includes the neck, shoulders and hands.
62
+ const mascot = readFileSync(new URL('../../assets/mascot-peeking.png', import.meta.url))
63
+ ctx.effect(() => ctx.webServer.register({
64
+ kind: 'exact',
65
+ path: MASCOT_PATH,
66
+ handler: (req, res) => {
67
+ if (!guard(req, res, 'GET')) return
68
+ res.statusCode = 200
69
+ res.setHeader('content-type', 'image/png')
70
+ res.setHeader('cache-control', 'private, max-age=3600')
71
+ res.end(mascot)
72
+ },
73
+ }), `notify-tray: GET ${MASCOT_PATH}`)
59
74
  /** Everything the settings page shows; only computed when a page asks. */
60
75
  const snapshot = () => {
61
76
  const currentUsage = host.usage()
package/locale/en.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Whale Notify Station",
4
- "description": "(Click to open the detailed settings) A plump blue whale girl: when a task finishes, needs a choice, or waits for your words, she blows bubbles and pops a notification — and keeps today's spend in mind for you. On macOS / Linux she also lives in your status bar; Windows has no status bar, so there she only notifies."
4
+ "description": "Notifications when tasks finish, fail, or need your attention, with daily spend and plan quota. Open Whale Notify Station in the left sidebar to configure it; this page contains the user guide. The status-bar whale is available on macOS / Linux; Windows supports notifications only.",
5
+ "detail": "README.md"
5
6
  }
6
7
  }
package/locale/zh.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "小鲸鱼通知站",
4
- "description": "(点击可进行详细设置)一只蓝色的大肥鲸鱼娘:任务做完、要你选一个、等你写几个字的时候,她会冒着泡泡弹通知来找你~ 顺便帮你记着今天花了多少钱。macOS / Linux 上她还会常驻状态栏;Windows 没有状态栏,只弹通知。"
4
+ "description": "任务完成、失败或需要你处理时弹通知,查看今日花费与套餐额度。点击左侧栏「小鲸鱼通知站」进行设置;此页为使用说明。macOS / Linux 支持状态栏小鲸鱼,Windows 仅提供通知。",
5
+ "detail": "README.md"
5
6
  }
6
7
  }