dsh-hello 0.1.0 → 0.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/README.md +529 -509
- package/cordis.patch.yml +2 -2
- package/lib/client.js +614 -544
- package/lib/config.d.ts +15 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +12 -7
- package/lib/config.js.map +1 -1
- package/lib/devices.js +2 -2
- package/lib/devices.js.map +1 -1
- package/lib/host.d.ts +26 -0
- package/lib/host.d.ts.map +1 -1
- package/lib/http.d.ts +8 -0
- package/lib/http.d.ts.map +1 -1
- package/lib/http.js +33 -4
- package/lib/http.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +290 -116
- package/lib/index.js.map +3 -3
- package/lib/interactions.d.ts +24 -0
- package/lib/interactions.d.ts.map +1 -1
- package/lib/interactions.js +65 -12
- package/lib/interactions.js.map +1 -1
- package/lib/pairing.d.ts +11 -2
- package/lib/pairing.d.ts.map +1 -1
- package/lib/pairing.js +31 -9
- package/lib/pairing.js.map +1 -1
- package/lib/protocol.d.ts +3 -1
- package/lib/protocol.d.ts.map +1 -1
- package/lib/push.d.ts +1 -1
- package/lib/push.js +6 -6
- package/lib/push.js.map +1 -1
- package/lib/read-state.d.ts +2 -2
- package/lib/read-state.js +1 -1
- package/lib/routes.d.ts +5 -0
- package/lib/routes.d.ts.map +1 -1
- package/lib/routes.js +164 -60
- package/lib/routes.js.map +1 -1
- package/lib/sessions.js +10 -1
- package/lib/sessions.js.map +1 -1
- package/lib/terminal.js +3 -3
- package/lib/terminal.js.map +1 -1
- package/lib/version.js +4 -4
- package/lib/version.js.map +1 -1
- package/package.json +82 -82
package/lib/client.js
CHANGED
|
@@ -1,544 +1,614 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser half of dsh-
|
|
3
|
-
*
|
|
4
|
-
* Ships one surface: a top-level Settings section, ordered just after General
|
|
5
|
-
* (order 5) so it is not the first menu item. There is no standalone page; the
|
|
6
|
-
* React panel reads the Host's `/admin/data` and `/admin/pair-code` endpoints.
|
|
7
|
-
*
|
|
8
|
-
* This file is hand-written in the lazy-CJS factory format the dsh client
|
|
9
|
-
* module system expects. build.mjs copies it to lib/client.js.
|
|
10
|
-
*/
|
|
11
|
-
window.__ModuleLoader__.load({
|
|
12
|
-
id: 'dsh-
|
|
13
|
-
factory(require) {
|
|
14
|
-
const React = require('react')
|
|
15
|
-
const { Button, Input } = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
16
|
-
const h = React.createElement
|
|
17
|
-
|
|
18
|
-
const NS = 'dshDoorAdmin'
|
|
19
|
-
const injected = globalThis.__DSH_DOOR__
|
|
20
|
-
const BASE = typeof injected?.basePath === 'string' && injected.basePath.length > 0
|
|
21
|
-
? injected.basePath.replace(/\/$/, '')
|
|
22
|
-
: '/dsh-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.dd-
|
|
36
|
-
.dd-
|
|
37
|
-
.dd-
|
|
38
|
-
.dd-
|
|
39
|
-
.dd-
|
|
40
|
-
.dd-
|
|
41
|
-
.dd-
|
|
42
|
-
.dd-
|
|
43
|
-
.dd-
|
|
44
|
-
.dd-
|
|
45
|
-
.dd-
|
|
46
|
-
.dd-
|
|
47
|
-
.dd-
|
|
48
|
-
.dd-
|
|
49
|
-
.dd-
|
|
50
|
-
.dd-
|
|
51
|
-
.dd-
|
|
52
|
-
.dd-
|
|
53
|
-
.dd-
|
|
54
|
-
.dd-
|
|
55
|
-
.dd-
|
|
56
|
-
.dd-
|
|
57
|
-
.dd-
|
|
58
|
-
.dd-
|
|
59
|
-
.dd-
|
|
60
|
-
.dd-
|
|
61
|
-
.dd-
|
|
62
|
-
.dd-
|
|
63
|
-
.dd-
|
|
64
|
-
.dd-
|
|
65
|
-
.dd-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
.dd-
|
|
71
|
-
.dd-
|
|
72
|
-
.dd-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
function
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
if (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
),
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
),
|
|
427
|
-
)),
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
:
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of dsh-hello.
|
|
3
|
+
*
|
|
4
|
+
* Ships one surface: a top-level Settings section, ordered just after General
|
|
5
|
+
* (order 5) so it is not the first menu item. There is no standalone page; the
|
|
6
|
+
* React panel reads the Host's `/admin/data` and `/admin/pair-code` endpoints.
|
|
7
|
+
*
|
|
8
|
+
* This file is hand-written in the lazy-CJS factory format the dsh client
|
|
9
|
+
* module system expects. build.mjs copies it to lib/client.js.
|
|
10
|
+
*/
|
|
11
|
+
window.__ModuleLoader__.load({
|
|
12
|
+
id: 'dsh-hello',
|
|
13
|
+
factory(require) {
|
|
14
|
+
const React = require('react')
|
|
15
|
+
const { Button, Input } = require('@deepseek-ai/dsh-client-ui-primitives')
|
|
16
|
+
const h = React.createElement
|
|
17
|
+
|
|
18
|
+
const NS = 'dshDoorAdmin'
|
|
19
|
+
const injected = globalThis.__DSH_DOOR__
|
|
20
|
+
const BASE = typeof injected?.basePath === 'string' && injected.basePath.length > 0
|
|
21
|
+
? injected.basePath.replace(/\/$/, '')
|
|
22
|
+
: '/dsh-hello'
|
|
23
|
+
// The Settings page knows the address it was loaded from; the Host's bind
|
|
24
|
+
// address does not. Send it with every admin request so the QR follows the
|
|
25
|
+
// public/actual URL, including behind a NAT.
|
|
26
|
+
const adminBaseQuery = () => {
|
|
27
|
+
try {
|
|
28
|
+
return '?base=' + encodeURIComponent(new URL('.', location.href).href)
|
|
29
|
+
} catch {
|
|
30
|
+
return ''
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const styles = `
|
|
35
|
+
.dd-page{display:flex;flex-direction:column;width:100%;gap:0}
|
|
36
|
+
.dd-head{padding:0 0 18px}
|
|
37
|
+
.dd-title{font-size:18px;font-weight:600;margin:0 0 4px;color:var(--dsw-alias-label-primary)}
|
|
38
|
+
.dd-desc{margin:0;font-size:13px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
39
|
+
.dd-row{display:flex;gap:24px;align-items:center;justify-content:space-between;padding:16px 0;border-bottom:0.5px solid var(--dsw-alias-border-l3,rgba(127,127,127,.22))}
|
|
40
|
+
.dd-rowTop{flex-wrap:wrap;row-gap:10px}
|
|
41
|
+
.dd-rowTop .dd-rowText{flex:1 1 240px}
|
|
42
|
+
.dd-rowTop .dd-control{margin-left:auto}
|
|
43
|
+
.dd-rowHead{border-bottom:none;padding-bottom:0}
|
|
44
|
+
.dd-row:last-child{border-bottom:none}
|
|
45
|
+
.dd-rowText{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
46
|
+
.dd-label{font-size:14px;color:var(--dsw-alias-label-primary)}
|
|
47
|
+
.dd-control{display:flex;gap:8px;align-items:center;flex-wrap:wrap;justify-content:flex-end;flex-shrink:0}
|
|
48
|
+
.dd-block{display:flex;flex-direction:column;gap:8px;padding:16px 0;border-bottom:0.5px solid var(--dsw-alias-border-l3,rgba(127,127,127,.22))}
|
|
49
|
+
.dd-code{font:600 20px ui-monospace,monospace;letter-spacing:3px;color:var(--dsw-alias-brand-primary,#3d7bfd)}
|
|
50
|
+
.dd-segment{display:inline-flex;gap:2px;padding:2px;border-radius:9px;background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
|
|
51
|
+
.dd-segmentButton{height:28px;padding:0 12px;border:0;border-radius:7px;background:transparent;color:var(--dsw-alias-label-tertiary,#888);font:inherit;font-size:13px;cursor:pointer;white-space:nowrap}
|
|
52
|
+
.dd-segmentButton.is-active{background:var(--dsw-alias-surface-primary,#fff);color:var(--dsw-alias-label-primary,#111);box-shadow:0 1px 2px rgba(0,0,0,.12)}
|
|
53
|
+
.dd-countdown{font-size:12px;color:var(--dsw-alias-label-tertiary,#888);white-space:nowrap}
|
|
54
|
+
.dd-modalBackdrop{position:fixed;inset:0;z-index:100;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.35)}
|
|
55
|
+
.dd-modal{display:flex;flex-direction:column;gap:12px;width:min(380px,90vw);padding:18px;border-radius:12px;background:var(--dsw-alias-surface-primary,#fff);box-shadow:0 12px 40px rgba(0,0,0,.28)}
|
|
56
|
+
.dd-modalTitle{margin:0;font-size:16px;font-weight:600;color:var(--dsw-alias-label-primary,#111)}
|
|
57
|
+
.dd-modalActions{display:flex;justify-content:flex-end;gap:8px}
|
|
58
|
+
.dd-modalInput{box-sizing:border-box;width:100%;max-width:100%;min-width:0}
|
|
59
|
+
.dd-qr{font-size:10px;line-height:1;overflow:auto;margin:0;color:var(--dsw-alias-label-secondary);max-height:220px}
|
|
60
|
+
.dd-qr-img{display:flex;justify-content:flex-start;align-self:flex-start;background:#fff;border-radius:8px;padding:8px}
|
|
61
|
+
.dd-qr-img svg{width:220px;height:220px;display:block}
|
|
62
|
+
.dd-table{width:100%;border-collapse:collapse;font-size:13px}
|
|
63
|
+
.dd-table th,.dd-table td{text-align:left;padding:8px 0;border-bottom:0.5px solid var(--dsw-alias-border-l3,rgba(127,127,127,.18));color:var(--dsw-alias-label-secondary)}
|
|
64
|
+
.dd-table th{font-weight:500;color:var(--dsw-alias-label-tertiary)}
|
|
65
|
+
.dd-devices{display:flex;flex-direction:column;margin-top:2px}
|
|
66
|
+
.dd-device{display:flex;gap:20px;align-items:flex-start;justify-content:space-between;padding:14px 0;border-bottom:0.5px solid var(--dsw-alias-border-l3,rgba(127,127,127,.18))}
|
|
67
|
+
.dd-device:last-child{border-bottom:0}
|
|
68
|
+
.dd-deviceInfo{display:flex;flex-direction:column;gap:3px;min-width:0;flex:1}
|
|
69
|
+
.dd-deviceNameRow{display:flex;align-items:center;gap:8px;min-width:0}
|
|
70
|
+
.dd-deviceName{font-size:14px;color:var(--dsw-alias-label-primary,#111)}
|
|
71
|
+
.dd-rename{padding:0;border:0;background:transparent;color:var(--dsw-alias-link,var(--dsw-alias-brand-primary,#3d7bfd));font:inherit;font-size:12px;cursor:pointer}
|
|
72
|
+
.dd-rename:disabled{opacity:.45;cursor:default}
|
|
73
|
+
.dd-deviceMeta{font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#888);word-break:break-all}
|
|
74
|
+
.dd-deviceSide{display:flex;align-items:center;gap:20px;flex:none}
|
|
75
|
+
.dd-deviceTimes{display:flex;flex-direction:column;gap:3px;text-align:right}
|
|
76
|
+
.dd-deviceTime{font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#888);white-space:nowrap}
|
|
77
|
+
.dd-deviceAction{flex:none}
|
|
78
|
+
.dd-deviceAction button{white-space:nowrap;color:var(--dsw-alias-state-error-primary,#e5484d)!important}
|
|
79
|
+
.dd-deviceAction button:hover{background:var(--dsw-alias-state-error-primary,#e5484d)!important;color:#fff!important}
|
|
80
|
+
@media (max-width:640px){
|
|
81
|
+
.dd-device{flex-wrap:wrap}
|
|
82
|
+
.dd-deviceSide{width:100%;justify-content:space-between}
|
|
83
|
+
}
|
|
84
|
+
.dd-error{color:var(--dsw-alias-state-error-primary,#f87171);font-size:13px;margin:0}
|
|
85
|
+
.dd-link{color:var(--dsw-alias-link,var(--dsw-alias-brand-primary,#3d7bfd))}
|
|
86
|
+
.dd-input{width:180px}
|
|
87
|
+
`
|
|
88
|
+
|
|
89
|
+
const zh = {
|
|
90
|
+
nav: 'DSH Hello',
|
|
91
|
+
title: 'DSH Hello',
|
|
92
|
+
pairingCode: '配对码',
|
|
93
|
+
lockMode: '锁定',
|
|
94
|
+
lockHintOn: '已锁定:新设备无法配对,已连接的设备照常使用',
|
|
95
|
+
oneTimeMode: '一次性',
|
|
96
|
+
fixedMode: '永久性',
|
|
97
|
+
remaining: '剩余 {time}',
|
|
98
|
+
reset: '重置',
|
|
99
|
+
modify: '修改',
|
|
100
|
+
setPermanentTitle: '设置永久配对码',
|
|
101
|
+
setPermanentDesc: '输入 4 位数字,将作为永久配对码。',
|
|
102
|
+
modifyTitle: '修改永久配对码',
|
|
103
|
+
modifyDesc: '输入新的 4 位数字,旧永久码会立即失效。',
|
|
104
|
+
passwordPlaceholder: '4 位数字',
|
|
105
|
+
passwordInvalid: '请输入 4 位数字',
|
|
106
|
+
confirm: '确定',
|
|
107
|
+
cancel: '取消',
|
|
108
|
+
resetTitle: '恢复为一次性配对码?',
|
|
109
|
+
resetDesc: '当前永久码会立即失效,并生成新的一次性码。',
|
|
110
|
+
qrTitle: '扫码/输入',
|
|
111
|
+
qrLoading: '二维码加载中…',
|
|
112
|
+
qrHint: '请用手机打开 DSH Hello,连接 → 添加服务器 → 使用插件配对 → 扫描二维码。',
|
|
113
|
+
devices: '已配对设备',
|
|
114
|
+
device: '设备',
|
|
115
|
+
pairedAt: '配对时间',
|
|
116
|
+
lastSeen: '最近连接',
|
|
117
|
+
actions: '操作',
|
|
118
|
+
revoke: '移除',
|
|
119
|
+
rename: '改名',
|
|
120
|
+
renameTitle: '重命名设备',
|
|
121
|
+
renameDesc: '只修改显示名称,不影响已配对连接。',
|
|
122
|
+
renameEmpty: '设备名称不能为空',
|
|
123
|
+
revokeConfirm: '移除设备「{name}」?它需要重新配对才能连接。',
|
|
124
|
+
via: '地址',
|
|
125
|
+
noDevices: '还没有设备',
|
|
126
|
+
codeLost: '登录已失效,请刷新 dsh Web UI',
|
|
127
|
+
operationFailed: '操作失败',
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const en = {
|
|
131
|
+
nav: 'DSH Hello',
|
|
132
|
+
title: 'DSH Hello',
|
|
133
|
+
pairingCode: 'Pairing code',
|
|
134
|
+
lockMode: 'Lock',
|
|
135
|
+
lockHintOn: 'Locked: new devices cannot pair, while paired devices keep working',
|
|
136
|
+
oneTimeMode: 'One-time',
|
|
137
|
+
fixedMode: 'Permanent',
|
|
138
|
+
remaining: '{time} left',
|
|
139
|
+
reset: 'Reset',
|
|
140
|
+
modify: 'Change',
|
|
141
|
+
setPermanentTitle: 'Set a permanent pairing code',
|
|
142
|
+
setPermanentDesc: 'Enter four digits to use as the permanent pairing code.',
|
|
143
|
+
modifyTitle: 'Change the permanent pairing code',
|
|
144
|
+
modifyDesc: 'Enter four new digits; the old permanent code stops working immediately.',
|
|
145
|
+
passwordPlaceholder: 'Four digits',
|
|
146
|
+
passwordInvalid: 'Enter four digits',
|
|
147
|
+
confirm: 'Confirm',
|
|
148
|
+
cancel: 'Cancel',
|
|
149
|
+
resetTitle: 'Restore one-time pairing?',
|
|
150
|
+
resetDesc: 'The permanent code stops working immediately and a fresh one-time code is generated.',
|
|
151
|
+
qrTitle: 'Scan or type',
|
|
152
|
+
qrLoading: 'Loading QR…',
|
|
153
|
+
qrHint: 'Open DSH Hello on your phone, then Connection → Add server → Plugin pairing → Scan QR code.',
|
|
154
|
+
devices: 'Paired devices',
|
|
155
|
+
device: 'Device',
|
|
156
|
+
pairedAt: 'Paired',
|
|
157
|
+
lastSeen: 'Last seen',
|
|
158
|
+
actions: 'Actions',
|
|
159
|
+
revoke: 'Remove',
|
|
160
|
+
rename: 'Rename',
|
|
161
|
+
renameTitle: 'Rename device',
|
|
162
|
+
renameDesc: 'Only the display name changes; the pairing stays connected.',
|
|
163
|
+
renameEmpty: 'The device name cannot be empty',
|
|
164
|
+
revokeConfirm: 'Remove “{name}”? It must pair again to reconnect.',
|
|
165
|
+
via: 'Via',
|
|
166
|
+
noDevices: 'No devices yet',
|
|
167
|
+
codeLost: 'Session expired. Reload the dsh Web UI.',
|
|
168
|
+
operationFailed: 'Operation failed',
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function installStyles() {
|
|
172
|
+
const style = document.createElement('style')
|
|
173
|
+
style.dataset.plugin = 'dsh-hello'
|
|
174
|
+
style.textContent = styles
|
|
175
|
+
document.head.append(style)
|
|
176
|
+
return () => style.remove()
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
return {
|
|
180
|
+
inject: ['slots', 'locale'],
|
|
181
|
+
apply(ctx) {
|
|
182
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-hello: admin copy')
|
|
183
|
+
ctx.effect(installStyles, 'dsh-hello: admin styles')
|
|
184
|
+
|
|
185
|
+
const t = ctx.locale.bind(NS)
|
|
186
|
+
|
|
187
|
+
/** Browser-local date/time for the device table; follows the page language. */
|
|
188
|
+
let deviceTimeFormat
|
|
189
|
+
function formatDeviceTime(value) {
|
|
190
|
+
const date = new Date(value)
|
|
191
|
+
if (Number.isNaN(date.getTime())) return '—'
|
|
192
|
+
try {
|
|
193
|
+
deviceTimeFormat ??= new Intl.DateTimeFormat(
|
|
194
|
+
document.documentElement.lang || navigator.language || undefined,
|
|
195
|
+
{ dateStyle: 'medium', timeStyle: 'short' },
|
|
196
|
+
)
|
|
197
|
+
return deviceTimeFormat.format(date)
|
|
198
|
+
} catch {
|
|
199
|
+
return date.toLocaleString()
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function AdminSection() {
|
|
204
|
+
const [data, setData] = React.useState(null)
|
|
205
|
+
const [error, setError] = React.useState(null)
|
|
206
|
+
const [busy, setBusy] = React.useState(false)
|
|
207
|
+
const [now, setNow] = React.useState(Date.now())
|
|
208
|
+
const [dialog, setDialog] = React.useState(null)
|
|
209
|
+
const [password, setPassword] = React.useState('')
|
|
210
|
+
const [dialogError, setDialogError] = React.useState(null)
|
|
211
|
+
const [busyDevice, setBusyDevice] = React.useState(null)
|
|
212
|
+
const [renameTarget, setRenameTarget] = React.useState(null)
|
|
213
|
+
const [renameValue, setRenameValue] = React.useState('')
|
|
214
|
+
const [renameError, setRenameError] = React.useState(null)
|
|
215
|
+
|
|
216
|
+
React.useEffect(() => {
|
|
217
|
+
let alive = true
|
|
218
|
+
async function load() {
|
|
219
|
+
try {
|
|
220
|
+
// Use the address the admin page is actually loaded from, not
|
|
221
|
+
// the Host's bind address. This keeps the Settings QR usable on
|
|
222
|
+
// a NATed cloud Host even when --public-url is not set.
|
|
223
|
+
const response = await fetch(BASE + '/admin/data' + adminBaseQuery(), { credentials: 'same-origin', cache: 'no-store' })
|
|
224
|
+
if (!response.ok) throw new Error(t('codeLost'))
|
|
225
|
+
const next = await response.json()
|
|
226
|
+
if (alive) {
|
|
227
|
+
setData(next)
|
|
228
|
+
setError(null)
|
|
229
|
+
}
|
|
230
|
+
} catch (failure) {
|
|
231
|
+
if (alive) setError(failure instanceof Error ? failure.message : String(failure))
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
void load()
|
|
235
|
+
const timer = setInterval(load, 5000)
|
|
236
|
+
return () => {
|
|
237
|
+
alive = false
|
|
238
|
+
clearInterval(timer)
|
|
239
|
+
}
|
|
240
|
+
}, [t])
|
|
241
|
+
|
|
242
|
+
React.useEffect(() => {
|
|
243
|
+
const timer = setInterval(() => setNow(Date.now()), 1000)
|
|
244
|
+
return () => clearInterval(timer)
|
|
245
|
+
}, [])
|
|
246
|
+
|
|
247
|
+
async function perform(payload) {
|
|
248
|
+
setBusy(true)
|
|
249
|
+
try {
|
|
250
|
+
const response = await fetch(BASE + '/admin/pair-code' + adminBaseQuery(), {
|
|
251
|
+
method: 'POST',
|
|
252
|
+
credentials: 'same-origin',
|
|
253
|
+
headers: { 'content-type': 'application/json' },
|
|
254
|
+
body: JSON.stringify(payload),
|
|
255
|
+
})
|
|
256
|
+
if (!response.ok) {
|
|
257
|
+
const body = await response.json().catch(() => null)
|
|
258
|
+
throw new Error(body?.error?.message || t('operationFailed'))
|
|
259
|
+
}
|
|
260
|
+
setData(await response.json())
|
|
261
|
+
return null
|
|
262
|
+
} catch (failure) {
|
|
263
|
+
return failure instanceof Error ? failure.message : String(failure)
|
|
264
|
+
} finally {
|
|
265
|
+
setBusy(false)
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
const fixed = data?.fixed === true
|
|
270
|
+
const locked = data?.locked === true
|
|
271
|
+
const remaining = !fixed && data ? Math.max(0, data.expiresAt - now) : null
|
|
272
|
+
const left = remaining === null
|
|
273
|
+
? ''
|
|
274
|
+
: `${Math.floor(remaining / 60000)}:${String(Math.floor((remaining % 60000) / 1000)).padStart(2, '0')}`
|
|
275
|
+
|
|
276
|
+
async function setLocked(next) {
|
|
277
|
+
setBusy(true)
|
|
278
|
+
setError(null)
|
|
279
|
+
try {
|
|
280
|
+
const response = await fetch(BASE + '/admin/lock' + adminBaseQuery(), {
|
|
281
|
+
method: 'POST',
|
|
282
|
+
credentials: 'same-origin',
|
|
283
|
+
headers: { 'content-type': 'application/json' },
|
|
284
|
+
body: JSON.stringify({ locked: next }),
|
|
285
|
+
})
|
|
286
|
+
if (!response.ok) {
|
|
287
|
+
const body = await response.json().catch(() => null)
|
|
288
|
+
throw new Error(body?.error?.message || t('operationFailed'))
|
|
289
|
+
}
|
|
290
|
+
setData(await response.json())
|
|
291
|
+
} catch (failure) {
|
|
292
|
+
setError(failure instanceof Error ? failure.message : String(failure))
|
|
293
|
+
} finally {
|
|
294
|
+
setBusy(false)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const openPermanent = () => {
|
|
299
|
+
setPassword('')
|
|
300
|
+
setDialogError(null)
|
|
301
|
+
setDialog('permanent')
|
|
302
|
+
}
|
|
303
|
+
const openReset = () => {
|
|
304
|
+
setDialogError(null)
|
|
305
|
+
setDialog('reset')
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* One three-way switch: Lock, One-time, Permanent. Unlocking restores
|
|
309
|
+
* whichever code mode was in force, so switching from Lock to another
|
|
310
|
+
* mode continues into that mode's dialog when it needs input.
|
|
311
|
+
*/
|
|
312
|
+
const chooseMode = async (next) => {
|
|
313
|
+
if (busy || data === null) return
|
|
314
|
+
if (next === 'lock') {
|
|
315
|
+
if (!locked) await setLocked(true)
|
|
316
|
+
return
|
|
317
|
+
}
|
|
318
|
+
if (locked) await setLocked(false)
|
|
319
|
+
if (next === 'one-time' && fixed) openReset()
|
|
320
|
+
if (next === 'permanent' && !fixed) openPermanent()
|
|
321
|
+
}
|
|
322
|
+
const confirmPermanent = async () => {
|
|
323
|
+
const code = password.trim()
|
|
324
|
+
if (!/^\d{4}$/.test(code)) {
|
|
325
|
+
setDialogError(t('passwordInvalid'))
|
|
326
|
+
return
|
|
327
|
+
}
|
|
328
|
+
const failure = await perform({ action: 'fixed', code })
|
|
329
|
+
if (failure !== null) {
|
|
330
|
+
setDialogError(failure)
|
|
331
|
+
return
|
|
332
|
+
}
|
|
333
|
+
setDialog(null)
|
|
334
|
+
setPassword('')
|
|
335
|
+
}
|
|
336
|
+
const confirmReset = async () => {
|
|
337
|
+
const failure = await perform({ action: 'auto' })
|
|
338
|
+
if (failure !== null) {
|
|
339
|
+
setDialogError(failure)
|
|
340
|
+
return
|
|
341
|
+
}
|
|
342
|
+
setDialog(null)
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const revokeDevice = async (device) => {
|
|
346
|
+
const name = device.deviceName || String(device.deviceId || '').slice(0, 12)
|
|
347
|
+
if (!window.confirm(t('revokeConfirm', { name }))) return
|
|
348
|
+
setBusyDevice(device.deviceId)
|
|
349
|
+
setError(null)
|
|
350
|
+
try {
|
|
351
|
+
const response = await fetch(BASE + '/admin/devices/' + encodeURIComponent(device.deviceId) + adminBaseQuery(), {
|
|
352
|
+
method: 'DELETE',
|
|
353
|
+
credentials: 'same-origin',
|
|
354
|
+
})
|
|
355
|
+
if (!response.ok) {
|
|
356
|
+
const body = await response.json().catch(() => null)
|
|
357
|
+
throw new Error(body?.error?.message || t('operationFailed'))
|
|
358
|
+
}
|
|
359
|
+
setData(await response.json())
|
|
360
|
+
} catch (failure) {
|
|
361
|
+
setError(failure instanceof Error ? failure.message : String(failure))
|
|
362
|
+
} finally {
|
|
363
|
+
setBusyDevice(null)
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
const openRename = (device) => {
|
|
368
|
+
setRenameValue(device.deviceName || '')
|
|
369
|
+
setRenameError(null)
|
|
370
|
+
setRenameTarget(device)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const confirmRename = async () => {
|
|
374
|
+
if (renameTarget === null) return
|
|
375
|
+
const name = renameValue.trim()
|
|
376
|
+
if (name.length === 0) {
|
|
377
|
+
setRenameError(t('renameEmpty'))
|
|
378
|
+
return
|
|
379
|
+
}
|
|
380
|
+
setBusyDevice(renameTarget.deviceId)
|
|
381
|
+
setRenameError(null)
|
|
382
|
+
setError(null)
|
|
383
|
+
try {
|
|
384
|
+
const response = await fetch(BASE + '/admin/devices/' + encodeURIComponent(renameTarget.deviceId) + adminBaseQuery(), {
|
|
385
|
+
method: 'PUT',
|
|
386
|
+
credentials: 'same-origin',
|
|
387
|
+
headers: { 'content-type': 'application/json' },
|
|
388
|
+
body: JSON.stringify({ name }),
|
|
389
|
+
})
|
|
390
|
+
if (!response.ok) {
|
|
391
|
+
const body = await response.json().catch(() => null)
|
|
392
|
+
throw new Error(body?.error?.message || t('operationFailed'))
|
|
393
|
+
}
|
|
394
|
+
setData(await response.json())
|
|
395
|
+
setRenameTarget(null)
|
|
396
|
+
} catch (failure) {
|
|
397
|
+
setRenameError(failure instanceof Error ? failure.message : String(failure))
|
|
398
|
+
} finally {
|
|
399
|
+
setBusyDevice(null)
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
const devices = Array.isArray(data?.devices) ? data.devices : []
|
|
404
|
+
|
|
405
|
+
return h('section', { className: 'dd-page' },
|
|
406
|
+
h('header', { className: 'dd-head' },
|
|
407
|
+
h('h2', { className: 'dd-title' }, t('title'))),
|
|
408
|
+
error === null ? null : h('p', { className: 'dd-error' }, error),
|
|
409
|
+
|
|
410
|
+
h('div', { className: 'dd-row dd-rowTop dd-rowHead' },
|
|
411
|
+
h('div', { className: 'dd-rowText' },
|
|
412
|
+
h('span', { className: 'dd-label' }, t('pairingCode')),
|
|
413
|
+
),
|
|
414
|
+
h('div', { className: 'dd-control' },
|
|
415
|
+
h('div', { className: 'dd-segment' },
|
|
416
|
+
h('button', {
|
|
417
|
+
type: 'button',
|
|
418
|
+
className: 'dd-segmentButton' + (locked ? ' is-active' : ''),
|
|
419
|
+
disabled: busy || data === null,
|
|
420
|
+
onClick: () => { void chooseMode('lock') },
|
|
421
|
+
}, t('lockMode')),
|
|
422
|
+
h('button', {
|
|
423
|
+
type: 'button',
|
|
424
|
+
className: 'dd-segmentButton' + (!locked && !fixed ? ' is-active' : ''),
|
|
425
|
+
disabled: busy || data === null,
|
|
426
|
+
onClick: () => { void chooseMode('one-time') },
|
|
427
|
+
}, t('oneTimeMode')),
|
|
428
|
+
h('button', {
|
|
429
|
+
type: 'button',
|
|
430
|
+
className: 'dd-segmentButton' + (!locked && fixed ? ' is-active' : ''),
|
|
431
|
+
disabled: busy || data === null,
|
|
432
|
+
onClick: () => { void chooseMode('permanent') },
|
|
433
|
+
}, t('fixedMode')),
|
|
434
|
+
),
|
|
435
|
+
),
|
|
436
|
+
),
|
|
437
|
+
|
|
438
|
+
locked
|
|
439
|
+
? h('div', { className: 'dd-row' },
|
|
440
|
+
h('span', { className: 'dd-desc' }, t('lockHintOn')),
|
|
441
|
+
)
|
|
442
|
+
: [
|
|
443
|
+
h('div', { className: 'dd-row', key: 'code' },
|
|
444
|
+
h('span', { className: 'dd-code' }, data?.formatted ?? '…'),
|
|
445
|
+
h('div', { className: 'dd-control' },
|
|
446
|
+
fixed
|
|
447
|
+
? h(Button, {
|
|
448
|
+
variant: 'outline',
|
|
449
|
+
size: 'sm',
|
|
450
|
+
disabled: busy,
|
|
451
|
+
onClick: openPermanent,
|
|
452
|
+
}, t('modify'))
|
|
453
|
+
: h('span', { className: 'dd-countdown' }, left.length > 0 ? t('remaining', { time: left }) : ''),
|
|
454
|
+
),
|
|
455
|
+
),
|
|
456
|
+
h('div', { className: 'dd-block', key: 'qr' },
|
|
457
|
+
h('span', { className: 'dd-label' }, t('qrTitle')),
|
|
458
|
+
typeof data?.qrSvg === 'string' && data.qrSvg.startsWith('<svg')
|
|
459
|
+
? h('div', { className: 'dd-qr-img', dangerouslySetInnerHTML: { __html: data.qrSvg } })
|
|
460
|
+
: h('span', { className: 'dd-desc' }, t('qrFailed')),
|
|
461
|
+
h('span', { className: 'dd-desc' }, t('qrHint')),
|
|
462
|
+
),
|
|
463
|
+
],
|
|
464
|
+
|
|
465
|
+
h('div', { className: 'dd-block' },
|
|
466
|
+
h('span', { className: 'dd-label' }, t('devices')),
|
|
467
|
+
h('div', { className: 'dd-devices' },
|
|
468
|
+
devices.length === 0
|
|
469
|
+
? h('div', { className: 'dd-desc' }, t('noDevices'))
|
|
470
|
+
: devices.map(device => h('div', { className: 'dd-device', key: String(device.deviceId) },
|
|
471
|
+
h('div', { className: 'dd-deviceInfo' },
|
|
472
|
+
h('div', { className: 'dd-deviceNameRow' },
|
|
473
|
+
h('span', { className: 'dd-deviceName' }, device.deviceName || '—'),
|
|
474
|
+
h('button', {
|
|
475
|
+
type: 'button',
|
|
476
|
+
className: 'dd-rename',
|
|
477
|
+
disabled: busyDevice === device.deviceId,
|
|
478
|
+
onClick: () => { openRename(device) },
|
|
479
|
+
}, t('rename')),
|
|
480
|
+
),
|
|
481
|
+
h('span', { className: 'dd-deviceMeta' },
|
|
482
|
+
`${device.platform || 'unknown'} · ${device.appVersion || '—'}`),
|
|
483
|
+
),
|
|
484
|
+
h('div', { className: 'dd-deviceSide' },
|
|
485
|
+
h('div', { className: 'dd-deviceTimes' },
|
|
486
|
+
h('span', { className: 'dd-deviceTime' }, `${t('lastSeen')} ${formatDeviceTime(device.lastSeenAt)}`),
|
|
487
|
+
h('span', { className: 'dd-deviceTime' }, `${t('pairedAt')} ${formatDeviceTime(device.pairedAt)}`),
|
|
488
|
+
),
|
|
489
|
+
h('div', { className: 'dd-deviceAction' },
|
|
490
|
+
h(Button, {
|
|
491
|
+
variant: 'ghost',
|
|
492
|
+
size: 'sm',
|
|
493
|
+
disabled: busyDevice === device.deviceId,
|
|
494
|
+
onClick: () => { void revokeDevice(device) },
|
|
495
|
+
}, t('revoke'))),
|
|
496
|
+
),
|
|
497
|
+
)),
|
|
498
|
+
),
|
|
499
|
+
),
|
|
500
|
+
|
|
501
|
+
dialog === null ? null : h('div', {
|
|
502
|
+
className: 'dd-modalBackdrop',
|
|
503
|
+
onMouseDown: (event) => {
|
|
504
|
+
if (event.target === event.currentTarget) setDialog(null)
|
|
505
|
+
},
|
|
506
|
+
},
|
|
507
|
+
h('div', { className: 'dd-modal', role: 'dialog', 'aria-modal': 'true' },
|
|
508
|
+
h('h3', { className: 'dd-modalTitle' },
|
|
509
|
+
dialog === 'permanent'
|
|
510
|
+
? (fixed ? t('modifyTitle') : t('setPermanentTitle'))
|
|
511
|
+
: t('resetTitle')),
|
|
512
|
+
h('p', { className: 'dd-desc' },
|
|
513
|
+
dialog === 'permanent'
|
|
514
|
+
? (fixed ? t('modifyDesc') : t('setPermanentDesc'))
|
|
515
|
+
: t('resetDesc')),
|
|
516
|
+
dialog === 'permanent'
|
|
517
|
+
? h(Input, {
|
|
518
|
+
className: 'dd-modalInput',
|
|
519
|
+
value: password,
|
|
520
|
+
placeholder: t('passwordPlaceholder'),
|
|
521
|
+
autoFocus: true,
|
|
522
|
+
autoComplete: 'off',
|
|
523
|
+
onChange: event => setPassword(event.target.value.replace(/\D/g, '').slice(0, 4)),
|
|
524
|
+
})
|
|
525
|
+
: null,
|
|
526
|
+
dialogError === null ? null : h('p', { className: 'dd-error' }, dialogError),
|
|
527
|
+
h('div', { className: 'dd-modalActions' },
|
|
528
|
+
h(Button, {
|
|
529
|
+
variant: 'ghost',
|
|
530
|
+
size: 'sm',
|
|
531
|
+
disabled: busy,
|
|
532
|
+
onClick: () => setDialog(null),
|
|
533
|
+
}, t('cancel')),
|
|
534
|
+
h(Button, {
|
|
535
|
+
variant: 'primary',
|
|
536
|
+
size: 'sm',
|
|
537
|
+
disabled: busy,
|
|
538
|
+
onClick: () => { void (dialog === 'permanent' ? confirmPermanent() : confirmReset()) },
|
|
539
|
+
}, t('confirm')),
|
|
540
|
+
),
|
|
541
|
+
)),
|
|
542
|
+
renameTarget === null ? null : h('div', {
|
|
543
|
+
className: 'dd-modalBackdrop',
|
|
544
|
+
onMouseDown: (event) => {
|
|
545
|
+
if (event.target === event.currentTarget) setRenameTarget(null)
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
h('div', { className: 'dd-modal', role: 'dialog', 'aria-modal': 'true' },
|
|
549
|
+
h('h3', { className: 'dd-modalTitle' }, t('renameTitle')),
|
|
550
|
+
h('p', { className: 'dd-desc' }, t('renameDesc')),
|
|
551
|
+
h(Input, {
|
|
552
|
+
className: 'dd-modalInput',
|
|
553
|
+
value: renameValue,
|
|
554
|
+
placeholder: t('renameTitle'),
|
|
555
|
+
autoFocus: true,
|
|
556
|
+
autoComplete: 'off',
|
|
557
|
+
onChange: event => setRenameValue(event.target.value.slice(0, 120)),
|
|
558
|
+
onKeyDown: (event) => {
|
|
559
|
+
if (event.key !== 'Enter') return
|
|
560
|
+
event.preventDefault()
|
|
561
|
+
void confirmRename()
|
|
562
|
+
},
|
|
563
|
+
}),
|
|
564
|
+
renameError === null ? null : h('p', { className: 'dd-error' }, renameError),
|
|
565
|
+
h('div', { className: 'dd-modalActions' },
|
|
566
|
+
h(Button, {
|
|
567
|
+
variant: 'ghost',
|
|
568
|
+
size: 'sm',
|
|
569
|
+
disabled: busyDevice === renameTarget.deviceId,
|
|
570
|
+
onClick: () => setRenameTarget(null),
|
|
571
|
+
}, t('cancel')),
|
|
572
|
+
h(Button, {
|
|
573
|
+
variant: 'primary',
|
|
574
|
+
size: 'sm',
|
|
575
|
+
disabled: busyDevice === renameTarget.deviceId,
|
|
576
|
+
onClick: () => { void confirmRename() },
|
|
577
|
+
}, t('confirm')),
|
|
578
|
+
),
|
|
579
|
+
)),
|
|
580
|
+
)
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
584
|
+
name: 'settings.section',
|
|
585
|
+
id: 'dsh-hello',
|
|
586
|
+
order: 5,
|
|
587
|
+
label: () => t('nav'),
|
|
588
|
+
}, AdminSection))
|
|
589
|
+
|
|
590
|
+
ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
|
|
591
|
+
name: 'settings.section.icon',
|
|
592
|
+
id: 'dsh-hello',
|
|
593
|
+
}, ({ size = 16, active }) => h('svg', {
|
|
594
|
+
width: size,
|
|
595
|
+
height: size,
|
|
596
|
+
viewBox: '0 0 16 16',
|
|
597
|
+
'aria-hidden': true,
|
|
598
|
+
},
|
|
599
|
+
h('path', {
|
|
600
|
+
d: 'M3 2.5h7v11H3z',
|
|
601
|
+
fill: active ? 'currentColor' : 'none',
|
|
602
|
+
stroke: 'currentColor',
|
|
603
|
+
strokeWidth: 1.2,
|
|
604
|
+
}),
|
|
605
|
+
h('path', {
|
|
606
|
+
d: 'M10 3.5l3 1v9l-3-1z',
|
|
607
|
+
fill: 'none',
|
|
608
|
+
stroke: 'currentColor',
|
|
609
|
+
strokeWidth: 1.2,
|
|
610
|
+
}))))
|
|
611
|
+
},
|
|
612
|
+
}
|
|
613
|
+
},
|
|
614
|
+
})
|