dsh-plugin-trim 0.3.5 → 0.3.7
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 +1 -1
- package/client.js +381 -24
- package/dist/index.js +56 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ dsh plugin --profile web add dsh-plugin-trim
|
|
|
13
13
|
从 GitHub Release 安装(备用,无需 npm):
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.
|
|
16
|
+
dsh plugin --profile web add "https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases/download/v0.3.7/dsh-plugin-trim-0.3.7.tgz"
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
本地开发:
|
package/client.js
CHANGED
|
@@ -25,6 +25,7 @@ window.__ModuleLoader__.load({
|
|
|
25
25
|
|
|
26
26
|
const LOCALE_KEY = 'dsh-experience-optimizer.locale'
|
|
27
27
|
const ONBOARDING_KEY = 'dsh-experience-optimizer.onboarding.v1'
|
|
28
|
+
const MAIN_GUIDE_KEY = 'dsh-experience-optimizer.main-guide.v1'
|
|
28
29
|
const ABOUT_LINKS = {
|
|
29
30
|
repo: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer',
|
|
30
31
|
npmTrim: 'https://www.npmjs.com/package/dsh-plugin-trim',
|
|
@@ -32,7 +33,7 @@ window.__ModuleLoader__.load({
|
|
|
32
33
|
releases: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer/releases',
|
|
33
34
|
issues: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer/issues',
|
|
34
35
|
homepage: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer',
|
|
35
|
-
qqGroup: '',
|
|
36
|
+
qqGroup: '1134419871',
|
|
36
37
|
qqLink: '',
|
|
37
38
|
donate: [],
|
|
38
39
|
}
|
|
@@ -191,6 +192,14 @@ window.__ModuleLoader__.load({
|
|
|
191
192
|
const storage = browserStorage()
|
|
192
193
|
try { if (storage) storage.removeItem(ONBOARDING_KEY) } catch { /* ignore */ }
|
|
193
194
|
}
|
|
195
|
+
function readPref(key, fallback) {
|
|
196
|
+
const storage = browserStorage()
|
|
197
|
+
try { return (storage && storage.getItem('dsh-experience-optimizer.' + key)) || fallback } catch { return fallback }
|
|
198
|
+
}
|
|
199
|
+
function writePref(key, value) {
|
|
200
|
+
const storage = browserStorage()
|
|
201
|
+
try { if (storage) storage.setItem('dsh-experience-optimizer.' + key, value) } catch { /* ignore */ }
|
|
202
|
+
}
|
|
194
203
|
|
|
195
204
|
const CSS = `
|
|
196
205
|
.eo-root{--eo-primary:var(--dsw-alias-label-primary,#1a1a1a);--eo-secondary:var(--dsw-alias-label-secondary,#5f6b7a);--eo-tertiary:var(--dsw-alias-label-tertiary,#8b96a5);--eo-border:var(--dsw-alias-border-l2,rgba(127,127,127,.16));--eo-border-strong:var(--dsw-alias-border-l3,rgba(127,127,127,.24));--eo-card-bg:var(--dsw-alias-settings-card-fill,transparent);--eo-card-stroke:var(--dsw-alias-settings-card-stroke,var(--dsw-alias-border-l2,rgba(127,127,127,.16)));--eo-hover:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.06));--eo-error:var(--dsw-alias-state-error-primary,#c4314b);--eo-success:var(--dsw-alias-state-success-primary,#1a7f37);--eo-code:var(--ds-font-family-code,"JetBrains Maple Mono",ui-monospace,monospace);--eo-radius:var(--dsw-radius-lg,12px);max-width:760px;color:var(--eo-primary);font-size:13px;line-height:20px;display:flex;flex-direction:column;gap:14px}
|
|
@@ -261,6 +270,47 @@ window.__ModuleLoader__.load({
|
|
|
261
270
|
.eo-metric-hint{font-size:11px;line-height:16px;color:var(--eo-tertiary);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
262
271
|
.eo-card{padding:14px;border:.5px solid var(--eo-card-stroke);border-radius:var(--eo-radius);background:var(--eo-card-bg)}
|
|
263
272
|
.eo-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin-bottom:10px}
|
|
273
|
+
.eo-card-toggle{appearance:none;border:0;background:transparent;color:inherit;font:inherit;padding:0;margin:0;display:flex;align-items:flex-start;gap:7px;text-align:left;cursor:pointer;min-width:0}
|
|
274
|
+
.eo-card-toggle:hover .eo-card-title{text-decoration:underline;text-underline-offset:3px}
|
|
275
|
+
.eo-card-chevron{display:inline-flex;align-items:center;color:var(--eo-tertiary);margin-top:3px;transition:transform .15s ease}
|
|
276
|
+
.eo-card-toggle[aria-expanded="false"] .eo-card-chevron{transform:rotate(-90deg)}
|
|
277
|
+
.eo-card-body{min-width:0}
|
|
278
|
+
.eo-viewbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:0 0 2px;padding:8px 10px;border:.5px solid var(--eo-border);border-radius:8px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.03))}
|
|
279
|
+
.eo-viewbar-label{font-size:11px;color:var(--eo-tertiary);white-space:nowrap}
|
|
280
|
+
.eo-viewbar .eo-inline{gap:4px}
|
|
281
|
+
.eo-viewbar .eo-btn{height:26px;font-size:11px;padding:0 8px;border-radius:6px}
|
|
282
|
+
.eo-viewbar .eo-btn-active{border-color:var(--eo-primary);color:var(--eo-primary);background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.06))}
|
|
283
|
+
.eo-density-compact .eo-card{padding:10px}
|
|
284
|
+
.eo-density-compact .eo-stack,.eo-stack.eo-density-compact{gap:8px}
|
|
285
|
+
.eo-density-compact .eo-item{padding:7px 0}
|
|
286
|
+
.eo-density-compact .eo-metric{padding:9px 11px}
|
|
287
|
+
.eo-layout-two .eo-findings{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px}
|
|
288
|
+
.eo-layout-two .eo-finding{padding:8px 0}
|
|
289
|
+
.eo-layout-two .eo-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:0 18px}
|
|
290
|
+
.eo-layout-two .eo-item{padding:8px 0}
|
|
291
|
+
.eo-layout-two .eo-owner-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 18px}
|
|
292
|
+
.eo-inventory-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
|
|
293
|
+
.eo-inventory-card{border:.5px solid var(--eo-border);border-radius:8px;padding:9px 10px;min-width:0}
|
|
294
|
+
.eo-inventory-card-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
|
|
295
|
+
.eo-inventory-card code{font:400 11px/16px var(--eo-code);word-break:break-all;color:var(--eo-secondary)}
|
|
296
|
+
.eo-inventory-card-meta{display:flex;gap:10px;flex-wrap:wrap;margin-top:6px;color:var(--eo-tertiary);font-size:11px}
|
|
297
|
+
.eo-main-guide{position:fixed;right:24px;left:auto;bottom:24px;z-index:30;width:min(340px,calc(100vw - 32px));padding:14px 16px;border:.5px solid var(--dsw-alias-border-l4,rgba(127,127,127,.25));border-radius:14px;background:var(--dsw-alias-bg-layer-1,#fff);box-shadow:0 14px 44px rgba(0,0,0,.2);color:var(--eo-primary);font-size:13px;line-height:20px}
|
|
298
|
+
.eo-guide-arrow{position:absolute;left:-16px;top:-20px;width:44px;height:44px;border-radius:50%;display:grid;place-items:center;background:var(--dsw-alias-button-primary-fill,var(--eo-primary));color:var(--dsw-alias-label-primary-inverted,#fff);transform:rotate(-12deg);box-shadow:0 8px 20px rgba(0,0,0,.18)}
|
|
299
|
+
.eo-guide-kicker{margin:0 0 3px;color:var(--eo-tertiary);font:500 10px/16px var(--eo-code);letter-spacing:.12em}
|
|
300
|
+
.eo-main-guide h3{margin:0 0 8px;font-size:16px;line-height:23px}
|
|
301
|
+
.eo-guide-path{display:flex;align-items:center;gap:5px;flex-wrap:wrap;margin:0 0 8px;font-size:12px;font-weight:500}
|
|
302
|
+
.eo-guide-path span{padding:2px 7px;border-radius:5px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08))}
|
|
303
|
+
.eo-guide-path i{font-style:normal;color:var(--eo-tertiary)}
|
|
304
|
+
.eo-guide-note{margin:0;color:var(--eo-tertiary);font-size:11px;line-height:17px}
|
|
305
|
+
.eo-guide-steps{max-height:220px;overflow:auto;margin:10px 0 0;padding:0;list-style:none;border-top:.5px solid var(--eo-border)}
|
|
306
|
+
.eo-guide-steps li{display:flex;gap:7px;align-items:flex-start;padding:7px 0;border-bottom:.5px solid var(--eo-border)}
|
|
307
|
+
.eo-guide-steps b{font:500 10px/18px var(--eo-code);color:var(--eo-tertiary);flex:0 0 auto}
|
|
308
|
+
.eo-guide-steps span{flex:0 0 auto;font-weight:500;font-size:12px}
|
|
309
|
+
.eo-guide-steps small{color:var(--eo-tertiary);font-size:11px;line-height:17px}
|
|
310
|
+
.eo-guide-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:12px}
|
|
311
|
+
.eo-main-guide .eo-btn{height:28px;font-size:11px;padding:0 9px}
|
|
312
|
+
@media(max-width:600px){.eo-main-guide{left:12px;right:12px;bottom:12px;width:auto}.eo-guide-arrow{display:none}}
|
|
313
|
+
.eo-about-hero{display:block;width:100%;height:auto;border-radius:12px;background:#0b1422;margin:0 0 10px}
|
|
264
314
|
.eo-card-title{margin:0;font-size:14px;line-height:22px;font-weight:500;letter-spacing:0}
|
|
265
315
|
.eo-card-sub{margin:2px 0 0;font-size:12px;line-height:18px;color:var(--eo-tertiary)}
|
|
266
316
|
.eo-btn{appearance:none;height:32px;padding:0 12px;border:.5px solid var(--eo-border-strong);border-radius:var(--dsw-radius-md,8px);background:transparent;color:var(--eo-primary);font:inherit;font-size:13px;line-height:20px;font-weight:500;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:6px;white-space:nowrap;transition:background .14s ease,border-color .14s ease,opacity .14s ease}
|
|
@@ -351,6 +401,14 @@ window.__ModuleLoader__.load({
|
|
|
351
401
|
.eo-note{padding:9px 12px;border:1px solid var(--dsw-alias-border-l3);border-radius:8px;background:var(--dsw-alias-bg-layer-3);color:var(--eo-secondary);font-size:12px;line-height:19px}
|
|
352
402
|
.eo-code{font:400 11px/16px var(--eo-code);color:var(--eo-secondary);word-break:break-all}
|
|
353
403
|
.eo-steps{margin:0;padding-left:20px;color:var(--eo-secondary);font-size:13px;line-height:22px}
|
|
404
|
+
.eo-tutorial-flow{position:relative;display:flex;flex-direction:column;gap:0}
|
|
405
|
+
.eo-tutorial-step{display:flex;gap:12px;position:relative;padding:0 0 14px}
|
|
406
|
+
.eo-tutorial-step:before{content:"";position:absolute;left:16px;top:34px;bottom:0;width:1px;background:var(--eo-border)}
|
|
407
|
+
.eo-tutorial-step:last-child:before{display:none}
|
|
408
|
+
.eo-tutorial-num{width:34px;height:34px;border-radius:50%;display:grid;place-items:center;flex:0 0 auto;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.08));border:1px solid var(--eo-border);color:var(--eo-secondary);font:500 10px/1 var(--eo-code)}
|
|
409
|
+
.eo-tutorial-copy{min-width:0;padding-top:1px}
|
|
410
|
+
.eo-tutorial-copy strong{display:block;font-size:13px;line-height:21px;color:var(--eo-primary)}
|
|
411
|
+
.eo-tutorial-copy p{margin:1px 0 0;color:var(--eo-tertiary);font-size:12px;line-height:19px}
|
|
354
412
|
.eo-steps li{margin:0 0 8px;padding-left:2px}
|
|
355
413
|
.eo-steps strong{color:var(--eo-primary);font-weight:500}
|
|
356
414
|
.eo-settings-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 18px}
|
|
@@ -368,14 +426,18 @@ window.__ModuleLoader__.load({
|
|
|
368
426
|
.eo-spacer{height:0}
|
|
369
427
|
@keyframes eo-spin{to{transform:rotate(360deg)}}
|
|
370
428
|
@keyframes eo-in{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
|
|
371
|
-
@media(max-width:820px){.eo-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.eo-metric:nth-child(2){border-right:0}.eo-metric:nth-child(-n+2){border-bottom:.5px solid var(--eo-border)}.eo-form-grid{grid-template-columns:1fr}.eo-hero{flex-wrap:wrap}.eo-hero-actions{margin-left:0}}
|
|
429
|
+
@media(max-width:820px){.eo-layout-two .eo-findings,.eo-layout-two .eo-list,.eo-layout-two .eo-owner-list,.eo-inventory-grid{grid-template-columns:1fr}.eo-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.eo-metric:nth-child(2){border-right:0}.eo-metric:nth-child(-n+2){border-bottom:.5px solid var(--eo-border)}.eo-form-grid{grid-template-columns:1fr}.eo-hero{flex-wrap:wrap}.eo-hero-actions{margin-left:0}}
|
|
372
430
|
@media(max-width:520px){.eo-metrics{grid-template-columns:1fr}.eo-metric{border-right:0;border-bottom:.5px solid var(--eo-border)}.eo-metric:last-child{border-bottom:0}}
|
|
373
431
|
`
|
|
374
432
|
|
|
375
433
|
|
|
376
434
|
function injectCss() {
|
|
377
435
|
if (typeof document === 'undefined') return
|
|
378
|
-
|
|
436
|
+
const existing = document.querySelector('style[data-plugin-css="' + CSS_ID + '"]')
|
|
437
|
+
if (existing !== null) {
|
|
438
|
+
existing.textContent = CSS
|
|
439
|
+
return
|
|
440
|
+
}
|
|
379
441
|
const tag = document.createElement('style')
|
|
380
442
|
tag.dataset.pluginCss = CSS_ID
|
|
381
443
|
tag.textContent = CSS
|
|
@@ -411,7 +473,13 @@ window.__ModuleLoader__.load({
|
|
|
411
473
|
)
|
|
412
474
|
}
|
|
413
475
|
|
|
414
|
-
function Card({ title, subtitle, extra, children, className = '', section }) {
|
|
476
|
+
function Card({ title, subtitle, extra, children, className = '', section, collapsible = false, collapsed = false, onToggle }) {
|
|
477
|
+
const heading = h(
|
|
478
|
+
'div',
|
|
479
|
+
null,
|
|
480
|
+
title ? h('h3', { className: 'eo-card-title' }, title) : null,
|
|
481
|
+
subtitle ? h('p', { className: 'eo-card-sub' }, subtitle) : null,
|
|
482
|
+
)
|
|
415
483
|
return h(
|
|
416
484
|
'section',
|
|
417
485
|
{ className: 'eo-card ' + className, 'data-section': section },
|
|
@@ -419,16 +487,25 @@ window.__ModuleLoader__.load({
|
|
|
419
487
|
? h(
|
|
420
488
|
'div',
|
|
421
489
|
{ className: 'eo-card-head' },
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
490
|
+
collapsible
|
|
491
|
+
? h(
|
|
492
|
+
'button',
|
|
493
|
+
{
|
|
494
|
+
type: 'button',
|
|
495
|
+
className: 'eo-card-toggle',
|
|
496
|
+
'aria-expanded': !collapsed,
|
|
497
|
+
onClick: onToggle,
|
|
498
|
+
},
|
|
499
|
+
h('span', { className: 'eo-card-chevron' }, h(Icon, { name: 'chevron', size: 14 })),
|
|
500
|
+
heading,
|
|
501
|
+
)
|
|
502
|
+
: heading,
|
|
428
503
|
extra || null,
|
|
429
504
|
)
|
|
430
505
|
: null,
|
|
431
|
-
|
|
506
|
+
collapsible && collapsed
|
|
507
|
+
? null
|
|
508
|
+
: h('div', { className: 'eo-card-body' }, children),
|
|
432
509
|
)
|
|
433
510
|
}
|
|
434
511
|
|
|
@@ -623,6 +700,8 @@ window.__ModuleLoader__.load({
|
|
|
623
700
|
['rect', { x: '4', y: '14', width: '6', height: '6', rx: '1' }],
|
|
624
701
|
['rect', { x: '14', y: '14', width: '6', height: '6', rx: '1' }],
|
|
625
702
|
],
|
|
703
|
+
chevron: [['path', { d: 'M6 9l6 6 6-6' }]],
|
|
704
|
+
arrow: [['path', { d: 'M19 5L5 19M5 9v10h10' }]],
|
|
626
705
|
}
|
|
627
706
|
|
|
628
707
|
function Icon({ name, size = 16 }) {
|
|
@@ -747,12 +826,106 @@ window.__ModuleLoader__.load({
|
|
|
747
826
|
)
|
|
748
827
|
}
|
|
749
828
|
|
|
829
|
+
function AboutHero() {
|
|
830
|
+
return h(
|
|
831
|
+
'svg',
|
|
832
|
+
{
|
|
833
|
+
viewBox: '0 0 1200 300',
|
|
834
|
+
className: 'eo-about-hero',
|
|
835
|
+
role: 'img',
|
|
836
|
+
'aria-label': tr('DSH 体验优化器', 'DSH Experience Optimizer'),
|
|
837
|
+
},
|
|
838
|
+
h('defs', null,
|
|
839
|
+
h('linearGradient', { id: 'eo-about-bg', x1: '0', y1: '0', x2: '1', y2: '1' },
|
|
840
|
+
h('stop', { offset: '0', stopColor: '#0a1220' }),
|
|
841
|
+
h('stop', { offset: '1', stopColor: '#101f34' }),
|
|
842
|
+
),
|
|
843
|
+
),
|
|
844
|
+
h('rect', { width: '1200', height: '300', rx: '18', fill: 'url(#eo-about-bg)' }),
|
|
845
|
+
h('circle', { cx: '1010', cy: '150', r: '94', fill: 'none', stroke: '#2a405e' }),
|
|
846
|
+
h('circle', { cx: '1010', cy: '150', r: '58', fill: 'none', stroke: '#355070' }),
|
|
847
|
+
h('path', { d: 'M944 116 L1004 88 L1076 112 L1092 174 L1038 214 L962 190 Z', fill: 'none', stroke: '#45658a', strokeWidth: '1.4' }),
|
|
848
|
+
h('path', { d: 'M944 116 L1038 214 M1004 88 L962 190 M1076 112 L944 116', stroke: '#334d6b' }),
|
|
849
|
+
[[944,116],[1004,88],[1076,112],[1092,174],[1038,214],[962,190]].map(([cx,cy],i) =>
|
|
850
|
+
h('circle', { key: i, cx, cy, r: 8, fill: '#0f1b2c', stroke: '#5eead4', strokeWidth: 1.5 }),
|
|
851
|
+
),
|
|
852
|
+
h('circle', { cx: '1010', cy: '150', r: '34', fill: '#0c1728', stroke: '#fbbf24', strokeWidth: 1.5 }),
|
|
853
|
+
h('path', { d: 'M1010 127 L1028 136 L1028 154 C1028 168 1019 177 1010 181 C1001 177 992 168 992 154 L992 136 Z', fill: 'none', stroke: '#fbbf24', strokeWidth: 1.8 }),
|
|
854
|
+
h('path', { d: 'M1002 151 L1008 157 L1019 144', fill: 'none', stroke: '#fbbf24', strokeWidth: 2, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
855
|
+
h('text', { x: '64', y: '72', fill: '#5eead4', fontFamily: 'ui-monospace, monospace', fontSize: '13', letterSpacing: '2.4' }, 'DSH PLUGIN SUITE · AGPL-3.0'),
|
|
856
|
+
h('text', { x: '62', y: '142', fill: '#f2f7ff', fontFamily: 'Noto Sans SC, sans-serif', fontSize: '44', fontWeight: '700' }, tr('DSH 体验优化器', 'DSH Experience Optimizer')),
|
|
857
|
+
h('text', { x: '64', y: '184', fill: '#c3d3e8', fontFamily: 'Noto Sans SC, sans-serif', fontSize: '20' }, tr('少一点插件负担,多一点兼容确定性。', 'Less plugin overhead, more compatibility certainty.')),
|
|
858
|
+
h('g', { transform: 'translate(64 220)' },
|
|
859
|
+
[tr('插件减负', 'Plugin diet'), tr('兼容性', 'Compatibility'), tr('工作流配方', 'Workflow recipe')].map((label, i) =>
|
|
860
|
+
h('g', { key: label, transform: `translate(${i * 150} 0)` },
|
|
861
|
+
h('rect', { width: '138', height: '30', rx: '15', fill: 'rgba(94,234,212,.08)', stroke: 'rgba(94,234,212,.35)' }),
|
|
862
|
+
h('circle', { cx: '16', cy: '15', r: '3', fill: ['#5eead4','#60a5fa','#fbbf24'][i] }),
|
|
863
|
+
h('text', { x: '28', y: '20', fill: '#dce9f9', fontFamily: 'Noto Sans SC, sans-serif', fontSize: '13' }, label),
|
|
864
|
+
),
|
|
865
|
+
),
|
|
866
|
+
),
|
|
867
|
+
h('text', { x: '64', y: '286', fill: '#7f93b0', fontFamily: 'ui-monospace, monospace', fontSize: '11', letterSpacing: '1.2' }, 'github.com/Starlit-Sky-code/dsh-experience-optimizer'),
|
|
868
|
+
)
|
|
869
|
+
}
|
|
870
|
+
|
|
871
|
+
function MainGuide() {
|
|
872
|
+
const [visible, setVisible] = useState(() => {
|
|
873
|
+
const storage = browserStorage()
|
|
874
|
+
try { return storage ? storage.getItem(MAIN_GUIDE_KEY) !== '1' : true } catch { return true }
|
|
875
|
+
})
|
|
876
|
+
const [stepsOpen, setStepsOpen] = useState(false)
|
|
877
|
+
const dismiss = () => {
|
|
878
|
+
const storage = browserStorage()
|
|
879
|
+
try { if (storage) storage.setItem(MAIN_GUIDE_KEY, '1') } catch { /* ignore */ }
|
|
880
|
+
setVisible(false)
|
|
881
|
+
}
|
|
882
|
+
if (!visible) return null
|
|
883
|
+
const steps = [
|
|
884
|
+
[tr('点击「更多」', 'Open “More”'), tr('在 DSH 主界面打开更多菜单。', 'Open the More menu on the DSH main screen.')],
|
|
885
|
+
[tr('点击「设置」', 'Open “Settings”'), tr('进入设置页。', 'Open Settings.')],
|
|
886
|
+
[tr('点击「体验优化」', 'Open “Experience Optimizer”'), tr('在 Agent 预设下方或插件页签里找到体验优化。', 'Find it below Agent presets or in the plugins tab.')],
|
|
887
|
+
[tr('生成减负方案', 'Build a slim plan'), tr('选任务或写目标,先看依据,再决定是否应用。', 'Pick a task or goal, read the evidence, then decide.')],
|
|
888
|
+
[tr('需要时看教程', 'Open the guide'), tr('教程、常见问题和关于都在同一页。', 'Guide, FAQ, and About live in the same panel.')],
|
|
889
|
+
]
|
|
890
|
+
return h(
|
|
891
|
+
'div',
|
|
892
|
+
{ className: 'eo-main-guide', role: 'dialog', 'aria-label': tr('初次使用路径', 'First-run path') },
|
|
893
|
+
h('div', { className: 'eo-guide-arrow' }, h(Icon, { name: 'arrow', size: 22 })),
|
|
894
|
+
h('p', { className: 'eo-guide-kicker' }, tr('初次使用', 'FIRST RUN')),
|
|
895
|
+
h('h3', null, tr('从这里打开体验优化', 'Open Experience Optimizer here')),
|
|
896
|
+
h(
|
|
897
|
+
'div',
|
|
898
|
+
{ className: 'eo-guide-path' },
|
|
899
|
+
h('span', null, tr('更多', 'More')),
|
|
900
|
+
h('i', null, '→'),
|
|
901
|
+
h('span', null, tr('设置', 'Settings')),
|
|
902
|
+
h('i', null, '→'),
|
|
903
|
+
h('span', null, tr('体验优化', 'Experience Optimizer')),
|
|
904
|
+
),
|
|
905
|
+
h('p', { className: 'eo-guide-note' }, tr('打开后会自动出现 5 步教程;也可以先看这里的路径。', 'A five-step guide opens there; you can follow this path first.')),
|
|
906
|
+
stepsOpen
|
|
907
|
+
? h('ol', { className: 'eo-guide-steps' }, steps.map(([title, body], index) =>
|
|
908
|
+
h('li', { key: title }, h('b', null, String(index + 1).padStart(2, '0')), h('span', null, title), h('small', null, body)),
|
|
909
|
+
))
|
|
910
|
+
: null,
|
|
911
|
+
h(
|
|
912
|
+
'div',
|
|
913
|
+
{ className: 'eo-guide-actions' },
|
|
914
|
+
h(Button, { variant: 'ghost', onClick: () => setStepsOpen((value) => !value) }, stepsOpen ? tr('收起步骤', 'Hide steps') : tr('查看 5 步教程', 'Show 5 steps')),
|
|
915
|
+
h(Button, { variant: 'accent', onClick: dismiss }, tr('知道了', 'Got it')),
|
|
916
|
+
),
|
|
917
|
+
)
|
|
918
|
+
}
|
|
919
|
+
|
|
750
920
|
function ExperiencePanel() {
|
|
751
921
|
|
|
752
922
|
const [tab, setTab] = useState('trim')
|
|
753
923
|
const [locale, setLocale] = useState(detectLocale)
|
|
754
924
|
const [showOnboarding, setShowOnboarding] = useState(false)
|
|
755
925
|
const [onboardingStep, setOnboardingStep] = useState(0)
|
|
926
|
+
const [collapsedCards, setCollapsedCards] = useState({ context: true })
|
|
927
|
+
const [layout, setLayout] = useState(() => readPref('layout', 'standard'))
|
|
928
|
+
const [density, setDensity] = useState(() => readPref('density', 'comfortable'))
|
|
756
929
|
const [overview, setOverview] = useState(null)
|
|
757
930
|
const [loading, setLoading] = useState(true)
|
|
758
931
|
const [error, setError] = useState('')
|
|
@@ -789,6 +962,8 @@ window.__ModuleLoader__.load({
|
|
|
789
962
|
const [settings, setSettings] = useState(null)
|
|
790
963
|
const [settingsBusy, setSettingsBusy] = useState(false)
|
|
791
964
|
const [settingsError, setSettingsError] = useState('')
|
|
965
|
+
const [updateInfo, setUpdateInfo] = useState(null)
|
|
966
|
+
const [updateBusy, setUpdateBusy] = useState(false)
|
|
792
967
|
CURRENT_LOCALE = locale
|
|
793
968
|
|
|
794
969
|
const notify = useCallback((message, kind) => {
|
|
@@ -845,6 +1020,22 @@ window.__ModuleLoader__.load({
|
|
|
845
1020
|
setShowOnboarding(true)
|
|
846
1021
|
}, [])
|
|
847
1022
|
|
|
1023
|
+
const toggleCard = useCallback((id) => {
|
|
1024
|
+
setCollapsedCards((current) => ({ ...current, [id]: !current[id] }))
|
|
1025
|
+
}, [])
|
|
1026
|
+
const collapseAllCards = useCallback(() => {
|
|
1027
|
+
setCollapsedCards({ draft: true, inventory: true, compat: true, context: true, result: true, dedupe: true, diagnostics: true })
|
|
1028
|
+
}, [])
|
|
1029
|
+
const expandAllCards = useCallback(() => setCollapsedCards({}), [])
|
|
1030
|
+
const changeLayout = useCallback((value) => {
|
|
1031
|
+
setLayout(value)
|
|
1032
|
+
writePref('layout', value)
|
|
1033
|
+
}, [])
|
|
1034
|
+
const changeDensity = useCallback((value) => {
|
|
1035
|
+
setDensity(value)
|
|
1036
|
+
writePref('density', value)
|
|
1037
|
+
}, [])
|
|
1038
|
+
|
|
848
1039
|
const loadSettings = useCallback(async () => {
|
|
849
1040
|
setSettingsBusy(true)
|
|
850
1041
|
setSettingsError('')
|
|
@@ -857,6 +1048,22 @@ window.__ModuleLoader__.load({
|
|
|
857
1048
|
}
|
|
858
1049
|
}, [])
|
|
859
1050
|
|
|
1051
|
+
const checkUpdate = useCallback(async () => {
|
|
1052
|
+
setUpdateBusy(true)
|
|
1053
|
+
try {
|
|
1054
|
+
setUpdateInfo(await fetchJson(API + '/update'))
|
|
1055
|
+
} catch (err) {
|
|
1056
|
+
setUpdateInfo({
|
|
1057
|
+
current: '0.3.6',
|
|
1058
|
+
latest: null,
|
|
1059
|
+
updateAvailable: false,
|
|
1060
|
+
error: err instanceof Error ? err.message : String(err),
|
|
1061
|
+
})
|
|
1062
|
+
} finally {
|
|
1063
|
+
setUpdateBusy(false)
|
|
1064
|
+
}
|
|
1065
|
+
}, [])
|
|
1066
|
+
|
|
860
1067
|
const findings = useMemo(() => {
|
|
861
1068
|
if (!overview) return []
|
|
862
1069
|
const query = findingQuery.trim().toLowerCase()
|
|
@@ -1239,12 +1446,26 @@ window.__ModuleLoader__.load({
|
|
|
1239
1446
|
{ className: 'eo-stack' },
|
|
1240
1447
|
h(
|
|
1241
1448
|
Card,
|
|
1242
|
-
{
|
|
1449
|
+
{
|
|
1450
|
+
title: tr('5 分钟上手', 'Five-minute guide'),
|
|
1451
|
+
subtitle: tr('从扫描到应用,每一步都可恢复', 'From scan to apply, every step is recoverable'),
|
|
1452
|
+
extra: h(Badge, { tone: 'info' }, tr('5 步', '5 steps')),
|
|
1453
|
+
},
|
|
1243
1454
|
h(
|
|
1244
|
-
'
|
|
1245
|
-
{ className: 'eo-
|
|
1455
|
+
'div',
|
|
1456
|
+
{ className: 'eo-tutorial-flow' },
|
|
1246
1457
|
steps.map(([zhTitle, enTitle, zhBody, enBody], index) =>
|
|
1247
|
-
h(
|
|
1458
|
+
h(
|
|
1459
|
+
'div',
|
|
1460
|
+
{ className: 'eo-tutorial-step', key: enTitle },
|
|
1461
|
+
h('div', { className: 'eo-tutorial-num' }, String(index + 1).padStart(2, '0')),
|
|
1462
|
+
h(
|
|
1463
|
+
'div',
|
|
1464
|
+
{ className: 'eo-tutorial-copy' },
|
|
1465
|
+
h('strong', null, tr(zhTitle, enTitle)),
|
|
1466
|
+
h('p', null, tr(zhBody, enBody)),
|
|
1467
|
+
),
|
|
1468
|
+
),
|
|
1248
1469
|
),
|
|
1249
1470
|
),
|
|
1250
1471
|
),
|
|
@@ -1323,6 +1544,79 @@ window.__ModuleLoader__.load({
|
|
|
1323
1544
|
return h(
|
|
1324
1545
|
'div',
|
|
1325
1546
|
{ className: 'eo-stack' },
|
|
1547
|
+
h(
|
|
1548
|
+
Card,
|
|
1549
|
+
{
|
|
1550
|
+
title: tr('界面偏好', 'Interface preferences'),
|
|
1551
|
+
subtitle: tr('只作用于插件减负页;偏好保存在本浏览器', 'Applies to the Plugin diet page; saved in this browser'),
|
|
1552
|
+
},
|
|
1553
|
+
h(
|
|
1554
|
+
'div',
|
|
1555
|
+
{ className: 'eo-settings-row' },
|
|
1556
|
+
h('span', null, tr('内容排列', 'Content layout')),
|
|
1557
|
+
h(
|
|
1558
|
+
'div',
|
|
1559
|
+
{ className: 'eo-inline' },
|
|
1560
|
+
h(Button, { variant: 'ghost', className: layout === 'standard' ? 'eo-btn-active' : '', onClick: () => changeLayout('standard') }, tr('标准', 'Standard')),
|
|
1561
|
+
h(Button, { variant: 'ghost', className: layout === 'two' ? 'eo-btn-active' : '', onClick: () => changeLayout('two') }, tr('双列', 'Two-column')),
|
|
1562
|
+
),
|
|
1563
|
+
),
|
|
1564
|
+
h(
|
|
1565
|
+
'div',
|
|
1566
|
+
{ className: 'eo-settings-row' },
|
|
1567
|
+
h('span', null, tr('密度', 'Density')),
|
|
1568
|
+
h(
|
|
1569
|
+
'div',
|
|
1570
|
+
{ className: 'eo-inline' },
|
|
1571
|
+
h(Button, { variant: 'ghost', className: density === 'comfortable' ? 'eo-btn-active' : '', onClick: () => changeDensity('comfortable') }, tr('舒适', 'Comfortable')),
|
|
1572
|
+
h(Button, { variant: 'ghost', className: density === 'compact' ? 'eo-btn-active' : '', onClick: () => changeDensity('compact') }, tr('紧凑', 'Compact')),
|
|
1573
|
+
),
|
|
1574
|
+
),
|
|
1575
|
+
h(
|
|
1576
|
+
'div',
|
|
1577
|
+
{ className: 'eo-settings-row' },
|
|
1578
|
+
h('span', null, tr('卡片', 'Cards')),
|
|
1579
|
+
h(
|
|
1580
|
+
'div',
|
|
1581
|
+
{ className: 'eo-inline' },
|
|
1582
|
+
h(Button, { variant: 'ghost', onClick: collapseAllCards }, tr('全部折叠', 'Collapse all')),
|
|
1583
|
+
h(Button, { variant: 'ghost', onClick: expandAllCards }, tr('全部展开', 'Expand all')),
|
|
1584
|
+
),
|
|
1585
|
+
),
|
|
1586
|
+
),
|
|
1587
|
+
h(
|
|
1588
|
+
Card,
|
|
1589
|
+
{
|
|
1590
|
+
title: tr('更新与反馈', 'Updates & feedback'),
|
|
1591
|
+
subtitle: tr('检查 npm 最新版本;反馈请走 GitHub Issues', 'Check the latest npm version; feedback via GitHub Issues'),
|
|
1592
|
+
},
|
|
1593
|
+
h(
|
|
1594
|
+
'div',
|
|
1595
|
+
{ className: 'eo-settings-row' },
|
|
1596
|
+
h('span', null, tr('当前版本', 'Current version')),
|
|
1597
|
+
h('code', null, updateInfo?.current || '0.3.6'),
|
|
1598
|
+
),
|
|
1599
|
+
h(
|
|
1600
|
+
'div',
|
|
1601
|
+
{ className: 'eo-settings-row' },
|
|
1602
|
+
h('span', null, tr('最新版本', 'Latest version')),
|
|
1603
|
+
h('code', null, updateInfo ? (updateInfo.latest || tr('检查失败', 'Check failed')) : tr('未检查', 'Not checked')),
|
|
1604
|
+
),
|
|
1605
|
+
updateInfo && updateInfo.updateAvailable
|
|
1606
|
+
? h('div', { className: 'eo-issue' }, h('span', null, tr('发现新版本:', 'New version available: ') + updateInfo.latest + ' · '), h('a', { href: updateInfo.url, target: '_blank', rel: 'noreferrer' }, tr('查看 npm', 'View npm')))
|
|
1607
|
+
: updateInfo && updateInfo.latest
|
|
1608
|
+
? h('div', { className: 'eo-issue' }, h('span', null, tr('已是最新版本。', 'You are on the latest version.')))
|
|
1609
|
+
: updateInfo && updateInfo.error
|
|
1610
|
+
? h('div', { className: 'eo-issue eo-issue-warn' }, h('span', null, tr('检查失败:', 'Check failed: ') + updateInfo.error))
|
|
1611
|
+
: null,
|
|
1612
|
+
h(
|
|
1613
|
+
'div',
|
|
1614
|
+
{ className: 'eo-inline', style: { marginTop: '10px' } },
|
|
1615
|
+
h(Button, { variant: 'accent', onClick: () => void checkUpdate(), disabled: updateBusy }, updateBusy ? tr('检查中…', 'Checking…') : tr('检查更新', 'Check for updates')),
|
|
1616
|
+
h('a', { className: 'eo-btn eo-btn-ghost', href: 'https://github.com/Starlit-Sky-code/dsh-experience-optimizer/issues/new/choose', target: '_blank', rel: 'noreferrer' }, tr('新建 Issue', 'New issue')),
|
|
1617
|
+
h('a', { className: 'eo-btn eo-btn-ghost', href: ABOUT_LINKS.issues, target: '_blank', rel: 'noreferrer' }, tr('问题列表', 'Issues')),
|
|
1618
|
+
),
|
|
1619
|
+
),
|
|
1326
1620
|
h(
|
|
1327
1621
|
Card,
|
|
1328
1622
|
{
|
|
@@ -1400,6 +1694,7 @@ window.__ModuleLoader__.load({
|
|
|
1400
1694
|
subtitle: tr('插件减负、兼容性检查与工作流蓝图', 'Plugin diet, compatibility checks, and workflow recipes'),
|
|
1401
1695
|
section: 'about',
|
|
1402
1696
|
},
|
|
1697
|
+
h(AboutHero),
|
|
1403
1698
|
h(
|
|
1404
1699
|
'div',
|
|
1405
1700
|
{ className: 'eo-about-grid' },
|
|
@@ -1408,7 +1703,7 @@ window.__ModuleLoader__.load({
|
|
|
1408
1703
|
{ className: 'eo-about-card' },
|
|
1409
1704
|
h('div', { className: 'eo-inline', style: { marginBottom: '8px' } }, h(Icon, { name: 'shield', size: 24 }), h('strong', null, 'DSH Experience Optimizer')),
|
|
1410
1705
|
h('p', null, tr('少一点插件负担,多一点兼容确定性。', 'Less plugin overhead, more compatibility certainty.')),
|
|
1411
|
-
h('p', null, tr('版本:', 'Version: ') + '0.3.
|
|
1706
|
+
h('p', null, tr('版本:', 'Version: ') + '0.3.7 · AGPL-3.0-only'),
|
|
1412
1707
|
h('p', null, tr('作者:Starlit Sky', 'Author: Starlit Sky')),
|
|
1413
1708
|
),
|
|
1414
1709
|
h(
|
|
@@ -1484,9 +1779,59 @@ window.__ModuleLoader__.load({
|
|
|
1484
1779
|
}
|
|
1485
1780
|
|
|
1486
1781
|
function renderTrim() {
|
|
1782
|
+
const renderInventoryCards = () =>
|
|
1783
|
+
h(
|
|
1784
|
+
'div',
|
|
1785
|
+
{ className: 'eo-inventory-grid' },
|
|
1786
|
+
filteredBundles.slice(0, showAllBundles ? 200 : 12).map((bundle) =>
|
|
1787
|
+
h(
|
|
1788
|
+
'div',
|
|
1789
|
+
{ className: 'eo-inventory-card', key: bundle.name },
|
|
1790
|
+
h(
|
|
1791
|
+
'div',
|
|
1792
|
+
{ className: 'eo-inventory-card-head' },
|
|
1793
|
+
h('code', null, bundle.name),
|
|
1794
|
+
h(
|
|
1795
|
+
Badge,
|
|
1796
|
+
{ tone: bundle.enabled ? 'ok' : 'neutral' },
|
|
1797
|
+
bundle.enabled ? tr('已启用', 'Enabled') : tr('已禁用', 'Disabled'),
|
|
1798
|
+
),
|
|
1799
|
+
),
|
|
1800
|
+
bundle.description ? h('div', { className: 'eo-muted' }, bundle.description) : null,
|
|
1801
|
+
h(
|
|
1802
|
+
'div',
|
|
1803
|
+
{ className: 'eo-inventory-card-meta' },
|
|
1804
|
+
h('span', null, tr('上下文', 'Context') + ' ' + formatNumber(bundle.contextTokens)),
|
|
1805
|
+
h(
|
|
1806
|
+
'span',
|
|
1807
|
+
null,
|
|
1808
|
+
tr('占比', 'Share') +
|
|
1809
|
+
' ' +
|
|
1810
|
+
(totalContextTokens > 0
|
|
1811
|
+
? Math.round((bundle.contextTokens / totalContextTokens) * 100) + '%'
|
|
1812
|
+
: '—'),
|
|
1813
|
+
),
|
|
1814
|
+
h(
|
|
1815
|
+
'span',
|
|
1816
|
+
null,
|
|
1817
|
+
tr('调用', 'Calls') +
|
|
1818
|
+
' ' +
|
|
1819
|
+
formatNumber((bundle.usage?.calls ?? 0) + (bundle.usage?.sessionCalls ?? 0)),
|
|
1820
|
+
),
|
|
1821
|
+
bundle.protected ? h('span', null, tr('受保护', 'Protected')) : null,
|
|
1822
|
+
h('span', null, bundle.guardStatus ? guardLabel(bundle.guardStatus) : '—'),
|
|
1823
|
+
),
|
|
1824
|
+
),
|
|
1825
|
+
),
|
|
1826
|
+
)
|
|
1487
1827
|
return h(
|
|
1488
1828
|
'div',
|
|
1489
|
-
{
|
|
1829
|
+
{
|
|
1830
|
+
className:
|
|
1831
|
+
'eo-stack' +
|
|
1832
|
+
(layout === 'two' ? ' eo-layout-two' : '') +
|
|
1833
|
+
(density === 'compact' ? ' eo-density-compact' : ''),
|
|
1834
|
+
},
|
|
1490
1835
|
h('div', { className: 'eo-grid eo-metrics' }, [
|
|
1491
1836
|
h(Metric, {
|
|
1492
1837
|
key: 'tokens',
|
|
@@ -1525,7 +1870,7 @@ window.__ModuleLoader__.load({
|
|
|
1525
1870
|
{
|
|
1526
1871
|
title: tr('兼容性检查', 'Compatibility check'),
|
|
1527
1872
|
subtitle: tr('插件 ↔ 插件 · 插件 ↔ DSH · 当前配置 / 工作区', 'Plugin ↔ plugin · plugin ↔ DSH · profile / workspace'),
|
|
1528
|
-
section: 'compat',
|
|
1873
|
+
section: 'compat', collapsible: true, collapsed: collapsedCards.compat === true, onToggle: () => toggleCard('compat'),
|
|
1529
1874
|
extra: h(
|
|
1530
1875
|
'div',
|
|
1531
1876
|
{ className: 'eo-inline' },
|
|
@@ -1635,7 +1980,7 @@ window.__ModuleLoader__.load({
|
|
|
1635
1980
|
Card,
|
|
1636
1981
|
{
|
|
1637
1982
|
title: tr('上下文成本', 'Context cost'),
|
|
1638
|
-
section: 'context',
|
|
1983
|
+
section: 'context', collapsible: true, collapsed: collapsedCards.context === true, onToggle: () => toggleCard('context'),
|
|
1639
1984
|
subtitle:
|
|
1640
1985
|
'总计 ' +
|
|
1641
1986
|
formatNumber(overview.context.totalTokens) +
|
|
@@ -1726,7 +2071,7 @@ window.__ModuleLoader__.load({
|
|
|
1726
2071
|
{
|
|
1727
2072
|
title: tr('插件清单', 'Plugin inventory'),
|
|
1728
2073
|
subtitle: `${filteredBundles.length} / ${totalBundles} ` + tr('个匹配 · 只读', 'matched · read-only'),
|
|
1729
|
-
section: 'inventory',
|
|
2074
|
+
section: 'inventory', collapsible: true, collapsed: collapsedCards.inventory === true, onToggle: () => toggleCard('inventory'),
|
|
1730
2075
|
extra: h(
|
|
1731
2076
|
Button,
|
|
1732
2077
|
{ variant: 'ghost', onClick: () => setShowAllBundles((value) => !value) },
|
|
@@ -1780,7 +2125,9 @@ window.__ModuleLoader__.load({
|
|
|
1780
2125
|
),
|
|
1781
2126
|
filteredBundles.length === 0
|
|
1782
2127
|
? h('div', { className: 'eo-empty' }, tr('没有匹配的插件。', 'No matching plugins.'))
|
|
1783
|
-
:
|
|
2128
|
+
: layout === 'two'
|
|
2129
|
+
? renderInventoryCards()
|
|
2130
|
+
: h(
|
|
1784
2131
|
'div',
|
|
1785
2132
|
{ className: 'eo-table-wrap' },
|
|
1786
2133
|
h(
|
|
@@ -1857,7 +2204,7 @@ window.__ModuleLoader__.load({
|
|
|
1857
2204
|
{
|
|
1858
2205
|
title: tr('插件减负方案', 'Slim plan'),
|
|
1859
2206
|
subtitle: tr('先建议,后确认;受保护项永不改动', 'Suggest first, confirm later; protected items never change'),
|
|
1860
|
-
section: 'draft',
|
|
2207
|
+
section: 'draft', collapsible: true, collapsed: collapsedCards.draft === true, onToggle: () => toggleCard('draft'),
|
|
1861
2208
|
},
|
|
1862
2209
|
h(
|
|
1863
2210
|
'div',
|
|
@@ -2043,7 +2390,7 @@ window.__ModuleLoader__.load({
|
|
|
2043
2390
|
{
|
|
2044
2391
|
title: tr('应用结果', 'Apply result'),
|
|
2045
2392
|
subtitle: applyResult.rolledBack ? tr('中途失败,已自动恢复', 'Failed midway; automatically restored') : tr('变更已写入当前配置', 'Changes written to the current profile'),
|
|
2046
|
-
section: 'result',
|
|
2393
|
+
section: 'result', collapsible: true, collapsed: collapsedCards.result === true, onToggle: () => toggleCard('result'),
|
|
2047
2394
|
extra: h(
|
|
2048
2395
|
Badge,
|
|
2049
2396
|
{ tone: applyResult.rolledBack ? 'warn' : 'ok' },
|
|
@@ -2134,7 +2481,7 @@ window.__ModuleLoader__.load({
|
|
|
2134
2481
|
draft && draft.dedupe && draft.dedupe.length > 0
|
|
2135
2482
|
? h(
|
|
2136
2483
|
Card,
|
|
2137
|
-
{ title: '
|
|
2484
|
+
{ title: tr('跨插件提示词重复', 'Cross-plugin prompt duplication'), subtitle: tr('只建议,不修改第三方源码', 'Suggestion only; never edits third-party source'), section: 'dedupe', collapsible: true, collapsed: collapsedCards.dedupe === true, onToggle: () => toggleCard('dedupe') },
|
|
2138
2485
|
h(
|
|
2139
2486
|
'div',
|
|
2140
2487
|
{ className: 'eo-list' },
|
|
@@ -2554,6 +2901,16 @@ window.__ModuleLoader__.load({
|
|
|
2554
2901
|
|
|
2555
2902
|
function apply(ctx) {
|
|
2556
2903
|
injectCss()
|
|
2904
|
+
ctx.slots.inject('shell.overlay', () =>
|
|
2905
|
+
ctx.slots.register(
|
|
2906
|
+
{
|
|
2907
|
+
name: 'shell.overlay',
|
|
2908
|
+
id: 'experience-optimizer-guide',
|
|
2909
|
+
order: 10,
|
|
2910
|
+
},
|
|
2911
|
+
MainGuide,
|
|
2912
|
+
),
|
|
2913
|
+
)
|
|
2557
2914
|
ctx.slots.inject('settings.plugins.tab', () =>
|
|
2558
2915
|
ctx.slots.register(
|
|
2559
2916
|
{
|
package/dist/index.js
CHANGED
|
@@ -4588,6 +4588,8 @@ function registerCompatTool(ctx, config) {
|
|
|
4588
4588
|
}
|
|
4589
4589
|
// src/api.ts
|
|
4590
4590
|
const API_PREFIX = "/api/dsh-experience-optimizer";
|
|
4591
|
+
const CURRENT_VERSION = "0.3.7";
|
|
4592
|
+
let updateCache;
|
|
4591
4593
|
const TASK_TAGS = [
|
|
4592
4594
|
"bugfix",
|
|
4593
4595
|
"feature",
|
|
@@ -4648,6 +4650,13 @@ async function handle(req, res, ctx, config, ledger) {
|
|
|
4648
4650
|
});
|
|
4649
4651
|
return;
|
|
4650
4652
|
}
|
|
4653
|
+
if (req.method === "GET" && path === "/update") {
|
|
4654
|
+
sendJson(res, 200, {
|
|
4655
|
+
ok: true,
|
|
4656
|
+
data: await checkForUpdate()
|
|
4657
|
+
});
|
|
4658
|
+
return;
|
|
4659
|
+
}
|
|
4651
4660
|
if (req.method === "POST" && path === "/suggest") {
|
|
4652
4661
|
sendJson(res, 200, {
|
|
4653
4662
|
ok: true,
|
|
@@ -4674,6 +4683,53 @@ async function handle(req, res, ctx, config, ledger) {
|
|
|
4674
4683
|
sendError(res, 500, error instanceof Error ? error.message : String(error));
|
|
4675
4684
|
}
|
|
4676
4685
|
}
|
|
4686
|
+
function compareVersions(left, right) {
|
|
4687
|
+
const parse = (value) => value.replace(/^v/, "").split("-")[0].split(".").map((part) => Number.parseInt(part, 10) || 0);
|
|
4688
|
+
const a = parse(left);
|
|
4689
|
+
const b = parse(right);
|
|
4690
|
+
for (let index = 0; index < Math.max(a.length, b.length); index++) {
|
|
4691
|
+
const difference = (a[index] ?? 0) - (b[index] ?? 0);
|
|
4692
|
+
if (difference !== 0) return difference > 0 ? 1 : -1;
|
|
4693
|
+
}
|
|
4694
|
+
return 0;
|
|
4695
|
+
}
|
|
4696
|
+
async function checkForUpdate() {
|
|
4697
|
+
if (updateCache !== void 0 && Date.now() - updateCache.at < 6e4) return updateCache.value;
|
|
4698
|
+
const base = {
|
|
4699
|
+
current: CURRENT_VERSION,
|
|
4700
|
+
package: "dsh-plugin-trim",
|
|
4701
|
+
url: "https://www.npmjs.com/package/dsh-plugin-trim"
|
|
4702
|
+
};
|
|
4703
|
+
try {
|
|
4704
|
+
const response = await fetch("https://registry.npmjs.org/dsh-plugin-trim/latest", {
|
|
4705
|
+
headers: { accept: "application/json" },
|
|
4706
|
+
signal: AbortSignal.timeout(4e3)
|
|
4707
|
+
});
|
|
4708
|
+
if (!response.ok) throw new Error(`registry HTTP ${response.status}`);
|
|
4709
|
+
const metadata = await response.json();
|
|
4710
|
+
const latest = typeof metadata.version === "string" ? metadata.version : void 0;
|
|
4711
|
+
if (latest === void 0) throw new Error("registry response has no version");
|
|
4712
|
+
const value = {
|
|
4713
|
+
...base,
|
|
4714
|
+
latest,
|
|
4715
|
+
updateAvailable: compareVersions(latest, CURRENT_VERSION) > 0,
|
|
4716
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4717
|
+
};
|
|
4718
|
+
updateCache = {
|
|
4719
|
+
at: Date.now(),
|
|
4720
|
+
value
|
|
4721
|
+
};
|
|
4722
|
+
return value;
|
|
4723
|
+
} catch (error) {
|
|
4724
|
+
return {
|
|
4725
|
+
...base,
|
|
4726
|
+
latest: null,
|
|
4727
|
+
updateAvailable: false,
|
|
4728
|
+
error: error instanceof Error ? error.message : String(error),
|
|
4729
|
+
checkedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
4730
|
+
};
|
|
4731
|
+
}
|
|
4732
|
+
}
|
|
4677
4733
|
function publicConfig(ctx, config) {
|
|
4678
4734
|
const profile = resolveProfileFacts(ctx);
|
|
4679
4735
|
return {
|