dsh-ui-alt 0.2.135 → 0.2.249

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.
Files changed (3) hide show
  1. package/README.md +34 -9
  2. package/client.js +932 -78
  3. package/package.json +1 -1
package/client.js CHANGED
@@ -6,15 +6,18 @@ window.__ModuleLoader__.load({
6
6
 
7
7
  const STORAGE_KEY = 'dsh-ui-alt:prefs:v1';
8
8
  /* 发版时与 package.json 的 version 一起改:设置页底部会显示这两个值 */
9
- const VERSION = '0.2.135';
10
- const UPDATED = '2026-11-12';
9
+ const VERSION = '0.2.249';
10
+ const UPDATED = '2026-11-13';
11
11
  const DEFAULTS = {
12
12
  radiusDensity: true,
13
13
  invertNewSession: true,
14
14
  dimSessions: true,
15
+ enabled: true,
15
16
  hideLogo: false,
16
17
  winFont: false,
17
18
  softenDarkText: true,
19
+ uiTransition: true,
20
+ disableMenuBlur: true,
18
21
  sessionDot: false,
19
22
  settingsFullscreen: true,
20
23
  hideHoverCard: true,
@@ -45,6 +48,15 @@ window.__ModuleLoader__.load({
45
48
 
46
49
  function applyPrefs(prefs) {
47
50
  const root = document.documentElement;
51
+ /* 总开关关掉时,把本插件写上去的所有属性全部摘掉:
52
+ 不受单独开关控制的那部分修复(标题栏去线、侧栏边距等)也一并失效。 */
53
+ if (!prefs.enabled) {
54
+ const keys = Object.keys(root.dataset).filter((key) => key.startsWith('dcc'));
55
+ for (const key of keys) delete root.dataset[key];
56
+ root.dataset.dccEnabled = 'off';
57
+ return;
58
+ }
59
+ root.dataset.dccEnabled = 'on';
48
60
  root.dataset.dccRadius = prefs.radiusDensity ? 'on' : 'off';
49
61
  root.dataset.dccNew = prefs.invertNewSession ? 'on' : 'off';
50
62
  root.dataset.dccDim = prefs.dimSessions ? 'on' : 'off';
@@ -52,6 +64,8 @@ window.__ModuleLoader__.load({
52
64
  root.dataset.dccDot = prefs.sessionDot ? 'on' : 'off';
53
65
  root.dataset.dccFont = prefs.winFont ? 'on' : 'off';
54
66
  root.dataset.dccTextDim = prefs.softenDarkText ? 'on' : 'off';
67
+ root.dataset.dccTransition = prefs.uiTransition ? 'on' : 'off';
68
+ root.dataset.dccMenuBlur = prefs.disableMenuBlur ? 'on' : 'off';
55
69
  root.dataset.dccFull = prefs.settingsFullscreen ? 'on' : 'off';
56
70
  root.dataset.dccHover = prefs.hideHoverCard ? 'off' : 'on';
57
71
  root.dataset.dccRowButtons = prefs.hideRowButtons ? 'on' : 'off';
@@ -93,16 +107,169 @@ html[data-dcc-font="on"][data-windows-titlebar] body {
93
107
 
94
108
  /* ---------- 设置页(始终可用) ---------- */
95
109
  .dcc-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; }
96
- .dcc-title { margin: 0; padding: 0 2px; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--dsw-alias-label-primary); }
110
+ .dcc-title { margin: 0; padding: 0 2px; font-size: 18px; line-height: 26px; font-weight: 600; color: var(--dsw-alias-label-primary); }
97
111
  .dcc-intro { margin: 0; padding: 0 2px; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
98
112
  .dcc-meta { margin: 0; padding: 2px 2px 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
99
113
  .dcc-group { display: flex; flex-direction: column; padding: 6px 20px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-1); }
100
- .dcc-group-title { padding: 14px 2px 4px; font-size: 13px; line-height: 20px; font-weight: 600; color: var(--dsw-alias-label-primary); }
114
+ /* 分组标题统一降为次要色:它是分区标签,不该和设置项标题抢注意力 */
115
+ .dcc-group-title { padding: 14px 2px 4px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
101
116
  .dcc-row { display: flex; align-items: center; gap: 16px; padding: 14px 2px; border-top: 1px solid var(--dsw-alias-border-l1); }
102
117
  .dcc-group-title + .dcc-row { border-top: none; }
118
+ /* 无组名的组(总开关那一块)没有标题,首行同样不该有分隔线 */
119
+ .dcc-group > .dcc-row:first-child { border-top: none; }
120
+ /* 启动遮罩:先盖住,等样式稳定后淡出。底色跟随深浅主题。
121
+ 这两个值不能依赖 --dsw-alias-bg-base:它在深色主题下仍是白的,
122
+ 所以这里直接按主题写死,和宿主两种模式的页面底色对齐。 */
123
+ .dcc-boot-cover {
124
+ position: fixed;
125
+ inset: 0;
126
+ z-index: 2147483000;
127
+ display: flex;
128
+ align-items: center;
129
+ justify-content: center;
130
+ background-color: #ffffff;
131
+ opacity: 1;
132
+ transition: opacity .3s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
133
+ pointer-events: none;
134
+ }
135
+ body[data-ds-dark-theme] .dcc-boot-cover {
136
+ background-color: #151517;
137
+ }
138
+ .dcc-boot-fish {
139
+ width: 64px;
140
+ height: auto;
141
+ opacity: .3;
142
+ color: #ffffff;
143
+ }
144
+ body:not([data-ds-dark-theme]) .dcc-boot-fish {
145
+ color: #000000;
146
+ }
147
+ .dcc-boot-cover-out { opacity: 0; }
148
+ /* 纯告知行:无右侧控件,用列表承载多条说明 */
149
+ .dcc-row-info {
150
+ align-items: flex-start;
151
+ }
152
+ .dcc-row-info .dcc-row-text {
153
+ flex: 1;
154
+ }
155
+ /* 底部信息行:左边版本信息(可换行),右边重置按钮 */
156
+ .dcc-meta-row {
157
+ display: flex;
158
+ align-items: flex-end;
159
+ justify-content: space-between;
160
+ gap: 16px;
161
+ padding: 2px 2px 0;
162
+ }
163
+ .dcc-meta-row .dcc-meta {
164
+ padding: 0;
165
+ white-space: pre-line;
166
+ }
167
+ .dcc-reset {
168
+ flex: none;
169
+ height: 26px;
170
+ padding: 0 10px;
171
+ border: 1px solid var(--dsw-alias-border-l3);
172
+ border-radius: var(--dsw-radius-sm, 8px);
173
+ background: transparent;
174
+ color: var(--dsw-alias-label-secondary);
175
+ font: inherit;
176
+ font-size: 12px;
177
+ cursor: pointer;
178
+ }
179
+ .dcc-reset:hover {
180
+ background: var(--dsw-alias-interactive-bg-hover);
181
+ color: var(--dsw-alias-label-primary);
182
+ }
183
+ /* 重置确认弹窗:结构与底色对齐宿主的 Dialog(root / mask / dialog / content / footer) */
184
+ .dcc-modal {
185
+ position: fixed;
186
+ inset: 0;
187
+ z-index: 2147483000;
188
+ display: flex;
189
+ align-items: center;
190
+ justify-content: center;
191
+ }
192
+ .dcc-modal-mask {
193
+ position: absolute;
194
+ inset: 0;
195
+ background: rgba(0, 0, 0, .5);
196
+ }
197
+ .dcc-modal-card {
198
+ position: relative;
199
+ width: 360px;
200
+ max-width: calc(100vw - 48px);
201
+ display: flex;
202
+ flex-direction: column;
203
+ border: 1px solid var(--dsw-alias-border-l2);
204
+ border-radius: var(--dsw-radius-lg, 12px);
205
+ background: var(--dsw-alias-bg-layer-1);
206
+ box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
207
+ animation: dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
208
+ }
209
+ .dcc-modal-content {
210
+ padding: 18px 20px 4px;
211
+ }
212
+ .dcc-modal-title {
213
+ font-size: 15px;
214
+ line-height: 22px;
215
+ font-weight: 600;
216
+ color: var(--dsw-alias-label-primary);
217
+ }
218
+ .dcc-modal-body {
219
+ margin-top: 6px;
220
+ font-size: 13px;
221
+ line-height: 20px;
222
+ color: var(--dsw-alias-label-secondary);
223
+ }
224
+ .dcc-modal-actions {
225
+ display: flex;
226
+ justify-content: flex-end;
227
+ gap: 8px;
228
+ padding: 14px 20px 18px;
229
+ }
230
+ .dcc-modal-btn {
231
+ height: 30px;
232
+ padding: 0 14px;
233
+ border: 1px solid var(--dsw-alias-border-l3);
234
+ border-radius: var(--dsw-radius-sm, 8px);
235
+ background: transparent;
236
+ color: var(--dsw-alias-label-primary);
237
+ font: inherit;
238
+ font-size: 13px;
239
+ cursor: pointer;
240
+ }
241
+ .dcc-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
242
+ /* 破坏性操作:常态无底色、文字红;悬停补一层淡红 */
243
+ .dcc-modal-primary {
244
+ border-color: transparent;
245
+ background: transparent;
246
+ color: var(--dsw-alias-state-error-primary, #e5484d);
247
+ }
248
+ .dcc-modal-primary:hover {
249
+ background: color-mix(in oklab, var(--dsw-alias-state-error-primary, #e5484d) 14%, transparent);
250
+ }
251
+ .dcc-action {
252
+ flex: none;
253
+ height: 28px;
254
+ padding: 0 12px;
255
+ border: 1px solid var(--dsw-alias-border-l4);
256
+ border-radius: var(--dsw-radius-sm, 8px);
257
+ background: var(--dsw-alias-bg-layer-1);
258
+ color: var(--dsw-alias-label-primary);
259
+ font: inherit;
260
+ font-size: 13px;
261
+ cursor: pointer;
262
+ }
263
+ .dcc-action:hover { background: var(--dsw-alias-interactive-bg-hover); }
264
+ /* 总开关关闭时,下面所有分组置灰且不可操作(第一个组是总开关本身,跳过) */
265
+ html[data-dcc-enabled="off"] .dcc-page .dcc-group:not(.dcc-primary) {
266
+ opacity: .4;
267
+ pointer-events: none;
268
+ }
103
269
  .dcc-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
104
- .dcc-row-title { font-size: 14px; line-height: 20px; color: var(--dsw-alias-label-primary); }
105
- .dcc-row-desc { font-size: 12px; line-height: 17px; color: var(--dsw-alias-label-secondary); }
270
+ .dcc-row-title { font-size: 15px; line-height: 22px; color: var(--dsw-alias-label-primary); }
271
+ .dcc-row-desc {
272
+ white-space: pre-line; font-size: 12px; line-height: 17px; color: var(--dsw-alias-label-secondary); }
106
273
  .dcc-switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: none; cursor: pointer; }
107
274
  .dcc-input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
108
275
  /* 宿主全站默认 corner-shape: superellipse(1.5),999px 会被渲染成圆角矩形而不是胶囊。
@@ -208,8 +375,8 @@ html[data-dcc-new="off"] button[data-dcc-newrow] {
208
375
  }
209
376
  /* 克隆行直接使用 panelRow 的类,宽度/内边距/行高/焦点环全部来自宿主;
210
377
  默认和其它导航行一样是透明底,悬停时统一由下面的导航行规则上色 */
378
+ /* 悬停底色交给克隆时一同复制过来的 panelEntry 类,和别的导航行完全一致 */
211
379
  html[data-dcc-new="on"] button[data-dcc-newrow] {
212
- background-color: transparent !important;
213
380
  color: var(--dsw-alias-label-primary) !important;
214
381
  }
215
382
  .dcc-newrow-content {
@@ -234,12 +401,21 @@ html[data-dcc-new="on"] button[data-dcc-newrow] {
234
401
  font: inherit;
235
402
  color: inherit;
236
403
  }
237
- /* 显示 logo 时,给导航区留出与上方接近的下边距 */
238
- html[data-dcc-logo="shown"] nav[class*="_panelList"] {
404
+ /* 左右内边距加到 12px 后,Logo 行整体右移了 4px,这里抵消回原位 */
405
+ /* 显示 logo 时,给导航区留出与上方接近的下边距(同样只在折叠开启时) */
406
+ html[data-dcc-collapse="on"][data-dcc-logo="shown"] nav[class*="_panelList"] {
239
407
  margin-top: 4px;
240
408
  }
241
- /* Logo 上下留白:高度略放大,底下留一点空隙,别贴着导航 */
242
- html[data-dcc-logo="shown"] [class*="_logoRow"] {
409
+ /* 新会话按钮换成小尺寸后,Logo 上方会显得空,向下挪 2px 找回平衡 */
410
+ html[data-dcc-collapse="on"][data-dcc-new="on"] [class*="_logoRow"] {
411
+ margin-top: 2px !important;
412
+ }
413
+ /* Logo 上下留白:高度略放大,底下留一点空隙,别贴着导航。
414
+ 只在「导航折叠」开启时生效——关掉后侧栏回到整块滚动,
415
+ 这圈额外留白就成了多余的空白,交给宿主原本的排布。 */
416
+ html[data-dcc-collapse="on"][data-dcc-logo="shown"] [class*="_logoRow"] {
417
+ /* 左右内边距加到 12px 后 Logo 会右移 4px,这里抵消回原位 */
418
+ margin-left: -4px !important;
243
419
  height: 32px !important;
244
420
  margin-bottom: 6px !important;
245
421
  padding-top: 2px !important;
@@ -259,26 +435,31 @@ html[data-dcc-logo="shown"] [class*="_logoRow"] {
259
435
  /* 侧栏滚动下放:整块滚动容器不再滚动,改成纵向布局;
260
436
  Logo / 面板列表 / 工作区标题全部固定,只有工作区列表自己滚。
261
437
  宽屏才有 data-sidebar-scrollport,收成细轨时这些规则不生效。 */
262
- [data-sidebar-scrollport] {
438
+ /* 这套固定布局只在「导航折叠」开启时生效;关掉后侧栏回到宿主原本的整块滚动。 */
439
+ html[data-dcc-collapse="on"] [data-sidebar-scrollport] {
263
440
  overflow: hidden !important;
264
441
  display: flex !important;
265
442
  flex-direction: column !important;
266
443
  }
267
- [data-sidebar-scrollport] > nav[class*="_panelList"] {
444
+ html[data-dcc-collapse="on"] [data-sidebar-scrollport] > nav[class*="_panelList"] {
268
445
  flex: none;
269
446
  }
270
- [data-sidebar-scrollport] > [class*="_regionArea"] {
447
+ html[data-dcc-collapse="on"] [data-sidebar-scrollport] > [class*="_regionArea"] {
271
448
  flex: 1 1 auto;
272
449
  min-height: 0;
273
450
  overflow: hidden;
274
451
  display: flex;
275
452
  flex-direction: column;
453
+ /* 宿主 scrollArea 的右侧列比左侧少 2px,再补 4px 免得文字贴边 */
454
+ padding-right: 4px;
276
455
  }
277
456
  /* 工作区标题保持不动,列表区成为唯一的滚动容器。
278
457
  宿主给 listArea 写的是 overflow-y:hidden,这里放开。 */
279
- [data-sidebar-scrollport] [class*="_listArea"] {
458
+ html[data-dcc-collapse="on"] [data-sidebar-scrollport] [class*="_listArea"] {
280
459
  overflow-y: auto !important;
281
460
  overflow-x: hidden !important;
461
+ /* 底部留出与 footArea 等高的空白,滚到底时最后一项不会被底栏压住 */
462
+ padding-bottom: 105px !important;
282
463
  }
283
464
 
284
465
  /* 导航折叠:收起时用 max-height 裁到前两项(新会话 + 插件),
@@ -286,9 +467,7 @@ html[data-dcc-logo="shown"] [class*="_logoRow"] {
286
467
  html[data-dcc-nav] nav[class*="_panelList"] {
287
468
  overflow: hidden;
288
469
  transition: max-height .15s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
289
- }
290
- /* 导航项之间放松一点,行与行不再挨得那么紧 */
291
- html[data-dcc-nav] nav[class*="_panelList"] {
470
+ /* 导航项之间放松一点,行与行不再挨得那么紧 */
292
471
  gap: 4px !important;
293
472
  margin-bottom: 4px !important;
294
473
  }
@@ -301,14 +480,11 @@ html[data-dcc-nav="expanded"] nav[class*="_panelList"] {
301
480
  /* 整个侧栏的左右内边距:宿主根上用 --dsh-sidebar-inline-padding(默认 8px),
302
481
  调大它,导航、工作区、会话列表会一起内缩,不用逐类去改 padding。
303
482
  用 :has(nav) 限定成「包含面板列表的那个根」,避免误伤其他 _root。 */
304
- html[data-dcc-nav] [class*="_root"]:has(nav[class*="_panelList"]) {
483
+ html[data-dcc-collapse="on"] [class*="_root"]:has(nav[class*="_panelList"]) {
305
484
  --dsh-sidebar-inline-padding: 12px !important;
306
485
  }
307
486
  /* 右边缘再多留一点:宿主的 scrollArea 第三列是 inline-padding - 2px,
308
487
  扣掉滚动条后文字几乎贴边,这里给工作区区域补 4px。 */
309
- html[data-dcc-nav] [data-sidebar-scrollport] > [class*="_regionArea"] {
310
- padding-right: 4px;
311
- }
312
488
 
313
489
  /* 折叠箭头:整行可点,高亮只画在中间那一小块 */
314
490
  .dcc-nav-toggle {
@@ -366,12 +542,152 @@ html[data-dcc-radius="on"] [class*="_groupSection"] {
366
542
  margin-top: 2px !important;
367
543
  }
368
544
 
369
- /* 深色模式下正文不再用纯白:整体压到 80% 白,长时间看不刺眼。
370
- 改 token 而不是逐个元素设色,图标、输入框、菜单都会一起跟上。 */
545
+ /* 深色模式下正文不再用纯白:主文本压到 80%,次级文本同步压得更低,
546
+ 否则主文本一降,和次级文本反而贴在一起,层次就没了。 */
371
547
  html[data-dcc-text-dim="on"] body[data-ds-dark-theme] {
372
548
  --dsw-alias-label-primary: rgba(255, 255, 255, .8) !important;
549
+ --dsw-alias-label-secondary: rgba(255, 255, 255, .52) !important;
550
+ }
551
+
552
+ /* 关掉动画开关时,只掐掉「消失」这一段:宿主在 dismiss 阶段会做淡出,
553
+ 这里让它瞬间结束。菜单项的 hover 等其余过渡保持原样。 */
554
+ html[data-dcc-transition="off"] [data-menu-phase="dismiss"],
555
+ html[data-dcc-transition="off"] [data-menu-phase="dismiss"] * {
556
+ transition: none !important;
557
+ animation: none !important;
558
+ }
559
+
560
+ /* 禁用菜单的毛玻璃:宿主那层模糊聊胜于无,关掉之后弹层改用不透明底色,
561
+ 既省掉合成开销,也让动画期间不再需要额外的兜底背景。 */
562
+ html[data-dcc-menu-blur="on"] [data-menu-material],
563
+ html[data-dcc-menu-blur="on"] [data-menu-material] *,
564
+ html[data-dcc-menu-blur="on"] [role="dialog"],
565
+ html[data-dcc-menu-blur="on"] [role="listbox"],
566
+ html[data-dcc-menu-blur="on"] [role="menu"] {
567
+ backdrop-filter: none !important;
568
+ -webkit-backdrop-filter: none !important;
569
+ }
570
+ /* 模糊没了就得有实底,否则会透出后面的内容。
571
+ 上下文用量这类弹层不是 data-menu-material,用 role 兜住。 */
572
+ html[data-dcc-menu-blur="on"] [data-menu-material],
573
+ html[data-dcc-menu-blur="on"] [role="dialog"],
574
+ html[data-dcc-menu-blur="on"] [role="listbox"],
575
+ html[data-dcc-menu-blur="on"] [role="menu"] {
576
+ background-color: var(--dsw-alias-bg-layer-1) !important;
577
+ }
578
+
579
+ /* 禁用模糊后弹层本身已是不透明底,动画就不该再去动 background-color——
580
+ 否则 keyframes 的 transparent 会盖掉实底,动画结束才回落,看起来就是闪一下。
581
+ 所以这套场景单独用一组不带背景色的关键帧。 */
582
+ @keyframes dcc-fade-out {
583
+ from { opacity: 1; }
584
+ to { opacity: 0; }
585
+ }
586
+ @keyframes dcc-plain-in {
587
+ from {
588
+ opacity: 0;
589
+ transform: scale(.94);
590
+ }
591
+ to {
592
+ opacity: 1;
593
+ transform: none;
594
+ }
595
+ }
596
+ @keyframes dcc-plain-out {
597
+ from {
598
+ opacity: 1;
599
+ transform: none;
600
+ }
601
+ to {
602
+ opacity: 0;
603
+ transform: scale(.96);
604
+ }
605
+ }
606
+
607
+ /* 兜底色:动画期间顶替失效的毛玻璃。各弹层的实际背景不一样,
608
+ 统一一个 token 会对不齐,所以按「浅色/深色 × 是否带毛玻璃」分档微调。 */
609
+ body:not([data-ds-dark-theme]) {
610
+ --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
611
+ }
612
+ body[data-ds-dark-theme] [data-menu-material] {
613
+ --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
614
+ }
615
+ body[data-ds-dark-theme] :where([role="dialog"], [role="listbox"], [role="menu"]):not([data-menu-material]) {
616
+ --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 82%, #fff);
617
+ }
618
+
619
+ /* 禁用悬停卡片时直接隐藏卡片本体。
620
+ 新版的卡片是预渲染的常驻节点,悬停时只改 left/top 不改结构,
621
+ 所以拦事件没有用;它带 --dsh-hover-preview-fade 这个专有变量,用它精确定位。 */
622
+ html[data-dcc-hover="off"] [class*="_card_"][style*="--dsh-hover-preview-fade"],
623
+ html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
624
+ display: none !important;
625
+ }
626
+
627
+ /* 菜单出现/消失:整体从点击处缩放。
628
+ transform 会让同元素的 backdrop-filter 在动画期间失效,所以动画期间
629
+ 用一层近似底色的背景兜住,避免那 130ms 出现「透明」的观感。 */
630
+ html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="enter"] {
631
+ transform-origin: var(--dcc-menu-origin, 50% 50%);
632
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
633
+ }
634
+ html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="dismiss"] {
635
+ transform-origin: var(--dcc-menu-origin, 50% 50%);
636
+ animation: dcc-menu-out .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards;
637
+ }
638
+ /* 子菜单、列表选择器这些没有 data-menu-phase 的弹出层,
639
+ 用 role 单独命中,套同一组入场动画。对话框单独处理:
640
+ 窗口从中心缩放,不跟随点击位置。 */
641
+ html[data-dcc-transition="on"] [role="menu"]:not([data-menu-phase]),
642
+ html[data-dcc-transition="on"] [role="listbox"]:not([data-menu-phase]) {
643
+ transform-origin: var(--dcc-menu-origin, left center);
644
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
645
+ }
646
+ html[data-dcc-transition="on"] [role="dialog"]:not([data-menu-phase]) {
647
+ transform-origin: 50% 50%;
648
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
649
+ }
650
+ /* animation 简写会把 name 重置回 dcc-menu-in,所以这条必须写在它之后 */
651
+ html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="enter"],
652
+ html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"],
653
+ html[data-dcc-menu-blur="on"] [role="menu"]:not([data-menu-phase]),
654
+ html[data-dcc-menu-blur="on"] [role="listbox"]:not([data-menu-phase]),
655
+ html[data-dcc-menu-blur="on"] [role="dialog"]:not([data-menu-phase]) {
656
+ animation-name: dcc-plain-in;
657
+ }
658
+ html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"] {
659
+ animation-name: dcc-plain-out;
660
+ }
661
+
662
+
663
+ @keyframes dcc-menu-in {
664
+ from {
665
+ opacity: 0;
666
+ transform: scale(.94);
667
+ background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
668
+ }
669
+ to {
670
+ opacity: 1;
671
+ transform: none;
672
+ /* 保持兜底到最后一帧:动画没有 forwards,结束即自动回到元素自身样式,
673
+ 那时 transform 也消失、backdrop-filter 恢复,衔接无痕。 */
674
+ background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
675
+ }
676
+ }
677
+ @keyframes dcc-menu-out {
678
+ from {
679
+ opacity: 1;
680
+ transform: none;
681
+ background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
682
+ }
683
+ to {
684
+ opacity: 0;
685
+ transform: scale(.96);
686
+ background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
687
+ }
373
688
  }
374
689
 
690
+
375
691
  /* ---------- 工作区名称更明显,「展开其余」更淡 ---------- */
376
692
  html[data-dcc-dim="on"] [class*="_projectRow"] [class*="_title"] {
377
693
  color: var(--dsw-alias-label-primary) !important;
@@ -530,9 +846,12 @@ html[data-dcc-compact-header="off"] .dcc-segmented {
530
846
  圆角用 sm(8px) 而不是 md(12px),描边用更浅的 l1。 */
531
847
  .dcc-segmented {
532
848
  box-sizing: border-box;
849
+ transition: opacity .35s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
533
850
  display: inline-flex;
534
851
  align-items: stretch;
535
852
  height: 24px;
853
+ /* 视图变多时向左长:不让自己被压缩,宽度由内容决定 */
854
+ flex: none;
536
855
  /* 宿主给 headerUtilities 的 gap 是 8px;我们这层带 0.5px 描边和圆角,
537
856
  视觉上边界内缩、显得比别的元素远一点,补 2px 回来 */
538
857
  margin-right: 2px;
@@ -542,7 +861,10 @@ html[data-dcc-compact-header="off"] .dcc-segmented {
542
861
  background: var(--dsw-alias-bg-layer-1);
543
862
  overflow: hidden;
544
863
  }
864
+ /* 单个分段也不压缩,标签文字保持完整 */
545
865
  .dcc-seg {
866
+ flex: none;
867
+ white-space: nowrap;
546
868
  display: inline-flex;
547
869
  align-items: center;
548
870
  border: 0;
@@ -778,24 +1100,25 @@ html[data-dcc-dot="on"] body[data-ds-dark-theme] [class*="_sessionRow"]::before
778
1100
  opacity: .28;
779
1101
  }
780
1102
  /* 浅色主题下导航 hover 与新会话常规底色略微加强 */
781
- body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
782
- box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .035) !important;
783
- }
784
1103
  /* 浅色主题下选中会话的背景再强一点 */
785
1104
  body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
786
1105
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .04) !important;
787
1106
  }
788
1107
 
789
- /* 导航行的悬停 / 选中:新会话行已经是普通导航行的一员,不再单独排除 */
790
- html[data-dcc-new="on"] nav[class*="_panelList"] [class*="_panelRow"]:hover,
791
- html[data-dcc-new="on"] nav[class*="_panelList"] [class*="_panelRow"][class*="_panelActive"] {
792
- background-color: var(--dsw-alias-interactive-bg-hover) !important;
793
- box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07) !important;
1108
+ /* 导航行:悬停弱、选中强。
1109
+ 宿主的激活标记不在行类名上,而是按钮的 aria-current="page",
1110
+ 所以悬停作用在 :hover、选中作用在 [aria-current="page"],两者叠出来才有层次。 */
1111
+ body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"]:hover {
1112
+ box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .05) !important;
794
1113
  }
795
- html[data-dcc-new="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"]:hover,
796
- html[data-dcc-new="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"][class*="_panelActive"] {
797
- background-color: var(--dsw-alias-interactive-bg-hover) !important;
798
- box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .1) !important;
1114
+ body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1115
+ box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .16) !important;
1116
+ }
1117
+ body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
1118
+ box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .025) !important;
1119
+ }
1120
+ body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1121
+ box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07) !important;
799
1122
  }
800
1123
 
801
1124
  /* ---------- 设置面板:全屏(避开 Electron 标题栏)+ 标题左侧返回按钮 ---------- */
@@ -910,7 +1233,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
910
1233
  const entryClasses = entry === null
911
1234
  ? []
912
1235
  : [...entry.classList].filter((name) => name.includes('_panelEntry'));
913
- clone.className = [...row.classList].filter((name) => !name.includes('_panelActive')).join(' ')
1236
+ clone.className = [...row.classList].join(' ')
914
1237
  + ' dcc-newrow'
915
1238
  + (entryClasses.length > 0 ? ' ' + entryClasses.join(' ') : '');
916
1239
  const aria = orig.getAttribute('aria-label');
@@ -940,7 +1263,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
940
1263
  if (nav === null || orig === null) return false;
941
1264
  /* 开关关掉时彻底还原:移除克隆行、去掉原按钮上的标记,
942
1265
  让它回到宿主本来的样子,而不是仅靠 CSS 隐藏 */
943
- if (document.documentElement.dataset.dccNew !== 'on') {
1266
+ if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccNew !== 'on') {
944
1267
  if (clone !== null) {
945
1268
  clone.remove();
946
1269
  clone = null;
@@ -1017,8 +1340,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1017
1340
  };
1018
1341
 
1019
1342
  /**
1020
- * 按钮垂直位置按「标题文字的实际矩形」算,而不是按容器盒算——
1021
- * 容器带 padding / inline 布局时,盒子中心和文字中心并不重合。
1343
+ * 按钮垂直位置按「标题文字的实际矩形」算——容器带 padding 时,
1344
+ * 盒子中心和文字中心并不重合。
1345
+ * 入场动画会给面板挂 transform,rect 是缩放后的,所以再除以缩放比
1346
+ * 还原成布局坐标,动画前后算出来的值才一致。
1022
1347
  */
1023
1348
  const align = () => {
1024
1349
  if (btn === null || !btn.isConnected || btn.offsetParent === null) return;
@@ -1029,8 +1354,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1029
1354
  const rects = range.getClientRects();
1030
1355
  if (rects.length === 0) return;
1031
1356
  const textRect = rects[0];
1032
- const panelRect = btn.offsetParent.getBoundingClientRect();
1033
- const centerY = textRect.top + textRect.height / 2 - panelRect.top;
1357
+ const panel = btn.offsetParent;
1358
+ const panelRect = panel.getBoundingClientRect();
1359
+ const scale = panel.offsetHeight > 0 ? panelRect.height / panel.offsetHeight : 1;
1360
+ const centerY = (textRect.top + textRect.height / 2 - panelRect.top) / (scale > 0 ? scale : 1);
1034
1361
  btn.style.top = `${Math.round(centerY - btn.offsetHeight / 2)}px`;
1035
1362
  };
1036
1363
 
@@ -1040,6 +1367,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1040
1367
  };
1041
1368
 
1042
1369
  const ensure = () => {
1370
+ /* 总开关关闭时自绘按钮也要撤掉,否则会留下一个没有样式的裸按钮 */
1371
+ if (document.documentElement.dataset.dccEnabled !== 'on') {
1372
+ if (btn !== null) btn.remove();
1373
+ btn = null;
1374
+ return;
1375
+ }
1043
1376
  const panel = findPanel();
1044
1377
  if (panel === null) {
1045
1378
  if (btn !== null) btn.remove();
@@ -1155,8 +1488,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1155
1488
  observer.observe(document.body, { childList: true, subtree: true });
1156
1489
  document.addEventListener('click', onClick, true);
1157
1490
  document.addEventListener('mousemove', onMove, true);
1491
+ /* 紧凑化开关切换后立刻重建分段控件 */
1492
+ const onPrefs = (event) => {
1493
+ if (event.detail && event.detail.key === 'compactHeader') ensure();
1494
+ };
1495
+ window.addEventListener('dcc-prefs-changed', onPrefs);
1158
1496
 
1159
1497
  return () => {
1498
+ window.removeEventListener('dcc-prefs-changed', onPrefs);
1160
1499
  observer.disconnect();
1161
1500
  if (timer !== null) clearTimeout(timer);
1162
1501
  if (rafId !== 0) window.cancelAnimationFrame(rafId);
@@ -1199,6 +1538,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1199
1538
  早先还挂了一个 MutationObserver 定期全量扫描,滚动时虚拟列表频繁改 DOM,
1200
1539
  每 400ms 扫一遍所有会话行,反而成了新的卡顿源,已移除。 */
1201
1540
  const onPointer = (event) => {
1541
+ /* 总开关关闭时,把之前打上的隐藏标记全部撤掉 */
1542
+ if (document.documentElement.dataset.dccEnabled !== 'on') {
1543
+ const marked = document.querySelectorAll('[data-dcc-hidden]');
1544
+ for (const el of marked) el.removeAttribute('data-dcc-hidden');
1545
+ return;
1546
+ }
1202
1547
  if (document.documentElement.dataset.dccRowButtons !== 'on') return;
1203
1548
  const target = event.target;
1204
1549
  if (!(target instanceof Element)) return;
@@ -1208,9 +1553,18 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1208
1553
  filterRow(row);
1209
1554
  };
1210
1555
 
1556
+ /* 开关切换后立刻撤掉/重建标记,不必等鼠标再划过去 */
1557
+ const onPrefs = (event) => {
1558
+ if (!event.detail || event.detail.key !== 'hideRowButtons') return;
1559
+ const marked = document.querySelectorAll('[data-dcc-hidden]');
1560
+ for (const el of marked) el.removeAttribute('data-dcc-hidden');
1561
+ lastRow = null;
1562
+ };
1563
+ window.addEventListener('dcc-prefs-changed', onPrefs);
1211
1564
  document.addEventListener('pointerover', onPointer, true);
1212
1565
  document.addEventListener('focusin', onPointer, true);
1213
1566
  return () => {
1567
+ window.removeEventListener('dcc-prefs-changed', onPrefs);
1214
1568
  document.removeEventListener('pointerover', onPointer, true);
1215
1569
  document.removeEventListener('focusin', onPointer, true);
1216
1570
  const marked = document.querySelectorAll('[data-dcc-hidden]');
@@ -1227,6 +1581,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1227
1581
  */
1228
1582
  function installHoverCardBlocker() {
1229
1583
  const ROW = '[class*="_sessionRow"], [class*="_projectRow"], [class*="_searchResultRow"]';
1584
+ /* 最近一次「进入行」的时间戳,供下面的定时器过滤使用 */
1585
+ let lastRowHoverAt = 0;
1230
1586
 
1231
1587
  const onOver = (event) => {
1232
1588
  if (document.documentElement.dataset.dccHover !== 'off') return;
@@ -1237,13 +1593,59 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1237
1593
  /* 已经在行内移动,不是「进入」,放行给宿主 */
1238
1594
  const related = event.relatedTarget;
1239
1595
  if (related instanceof Node && row.contains(related)) return;
1240
- event.stopPropagation();
1596
+ lastRowHoverAt = Date.now();
1597
+ /* 用 stopImmediatePropagation 而不是 stopPropagation:
1598
+ 宿主的悬停计时器只要收到「进入」就会挂上,同层的监听器也得一并掐断。 */
1599
+ event.stopImmediatePropagation();
1600
+ };
1601
+
1602
+ /* 宿主是在「进入行」之后用 setTimeout 排一个延迟,到点才真的取数并渲染。
1603
+ 事件层抢不过它的注册顺序,所以改从这里掐:只丢弃悬停进入后极短时间内
1604
+ 注册、且延迟落在该区间里的那一个,其余定时器全部放行。 */
1605
+ const originalSetTimeout = window.setTimeout;
1606
+ const patchedSetTimeout = function (fn, delay, ...rest) {
1607
+ if (document.documentElement.dataset.dccHover === 'off'
1608
+ && typeof delay === 'number'
1609
+ && delay >= 300 && delay <= 2000
1610
+ && Date.now() - lastRowHoverAt < 400) {
1611
+ return 0;
1612
+ }
1613
+ return originalSetTimeout.call(this, fn, delay, ...rest);
1614
+ };
1615
+ window.setTimeout = patchedSetTimeout;
1616
+ const onMove = (event) => {
1617
+ if (document.documentElement.dataset.dccHover !== 'off') return;
1618
+ const target = event.target;
1619
+ if (!(target instanceof Element)) return;
1620
+ if (target.closest(ROW) === null) return;
1621
+ /* 行内移动也要刷新时间戳:宿主随时可能因为一次移动重新排上延迟调用,
1622
+ 只在「进入」时记一次的话,停留久了时间戳过期,定时器就漏过去了。 */
1623
+ lastRowHoverAt = Date.now();
1624
+ event.stopImmediatePropagation();
1241
1625
  };
1242
1626
 
1243
1627
  /* 放在 window 捕获阶段:这是事件流最早的位置,先于 React 挂在 root 容器上的
1244
- onPointerOverCapture,才能保证宿主那一层完全收不到「进入行」这件事。 */
1628
+ onPointerOverCapture,才能保证宿主那一层完全收不到「进入行」这件事。
1629
+ 新版悬停卡片还会用 pointerenter / mouseenter 那条路径,一并截住。
1630
+ document 上再挂一层,覆盖宿主把监听挂在 document 的情况。 */
1245
1631
  window.addEventListener('pointerover', onOver, true);
1246
- return () => window.removeEventListener('pointerover', onOver, true);
1632
+ window.addEventListener('pointerenter', onOver, true);
1633
+ window.addEventListener('mouseenter', onOver, true);
1634
+ window.addEventListener('pointermove', onMove, true);
1635
+ window.addEventListener('mousemove', onMove, true);
1636
+ document.addEventListener('pointerover', onOver, true);
1637
+ document.addEventListener('pointermove', onMove, true);
1638
+ return () => {
1639
+ /* 还原 setTimeout,避免插件卸载后仍影响全局定时器 */
1640
+ if (window.setTimeout === patchedSetTimeout) window.setTimeout = originalSetTimeout;
1641
+ window.removeEventListener('pointerover', onOver, true);
1642
+ window.removeEventListener('pointerenter', onOver, true);
1643
+ window.removeEventListener('mouseenter', onOver, true);
1644
+ window.removeEventListener('pointermove', onMove, true);
1645
+ window.removeEventListener('mousemove', onMove, true);
1646
+ document.removeEventListener('pointerover', onOver, true);
1647
+ document.removeEventListener('pointermove', onMove, true);
1648
+ };
1247
1649
  }
1248
1650
 
1249
1651
  /**
@@ -1255,6 +1657,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1255
1657
  let bar = null;
1256
1658
  let observer = null;
1257
1659
  let timer = null;
1660
+ /* 正在淡出的旧控件被临时挂到 body 上,卸载时要一起收走 */
1661
+ const ghosts = new Set();
1258
1662
 
1259
1663
  const findTabs = () => document.querySelector('[data-conversation-tabs]');
1260
1664
  const findHost = () => document.querySelector('[class*="_headerUtilities"]');
@@ -1273,9 +1677,38 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1273
1677
  };
1274
1678
 
1275
1679
  const build = (tabs, host) => {
1276
- if (bar !== null) bar.remove();
1680
+ /* 旧控件先淡出再移除,新控件从透明淡入——这样重建时是渐变而不是硬切 */
1681
+ if (bar !== null) {
1682
+ const old = bar;
1683
+ const rect = old.getBoundingClientRect();
1684
+ /* 控件已经被宿主摘掉时 rect 全是 0,照着定位会把它摆到窗口左上角。
1685
+ 这种情况直接丢掉,不做淡出。 */
1686
+ if (!old.isConnected || rect.width === 0) {
1687
+ old.remove();
1688
+ } else {
1689
+ /* 把旧控件固定到原位置、脱离布局流再淡出——
1690
+ 否则新旧两个都在标题栏里会互相挤动,看不出「淡出」这个动作。 */
1691
+ old.style.position = 'fixed';
1692
+ old.style.left = `${rect.left}px`;
1693
+ old.style.top = `${rect.top}px`;
1694
+ old.style.margin = '0';
1695
+ old.style.pointerEvents = 'none';
1696
+ old.style.zIndex = '1';
1697
+ document.body.appendChild(old);
1698
+ ghosts.add(old);
1699
+ window.requestAnimationFrame(() => {
1700
+ old.style.opacity = '0';
1701
+ });
1702
+ window.setTimeout(() => {
1703
+ old.remove();
1704
+ ghosts.delete(old);
1705
+ }, 300);
1706
+ }
1707
+ bar = null;
1708
+ }
1277
1709
  bar = document.createElement('div');
1278
1710
  bar.className = 'dcc-segmented';
1711
+ bar.style.opacity = '0';
1279
1712
  const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
1280
1713
  sources.forEach((source, index) => {
1281
1714
  const item = document.createElement('button');
@@ -1297,23 +1730,38 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1297
1730
  bar.appendChild(item);
1298
1731
  });
1299
1732
  host.insertBefore(bar, host.firstChild);
1733
+ window.requestAnimationFrame(() => {
1734
+ if (bar !== null) bar.style.opacity = '';
1735
+ });
1300
1736
  syncActive();
1301
1737
  };
1302
1738
 
1303
1739
  const ensure = () => {
1304
1740
  /* 开关关掉时把自绘控件撤掉,标签行由 CSS 恢复原样 */
1305
- if (document.documentElement.dataset.dccCompactHeader !== 'on') {
1741
+ if (document.documentElement.dataset.dccEnabled !== 'on'
1742
+ || document.documentElement.dataset.dccCompactHeader !== 'on') {
1306
1743
  if (bar !== null) { bar.remove(); bar = null; }
1307
1744
  return;
1308
1745
  }
1309
1746
  const tabs = findTabs();
1310
1747
  const host = findHost();
1311
- if (tabs === null || host === null) {
1748
+ /* 切换工作区时 tabs 会短暂消失再回来。这时别急着删控件——
1749
+ 等它回来时不一定还有新的 DOM 变化来触发重建,控件就永久丢了。
1750
+ 只有 host 真的没了才清掉。 */
1751
+ if (host === null) {
1312
1752
  if (bar !== null) { bar.remove(); bar = null; }
1313
1753
  return;
1314
1754
  }
1755
+ if (tabs === null) return;
1315
1756
  const count = tabs.querySelectorAll('button[role="tab"]').length;
1316
- if (bar === null || !bar.isConnected || bar.parentElement !== host || bar.children.length !== count) {
1757
+ /* 切换工作区那一瞬标签还没渲染完,数量会短暂变成 0。
1758
+ 这时如果按「数量不一致」去重建,就会闪一下。等它稳定下来再说。 */
1759
+ if (count === 0) return;
1760
+ /* 控件还在 DOM 里、只是容器换了 → 直接搬过去,不要重建(重建会闪一下) */
1761
+ if (bar !== null && bar.isConnected && bar.parentElement !== host) {
1762
+ host.insertBefore(bar, host.firstChild);
1763
+ }
1764
+ if (bar === null || !bar.isConnected || bar.children.length !== count) {
1317
1765
  build(tabs, host);
1318
1766
  return;
1319
1767
  }
@@ -1341,6 +1789,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1341
1789
  observer.disconnect();
1342
1790
  if (timer !== null) clearTimeout(timer);
1343
1791
  if (bar !== null) bar.remove();
1792
+ for (const ghost of ghosts) ghost.remove();
1793
+ ghosts.clear();
1344
1794
  };
1345
1795
  }
1346
1796
 
@@ -1368,6 +1818,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1368
1818
  const sync = () => {
1369
1819
  if (text === '') return;
1370
1820
  const root = document.documentElement;
1821
+ /* 总开关关闭时不再写这两个值,否则会留下一个永远显示余额的伪元素 */
1822
+ if (root.dataset.dccEnabled !== 'on') {
1823
+ root.style.removeProperty('--dcc-balance-text');
1824
+ if (root.dataset.dccBalanceLow !== undefined) delete root.dataset.dccBalanceLow;
1825
+ return;
1826
+ }
1371
1827
  const next = JSON.stringify(`余额 ${text}`);
1372
1828
  if (root.style.getPropertyValue('--dcc-balance-text') !== next) {
1373
1829
  root.style.setProperty('--dcc-balance-text', next);
@@ -1416,11 +1872,17 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1416
1872
  };
1417
1873
 
1418
1874
  window.addEventListener('dcc-balance-threshold', onThreshold);
1875
+ /* 开关切换后立刻按已拿到的数据重算,不必等下一次轮询 */
1876
+ const onPrefs = (event) => {
1877
+ if (event.detail && event.detail.key === 'showBalance') recalc();
1878
+ };
1879
+ window.addEventListener('dcc-prefs-changed', onPrefs);
1419
1880
  load();
1420
1881
  refresh = window.setInterval(load, 60000);
1421
1882
 
1422
1883
  return () => {
1423
1884
  window.removeEventListener('dcc-balance-threshold', onThreshold);
1885
+ window.removeEventListener('dcc-prefs-changed', onPrefs);
1424
1886
  if (refresh !== null) window.clearInterval(refresh);
1425
1887
  document.documentElement.style.removeProperty('--dcc-balance-text');
1426
1888
  delete document.documentElement.dataset.dccBalanceLow;
@@ -1443,7 +1905,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1443
1905
  const sync = () => {
1444
1906
  if (btn === null) return;
1445
1907
  /* 开关关掉时撤掉箭头并强制展开,导航回到宿主原样 */
1446
- if (document.documentElement.dataset.dccCollapse !== 'on') {
1908
+ if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccCollapse !== 'on') {
1447
1909
  btn.remove();
1448
1910
  btn = null;
1449
1911
  document.documentElement.dataset.dccNav = 'expanded';
@@ -1529,8 +1991,20 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1529
1991
  ensure();
1530
1992
  observer = new MutationObserver(schedule);
1531
1993
  observer.observe(document.body, { childList: true, subtree: true });
1994
+ /* 新会话克隆行增删会改变「折叠时保留几项」,要立刻重算高度 */
1995
+ const onNewSessionPref = () => ensure();
1996
+ window.addEventListener('dcc-newsession-pref', onNewSessionPref);
1997
+ /* 导航折叠开关本身切换后也要立刻重算,否则箭头和布局要等 400ms 防抖 */
1998
+ const onNavPref = (event) => {
1999
+ if (event.detail && event.detail.key === 'navCollapse') {
2000
+ window.setTimeout(() => ensure(), 0);
2001
+ }
2002
+ };
2003
+ window.addEventListener('dcc-prefs-changed', onNavPref);
1532
2004
 
1533
2005
  return () => {
2006
+ window.removeEventListener('dcc-newsession-pref', onNewSessionPref);
2007
+ window.removeEventListener('dcc-prefs-changed', onNavPref);
1534
2008
  observer.disconnect();
1535
2009
  if (timer !== null) clearTimeout(timer);
1536
2010
  if (btn !== null) btn.remove();
@@ -1538,6 +2012,257 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1538
2012
  };
1539
2013
  }
1540
2014
 
2015
+ /**
2016
+ * 菜单从点击处缩放展开。CSS 负责动画,这里只把「最后一次指针位置」
2017
+ * 换算成菜单内的相对坐标写进变量,让缩放的锚点落在点下去的地方。
2018
+ */
2019
+ function installMenuOrigin() {
2020
+ let lastX = 0;
2021
+ let lastY = 0;
2022
+ let observer = null;
2023
+ /* 每出现一个新菜单就递增编号,用来判断「谁是最后出现的」。
2024
+ 不能用 DOM 顺序:子菜单是 portal 节点,先出现的可能排在后面。 */
2025
+ let seq = 0;
2026
+
2027
+ const onDown = (event) => {
2028
+ lastX = event.clientX;
2029
+ lastY = event.clientY;
2030
+ };
2031
+
2032
+ const mark = () => {
2033
+ const menus = document.querySelectorAll('[role="menu"], [role="listbox"], [role="dialog"]');
2034
+ for (let i = 0; i < menus.length; i += 1) {
2035
+ const menu = menus[i];
2036
+ if (menu.hasAttribute('data-dcc-menu-seq')) continue;
2037
+ seq += 1;
2038
+ menu.setAttribute('data-dcc-menu-seq', String(seq));
2039
+ if (document.documentElement.dataset.dccTransition !== 'on') continue;
2040
+ const rect = menu.getBoundingClientRect();
2041
+ if (rect.width <= 0 || rect.height <= 0) continue;
2042
+ const x = Math.min(1, Math.max(0, (lastX - rect.left) / rect.width));
2043
+ const y = Math.min(1, Math.max(0, (lastY - rect.top) / rect.height));
2044
+ menu.style.setProperty('--dcc-menu-origin', `${Math.round(x * 100)}% ${Math.round(y * 100)}%`);
2045
+ }
2046
+ /* 宿主切换可展开项时,旧子菜单要等关闭延迟才移除,期间会和新叠在一起。
2047
+ 只留编号最大(最后出现)的那个可见,其余立即隐身;
2048
+ 不碰宿主状态,它照常走自己的关闭流程。 */
2049
+ const subs = Array.from(document.querySelectorAll('[role="menu"]:not([data-menu-phase])'));
2050
+ if (subs.length < 2) {
2051
+ for (let i = 0; i < subs.length; i += 1) {
2052
+ subs[i].style.opacity = '';
2053
+ subs[i].style.pointerEvents = '';
2054
+ }
2055
+ return;
2056
+ }
2057
+ let newest = null;
2058
+ let newestSeq = -1;
2059
+ for (let i = 0; i < subs.length; i += 1) {
2060
+ const value = Number(subs[i].getAttribute('data-dcc-menu-seq') || 0);
2061
+ if (value > newestSeq) {
2062
+ newestSeq = value;
2063
+ newest = subs[i];
2064
+ }
2065
+ }
2066
+ for (let i = 0; i < subs.length; i += 1) {
2067
+ const sub = subs[i];
2068
+ const keep = sub === newest;
2069
+ sub.style.opacity = keep ? '' : '0';
2070
+ sub.style.pointerEvents = keep ? '' : 'none';
2071
+ }
2072
+ };
2073
+
2074
+ window.addEventListener('pointerdown', onDown, true);
2075
+ observer = new MutationObserver(mark);
2076
+ observer.observe(document.body, { childList: true, subtree: true });
2077
+ mark();
2078
+
2079
+ return () => {
2080
+ observer.disconnect();
2081
+ window.removeEventListener('pointerdown', onDown, true);
2082
+ };
2083
+ }
2084
+
2085
+ /**
2086
+ * 对话框没有关闭阶段(open 为 false 时整个 portal 直接卸载),
2087
+ * 所以退场动画只能靠「卸载瞬间克隆一份快照、覆盖在原位播完再删」。
2088
+ * 原节点照常卸载,不干扰 React 状态。
2089
+ */
2090
+ function installDialogExit() {
2091
+ let observer = null;
2092
+ /* 节点被移除时再量尺寸已经晚了——脱离文档的元素 rect 全是 0。
2093
+ 所以对话框一出现就把位置记下来,移除时直接取这份快照。 */
2094
+ const rects = new WeakMap();
2095
+
2096
+ const remember = (root) => {
2097
+ if (root.hasAttribute('data-dcc-dialog-clone')) return;
2098
+ const dialog = root.matches('[role="dialog"]') ? root : root.querySelector('[role="dialog"]');
2099
+ if (dialog === null || rects.has(dialog)) return;
2100
+ const rect = dialog.getBoundingClientRect();
2101
+ if (rect.width > 0 && rect.height > 0) rects.set(dialog, rect);
2102
+ };
2103
+
2104
+ const playExit = (dialog) => {
2105
+ if (document.documentElement.dataset.dccTransition !== 'on') return;
2106
+ /* 快照自己也是 role="dialog",不排除的话它的移除会再触发一轮快照,无限循环 */
2107
+ /* 标记打在克隆的遮罩层上,卡片只是它的子孙,所以用 closest 向上找 */
2108
+ if (dialog.closest('[data-dcc-dialog-clone]') !== null) return;
2109
+ if (!rects.has(dialog)) return;
2110
+ /* 卡片本身是 position: relative,靠父级(fixed + flex)居中。
2111
+ 所以克隆父级整层、保持它的定位不动,只把动画加在卡片上——
2112
+ 卡片一旦被单独提出来改成 fixed,就会脱离这层居中上下文。 */
2113
+ const overlay = dialog.parentElement;
2114
+ const source = overlay !== null && overlay !== document.body ? overlay : dialog;
2115
+ const clone = source.cloneNode(true);
2116
+ clone.removeAttribute('data-dcc-menu-seq');
2117
+ clone.setAttribute('data-dcc-dialog-clone', '');
2118
+ clone.style.zIndex = '2147483000';
2119
+ clone.style.pointerEvents = 'none';
2120
+ /* 禁用模糊时弹层是不透明底,得用不带背景色的那组关键帧,
2121
+ 否则快照会从实底渐变到兜底色,看起来就是退场时变色。 */
2122
+ const exitAnim = document.documentElement.dataset.dccMenuBlur === 'on'
2123
+ ? 'dcc-plain-out'
2124
+ : 'dcc-menu-out';
2125
+ /* 整层统一淡出:这样压暗层和卡片一定同步,不依赖 mask 的类名是否命中 */
2126
+ clone.style.animation = 'dcc-fade-out .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards';
2127
+ /* 卡片在这之上再加缩放 */
2128
+ const inner = clone.querySelector('[role="dialog"]');
2129
+ if (inner !== null) {
2130
+ inner.style.animation = `${exitAnim} .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards`;
2131
+ }
2132
+ document.body.appendChild(clone);
2133
+ window.setTimeout(() => clone.remove(), 220);
2134
+ };
2135
+
2136
+ observer = new MutationObserver((records) => {
2137
+ for (let i = 0; i < records.length; i += 1) {
2138
+ const added = records[i].addedNodes;
2139
+ for (let j = 0; j < added.length; j += 1) {
2140
+ const node = added[j];
2141
+ if (node instanceof Element) remember(node);
2142
+ }
2143
+ const removed = records[i].removedNodes;
2144
+ for (let j = 0; j < removed.length; j += 1) {
2145
+ const node = removed[j];
2146
+ if (!(node instanceof Element)) continue;
2147
+ const dialog = node.matches('[role="dialog"]')
2148
+ ? node
2149
+ : node.querySelector('[role="dialog"]');
2150
+ if (dialog !== null) playExit(dialog);
2151
+ }
2152
+ }
2153
+ });
2154
+ observer.observe(document.body, { childList: true, subtree: true });
2155
+
2156
+ return () => observer.disconnect();
2157
+ }
2158
+
2159
+ /**
2160
+ * 启动遮罩:宿主的加载页退场、应用界面渲染出来之后,本插件注入的样式
2161
+ * 还要再落一次,中间能看到一次布局跳变。这里等界面真正出现(侧栏根节点
2162
+ * 就位且有尺寸)再多等一帧,然后盖 500ms 再淡出。
2163
+ */
2164
+ function installBootCover(prefs) {
2165
+ if (!prefs.enabled) return () => {};
2166
+ let cover = null;
2167
+ let themeObserver = null;
2168
+ let bootObserver = null;
2169
+ let rafId = 0;
2170
+ let fadeTimer = 0;
2171
+ let removeTimer = 0;
2172
+ let disposed = false;
2173
+
2174
+ const ready = () => {
2175
+ const sidebar = document.querySelector('[class*="_root"]:has(nav[class*="_panelList"])');
2176
+ if (sidebar === null) return false;
2177
+ const rect = sidebar.getBoundingClientRect();
2178
+ return rect.width > 100 && rect.height > 100;
2179
+ };
2180
+
2181
+ const wait = () => {
2182
+ if (disposed) return;
2183
+ if (!ready()) {
2184
+ rafId = window.requestAnimationFrame(wait);
2185
+ return;
2186
+ }
2187
+ makeCover();
2188
+ };
2189
+
2190
+ const makeCover = () => {
2191
+ if (disposed || cover !== null) return;
2192
+ cover = document.createElement('div');
2193
+ cover.className = 'dcc-boot-cover';
2194
+ const applyTheme = () => {
2195
+ if (cover === null) return;
2196
+ const dark = document.body.hasAttribute('data-ds-dark-theme')
2197
+ || document.documentElement.hasAttribute('data-ds-dark-theme');
2198
+ cover.style.backgroundColor = dark ? '#151517' : '#ffffff';
2199
+ };
2200
+ applyTheme();
2201
+ themeObserver = new MutationObserver(applyTheme);
2202
+ themeObserver.observe(document.body, {
2203
+ attributes: true,
2204
+ attributeFilter: ['data-ds-dark-theme', 'class'],
2205
+ });
2206
+ themeObserver.observe(document.documentElement, {
2207
+ attributes: true,
2208
+ attributeFilter: ['data-ds-dark-theme', 'class'],
2209
+ });
2210
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
2211
+ svg.setAttribute('viewBox', '0 0 23.16 17.04');
2212
+ svg.setAttribute('class', 'dcc-boot-fish');
2213
+ svg.setAttribute('aria-hidden', 'true');
2214
+ const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2215
+ shape.setAttribute('d', FISH_LOGO_PATH);
2216
+ shape.setAttribute('fill', 'currentColor');
2217
+ svg.appendChild(shape);
2218
+ cover.appendChild(svg);
2219
+ document.documentElement.appendChild(cover);
2220
+ fadeTimer = window.setTimeout(() => {
2221
+ if (cover === null) return;
2222
+ cover.classList.add('dcc-boot-cover-out');
2223
+ removeTimer = window.setTimeout(() => {
2224
+ if (themeObserver !== null) {
2225
+ themeObserver.disconnect();
2226
+ themeObserver = null;
2227
+ }
2228
+ if (cover !== null) cover.remove();
2229
+ cover = null;
2230
+ }, 320);
2231
+ }, 500);
2232
+ };
2233
+
2234
+ /* 宿主的加载页是 [data-dsh-boot]。它一被移除就立刻盖遮罩——
2235
+ MutationObserver 的回调在同一轮微任务里跑,赶在浏览器绘制之前,
2236
+ 所以中间不会露出没有样式的那一帧。 */
2237
+ const hasBoot = () => document.querySelector('[data-dsh-boot]') !== null;
2238
+ if (hasBoot()) {
2239
+ bootObserver = new MutationObserver(() => {
2240
+ if (hasBoot()) return;
2241
+ bootObserver.disconnect();
2242
+ bootObserver = null;
2243
+ makeCover();
2244
+ });
2245
+ bootObserver.observe(document.body, { childList: true, subtree: true });
2246
+ } else {
2247
+ /* 插件加载得比加载页还晚,那就等界面就绪 */
2248
+ wait();
2249
+ }
2250
+
2251
+ wait();
2252
+ return () => {
2253
+ disposed = true;
2254
+ if (bootObserver !== null) bootObserver.disconnect();
2255
+ if (themeObserver !== null) themeObserver.disconnect();
2256
+ if (rafId !== 0) window.cancelAnimationFrame(rafId);
2257
+ window.clearTimeout(fadeTimer);
2258
+ window.clearTimeout(removeTimer);
2259
+ if (cover !== null) cover.remove();
2260
+ };
2261
+ }
2262
+
2263
+ /* 侧栏 Logo 那条鲸鱼(与宿主同一份 path),遮罩中心会用到 */
2264
+ const FISH_LOGO_PATH = 'M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018ZM11.1749 14.4736C9.15936 12.889 8.18184 12.3675 7.77832 12.39C7.40081 12.4125 7.46881 12.8445 7.55182 13.126C7.63882 13.404 7.75182 13.5955 7.91033 13.8396C8.01983 14.0011 8.09533 14.2411 7.80083 14.4216C7.15181 14.8231 6.02327 14.2866 5.97027 14.2601C4.65673 13.4865 3.5587 12.4655 2.78467 11.069C2.03715 9.72493 1.60314 8.28289 1.53164 6.74384C1.51264 6.37233 1.62214 6.24082 1.99215 6.17332C2.47916 6.08332 2.98118 6.06432 3.46769 6.13582C5.52476 6.43633 7.27581 7.35586 8.74385 8.8129C9.58188 9.64243 10.2159 10.634 10.8689 11.6025C11.5634 12.631 12.3105 13.611 13.262 14.4146C13.598 14.6961 13.866 14.9101 14.1225 15.0681C13.349 15.1546 12.058 15.1731 11.1749 14.4746L11.1749 14.4736ZM12.141 8.25988C12.141 8.09488 12.273 7.96338 12.439 7.96338C12.4765 7.96338 12.5105 7.97088 12.541 7.98188C12.5825 7.99688 12.6205 8.01938 12.6505 8.05338C12.7035 8.10588 12.7335 8.18088 12.7335 8.25988C12.7335 8.42489 12.6015 8.55639 12.4355 8.55639C12.2695 8.55639 12.141 8.42489 12.141 8.25988ZM15.1415 9.79893C14.949 9.87793 14.7565 9.94544 14.5715 9.95294C14.2845 9.96794 13.9715 9.85143 13.8015 9.70893C13.5375 9.48742 13.3485 9.36342 13.2695 8.97691C13.2355 8.8119 13.2545 8.55639 13.2845 8.40989C13.3525 8.09438 13.277 7.89187 13.0545 7.70787C12.8735 7.55786 12.643 7.51636 12.39 7.51636C12.2955 7.51636 12.209 7.47486 12.1445 7.44136C12.039 7.38886 11.9519 7.25735 12.035 7.09585C12.0615 7.04335 12.19 6.91584 12.22 6.89334C12.5635 6.69784 12.9595 6.76184 13.326 6.90834C13.6655 7.04735 13.9225 7.30236 14.292 7.66287C14.6695 8.09838 14.7375 8.21838 14.9525 8.54539C15.1225 8.8009 15.277 9.06341 15.3831 9.36392C15.4471 9.55142 15.3641 9.70493 15.1415 9.79893Z';
2265
+
1541
2266
  function Switch(props) {
1542
2267
  return h('label', { className: 'dcc-switch' },
1543
2268
  h('input', {
@@ -1559,9 +2284,37 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1559
2284
  h(Switch, { checked: props.checked, onChange: props.onChange, title: props.title }));
1560
2285
  }
1561
2286
 
2287
+ /* 纯告知行:右侧没有任何控件,内容按纯文本渲染(换行由 pre-line 处理) */
2288
+ function InfoRow(props) {
2289
+ return h('div', { className: 'dcc-row dcc-row-info' },
2290
+ h('div', { className: 'dcc-row-text' },
2291
+ h('div', { className: 'dcc-row-title' }, props.title),
2292
+ h('div', { className: 'dcc-row-desc' }, props.desc)));
2293
+ }
2294
+
2295
+ /* 右侧是按钮而不是开关的行:用于「重载前端界面」这类一次性操作 */
2296
+ function ActionRow(props) {
2297
+ return h('div', { className: 'dcc-row' },
2298
+ h('div', { className: 'dcc-row-text' },
2299
+ h('div', { className: 'dcc-row-title' }, props.title),
2300
+ props.desc ? h('div', { className: 'dcc-row-desc' }, props.desc) : null),
2301
+ h('button', {
2302
+ type: 'button',
2303
+ className: 'dcc-action',
2304
+ onClick: props.onClick,
2305
+ }, props.label));
2306
+ }
2307
+
1562
2308
  function Section() {
1563
2309
  const [prefs, setPrefs] = React.useState(readPrefs);
2310
+ const [confirmReset, setConfirmReset] = React.useState(false);
1564
2311
  const zh = isZh();
2312
+ /* 重置全部设置:写回默认值后重载,避免残留的 DOM 与属性状态 */
2313
+ const resetPrefs = () => {
2314
+ const next = { ...DEFAULTS };
2315
+ savePrefs(next);
2316
+ if (typeof window !== 'undefined') window.location.reload();
2317
+ };
1565
2318
  const update = (key) => (value) => {
1566
2319
  setPrefs((current) => {
1567
2320
  const next = { ...current, [key]: value };
@@ -1572,26 +2325,56 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1572
2325
  if ((key === 'balanceThreshold' || key === 'balanceDecimals') && typeof window !== 'undefined') {
1573
2326
  window.dispatchEvent(new Event('dcc-balance-threshold'));
1574
2327
  }
1575
- /* 「统一新会话按钮样式」关掉时要立刻拆掉克隆行并还原原按钮 */
2328
+ /* 「统一新会话按钮样式」切换后要立刻重建克隆行。
2329
+ 延后一拍再发:属性由 applyPrefs 在下一次渲染里写入,
2330
+ 事件如果先到,ensure 读到的还是旧值,看起来就像没反应。 */
1576
2331
  if (key === 'invertNewSession' && typeof window !== 'undefined') {
1577
- window.dispatchEvent(new Event('dcc-newsession-pref'));
2332
+ window.setTimeout(() => {
2333
+ window.dispatchEvent(new Event('dcc-newsession-pref'));
2334
+ }, 0);
2335
+ }
2336
+ /* 其余需要重建 DOM 的开关统一走这个事件,各模块只处理自己关心的 key。
2337
+ 同样延后一拍,等 applyPrefs 把属性写进 html。 */
2338
+ if (typeof window !== 'undefined') {
2339
+ window.setTimeout(() => {
2340
+ window.dispatchEvent(new CustomEvent('dcc-prefs-changed', { detail: { key } }));
2341
+ }, 0);
2342
+ }
2343
+ /* 总开关切换会整体改变已注入的 DOM 与样式,重载一次前端最干净。
2344
+ 偏好此时已经写进存储,重载后会按新状态重建。 */
2345
+ if (key === 'enabled' && typeof window !== 'undefined') {
2346
+ window.setTimeout(() => window.location.reload(), 60);
1578
2347
  }
1579
2348
  };
1580
2349
  return h('div', { className: 'dcc-page' },
1581
2350
  h('div', { className: 'dcc-title' }, zh ? 'UI 改进' : 'UI improvements'),
1582
2351
  h('p', { className: 'dcc-intro' },
1583
2352
  zh ? '在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。' : 'Keeps the overall layout of the stock UI while tightening its radii, spacing and tidiness for a calmer, more professional and more efficient look. Also adds an account balance display. Most changes can be switched on or off individually in Settings.'),
2353
+ /* 无组名的操作区:总开关 + 重载前端界面 */
2354
+ h('div', { className: 'dcc-group dcc-primary' },
2355
+ h(Row, {
2356
+ title: zh ? '总开关' : 'Master switch',
2357
+ desc: zh ? '关闭后将禁用全部修改,包括始终启用的部分界面修复功能。\n打开和关闭会重载前端界面,不影响正在运行的任务。' : 'Turning it off disables every change, including the always-on UI fixes.\nToggling it reloads the UI; running tasks are not affected.',
2358
+ checked: prefs.enabled,
2359
+ onChange: update('enabled'),
2360
+ }),
2361
+ h(ActionRow, {
2362
+ title: zh ? '重载前端界面' : 'Reload the UI',
2363
+ desc: zh ? '调整本插件的设置后建议执行一次。使用了其他修改前端界面类的插件,也可以在此处重载。\n不会影响正在运行的任务。' : 'Recommended after changing this plugin settings. Also reloads other UI-modifying plugins.\nRunning tasks are not affected.',
2364
+ label: zh ? '重载' : 'Reload',
2365
+ onClick: () => { window.location.reload(); },
2366
+ })),
1584
2367
  h('div', { className: 'dcc-group' },
1585
2368
  h('div', { className: 'dcc-group-title' }, zh ? '外观' : 'Appearance'),
1586
2369
  h(Row, {
1587
- title: zh ? '隐藏左上角 Logo' : 'Hide the top-left logo',
1588
- desc: zh ? '隐藏侧栏顶部的 Logo。' : 'Hide the logo at the top of the sidebar.',
1589
- checked: prefs.hideLogo,
1590
- onChange: update('hideLogo'),
2370
+ title: zh ? '减小圆角与间距' : 'Smaller radii and spacing',
2371
+ desc: zh ? '缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效。' : 'Smaller global radii, smaller sidebar type and tighter spacing, for a more efficient interface.',
2372
+ checked: prefs.radiusDensity,
2373
+ onChange: update('radiusDensity'),
1591
2374
  }),
1592
2375
  h(Row, {
1593
2376
  title: zh ? 'Windows 默认微软雅黑字体' : 'Microsoft YaHei on Windows',
1594
- desc: zh ? '将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响。' : 'Use Microsoft YaHei as the default Windows font. It carries hinting, which keeps text sharp below 200% display scaling. Has no effect if you set a font manually, or on macOS.',
2377
+ desc: zh ? '将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。\n若手动设置了字体,或使用 macOS 端,则不受影响。' : 'Use Microsoft YaHei as the default Windows font. It carries hinting, which keeps text sharp below 200% display scaling.\nHas no effect if you set a font manually, or on macOS.',
1595
2378
  checked: prefs.winFont,
1596
2379
  onChange: update('winFont'),
1597
2380
  }),
@@ -1600,20 +2383,32 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1600
2383
  desc: zh ? '略微降低深色模式文字亮度,避免纯白文字过于刺眼。' : 'Slightly dims text in dark mode so pure white is less harsh.',
1601
2384
  checked: prefs.softenDarkText,
1602
2385
  onChange: update('softenDarkText'),
1603
- })),
1604
- h('div', { className: 'dcc-group' },
1605
- h('div', { className: 'dcc-group-title' }, zh ? '布局' : 'Layout'),
2386
+ }),
1606
2387
  h(Row, {
1607
- title: zh ? '减小圆角与间距' : 'Smaller radii and spacing',
1608
- desc: zh ? '缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效。' : 'Smaller global radii, smaller sidebar type and tighter spacing, for a more efficient interface.',
1609
- checked: prefs.radiusDensity,
1610
- onChange: update('radiusDensity'),
2388
+ title: zh ? '为菜单和窗口添加动画' : 'Animate menus and dialogs',
2389
+ desc: zh ? '为菜单添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画。' : 'Smoother open and close animations for menus. Some menus cannot animate their close due to platform limits.',
2390
+ checked: prefs.uiTransition,
2391
+ onChange: update('uiTransition'),
1611
2392
  }),
1612
2393
  h(Row, {
1613
- title: zh ? '会话标题栏紧凑化' : 'Compact session header',
1614
- desc: zh ? '紧凑化会话标题栏,使会话内容可视范围更大。' : 'Tighten the session header so more of the conversation is visible.',
1615
- checked: prefs.compactHeader,
1616
- onChange: update('compactHeader'),
2394
+ title: zh ? '禁用菜单模糊效果' : 'Disable menu blur',
2395
+ desc: zh ? '禁用原版菜单聊胜于无的模糊效果,增加流畅度和整体感。' : 'Drops the stock menu blur for smoother rendering and a more unified look.',
2396
+ checked: prefs.disableMenuBlur,
2397
+ onChange: update('disableMenuBlur'),
2398
+ }),
2399
+ h(Row, {
2400
+ title: zh ? '设置面板全屏' : 'Full-screen settings panel',
2401
+ desc: zh ? '使用非窗口化的设置页面。' : 'Use a non-windowed settings page.',
2402
+ checked: prefs.settingsFullscreen,
2403
+ onChange: update('settingsFullscreen'),
2404
+ })),
2405
+ h('div', { className: 'dcc-group' },
2406
+ h('div', { className: 'dcc-group-title' }, zh ? '导航和工作区' : 'Navigation and workspace'),
2407
+ h(Row, {
2408
+ title: zh ? '隐藏左上角 Logo' : 'Hide the top-left logo',
2409
+ desc: zh ? '隐藏侧栏顶部的 Logo。' : 'Hide the logo at the top of the sidebar.',
2410
+ checked: prefs.hideLogo,
2411
+ onChange: update('hideLogo'),
1617
2412
  }),
1618
2413
  h(Row, {
1619
2414
  title: zh ? '统一新会话按钮样式' : 'Unified new-session button',
@@ -1640,22 +2435,24 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1640
2435
  onChange: update('sessionDot'),
1641
2436
  }),
1642
2437
  h(Row, {
1643
- title: zh ? '移除工作区与会话悬停提示' : 'Remove workspace and session hover hints',
2438
+ title: zh ? '移除工作区与会话悬停详情卡片' : 'Remove workspace and session hover cards',
1644
2439
  desc: zh ? '悬停在侧栏工作区、会话上时,不再显示详情卡片。使滚动更流畅。' : 'Hovering a workspace or session no longer shows a details card, which keeps scrolling smooth.',
1645
2440
  checked: prefs.hideHoverCard,
1646
2441
  onChange: update('hideHoverCard'),
1647
2442
  }),
1648
2443
  h(Row, {
1649
2444
  title: zh ? '隐藏会话悬停多余按钮' : 'Hide extra session-row buttons',
1650
- desc: zh ? '隐藏会话悬停时除了菜单和置顶之外的其他按钮,避免拥挤遮盖过多标题。正常情况下这些按钮都已经在右键菜单中包含。若其他插件添加的按钮未在右键菜单包含,可以关闭此功能。' : 'Hide every button on a hovered session row except the "…" menu and pin, so they stop crowding the title. These actions are normally in the right-click menu too; turn this off if a plugin adds a button that is not.',
2445
+ desc: zh ? '隐藏会话悬停时除了菜单和置顶之外的其他按钮,避免拥挤遮盖过多标题。\n正常情况下这些按钮都已经在右键菜单中包含。若其他插件添加的按钮未在右键菜单包含,可以关闭此功能。' : 'Hide every button on a hovered session row except the "…" menu and pin, so they stop crowding the title.\nThese actions are normally in the right-click menu too; turn this off if a plugin adds a button that is not.',
1651
2446
  checked: prefs.hideRowButtons,
1652
2447
  onChange: update('hideRowButtons'),
1653
- }),
2448
+ })),
2449
+ h('div', { className: 'dcc-group' },
2450
+ h('div', { className: 'dcc-group-title' }, zh ? '会话标题栏' : 'Session header'),
1654
2451
  h(Row, {
1655
- title: zh ? '设置面板全屏' : 'Full-screen settings panel',
1656
- desc: zh ? '使用非窗口化的设置页面。' : 'Use a non-windowed settings page.',
1657
- checked: prefs.settingsFullscreen,
1658
- onChange: update('settingsFullscreen'),
2452
+ title: zh ? '会话标题栏紧凑化' : 'Compact session header',
2453
+ desc: zh ? '紧凑化会话标题栏,将视图切换标签移到工具按钮处,使会话内容可视范围更大。' : 'Tighten the session header by moving the view tabs next to the toolbar buttons, so more of the conversation is visible.',
2454
+ checked: prefs.compactHeader,
2455
+ onChange: update('compactHeader'),
1659
2456
  })),
1660
2457
  h('div', { className: 'dcc-group' },
1661
2458
  h('div', { className: 'dcc-group-title' }, zh ? '性能与用量信息' : 'Performance and usage'),
@@ -1712,9 +2509,57 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1712
2509
  checked: prefs.textSelectLimit,
1713
2510
  onChange: update('textSelectLimit'),
1714
2511
  })),
1715
- h('p', { className: 'dcc-meta' },
1716
- /* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
1717
- zh ? `版本:${VERSION}\u3000更新日期:${UPDATED}\u3000基于 DSH v0.2.2-rc.2 测试` : `Version: ${VERSION} Updated: ${UPDATED} Tested on DSH v0.2.2-rc.2`));
2512
+ h('div', { className: 'dcc-group' },
2513
+ h('div', { className: 'dcc-group-title' }, zh ? '基础改进' : 'Base fixes'),
2514
+ h(InfoRow, {
2515
+ title: zh ? '基础细节改进和修复' : 'Base detail fixes and improvements',
2516
+ desc: zh
2517
+ ? [
2518
+ '这些基础修复和改进影响很小,会始终启用,除非关闭总开关。',
2519
+ '- 左侧导航栏部分布局细节优化。',
2520
+ '- 工作区文件夹悬停时保留图标。',
2521
+ '- 已归档会话显示删除线。',
2522
+ '- 会话标题栏与正文间去除分割线,柔化过渡。',
2523
+ '- 选择题弹窗细节优化。',
2524
+ '- 避免界面加载时跳变添加的过渡遮罩。',
2525
+ '- 修复二级右键菜单消失延迟。',
2526
+ ].join('\n')
2527
+ : [
2528
+ 'These small fixes and improvements are always on unless the master switch is off.',
2529
+ '- Layout details refined in the left navigation.',
2530
+ '- Workspace folder icons stay visible on hover.',
2531
+ '- Archived sessions show a strikethrough.',
2532
+ '- No divider between the session header and the body; softened transition.',
2533
+ '- Multiple-choice dialog details refined.',
2534
+ '- A transition cover added to avoid layout jumps on startup.',
2535
+ '- Fixed the delay when closing a second-level context menu.',
2536
+ ].join('\n'),
2537
+ })),
2538
+ h('div', { className: 'dcc-meta-row' },
2539
+ h('p', { className: 'dcc-meta' },
2540
+ /* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
2541
+ zh
2542
+ ? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc2 测试`
2543
+ : `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc2`),
2544
+ h('button', {
2545
+ type: 'button',
2546
+ className: 'dcc-reset',
2547
+ onClick: () => setConfirmReset(true),
2548
+ }, zh ? '重置设置' : 'Reset')),
2549
+ confirmReset ? h('div', { className: 'dcc-modal', role: 'presentation' },
2550
+ h('div', {
2551
+ className: 'dcc-modal-mask',
2552
+ 'aria-hidden': 'true',
2553
+ onClick: () => setConfirmReset(false),
2554
+ }),
2555
+ h('div', { className: 'dcc-modal-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': zh ? '重置 UI 改进选项' : 'Reset UI improvements' },
2556
+ h('div', { className: 'dcc-modal-content' },
2557
+ h('div', { className: 'dcc-modal-title' }, zh ? '重置 UI 改进选项' : 'Reset UI improvements'),
2558
+ h('div', { className: 'dcc-modal-body' }, zh ? '将会重置本插件的所有设置项到默认状态。' : 'Every option in this plugin will be reset to its default.')),
2559
+ h('div', { className: 'dcc-modal-actions' },
2560
+ h('button', { type: 'button', className: 'dcc-modal-btn', onClick: () => setConfirmReset(false) }, zh ? '取消' : 'Cancel'),
2561
+ h('button', { type: 'button', className: 'dcc-modal-btn dcc-modal-primary', onClick: () => { resetPrefs(); } }, zh ? '重置' : 'Reset'))))
2562
+ : null);
1718
2563
  }
1719
2564
 
1720
2565
  function SectionIcon(props) {
@@ -1750,7 +2595,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1750
2595
  const removeHoverCardBlocker = installHoverCardBlocker();
1751
2596
  const removeViewSwitcher = installViewSwitcher();
1752
2597
  const removeBalance = installBalancePill(ctx);
2598
+ const removeBootCover = installBootCover(readPrefs());
1753
2599
  const removePluginPin = installNavToggle();
2600
+ const removeMenuOrigin = installMenuOrigin();
2601
+ const removeDialogExit = installDialogExit();
1754
2602
  return () => {
1755
2603
  removeCss();
1756
2604
  removeNewSessionRow();
@@ -1759,15 +2607,21 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1759
2607
  removeHoverCardBlocker();
1760
2608
  removeViewSwitcher();
1761
2609
  removeBalance();
2610
+ removeBootCover();
1762
2611
  removePluginPin();
2612
+ removeMenuOrigin();
2613
+ removeDialogExit();
1763
2614
  const root = document.documentElement;
1764
2615
  delete root.dataset.dccRadius;
1765
2616
  delete root.dataset.dccNew;
1766
2617
  delete root.dataset.dccDim;
2618
+ delete root.dataset.dccEnabled;
1767
2619
  delete root.dataset.dccLogo;
1768
2620
  delete root.dataset.dccDot;
1769
2621
  delete root.dataset.dccFont;
1770
2622
  delete root.dataset.dccTextDim;
2623
+ delete root.dataset.dccTransition;
2624
+ delete root.dataset.dccMenuBlur;
1771
2625
  delete root.dataset.dccFull;
1772
2626
  delete root.dataset.dccHover;
1773
2627
  delete root.dataset.dccRowButtons;