dsh-notify-tray 0.1.6 → 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/README.en.md +109 -0
- package/README.md +78 -150
- package/README.zh-CN.md +85 -129
- package/assets/mascot-peeking.png +0 -0
- package/assets/mascot-peeking.prompt.txt +6 -0
- package/lib/catalog.js +11 -3
- package/lib/client.js +426 -57
- package/lib/format.js +1 -1
- package/lib/host/context.js +89 -0
- package/lib/host/notify.js +89 -0
- package/lib/host/routes.js +170 -0
- package/lib/host/spend.js +159 -0
- package/lib/host/tray.js +120 -0
- package/lib/index.js +16 -488
- package/lib/models-dev.json +2684 -0
- package/lib/notices.js +119 -0
- package/lib/pricing.js +31 -3
- package/lib/quota.js +46 -2
- package/lib/system.js +60 -10
- package/lib/tracker.js +7 -0
- package/lib/tray/linux.js +34 -7
- package/lib/voice.js +19 -1
- package/locale/en.json +2 -1
- package/locale/zh.json +2 -1
- package/package.json +10 -6
package/lib/client.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
// dsh-notify-tray, browser half (hand-written in DSH's client module format,
|
|
2
2
|
// so no build step is needed).
|
|
3
3
|
//
|
|
4
|
-
// Polls the host's `notify-tray/state` route
|
|
5
|
-
// each new
|
|
6
|
-
//
|
|
4
|
+
// Polls the host's `notify-tray/state` route (its light `lite=1` form), shows
|
|
5
|
+
// a native Notification for each new notice (completed / failed / approval /
|
|
6
|
+
// choice / input; one per session, closed again once a question is answered)
|
|
7
|
+
// and opens the session when a notification — or a tray menu row — is
|
|
8
|
+
// clicked. In the
|
|
7
9
|
// desktop app these notifications are OS-native and attributed to
|
|
8
10
|
// "DeepSeek Harness".
|
|
9
11
|
window.__ModuleLoader__.load({
|
|
@@ -40,15 +42,14 @@ window.__ModuleLoader__.load({
|
|
|
40
42
|
return true
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
//
|
|
45
|
+
// Settings mount independently once the layout and host namespace are ready.
|
|
44
46
|
var inject = ['uiWorkspace', 'sessions', 'slots', 'locale', 'configForms']
|
|
45
47
|
|
|
46
48
|
// ------------------------------------------------------------------------
|
|
47
|
-
// Settings page:
|
|
48
|
-
// same frame the official "子智能体 / Agent 循环" pages use — a SettingsForm
|
|
49
|
+
// Settings page: a sidebar entry opens a main panel containing a SettingsForm
|
|
49
50
|
// over the `notify-tray` settings namespace (the `.volatile()` fields of
|
|
50
51
|
// lib/index.js Config, served by @deepseek-ai/dsh-settings), grouped into
|
|
51
|
-
// sections with toggles, segmented choices and number fields,
|
|
52
|
+
// sections with toggles, segmented choices and number fields, saved automatically.
|
|
52
53
|
// Plain React.createElement, so no build step is needed.
|
|
53
54
|
// ------------------------------------------------------------------------
|
|
54
55
|
function mountSettingsPage(ctx, require) {
|
|
@@ -60,8 +61,8 @@ window.__ModuleLoader__.load({
|
|
|
60
61
|
const NS = 'notify-tray'
|
|
61
62
|
/** Dictionary namespace owned by this page. */
|
|
62
63
|
const LOCALE_NS = 'notify-tray.settings'
|
|
63
|
-
/** The
|
|
64
|
-
const
|
|
64
|
+
/** The sidebar id and main slot key must match for layout navigation. */
|
|
65
|
+
const PANEL_ID = 'notify-tray'
|
|
65
66
|
const CATALOG_ROUTE = 'notify-tray/catalog'
|
|
66
67
|
const REFRESH_ROUTE = 'notify-tray/refresh'
|
|
67
68
|
const TRAY_ROUTE = 'notify-tray/tray'
|
|
@@ -104,6 +105,33 @@ window.__ModuleLoader__.load({
|
|
|
104
105
|
}
|
|
105
106
|
|
|
106
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
|
+
|
|
107
135
|
summary: '任务做完或需要你时提醒你,状态栏里看进度和花费。',
|
|
108
136
|
summary_win32: '任务做完或需要你时弹通知,顺便算算今天花了多少。Windows 没有状态栏,小鲸鱼只用通知来找你。',
|
|
109
137
|
sectionNotify: '提醒我',
|
|
@@ -121,8 +149,8 @@ window.__ModuleLoader__.load({
|
|
|
121
149
|
|
|
122
150
|
sectionTray: '状态栏小鲸鱼',
|
|
123
151
|
tray: '显示小鲸鱼',
|
|
124
|
-
trayHint: '
|
|
125
|
-
trayHint_linux: 'UOS / Deepin / 麒麟 / KDE 自带托盘;GNOME 要装 AppIndicator
|
|
152
|
+
trayHint: '更改后自动保存并生效。',
|
|
153
|
+
trayHint_linux: 'UOS / Deepin / 麒麟 / KDE 自带托盘;GNOME 要装 AppIndicator 扩展。更改后自动保存并生效。',
|
|
126
154
|
trayHiddenNote: '状态栏图标已从它的菜单里隐藏。',
|
|
127
155
|
trayShowAgain: '重新显示状态栏图标',
|
|
128
156
|
trayShowing: '正在显示…',
|
|
@@ -163,6 +191,8 @@ window.__ModuleLoader__.load({
|
|
|
163
191
|
refreshing: '刷新中…',
|
|
164
192
|
updatedAt: '更新',
|
|
165
193
|
fetchFailed: '获取失败',
|
|
194
|
+
attemptSkipped: '没用上',
|
|
195
|
+
attemptFailed: '失败',
|
|
166
196
|
noFetchYet: '还没获取过',
|
|
167
197
|
resetsAt: '重置',
|
|
168
198
|
remainingShort: '剩余',
|
|
@@ -245,16 +275,43 @@ window.__ModuleLoader__.load({
|
|
|
245
275
|
srcCustom: '自定义价',
|
|
246
276
|
srcCatalog: '目录价',
|
|
247
277
|
srcStatic: '内置价',
|
|
278
|
+
srcModelsDev: 'models.dev 价',
|
|
248
279
|
overridden: '已修改',
|
|
249
280
|
reset: '恢复默认',
|
|
250
281
|
readOnly: '本部署的设置为只读。',
|
|
251
282
|
unavailable: '小鲸鱼还没加载好,暂时不能配置。',
|
|
252
|
-
save: '保存',
|
|
253
283
|
saving: '保存中…',
|
|
254
|
-
saveFailed: '
|
|
284
|
+
saveFailed: '设置未保存,修改已保留,请重试。',
|
|
255
285
|
invalidNumber: '请填数字;留空表示用默认值。',
|
|
256
286
|
}
|
|
257
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
|
+
|
|
258
315
|
summary: 'Notifies you when a task finishes or needs you; the status bar shows progress and spend.',
|
|
259
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.',
|
|
260
317
|
sectionNotify: 'Notify me',
|
|
@@ -272,8 +329,8 @@ window.__ModuleLoader__.load({
|
|
|
272
329
|
|
|
273
330
|
sectionTray: 'Status-bar whale',
|
|
274
331
|
tray: 'Show the whale',
|
|
275
|
-
trayHint: '
|
|
276
|
-
trayHint_linux: 'Built into UOS / Deepin / Kylin / KDE; GNOME needs the AppIndicator extension.
|
|
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.',
|
|
277
334
|
trayHiddenNote: 'The status-bar icon was hidden from its own menu.',
|
|
278
335
|
trayShowAgain: 'Show the status-bar icon again',
|
|
279
336
|
trayShowing: 'Showing…',
|
|
@@ -314,6 +371,8 @@ window.__ModuleLoader__.load({
|
|
|
314
371
|
refreshing: 'Refreshing…',
|
|
315
372
|
updatedAt: 'updated',
|
|
316
373
|
fetchFailed: 'Fetch failed',
|
|
374
|
+
attemptSkipped: 'not used',
|
|
375
|
+
attemptFailed: 'failed',
|
|
317
376
|
noFetchYet: 'Not fetched yet',
|
|
318
377
|
resetsAt: 'resets',
|
|
319
378
|
remainingShort: 'Remaining',
|
|
@@ -396,11 +455,11 @@ window.__ModuleLoader__.load({
|
|
|
396
455
|
srcCustom: 'custom',
|
|
397
456
|
srcCatalog: 'catalog',
|
|
398
457
|
srcStatic: 'built-in',
|
|
458
|
+
srcModelsDev: 'models.dev',
|
|
399
459
|
overridden: 'Changed',
|
|
400
460
|
reset: 'Reset to default',
|
|
401
461
|
readOnly: 'This deployment stores settings read-only.',
|
|
402
462
|
unavailable: 'The whale is not loaded yet, so it cannot be configured right now.',
|
|
403
|
-
save: 'Save',
|
|
404
463
|
saving: 'Saving…',
|
|
405
464
|
saveFailed: 'The deployment did not accept these values; they were left for you to correct.',
|
|
406
465
|
invalidNumber: 'Enter a number, or leave blank to use the default.',
|
|
@@ -436,6 +495,8 @@ window.__ModuleLoader__.load({
|
|
|
436
495
|
/** Plan fields a preset fills in; switching provider clears them. */
|
|
437
496
|
const PRESET_FIELDS = ['planId', 'planName', 'planPrice', 'planCurrency', 'planPeriod', 'planQuota', 'planQuotaUrl']
|
|
438
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.
|
|
439
500
|
class Controller {
|
|
440
501
|
constructor(scope) {
|
|
441
502
|
this.form = new ui.SettingsFormModel(scope, [
|
|
@@ -444,21 +505,184 @@ window.__ModuleLoader__.load({
|
|
|
444
505
|
...NUMBERS.map(f => ui.settingsNumberField(f)),
|
|
445
506
|
...TEXTS.map(textField),
|
|
446
507
|
])
|
|
447
|
-
this.
|
|
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()
|
|
448
522
|
}
|
|
449
523
|
|
|
450
524
|
projection() {
|
|
451
525
|
const fields = {}
|
|
452
526
|
for (const f of FIELDS) fields[f] = this.form.field(f)
|
|
453
|
-
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
|
|
454
592
|
}
|
|
455
593
|
|
|
456
594
|
inject() {
|
|
457
|
-
return {
|
|
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
|
+
}
|
|
458
657
|
}
|
|
459
658
|
|
|
460
|
-
|
|
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
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
dispose() { this.disposed = true; this.listeners.clear() }
|
|
461
684
|
}
|
|
685
|
+
exports.__UpdateController = UpdateController
|
|
462
686
|
|
|
463
687
|
// ---- live data: catalog once, host state while the page is open ------------------
|
|
464
688
|
const live = { catalog: undefined, state: undefined, listeners: new Set() }
|
|
@@ -477,7 +701,13 @@ window.__ModuleLoader__.load({
|
|
|
477
701
|
fetchJson(CATALOG_ROUTE).then(body => { if (body) { live.catalog = body; publishLive() } }).catch(() => {})
|
|
478
702
|
}
|
|
479
703
|
function loadState() {
|
|
480
|
-
|
|
704
|
+
// Sending back the rev we hold: an unchanged snapshot comes back as `unchanged` only.
|
|
705
|
+
const rev = live.state && live.state.rev ? '&rev=' + encodeURIComponent(live.state.rev) : ''
|
|
706
|
+
return fetchJson(ROUTE + '?after=-2' + rev).then(body => {
|
|
707
|
+
if (!body || body.unchanged) return
|
|
708
|
+
live.state = body
|
|
709
|
+
publishLive()
|
|
710
|
+
}).catch(() => {})
|
|
481
711
|
}
|
|
482
712
|
// Test seam: lets a test drive the loaders without React effects.
|
|
483
713
|
const currentPlatform = () => normalizePlatform(live.state && live.state.platform) || guessPlatform()
|
|
@@ -499,7 +729,7 @@ window.__ModuleLoader__.load({
|
|
|
499
729
|
const S = {
|
|
500
730
|
section: { marginTop: 28 },
|
|
501
731
|
sectionTitle: { fontSize: 15, fontWeight: 600, margin: '0 0 4px' },
|
|
502
|
-
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)' },
|
|
503
733
|
rowText: { minWidth: 0 },
|
|
504
734
|
label: { fontSize: 14 },
|
|
505
735
|
hint: { margin: '2px 0 0', opacity: 0.6, fontSize: 12 },
|
|
@@ -509,7 +739,7 @@ window.__ModuleLoader__.load({
|
|
|
509
739
|
grid: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(200px, 1fr))', gap: '8px 16px', marginTop: 12 },
|
|
510
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' },
|
|
511
741
|
cardTitle: { fontSize: 12, fontWeight: 500, opacity: 0.65, marginBottom: 4 },
|
|
512
|
-
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 },
|
|
513
743
|
muted: { opacity: 0.65 },
|
|
514
744
|
error: { color: 'var(--dsw-alias-state-error-primary, #d33)' },
|
|
515
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' },
|
|
@@ -518,7 +748,7 @@ window.__ModuleLoader__.load({
|
|
|
518
748
|
lines: { margin: '6px 0 0', paddingLeft: 18, fontSize: 12, opacity: 0.75 },
|
|
519
749
|
checks: { display: 'flex', flexWrap: 'wrap', gap: '8px 18px', marginTop: 10 },
|
|
520
750
|
check: { display: 'inline-flex', alignItems: 'center', gap: 6, fontSize: 13 },
|
|
521
|
-
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' },
|
|
522
752
|
spendValue: { fontSize: 22, fontWeight: 600, lineHeight: '28px' },
|
|
523
753
|
keyRow: { display: 'flex', alignItems: 'flex-start', gap: 8, flexWrap: 'wrap' },
|
|
524
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' },
|
|
@@ -610,9 +840,9 @@ window.__ModuleLoader__.load({
|
|
|
610
840
|
}, options.map(([value, label]) => h('option', { key: value, value }, label)))
|
|
611
841
|
}
|
|
612
842
|
|
|
613
|
-
function Section({ title, children }) {
|
|
614
|
-
return h('section', {
|
|
615
|
-
h('
|
|
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),
|
|
616
846
|
children)
|
|
617
847
|
}
|
|
618
848
|
|
|
@@ -635,7 +865,7 @@ window.__ModuleLoader__.load({
|
|
|
635
865
|
const SYM = { CNY: '¥', USD: '$' }
|
|
636
866
|
const fmt = (n, currency) => (typeof n === 'number' ? `${SYM[currency] ?? ''}${Number.isInteger(n) ? n : (n < 1 ? n.toFixed(4).replace(/0+$/u, '').replace(/\.$/u, '') : n.toFixed(2))}` : '—')
|
|
637
867
|
const priceLine = (p, currency) => `${fmt(p.input, currency)} / ${fmt(p.cacheRead, currency)} / ${fmt(p.output, currency)}`
|
|
638
|
-
const SOURCE_KEY = { table: 'srcTable', custom: 'srcCustom', catalog: 'srcCatalog', static: 'srcStatic' }
|
|
868
|
+
const SOURCE_KEY = { table: 'srcTable', custom: 'srcCustom', catalog: 'srcCatalog', static: 'srcStatic', modelsDev: 'srcModelsDev' }
|
|
639
869
|
const clock = at => {
|
|
640
870
|
const d = new Date(at)
|
|
641
871
|
return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`
|
|
@@ -673,7 +903,15 @@ window.__ModuleLoader__.load({
|
|
|
673
903
|
/** One line on the last quota fetch, plus the fetched lines. */
|
|
674
904
|
function QuotaStatus({ t, plan }) {
|
|
675
905
|
if (!plan || !plan.fetch) return h('p', { style: S.hint }, t('noFetchYet'))
|
|
676
|
-
if (!plan.fetch.ok)
|
|
906
|
+
if (!plan.fetch.ok) {
|
|
907
|
+
// What was tried, in order, and what to fix (lib/quota.js runQuotaPlan).
|
|
908
|
+
const tried = (plan.fetch.attempts || []).filter(a => a.outcome !== 'ok')
|
|
909
|
+
return h('div', null,
|
|
910
|
+
h('p', { style: { ...S.hint, ...S.error } }, `${t('fetchFailed')}(${clock(plan.fetch.at)}):${plan.fetch.error}`),
|
|
911
|
+
tried.length > 1 || tried.some(a => a.hint)
|
|
912
|
+
? h('ul', { style: S.lines }, tried.map((a, i) => h('li', { key: i }, `${a.label}:${a.outcome === 'skipped' ? t('attemptSkipped') : t('attemptFailed')} · ${a.hint || a.detail}`)))
|
|
913
|
+
: null)
|
|
914
|
+
}
|
|
677
915
|
const bits = []
|
|
678
916
|
if (plan.remaining !== undefined) bits.push(`${t('remainingShort')} ${plan.remaining}`)
|
|
679
917
|
if (plan.resetAt) bits.push(`${String(plan.resetAt)} ${t('resetsAt')}`)
|
|
@@ -715,7 +953,7 @@ window.__ModuleLoader__.load({
|
|
|
715
953
|
const [busy, setBusy] = React.useState(false)
|
|
716
954
|
const refresh = () => {
|
|
717
955
|
setBusy(true)
|
|
718
|
-
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))
|
|
719
957
|
}
|
|
720
958
|
const choosePlan = id => {
|
|
721
959
|
edit('planId', id)
|
|
@@ -831,36 +1069,139 @@ window.__ModuleLoader__.load({
|
|
|
831
1069
|
h(TextField, { name: 'planQuotaUrl', field: f.planQuotaUrl, placeholder: quotaSpec?.url ?? 'https://…', ...common }))) : null))
|
|
832
1070
|
}
|
|
833
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
|
+
|
|
834
1122
|
function Page(props) {
|
|
835
|
-
|
|
836
|
-
|
|
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' }))
|
|
837
1177
|
}
|
|
838
1178
|
|
|
839
1179
|
function FullPage(props) {
|
|
840
1180
|
const state = props.useNotifyTray(snapshot => snapshot)
|
|
841
|
-
const liveData =
|
|
1181
|
+
const liveData = props.liveData
|
|
842
1182
|
const platform = currentPlatform()
|
|
843
1183
|
const features = (platform && FEATURES[platform]) || ALL_FEATURES
|
|
844
1184
|
const t = platformT(props.t, platform)
|
|
845
1185
|
const disabled = !state.writable
|
|
846
|
-
const common = { t, disabled, edit: props.edit, resetField: props.resetField }
|
|
1186
|
+
const common = { t, disabled, edit: props.edit, resetField: props.resetField, flush: props.flush }
|
|
847
1187
|
const f = state.fields
|
|
848
1188
|
const toggle = name => h(ToggleRow, { key: name, name, field: f[name], ...common })
|
|
849
1189
|
const titleStyle = f.titleStyle.text || 'text'
|
|
850
|
-
return h(
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
},
|
|
856
|
-
h(
|
|
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' },
|
|
857
1198
|
h(CheckRow, { label: 'notifyWhen', names: NOTIFY_FIELDS, f, ...common }),
|
|
858
1199
|
toggle('sound')),
|
|
859
|
-
features.tray ? h(Section, { title: t('sectionTray') },
|
|
1200
|
+
features.tray ? h(Section, { title: t('sectionTray'), icon: 'settings' },
|
|
860
1201
|
toggle('tray'),
|
|
861
1202
|
h(TrayStatus, { t, state: liveData.state }),
|
|
862
|
-
features.menuBarTitle ? h(ChoiceRow, { name: 'titleStyle', field: f.titleStyle, hint: `titleStyleHint_${titleStyle}`, ...common, options: [['text', 'titleText'], ['count', 'titleCount'], ['icon', 'titleIcon']] }) : null) : null,
|
|
863
|
-
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' },
|
|
864
1205
|
h(SpendCard, { t, state: liveData.state }),
|
|
865
1206
|
h(PlanSection, { t, f, common, state: liveData.state, catalog: liveData.catalog })),
|
|
866
1207
|
h(AdvancedSection, { t, f, common, features, state: liveData.state, catalog: liveData.catalog }))
|
|
@@ -870,18 +1211,31 @@ window.__ModuleLoader__.load({
|
|
|
870
1211
|
const t = ctx.locale.bind(LOCALE_NS)
|
|
871
1212
|
ctx.effect(() => ctx.locale.register(LOCALE_NS, { zh: { ...zh, CNY: '¥ 人民币', USD: '$ 美元' }, en: { ...en, CNY: '¥ CNY', USD: '$ USD' } }), 'notify-tray: settings dictionaries')
|
|
872
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')
|
|
873
1216
|
ctx.effect(() => () => card.dispose(), 'notify-tray: settings form')
|
|
874
|
-
//
|
|
875
|
-
//
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
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
|
+
})
|
|
885
1239
|
}
|
|
886
1240
|
|
|
887
1241
|
|
|
@@ -900,14 +1254,29 @@ window.__ModuleLoader__.load({
|
|
|
900
1254
|
}
|
|
901
1255
|
}
|
|
902
1256
|
|
|
1257
|
+
/** Notifications this window put up, by key (session): the next one for a key replaces it. */
|
|
1258
|
+
var shown = {}
|
|
1259
|
+
|
|
1260
|
+
function withdraw(notice) {
|
|
1261
|
+
var n = shown[notice.key]
|
|
1262
|
+
if (!n) return
|
|
1263
|
+
delete shown[notice.key]
|
|
1264
|
+
try { n.close() } catch (e) {}
|
|
1265
|
+
}
|
|
1266
|
+
|
|
903
1267
|
function show(event, state) {
|
|
1268
|
+
if (event.kind === 'withdraw') return withdraw(event)
|
|
904
1269
|
if (typeof Notification === 'undefined') return
|
|
905
1270
|
if (state.suppressWhenFocused && document.hasFocus() && mainSessionId(ctx.sessions) === event.sessionId) return
|
|
906
1271
|
// Without permission the host is not told we listen, so it notifies itself.
|
|
907
1272
|
if (Notification.permission !== 'granted') return
|
|
908
1273
|
if (!claim(boot, event.seq)) return
|
|
909
1274
|
var display = event.display || { title: (state.titles[event.type] || 'DeepSeek Harness') + ' · ' + event.title, body: event.body }
|
|
910
|
-
var
|
|
1275
|
+
var key = event.key || event.sessionId
|
|
1276
|
+
// Same tag: the OS swaps the session's previous notification for this one.
|
|
1277
|
+
var n = new Notification(display.title, { body: display.body, tag: 'dsh-notify-tray:' + key, renotify: true })
|
|
1278
|
+
shown[key] = n
|
|
1279
|
+
n.onclose = function () { if (shown[key] === n) delete shown[key] }
|
|
911
1280
|
n.onclick = function () {
|
|
912
1281
|
n.close()
|
|
913
1282
|
// The renderer cannot move the OS foreground; the host brings the window forward where it can (Windows).
|
|
@@ -921,7 +1290,7 @@ window.__ModuleLoader__.load({
|
|
|
921
1290
|
var focused = typeof document !== 'undefined' && typeof document.hasFocus === 'function' && document.hasFocus()
|
|
922
1291
|
var claimToast = focused && !wasFocused
|
|
923
1292
|
wasFocused = focused
|
|
924
|
-
fetch(ROUTE + '?after=' + cursor + (granted ? '¬ify=1' : '') + (claimToast ? '&claim=1' : ''), { headers: { accept: 'application/json' }, cache: 'no-store' })
|
|
1293
|
+
fetch(ROUTE + '?lite=1&after=' + cursor + (granted ? '¬ify=1' : '') + (claimToast ? '&claim=1' : ''), { headers: { accept: 'application/json' }, cache: 'no-store' })
|
|
925
1294
|
.then(function (res) { return res.ok ? res.json() : undefined })
|
|
926
1295
|
.then(function (state) {
|
|
927
1296
|
if (!state || stopped) return
|