dsh-ui-alt 0.2.249 → 0.2.343

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 +21 -7
  2. package/client.js +423 -118
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -19,9 +19,9 @@
19
19
  | 开关 | 默认 | 效果 |
20
20
  | --- | --- | --- |
21
21
  | 减小圆角与间距 | 开 | 缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效 |
22
- | Windows 默认微软雅黑字体 | 关 | 将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响 |
22
+ | Windows 默认使用微软雅黑字体 | 关 | 将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响 |
23
23
  | 降低深色模式文字亮度 | 开 | 略微降低深色模式文字亮度,避免纯白文字过于刺眼 |
24
- | 为菜单和窗口添加动画 | 开 | 为菜单添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画 |
24
+ | 为菜单和窗口添加动画 | 开 | 为菜单、对话框和压暗遮罩添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画 |
25
25
  | 禁用菜单模糊效果 | 开 | 禁用原版菜单聊胜于无的模糊效果,增加流畅度和整体感 |
26
26
  | 设置面板全屏 | 开 | 使用非窗口化的设置页面 |
27
27
 
@@ -33,7 +33,7 @@
33
33
  | 统一新会话按钮样式 | 开 | 新会话按钮样式改为与导航按钮一致 |
34
34
  | 导航折叠 | 开 | 导航下方显示折叠箭头,可展开和收起 |
35
35
  | 弱化工作区名称 | 开 | 工作区名称弱化,使工作区和会话更易区分 |
36
- | 会话前圆点 | 关 | 会话前显示一个圆点 |
36
+ | 会话前圆点 | 关 | 在侧栏工作区会话前显示一个圆点标记 |
37
37
  | 移除工作区与会话悬停详情卡片 | 开 | 悬停在侧栏工作区、会话上时不再显示详情卡片。实现上会丢弃宿主为卡片排的延迟调用,避免悬停后仍在后台取数导致滚动卡顿 |
38
38
  | 隐藏会话悬停多余按钮 | 开 | 悬停会话行时只保留菜单和置顶,其余按钮(含插件添加的)隐藏;若有插件按钮未在右键菜单中,可关闭 |
39
39
 
@@ -41,7 +41,9 @@
41
41
 
42
42
  | 开关 | 默认 | 效果 |
43
43
  | --- | --- | --- |
44
- | 会话标题栏紧凑化 | 开 | 紧凑化会话标题栏,将视图切换标签移到工具按钮处,使会话内容可视范围更大 |
44
+ | 柔化标题栏与会话区域过渡 | 开 | 移除分割线,使用柔化边缘过渡标题栏和会话正文 |
45
+ | 会话标题栏紧凑化 | 开 | 将视图切换按钮移到右上工具按钮处,使会话内容可视范围更大。按钮是一个下拉控件,显示当前视图名,点击展开完整视图列表。此按钮在对话模式下默认隐藏,鼠标位于标题栏区域时才会显示 |
46
+ | 紧凑标题栏始终显示视图切换控件 | 关 | 在对话视图下不自动隐藏视图切换控件。仅在「会话标题栏紧凑化」开启时可用,否则该项置灰 |
45
47
 
46
48
  **性能与用量信息**
47
49
 
@@ -63,7 +65,7 @@
63
65
 
64
66
  | 项 | 说明 |
65
67
  | --- | --- |
66
- | 基础细节改进和修复 | 这些基础修复和改进影响很小,会始终启用,除非关闭总开关:左侧导航栏布局细节、工作区文件夹悬停保留图标、已归档会话删除线、标题栏与正文间去分割线、选择题弹窗细节、加载过渡遮罩、二级右键菜单消失延迟 |
68
+ | 基础细节改进和修复 | 这些基础修复和改进影响很小,会始终启用,除非关闭总开关:左侧导航栏布局细节、工作区文件夹悬停保留图标、已归档会话删除线、选择题弹窗细节、加载过渡遮罩、二级右键菜单消失延迟 |
67
69
 
68
70
  另有一些不挂开关的固定样式:设置导航列宽 220px、归档会话标题画删除线、选择题选中项的序号反色高亮、浅色主题下选中会话背景加强、工作区行悬停时保持文件夹图标。
69
71
 
@@ -100,9 +102,12 @@ plugin_manager install_bundle target=<本仓库绝对路径>
100
102
  | `data-dcc-full` | `on` / `off` |
101
103
  | `data-dcc-hover` | `on` / `off` |
102
104
  | `data-dcc-row-buttons` | `on` / `off` |
105
+ | `data-dcc-header-fade` | `on` / `off` |
103
106
  | `data-dcc-compact-header` | `on` / `off` |
107
+ | `data-dcc-always-show` | `on` / `off` |
104
108
  | `data-dcc-stats` | `on` / `off` |
105
109
  | `data-dcc-balance` | `on` / `off` |
110
+ | `data-dcc-balance-low` | `on` / `off`(余额低于阈值时由脚本设置)|
106
111
  | `data-dcc-pointer` | `on` / `off` |
107
112
  | `data-dcc-select` | `on` / `off` |
108
113
 
@@ -124,10 +129,17 @@ dsh-ui-alt/
124
129
 
125
130
  - 预置数据:`STORAGE_KEY`、`DEFAULTS`、`readPrefs()` / `applyPrefs()` / `savePrefs()`。
126
131
  - 一大段 `css` 字符串,全部按 `html[data-dcc-*]` 条件生效;设置页自身样式用 `.dcc-*` 前缀。
127
- - 三个 DOM 注入函数,各带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖)兜底宿主重渲染:
132
+ - 十个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
128
133
  - `installNewSessionRow()`:克隆宿主的「新会话」按钮成导航行,点击转发给原按钮。
129
134
  - `installNavToggle()`:导航下方插入展开/收起箭头,点击切换 `data-dcc-nav` 并写回偏好。
130
135
  - `installSettingsBackButton()`:设置面板左上角插入返回按钮,点击触发原关闭按钮。
136
+ - `installViewSwitcher()`:把视图标签行换成一个下拉按钮,展开后列出全部视图。
137
+ - `installBalancePill()`:在状态行显示账户余额,每 40 秒刷新一次。
138
+ - `installRowActionFilter()`:悬停会话行时只保留菜单和置顶按钮。
139
+ - `installHoverCardBlocker()`:拦截宿主的悬停卡片触发事件与延迟取数。
140
+ - `installMenuOrigin()`:记录点击坐标,让菜单从点击处展开。
141
+ - `installDialogExit()`:接管对话框移除,补一段退场动画。
142
+ - `installBootCover()`:启动时的过渡遮罩。
131
143
  - 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
132
144
 
133
145
  ## 开发
@@ -160,8 +172,10 @@ plugin_manager install_bundle target=<本仓库绝对路径>
160
172
  - 克隆出来的新会话行没有原按钮的 Tooltip 与快捷键提示(点击行为已转发)。
161
173
  - 设置返回按钮依赖宿主的 `_navTitle` / `_close` 类名。
162
174
  - 侧栏悬停卡片是预渲染的常驻节点,悬停后宿主会排一个延迟调用去取数。插件在事件层抢不到它的注册顺序,改为在悬停进入后的极短窗口内丢弃该延迟调用;其余定时器全部放行。
163
- - 余额取自宿主账户接口,未登录或接口不可用时该项不显示;余额每分钟刷新一次。
175
+ - 余额取自宿主账户接口,未登录或接口不可用时该项不显示;余额每 40 秒刷新一次。
164
176
  - 余额警告阈值只接受非负数值,负数或非法输入会被归零。
177
+ - 菜单与对话框动画依赖宿主的 `data-menu-material` / `data-menu-phase` 标记;宿主若改名,动画会静默失效。
178
+ - 第三方插件的全局动效规则(如 `[data-motion] * { animation-duration: … !important }`)会压平本插件的动画。本插件已对自身动画加 `!important` 抵御,但如果对方的特异性更高仍可能失效。
165
179
  - 余额用伪元素渲染(这样余额刷新时不会闪),因此图标只能用 `background-image` 贴上去、颜色写死为中灰;低于阈值时也是整段变红,做不到只染数字。
166
180
  - 「指针样式规范化」会把拖拽、缩放手柄的 `grab` / `resize` 光标一并压成箭头(拖拽功能本身不受影响)。
167
181
  - 「文本可选中限制」依赖宿主的 `_action` / `_time` 等类名片段来排除操作栏;宿主若改名,可能需要补充排除项。
package/client.js CHANGED
@@ -6,8 +6,8 @@ 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.249';
10
- const UPDATED = '2026-11-13';
9
+ const VERSION = '0.2.343';
10
+ const UPDATED = '2026-11-14';
11
11
  const DEFAULTS = {
12
12
  radiusDensity: true,
13
13
  invertNewSession: true,
@@ -22,7 +22,9 @@ window.__ModuleLoader__.load({
22
22
  settingsFullscreen: true,
23
23
  hideHoverCard: true,
24
24
  hideRowButtons: true,
25
+ headerFade: true,
25
26
  compactHeader: true,
27
+ compactAlwaysShow: false,
26
28
  navCollapse: true,
27
29
  optimizeStatsLayout: true,
28
30
  showBalance: true,
@@ -69,7 +71,9 @@ window.__ModuleLoader__.load({
69
71
  root.dataset.dccFull = prefs.settingsFullscreen ? 'on' : 'off';
70
72
  root.dataset.dccHover = prefs.hideHoverCard ? 'off' : 'on';
71
73
  root.dataset.dccRowButtons = prefs.hideRowButtons ? 'on' : 'off';
74
+ root.dataset.dccHeaderFade = prefs.headerFade ? 'on' : 'off';
72
75
  root.dataset.dccCompactHeader = prefs.compactHeader ? 'on' : 'off';
76
+ root.dataset.dccAlwaysShow = prefs.compactAlwaysShow ? 'on' : 'off';
73
77
  root.dataset.dccCollapse = prefs.navCollapse ? 'on' : 'off';
74
78
  root.dataset.dccStats = prefs.optimizeStatsLayout ? 'on' : 'off';
75
79
  root.dataset.dccBalance = prefs.showBalance ? 'on' : 'off';
@@ -113,6 +117,11 @@ html[data-dcc-font="on"][data-windows-titlebar] body {
113
117
  .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); }
114
118
  /* 分组标题统一降为次要色:它是分区标签,不该和设置项标题抢注意力 */
115
119
  .dcc-group-title { padding: 14px 2px 4px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
120
+ /* 依赖项未开启时置灰 */
121
+ .dcc-row-disabled {
122
+ opacity: .45;
123
+ pointer-events: none;
124
+ }
116
125
  .dcc-row { display: flex; align-items: center; gap: 16px; padding: 14px 2px; border-top: 1px solid var(--dsw-alias-border-l1); }
117
126
  .dcc-group-title + .dcc-row { border-top: none; }
118
127
  /* 无组名的组(总开关那一块)没有标题,首行同样不该有分隔线 */
@@ -139,10 +148,6 @@ body[data-ds-dark-theme] .dcc-boot-cover {
139
148
  width: 64px;
140
149
  height: auto;
141
150
  opacity: .3;
142
- color: #ffffff;
143
- }
144
- body:not([data-ds-dark-theme]) .dcc-boot-fish {
145
- color: #000000;
146
151
  }
147
152
  .dcc-boot-cover-out { opacity: 0; }
148
153
  /* 纯告知行:无右侧控件,用列表承载多条说明 */
@@ -204,7 +209,7 @@ body:not([data-ds-dark-theme]) .dcc-boot-fish {
204
209
  border-radius: var(--dsw-radius-lg, 12px);
205
210
  background: var(--dsw-alias-bg-layer-1);
206
211
  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));
212
+ animation: dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
208
213
  }
209
214
  .dcc-modal-content {
210
215
  padding: 18px 20px 4px;
@@ -307,13 +312,13 @@ html[data-dcc-radius="on"][data-windows-titlebar] [class*="_frame"] {
307
312
  --dsh-windows-content-radius: 6px !important;
308
313
  }
309
314
  /* 选择题:选中项的序号用高亮反色(和勾选框一致) */
310
- html [class*="_optionRow"][class*="_optionSelected"] [class*="_number"] {
315
+ html[data-dcc-enabled="on"] [class*="_optionRow"][class*="_optionSelected"] [class*="_number"] {
311
316
  background-color: var(--dsw-alias-label-primary) !important;
312
317
  color: var(--dsw-alias-label-primary-foreground) !important;
313
318
  font-weight: 600 !important;
314
319
  }
315
320
  /* 悬停选项时序号数字更明显,但序号底色不变(选中项由上面的反色规则接管) */
316
- html [class*="_optionRow"]:not([class*="_optionSelected"]):hover [class*="_number"] {
321
+ html[data-dcc-enabled="on"] [class*="_optionRow"]:not([class*="_optionSelected"]):hover [class*="_number"] {
317
322
  color: var(--dsw-alias-label-primary) !important;
318
323
  }
319
324
 
@@ -364,6 +369,18 @@ html[data-dcc-radius="on"] [class*="_media_"] {
364
369
  html[data-dcc-new="on"] button[data-dcc-original] {
365
370
  display: none !important;
366
371
  }
372
+ /* 原版按钮被隐藏后,它外面那层容器仍然占着高度,形成一块空白。
373
+ 用克隆行时把整层一并收掉;侧栏收窄到只剩图标时再放出来。 */
374
+ html[data-dcc-new="on"] div[class*="_newSessionRow"] {
375
+ display: none !important;
376
+ }
377
+ html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) div[class*="_newSessionRow"] {
378
+ display: block !important;
379
+ }
380
+ /* 用克隆行时,宿主给滚动区留的 4px 上边距也没有意义了 */
381
+ html[data-dcc-new="on"] [class*="_scrollRegion"] {
382
+ margin-top: 0 !important;
383
+ }
367
384
  html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) button[data-dcc-original] {
368
385
  display: flex !important;
369
386
  }
@@ -422,6 +439,7 @@ html[data-dcc-collapse="on"][data-dcc-logo="shown"] [class*="_logoRow"] {
422
439
  padding-bottom: 2px !important;
423
440
  }
424
441
 
442
+
425
443
  /* 克隆出来的新会话行在 nav 里,滚动时要固定;
426
444
  原按钮不在这里处理——它在 nav 外面本来就固定,加 sticky 和背景
427
445
  反而会让关闭开关后的外观和宿主原版不一样。 */
@@ -583,6 +601,10 @@ html[data-dcc-menu-blur="on"] [role="menu"] {
583
601
  from { opacity: 1; }
584
602
  to { opacity: 0; }
585
603
  }
604
+ @keyframes dcc-fade-in {
605
+ from { opacity: 0; }
606
+ to { opacity: 1; }
607
+ }
586
608
  @keyframes dcc-plain-in {
587
609
  from {
588
610
  opacity: 0;
@@ -606,13 +628,13 @@ html[data-dcc-menu-blur="on"] [role="menu"] {
606
628
 
607
629
  /* 兜底色:动画期间顶替失效的毛玻璃。各弹层的实际背景不一样,
608
630
  统一一个 token 会对不齐,所以按「浅色/深色 × 是否带毛玻璃」分档微调。 */
609
- body:not([data-ds-dark-theme]) {
631
+ html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) {
610
632
  --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
611
633
  }
612
- body[data-ds-dark-theme] [data-menu-material] {
634
+ html[data-dcc-enabled="on"] body[data-ds-dark-theme] [data-menu-material] {
613
635
  --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
614
636
  }
615
- body[data-ds-dark-theme] :where([role="dialog"], [role="listbox"], [role="menu"]):not([data-menu-material]) {
637
+ html[data-dcc-enabled="on"] body[data-ds-dark-theme] :where([role="dialog"], [role="listbox"], [role="menu"]):not([data-menu-material]) {
616
638
  --dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 82%, #fff);
617
639
  }
618
640
 
@@ -624,16 +646,30 @@ html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
624
646
  display: none !important;
625
647
  }
626
648
 
649
+ /* 快照里的遮罩不要重播淡入——它是退场快照的一部分,
650
+ 应该跟着外层一起淡出,否则看起来遮罩一直不消失。 */
651
+ /* 特异性必须压过下面那条入场规则,否则快照里的遮罩会重播淡入、闪出白底。
652
+ 不要改它的定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
653
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone] [class*="_mask"] {
654
+ animation: none !important;
655
+ }
656
+
657
+ /* 压暗遮罩的入场:从透明淡到实,时长与退场的 dcc-fade-out 对齐。
658
+ 带 !important,避免被其他插件的通配符动效规则压平。 */
659
+ html[data-dcc-transition="on"] [class*="_mask"] {
660
+ animation: dcc-fade-in .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
661
+ }
662
+
627
663
  /* 菜单出现/消失:整体从点击处缩放。
628
664
  transform 会让同元素的 backdrop-filter 在动画期间失效,所以动画期间
629
665
  用一层近似底色的背景兜住,避免那 130ms 出现「透明」的观感。 */
630
666
  html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="enter"] {
631
667
  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));
668
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
633
669
  }
634
670
  html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="dismiss"] {
635
671
  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;
672
+ animation: dcc-menu-out .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards !important;
637
673
  }
638
674
  /* 子菜单、列表选择器这些没有 data-menu-phase 的弹出层,
639
675
  用 role 单独命中,套同一组入场动画。对话框单独处理:
@@ -641,11 +677,11 @@ html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="dismiss"] {
641
677
  html[data-dcc-transition="on"] [role="menu"]:not([data-menu-phase]),
642
678
  html[data-dcc-transition="on"] [role="listbox"]:not([data-menu-phase]) {
643
679
  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));
680
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
645
681
  }
646
682
  html[data-dcc-transition="on"] [role="dialog"]:not([data-menu-phase]) {
647
683
  transform-origin: 50% 50%;
648
- animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
684
+ animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
649
685
  }
650
686
  /* animation 简写会把 name 重置回 dcc-menu-in,所以这条必须写在它之后 */
651
687
  html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="enter"],
@@ -653,14 +689,15 @@ html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"],
653
689
  html[data-dcc-menu-blur="on"] [role="menu"]:not([data-menu-phase]),
654
690
  html[data-dcc-menu-blur="on"] [role="listbox"]:not([data-menu-phase]),
655
691
  html[data-dcc-menu-blur="on"] [role="dialog"]:not([data-menu-phase]) {
656
- animation-name: dcc-plain-in;
692
+ animation-name: dcc-plain-in !important;
657
693
  }
658
694
  html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"] {
659
- animation-name: dcc-plain-out;
695
+ animation-name: dcc-plain-out !important;
660
696
  }
661
697
 
662
698
 
663
699
  @keyframes dcc-menu-in {
700
+ /* 缩放幅度保持 6%:再大宿主按 rect 算子菜单位置就会偏出去 */
664
701
  from {
665
702
  opacity: 0;
666
703
  transform: scale(.94);
@@ -668,9 +705,9 @@ html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"] {
668
705
  }
669
706
  to {
670
707
  opacity: 1;
708
+ /* 必须是 none 而不是 scale(1):任何非 none 的 transform 都会创建包含块,
709
+ position: fixed 的后代(子菜单)会改为相对它定位,长菜单因此错位。 */
671
710
  transform: none;
672
- /* 保持兜底到最后一帧:动画没有 forwards,结束即自动回到元素自身样式,
673
- 那时 transform 也消失、backdrop-filter 恢复,衔接无痕。 */
674
711
  background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
675
712
  }
676
713
  }
@@ -722,7 +759,7 @@ html[data-dcc-dot="on"] [class*="_sessionRow"]:has(.dsham_starSlot[data-favorite
722
759
  }
723
760
  /* 未收藏时的空心星(悬停才出现):压到与会话标题同色,不再用偏亮的 label-primary。
724
761
  已收藏的实心金星保持 archive-manager 原色,不做处理。 */
725
- html [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) .dsham_rowStar {
762
+ html[data-dcc-enabled="on"] [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) .dsham_rowStar {
726
763
  color: var(--dsw-alias-label-secondary) !important;
727
764
  }
728
765
  /* 「展开其余 N 个会话 / 收起」比工作区标题更淡 */
@@ -736,10 +773,10 @@ html[data-dcc-dim="on"] [class*="_sessionOverflowButton"]:hover {
736
773
 
737
774
  /* ---------- 工作区行:悬停时不换成展开箭头,保持文件夹图标 ---------- */
738
775
  /* 宿主默认:hover 时 .chevron 显示、.folder 隐藏(Rows.module.css)。这里反着压回去。 */
739
- html [class*="_projectRow"]:hover [class*="_folder"] {
776
+ html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_folder"] {
740
777
  display: inline-flex !important;
741
778
  }
742
- html [class*="_projectRow"]:hover [class*="_chevron"] {
779
+ html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_chevron"] {
743
780
  display: none !important;
744
781
  }
745
782
 
@@ -797,6 +834,12 @@ html[data-dcc-hover="off"] [class*="_bridge_bgejw"] {
797
834
  html[data-dcc-row-buttons="on"] [class*="_sessionRow"] [class*="_rowActions"] button[data-dcc-hidden] {
798
835
  display: none !important;
799
836
  }
837
+ /* 兜底:不等脚本标记,按按钮身份直接隐藏。
838
+ 悬停行时「菜单」和「置顶」保留,其余立刻不可见——
839
+ 脚本晚一拍也不会先闪出一排按钮。 */
840
+ html[data-dcc-row-buttons="on"] [class*="_sessionRow"]:hover [class*="_rowActions"] button:not([data-context-menu-trigger]):not([aria-label*="置顶"]):not([aria-label*="pin" i]):not([aria-label*="取消置顶"]):not([aria-label*="unpin" i]) {
841
+ display: none !important;
842
+ }
800
843
 
801
844
  /* ---------- 会话标题栏紧凑化:标签行并入顶部工具区 ---------- */
802
845
  /* 注意不能 display:none:宿主按标签行的 clientWidth 计算「能显示几个视图」,
@@ -825,70 +868,160 @@ html[data-dcc-compact-header="on"] [class*="_header"]:has([data-conversation-tab
825
868
  这一条不受「会话标题栏紧凑化」开关控制——用户关掉「轨迹」后标题栏本来就矮,
826
869
  没有标签行可压,但那根线依然不该出现。用 headerUtilities 而不是 tabs 定位,
827
870
  保证两种形态(有/无标签行)都能命中。 */
828
- [class*="_header"]:has([class*="_headerUtilities"]) {
871
+ /* 标题栏去掉硬分割线,改用内容顶部的柔边过渡 */
872
+ html[data-dcc-enabled="on"][data-dcc-header-fade="on"] [class*="_header"]:has([class*="_headerUtilities"]) {
829
873
  border-bottom: none !important;
830
874
  }
831
875
  /* 顶部柔边只给「对话」用:轨迹视图整块都是界面,渐隐会吃掉它自己的表头。
832
876
  轨道上没有 data-view 之类的标记,只能借标签页的选中态判断——
833
877
  第一个 tab 就是「对话」,它 aria-selected 时才挂 mask。 */
834
- html:has([data-conversation-tabs] [role="tab"]:first-child[aria-selected="true"]) [data-conversation-scroll] {
878
+ html[data-dcc-enabled="on"][data-dcc-header-fade="on"]:has([data-conversation-tabs] [role="tab"]:first-child[aria-selected="true"]) [data-conversation-scroll] {
835
879
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
836
880
  mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
837
881
  }
838
- html[data-dcc-compact-header="on"] [class*="_viewsMore"] {
882
+ /* 宿主自带的「更多」按钮:只在紧凑化开启时隐藏——那时标签行被本插件的
883
+ 下拉按钮取代,宿主这个按钮用不上。紧凑化关闭时标签行是原版的,
884
+ 这个按钮必须留着,否则视图被裁掉后无法访问。 */
885
+ html[data-dcc-enabled="on"][data-dcc-compact-header="on"] [class*="_viewsMoreAnchor"] {
839
886
  display: none !important;
840
887
  }
841
888
  /* 开关关掉时,自绘的分段控件不出现,标签行恢复原样 */
842
889
  html[data-dcc-compact-header="off"] .dcc-segmented {
843
890
  display: none !important;
844
891
  }
845
- /* 分组按钮:与顶部官方按钮对齐——box-sizing 让 height 含边框,
846
- 圆角用 sm(8px) 而不是 md(12px),描边用更浅的 l1。 */
892
+ /* 视图控件:一个普通的下拉按钮(当前视图名 + 箭头),点整块展开菜单。 */
847
893
  .dcc-segmented {
848
894
  box-sizing: border-box;
849
- transition: opacity .35s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
850
895
  display: inline-flex;
851
896
  align-items: stretch;
852
897
  height: 24px;
853
- /* 视图变多时向左长:不让自己被压缩,宽度由内容决定 */
854
898
  flex: none;
855
- /* 宿主给 headerUtilities 的 gap 是 8px;我们这层带 0.5px 描边和圆角,
856
- 视觉上边界内缩、显得比别的元素远一点,补 2px 回来 */
857
899
  margin-right: 2px;
858
- padding: 0;
859
- border: 0.5px solid var(--dsw-alias-border-l4);
860
- border-radius: var(--dsw-radius-sm, 8px);
861
- background: var(--dsw-alias-bg-layer-1);
862
- overflow: hidden;
900
+ opacity: 0;
901
+ transition: opacity .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
863
902
  }
864
- /* 单个分段也不压缩,标签文字保持完整 */
865
- .dcc-seg {
866
- flex: none;
867
- white-space: nowrap;
903
+ /* 悬停整个标题栏区域时浮现;鼠标直接落在控件上也保持可见 */
904
+ [class*="_header"]:hover .dcc-segmented,
905
+ .dcc-segmented:hover,
906
+ .dcc-segmented:focus-within {
907
+ opacity: 1;
908
+ }
909
+ /* 不在「对话」视图时,控件常驻显示当前视图名 */
910
+ /* 开关打开时,对话视图下也不再自动隐藏 */
911
+ html[data-dcc-always-show="on"] .dcc-segmented {
912
+ opacity: 1;
913
+ }
914
+ .dcc-segmented[data-pinned="true"] {
915
+ opacity: 1;
916
+ }
917
+ .dcc-trigger {
868
918
  display: inline-flex;
869
919
  align-items: center;
870
- border: 0;
871
- background: transparent;
872
- color: var(--dsw-alias-label-tertiary);
920
+ gap: 6px;
921
+ height: 24px;
922
+ /* 左边多给 2px:右侧有箭头撑着,等宽内边距会让左边缘显得更挤 */
923
+ padding: 0 6px 0 8px;
924
+ border: 0.5px solid var(--dsw-alias-border-l4);
925
+ border-radius: var(--dsw-radius-sm, 8px);
926
+ background: var(--dsw-alias-bg-layer-1);
927
+ color: var(--dsw-alias-label-secondary);
873
928
  font: inherit;
874
929
  font-size: 12px;
875
930
  line-height: 1;
876
- padding: 0 8px;
931
+ white-space: nowrap;
877
932
  cursor: pointer;
878
933
  transition: background-color .12s, color .12s;
879
934
  }
880
- .dcc-seg + .dcc-seg {
881
- border-left: 0.5px solid var(--dsw-alias-border-l4);
935
+ .dcc-trigger:hover {
936
+ background: var(--dsw-alias-interactive-bg-hover);
937
+ color: var(--dsw-alias-label-primary);
882
938
  }
883
- .dcc-seg:hover:not([data-active="true"]) {
939
+ .dcc-trigger[data-open="true"] {
884
940
  background: var(--dsw-alias-interactive-bg-hover);
885
941
  color: var(--dsw-alias-label-primary);
886
942
  }
887
- .dcc-seg[data-active="true"] {
943
+ .dcc-trigger-label {
944
+ max-width: 120px;
945
+ overflow: hidden;
946
+ text-overflow: ellipsis;
947
+ }
948
+ .dcc-trigger-arrow {
949
+ display: block;
950
+ width: 12px;
951
+ height: 12px;
952
+ flex: none;
953
+ transition: transform .15s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
954
+ }
955
+ .dcc-trigger[data-open="true"] .dcc-trigger-arrow {
956
+ transform: rotate(180deg);
957
+ }
958
+
959
+ /* 溢出菜单:对齐宿主菜单的尺寸与层级(圆角 12、内距 6、项高 32、项圆角 8) */
960
+ .dcc-seg-menu {
961
+ position: fixed;
962
+ z-index: 2147483000;
963
+ min-width: 140px;
964
+ padding: 6px;
965
+ border-radius: var(--dsw-radius-md, 12px);
966
+ background: var(--dsw-alias-bg-layer-1);
967
+ box-shadow:
968
+ 0 0 0 1px var(--dsw-alias-border-l2),
969
+ 0 10px 32px rgba(0, 0, 0, .24);
970
+ display: flex;
971
+ flex-direction: column;
972
+ gap: 2px;
973
+ }
974
+ .dcc-seg-menu-item {
975
+ display: flex;
976
+ align-items: center;
977
+ justify-content: space-between;
978
+ gap: 16px;
979
+ height: 32px;
980
+ padding: 0 12px;
981
+ border: 0;
982
+ border-radius: var(--dsw-radius-sm, 8px);
888
983
  background: transparent;
984
+ color: var(--dsw-alias-label-primary);
985
+ font: inherit;
986
+ font-size: 13px;
987
+ line-height: 32px;
988
+ text-align: left;
989
+ white-space: nowrap;
990
+ cursor: pointer;
991
+ }
992
+ .dcc-seg-menu-label {
993
+ min-width: 0;
994
+ overflow: hidden;
995
+ text-overflow: ellipsis;
996
+ }
997
+ .dcc-seg-menu-check {
998
+ flex: none;
999
+ width: 14px;
1000
+ height: 14px;
1001
+ opacity: 0;
1002
+ color: var(--dsw-alias-state-business-primary);
1003
+ }
1004
+ .dcc-seg-menu-check::before {
1005
+ content: '';
1006
+ display: block;
1007
+ width: 100%;
1008
+ height: 100%;
1009
+ background-color: currentColor;
1010
+ -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.2 11.7 13 4.9' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1011
+ mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.2 11.7 13 4.9' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
1012
+ -webkit-mask-size: contain;
1013
+ mask-size: contain;
1014
+ }
1015
+ .dcc-seg-menu-item[data-active="true"] .dcc-seg-menu-check {
1016
+ opacity: 1;
1017
+ }
1018
+ .dcc-seg-menu-item[data-active="true"] {
889
1019
  color: var(--dsw-alias-state-business-primary);
890
1020
  font-weight: 500;
891
1021
  }
1022
+ .dcc-seg-menu-item:hover {
1023
+ background: var(--dsw-alias-interactive-bg-hover);
1024
+ }
892
1025
 
893
1026
  /* ---------- 输入框下方状态行:速率/缓存靠左,上下文环推到最右 ---------- */
894
1027
  /* 宿主的 _dock 只有 280px 宽且居中,里面是两个子项:左边的胶囊组和包着环的
@@ -1085,7 +1218,7 @@ html[data-dcc-select="on"] body [class*="_crumb"] * {
1085
1218
  }
1086
1219
 
1087
1220
  /* ---------- 已归档会话:标题画删除线 ---------- */
1088
- html [class*="_sessionRow"][class*="_archived"] [class*="_title"] {
1221
+ html[data-dcc-enabled="on"] [class*="_sessionRow"][class*="_archived"] [class*="_title"] {
1089
1222
  text-decoration: line-through;
1090
1223
  text-decoration-thickness: 1px;
1091
1224
  }
@@ -1101,23 +1234,23 @@ html[data-dcc-dot="on"] body[data-ds-dark-theme] [class*="_sessionRow"]::before
1101
1234
  }
1102
1235
  /* 浅色主题下导航 hover 与新会话常规底色略微加强 */
1103
1236
  /* 浅色主题下选中会话的背景再强一点 */
1104
- body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
1237
+ html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
1105
1238
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .04) !important;
1106
1239
  }
1107
1240
 
1108
1241
  /* 导航行:悬停弱、选中强。
1109
1242
  宿主的激活标记不在行类名上,而是按钮的 aria-current="page",
1110
1243
  所以悬停作用在 :hover、选中作用在 [aria-current="page"],两者叠出来才有层次。 */
1111
- body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"]:hover {
1244
+ html[data-dcc-enabled="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"]:hover {
1112
1245
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .05) !important;
1113
1246
  }
1114
- body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1247
+ html[data-dcc-enabled="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1115
1248
  box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .16) !important;
1116
1249
  }
1117
- body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
1250
+ html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
1118
1251
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .025) !important;
1119
1252
  }
1120
- body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1253
+ html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
1121
1254
  box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07) !important;
1122
1255
  }
1123
1256
 
@@ -1488,9 +1621,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1488
1621
  observer.observe(document.body, { childList: true, subtree: true });
1489
1622
  document.addEventListener('click', onClick, true);
1490
1623
  document.addEventListener('mousemove', onMove, true);
1491
- /* 紧凑化开关切换后立刻重建分段控件 */
1624
+ /* 设置面板全屏 / 窗口模式切换后,返回按钮要重新对齐位置 */
1492
1625
  const onPrefs = (event) => {
1493
- if (event.detail && event.detail.key === 'compactHeader') ensure();
1626
+ if (event.detail && event.detail.key === 'settingsFullscreen') ensure();
1494
1627
  };
1495
1628
  window.addEventListener('dcc-prefs-changed', onPrefs);
1496
1629
 
@@ -1585,6 +1718,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1585
1718
  let lastRowHoverAt = 0;
1586
1719
 
1587
1720
  const onOver = (event) => {
1721
+ if (document.documentElement.dataset.dccEnabled !== 'on') return;
1588
1722
  if (document.documentElement.dataset.dccHover !== 'off') return;
1589
1723
  const target = event.target;
1590
1724
  if (!(target instanceof Element)) return;
@@ -1662,17 +1796,44 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1662
1796
 
1663
1797
  const findTabs = () => document.querySelector('[data-conversation-tabs]');
1664
1798
  const findHost = () => document.querySelector('[class*="_headerUtilities"]');
1799
+ /* 视图控件始终折叠:只显示「当前激活」+「⋯」,其余收进菜单。 */
1800
+ let segMenu = null;
1801
+ let segMenuGuard = null;
1802
+ let segMenuAnchor = null;
1803
+ const closeSegMenu = () => {
1804
+ if (segMenu !== null) {
1805
+ segMenu.remove();
1806
+ segMenu = null;
1807
+ }
1808
+ if (segMenuAnchor !== null) {
1809
+ segMenuAnchor.removeAttribute('data-open');
1810
+ /* 主动移除焦点:否则 :focus-within 会一直成立,鼠标移走后控件还留在那里 */
1811
+ if (typeof segMenuAnchor.blur === 'function') segMenuAnchor.blur();
1812
+ segMenuAnchor = null;
1813
+ }
1814
+ if (segMenuGuard !== null) {
1815
+ document.removeEventListener('pointerdown', segMenuGuard, true);
1816
+ segMenuGuard = null;
1817
+ }
1818
+ };
1665
1819
 
1666
1820
  const syncActive = () => {
1667
1821
  if (bar === null) return;
1668
1822
  const tabs = findTabs();
1669
1823
  if (tabs === null) return;
1670
1824
  const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
1671
- const items = Array.from(bar.querySelectorAll('.dcc-seg'));
1672
- for (let i = 0; i < items.length; i += 1) {
1673
- const on = sources[i] !== undefined && sources[i].getAttribute('aria-selected') === 'true';
1674
- if (on) items[i].setAttribute('data-active', 'true');
1675
- else items[i].removeAttribute('data-active');
1825
+ const activeIndex = sources.findIndex((el) => el.getAttribute('aria-selected') === 'true');
1826
+ /* 按钮上显示当前视图名 */
1827
+ const label = bar.querySelector('.dcc-trigger-label');
1828
+ if (label !== null && sources[activeIndex] !== undefined) {
1829
+ const text = (sources[activeIndex].textContent || '').trim();
1830
+ if (label.textContent !== text) label.textContent = text;
1831
+ }
1832
+ /* 第一个视图(对话)之外的页面,控件要常驻显示当前视图名。
1833
+ 宿主切视图的中间态可能一个选中项都没有(activeIndex 为 -1),
1834
+ 这时保持上一次的状态,不要误判成「回到对话」而闪一下隐藏。 */
1835
+ if (activeIndex >= 0) {
1836
+ bar.dataset.pinned = activeIndex > 0 ? 'true' : 'false';
1676
1837
  }
1677
1838
  };
1678
1839
 
@@ -1683,7 +1844,11 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1683
1844
  const rect = old.getBoundingClientRect();
1684
1845
  /* 控件已经被宿主摘掉时 rect 全是 0,照着定位会把它摆到窗口左上角。
1685
1846
  这种情况直接丢掉,不做淡出。 */
1686
- if (!old.isConnected || rect.width === 0) {
1847
+ /* 控件平时是隐藏的(opacity:0),只有标题栏被悬停时才可见。
1848
+ 不可见时做淡出没有意义,反而会凭空闪一下,所以直接丢掉。 */
1849
+ const visible = old.isConnected && rect.width > 0
1850
+ && window.getComputedStyle(old).opacity !== '0';
1851
+ if (!visible) {
1687
1852
  old.remove();
1688
1853
  } else {
1689
1854
  /* 把旧控件固定到原位置、脱离布局流再淡出——
@@ -1708,32 +1873,114 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1708
1873
  }
1709
1874
  bar = document.createElement('div');
1710
1875
  bar.className = 'dcc-segmented';
1711
- bar.style.opacity = '0';
1876
+ closeSegMenu();
1712
1877
  const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
1713
- sources.forEach((source, index) => {
1714
- const item = document.createElement('button');
1715
- item.type = 'button';
1716
- item.className = 'dcc-seg';
1717
- item.textContent = (source.textContent || '').trim();
1718
- item.addEventListener('click', () => {
1719
- /* 先乐观更新选中态,让蓝色在点击瞬间就到位;
1720
- 否则要等 observer 同步 aria-selected(有 350ms 防抖),中间会空一下。 */
1721
- const segs = bar.querySelectorAll('.dcc-seg');
1722
- for (let i = 0; i < segs.length; i += 1) {
1723
- segs[i].dataset.active = i === index ? 'true' : 'false';
1724
- }
1725
- const current = findTabs();
1726
- if (current === null) return;
1727
- const target = current.querySelectorAll('button[role="tab"]')[index];
1728
- if (target !== undefined) target.click();
1878
+ const activeIndex = sources.findIndex((el) => el.getAttribute('aria-selected') === 'true');
1879
+
1880
+ /* 把点击转发给宿主对应的标签按钮 */
1881
+ const forward = (index) => {
1882
+ const current = findTabs();
1883
+ if (current === null) return;
1884
+ const target = current.querySelectorAll('button[role="tab"]')[index];
1885
+ if (target !== undefined) target.click();
1886
+ };
1887
+
1888
+
1889
+ /* 控件就是一个普通的下拉按钮:当前视图名 + 箭头,点整块展开菜单 */
1890
+ {
1891
+ const activeIdx = activeIndex >= 0 ? activeIndex : 0;
1892
+ const trigger = document.createElement('button');
1893
+ trigger.type = 'button';
1894
+ trigger.className = 'dcc-trigger';
1895
+ trigger.setAttribute('aria-haspopup', 'menu');
1896
+ const textNode = document.createElement('span');
1897
+ textNode.className = 'dcc-trigger-label';
1898
+ textNode.textContent = sources[activeIdx] === undefined
1899
+ ? ''
1900
+ : (sources[activeIdx].textContent || '').trim();
1901
+ trigger.appendChild(textNode);
1902
+
1903
+ const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
1904
+ arrow.setAttribute('class', 'dcc-trigger-arrow');
1905
+ arrow.setAttribute('viewBox', '0 0 16 16');
1906
+ arrow.setAttribute('aria-hidden', 'true');
1907
+ const arrowPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
1908
+ arrowPath.setAttribute('d', 'M4 6.5 8 10.5 12 6.5');
1909
+ arrowPath.setAttribute('fill', 'none');
1910
+ arrowPath.setAttribute('stroke', 'currentColor');
1911
+ arrowPath.setAttribute('stroke-width', '1.6');
1912
+ arrowPath.setAttribute('stroke-linecap', 'round');
1913
+ arrowPath.setAttribute('stroke-linejoin', 'round');
1914
+ arrow.appendChild(arrowPath);
1915
+ trigger.appendChild(arrow);
1916
+ bar.appendChild(trigger);
1917
+
1918
+ const more = trigger;
1919
+ more.addEventListener('click', (event) => {
1920
+ event.stopPropagation();
1921
+ if (segMenu !== null) { closeSegMenu(); return; }
1922
+ const rect = bar.getBoundingClientRect();
1923
+ const menu = document.createElement('div');
1924
+ menu.className = 'dcc-seg-menu';
1925
+ /* 先插进 DOM 再量宽度,右边缘对齐到按钮右侧 —— 菜单宽度由内容决定,
1926
+ 不能用固定值估算,否则会对不齐。 */
1927
+ /* 用 right 对齐按钮右边缘,不需要先量宽度——
1928
+ 量宽度要读一次布局,会强制重排,表现为点击后慢半拍。 */
1929
+ menu.style.right = (window.innerWidth - rect.right) + 'px';
1930
+ menu.style.top = rect.bottom + 6 + 'px';
1931
+ const live = findTabs();
1932
+ const list = live === null ? [] : Array.from(live.querySelectorAll('button[role="tab"]'));
1933
+ const act = list.findIndex((el) => el.getAttribute('aria-selected') === 'true');
1934
+ /* 列出全部视图,当前选中的那项做标记——和标准下拉菜单一致 */
1935
+ list.forEach((source, index) => {
1936
+ const entry = document.createElement('button');
1937
+ entry.type = 'button';
1938
+ entry.className = 'dcc-seg-menu-item';
1939
+ const label = document.createElement('span');
1940
+ label.className = 'dcc-seg-menu-label';
1941
+ label.textContent = (source.textContent || '').trim();
1942
+ const check = document.createElement('span');
1943
+ check.className = 'dcc-seg-menu-check';
1944
+ check.setAttribute('aria-hidden', 'true');
1945
+ entry.append(label, check);
1946
+ if (index === act) {
1947
+ entry.dataset.active = 'true';
1948
+ entry.setAttribute('aria-current', 'true');
1949
+ }
1950
+ entry.addEventListener('click', () => {
1951
+ closeSegMenu();
1952
+ if (index === act) return;
1953
+ forward(index);
1954
+ });
1955
+ menu.appendChild(entry);
1956
+ });
1957
+ document.body.appendChild(menu);
1958
+ menu.style.transformOrigin = 'top right';
1959
+ menu.style.animation = 'dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1))';
1960
+ segMenu = menu;
1961
+ segMenuAnchor = more;
1962
+ more.setAttribute('data-open', 'true');
1963
+ window.setTimeout(() => {
1964
+ const onDown = (ev) => {
1965
+ if (segMenu !== menu) return;
1966
+ if (menu.contains(ev.target) || more.contains(ev.target)) return;
1967
+ closeSegMenu();
1968
+ };
1969
+ document.addEventListener('pointerdown', onDown, true);
1970
+ segMenuGuard = onDown;
1971
+ }, 0);
1729
1972
  });
1730
- bar.appendChild(item);
1731
- });
1973
+ }
1732
1974
  host.insertBefore(bar, host.firstChild);
1733
- window.requestAnimationFrame(() => {
1734
- if (bar !== null) bar.style.opacity = '';
1735
- });
1736
1975
  syncActive();
1976
+ /* 重建后如果这一页需要常驻显示(非对话视图),让它淡入而不是直接跳出来 */
1977
+ if (bar.dataset.pinned === 'true') {
1978
+ const fresh = bar;
1979
+ fresh.style.opacity = '0';
1980
+ window.requestAnimationFrame(() => {
1981
+ if (fresh.isConnected) fresh.style.opacity = '';
1982
+ });
1983
+ }
1737
1984
  };
1738
1985
 
1739
1986
  const ensure = () => {
@@ -1761,11 +2008,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1761
2008
  if (bar !== null && bar.isConnected && bar.parentElement !== host) {
1762
2009
  host.insertBefore(bar, host.firstChild);
1763
2010
  }
1764
- if (bar === null || !bar.isConnected || bar.children.length !== count) {
1765
- build(tabs, host);
1766
- return;
1767
- }
1768
- syncActive();
2011
+ /* 控件固定只有两项(激活项 + ⋯),不能拿它和标签总数比,
2012
+ 否则每次都会判定「数量不一致」→ 反复重建 → 看起来一直在闪。 */
2013
+ if (bar === null || !bar.isConnected) build(tabs, host);
2014
+ else syncActive();
1769
2015
  };
1770
2016
 
1771
2017
  const schedule = () => {
@@ -1777,7 +2023,20 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1777
2023
  };
1778
2024
 
1779
2025
  ensure();
1780
- observer = new MutationObserver(schedule);
2026
+ /* 切视图时 aria-selected 一变就立刻同步,不走 350ms 防抖:
2027
+ 否则非对话视图下要等半拍控件才常驻出来。 */
2028
+ const onSelect = () => {
2029
+ if (timer !== null) {
2030
+ clearTimeout(timer);
2031
+ timer = null;
2032
+ }
2033
+ ensure();
2034
+ };
2035
+ observer = new MutationObserver((records) => {
2036
+ const selected = records.some((record) => record.type === 'attributes');
2037
+ if (selected) onSelect();
2038
+ else schedule();
2039
+ });
1781
2040
  observer.observe(document.body, {
1782
2041
  childList: true,
1783
2042
  subtree: true,
@@ -1785,9 +2044,22 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1785
2044
  attributeFilter: ['aria-selected'],
1786
2045
  });
1787
2046
 
2047
+ /* 紧凑化和完整模式这两个开关变化时重建控件。
2048
+ 属性由 applyPrefs 在重渲染时写入,因此延后两帧再建,
2049
+ 否则 ensure 读到的还是旧属性值。 */
2050
+ const onPrefs = (event) => {
2051
+ if (!event.detail) return;
2052
+ const key = event.detail.key;
2053
+ if (key !== 'compactHeader' && key !== 'compactHeaderFull') return;
2054
+ window.setTimeout(() => window.requestAnimationFrame(() => ensure()), 0);
2055
+ };
2056
+ window.addEventListener('dcc-prefs-changed', onPrefs);
2057
+
1788
2058
  return () => {
2059
+ window.removeEventListener('dcc-prefs-changed', onPrefs);
1789
2060
  observer.disconnect();
1790
2061
  if (timer !== null) clearTimeout(timer);
2062
+ closeSegMenu();
1791
2063
  if (bar !== null) bar.remove();
1792
2064
  for (const ghost of ghosts) ghost.remove();
1793
2065
  ghosts.clear();
@@ -1871,14 +2143,17 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1871
2143
  }
1872
2144
  };
1873
2145
 
2146
+
1874
2147
  window.addEventListener('dcc-balance-threshold', onThreshold);
1875
2148
  /* 开关切换后立刻按已拿到的数据重算,不必等下一次轮询 */
1876
2149
  const onPrefs = (event) => {
1877
- if (event.detail && event.detail.key === 'showBalance') recalc();
2150
+ if (!event.detail) return;
2151
+ /* 小数位数变化也要立刻重算,否则要关掉设置面板才看到效果 */
2152
+ if (event.detail.key === 'showBalance' || event.detail.key === 'balanceDecimals') recalc();
1878
2153
  };
1879
2154
  window.addEventListener('dcc-prefs-changed', onPrefs);
1880
2155
  load();
1881
- refresh = window.setInterval(load, 60000);
2156
+ refresh = window.setInterval(load, 40000);
1882
2157
 
1883
2158
  return () => {
1884
2159
  window.removeEventListener('dcc-balance-threshold', onThreshold);
@@ -1997,6 +2272,11 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1997
2272
  /* 导航折叠开关本身切换后也要立刻重算,否则箭头和布局要等 400ms 防抖 */
1998
2273
  const onNavPref = (event) => {
1999
2274
  if (event.detail && event.detail.key === 'navCollapse') {
2275
+ /* 重新打开导航折叠时,默认回到收起状态——
2276
+ 否则会沿用上一次的展开状态,看起来像开关没生效。 */
2277
+ if (document.documentElement.dataset.dccCollapse === 'on') {
2278
+ document.documentElement.dataset.dccNav = 'collapsed';
2279
+ }
2000
2280
  window.setTimeout(() => ensure(), 0);
2001
2281
  }
2002
2282
  };
@@ -2036,6 +2316,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2036
2316
  if (menu.hasAttribute('data-dcc-menu-seq')) continue;
2037
2317
  seq += 1;
2038
2318
  menu.setAttribute('data-dcc-menu-seq', String(seq));
2319
+ if (document.documentElement.dataset.dccEnabled !== 'on') continue;
2039
2320
  if (document.documentElement.dataset.dccTransition !== 'on') continue;
2040
2321
  const rect = menu.getBoundingClientRect();
2041
2322
  if (rect.width <= 0 || rect.height <= 0) continue;
@@ -2102,6 +2383,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2102
2383
  };
2103
2384
 
2104
2385
  const playExit = (dialog) => {
2386
+ if (document.documentElement.dataset.dccEnabled !== 'on') return;
2105
2387
  if (document.documentElement.dataset.dccTransition !== 'on') return;
2106
2388
  /* 快照自己也是 role="dialog",不排除的话它的移除会再触发一轮快照,无限循环 */
2107
2389
  /* 标记打在克隆的遮罩层上,卡片只是它的子孙,所以用 closest 向上找 */
@@ -2123,14 +2405,16 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2123
2405
  ? 'dcc-plain-out'
2124
2406
  : 'dcc-menu-out';
2125
2407
  /* 整层统一淡出:这样压暗层和卡片一定同步,不依赖 mask 的类名是否命中 */
2126
- clone.style.animation = 'dcc-fade-out .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards';
2408
+ /* 必须带 important:CSS 里的入场动画是 !important 的,
2409
+ 内联样式不加同级就盖不过去,退场会反着放成入场。 */
2410
+ clone.style.setProperty('animation', 'dcc-fade-out .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards', 'important');
2127
2411
  /* 卡片在这之上再加缩放 */
2128
2412
  const inner = clone.querySelector('[role="dialog"]');
2129
2413
  if (inner !== null) {
2130
- inner.style.animation = `${exitAnim} .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards`;
2414
+ inner.style.setProperty('animation', `${exitAnim} .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards`, 'important');
2131
2415
  }
2132
2416
  document.body.appendChild(clone);
2133
- window.setTimeout(() => clone.remove(), 220);
2417
+ window.setTimeout(() => clone.remove(), 300);
2134
2418
  };
2135
2419
 
2136
2420
  observer = new MutationObserver((records) => {
@@ -2213,7 +2497,11 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2213
2497
  svg.setAttribute('aria-hidden', 'true');
2214
2498
  const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2215
2499
  shape.setAttribute('d', FISH_LOGO_PATH);
2216
- shape.setAttribute('fill', 'currentColor');
2500
+ /* 直接按主题写死填充色,不依赖 CSS 选择器:
2501
+ 之前靠 body:not([...]) 反色,浅色下没生效就会变成白鱼压在白底上。 */
2502
+ const darkNow = document.body.hasAttribute('data-ds-dark-theme')
2503
+ || document.documentElement.hasAttribute('data-ds-dark-theme');
2504
+ shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
2217
2505
  svg.appendChild(shape);
2218
2506
  cover.appendChild(svg);
2219
2507
  document.documentElement.appendChild(cover);
@@ -2277,11 +2565,15 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2277
2565
  }
2278
2566
 
2279
2567
  function Row(props) {
2280
- return h('div', { className: 'dcc-row' },
2568
+ return h('div', { className: props.disabled ? 'dcc-row dcc-row-disabled' : 'dcc-row' },
2281
2569
  h('div', { className: 'dcc-row-text' },
2282
2570
  h('div', { className: 'dcc-row-title' }, props.title),
2283
2571
  props.desc ? h('div', { className: 'dcc-row-desc' }, props.desc) : null),
2284
- h(Switch, { checked: props.checked, onChange: props.onChange, title: props.title }));
2572
+ h(Switch, {
2573
+ checked: props.checked,
2574
+ onChange: props.disabled ? () => {} : props.onChange,
2575
+ title: props.title,
2576
+ }));
2285
2577
  }
2286
2578
 
2287
2579
  /* 纯告知行:右侧没有任何控件,内容按纯文本渲染(换行由 pre-line 处理) */
@@ -2372,12 +2664,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2372
2664
  checked: prefs.radiusDensity,
2373
2665
  onChange: update('radiusDensity'),
2374
2666
  }),
2375
- h(Row, {
2376
- title: zh ? 'Windows 默认微软雅黑字体' : 'Microsoft YaHei on Windows',
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.',
2378
- checked: prefs.winFont,
2379
- onChange: update('winFont'),
2380
- }),
2381
2667
  h(Row, {
2382
2668
  title: zh ? '降低深色模式文字亮度' : 'Soften dark-mode text',
2383
2669
  desc: zh ? '略微降低深色模式文字亮度,避免纯白文字过于刺眼。' : 'Slightly dims text in dark mode so pure white is less harsh.',
@@ -2401,7 +2687,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2401
2687
  desc: zh ? '使用非窗口化的设置页面。' : 'Use a non-windowed settings page.',
2402
2688
  checked: prefs.settingsFullscreen,
2403
2689
  onChange: update('settingsFullscreen'),
2404
- })),
2690
+ }),
2691
+ h(Row, {
2692
+ title: zh ? 'Windows 默认使用微软雅黑字体' : 'Use Microsoft YaHei by default on Windows',
2693
+ 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.',
2694
+ checked: prefs.winFont,
2695
+ onChange: update('winFont'),
2696
+ }),
2697
+ ),
2405
2698
  h('div', { className: 'dcc-group' },
2406
2699
  h('div', { className: 'dcc-group-title' }, zh ? '导航和工作区' : 'Navigation and workspace'),
2407
2700
  h(Row, {
@@ -2428,12 +2721,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2428
2721
  checked: prefs.dimSessions,
2429
2722
  onChange: update('dimSessions'),
2430
2723
  }),
2431
- h(Row, {
2432
- title: zh ? '会话前圆点' : 'Session leading dot',
2433
- desc: zh ? '会话前显示一个圆点。' : 'Show a dot before each session.',
2434
- checked: prefs.sessionDot,
2435
- onChange: update('sessionDot'),
2436
- }),
2437
2724
  h(Row, {
2438
2725
  title: zh ? '移除工作区与会话悬停详情卡片' : 'Remove workspace and session hover cards',
2439
2726
  desc: zh ? '悬停在侧栏工作区、会话上时,不再显示详情卡片。使滚动更流畅。' : 'Hovering a workspace or session no longer shows a details card, which keeps scrolling smooth.',
@@ -2445,14 +2732,34 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2445
2732
  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.',
2446
2733
  checked: prefs.hideRowButtons,
2447
2734
  onChange: update('hideRowButtons'),
2448
- })),
2735
+ }),
2736
+ h(Row, {
2737
+ title: zh ? '会话前圆点' : 'Session leading dot',
2738
+ desc: zh ? '在侧栏工作区会话前显示一个圆点标记。' : 'Show a dot marker before each session in the sidebar.',
2739
+ checked: prefs.sessionDot,
2740
+ onChange: update('sessionDot'),
2741
+ }),
2742
+ ),
2449
2743
  h('div', { className: 'dcc-group' },
2450
2744
  h('div', { className: 'dcc-group-title' }, zh ? '会话标题栏' : 'Session header'),
2745
+ h(Row, {
2746
+ title: zh ? '柔化标题栏与会话区域过渡' : 'Soften the header-to-conversation transition',
2747
+ desc: zh ? '移除分割线,使用柔化边缘过渡标题栏和会话正文。' : 'Remove the divider and use a soft edge to ease the transition between the header and the conversation.',
2748
+ checked: prefs.headerFade,
2749
+ onChange: update('headerFade'),
2750
+ }),
2451
2751
  h(Row, {
2452
2752
  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.',
2753
+ desc: zh ? '将视图切换按钮移到右上工具按钮处。使会话内容可视范围更大。\n此按钮在对话模式下默认隐藏,鼠标位于标题栏区域时才会显示。' : 'Move the view switcher button to the toolbar buttons in the top-right, giving the conversation more room.\nIn the conversation view it is hidden by default and only appears when the pointer is over the header.',
2454
2754
  checked: prefs.compactHeader,
2455
2755
  onChange: update('compactHeader'),
2756
+ }),
2757
+ h(Row, {
2758
+ title: zh ? '紧凑标题栏始终显示视图切换控件' : 'Always show view switcher',
2759
+ desc: zh ? '在对话视图下不自动隐藏视图切换控件。' : 'Keep the view switcher visible in the conversation view instead of hiding it until hover.',
2760
+ checked: prefs.compactAlwaysShow,
2761
+ disabled: !prefs.compactHeader,
2762
+ onChange: update('compactAlwaysShow'),
2456
2763
  })),
2457
2764
  h('div', { className: 'dcc-group' },
2458
2765
  h('div', { className: 'dcc-group-title' }, zh ? '性能与用量信息' : 'Performance and usage'),
@@ -2519,7 +2826,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2519
2826
  '- 左侧导航栏部分布局细节优化。',
2520
2827
  '- 工作区文件夹悬停时保留图标。',
2521
2828
  '- 已归档会话显示删除线。',
2522
- '- 会话标题栏与正文间去除分割线,柔化过渡。',
2523
2829
  '- 选择题弹窗细节优化。',
2524
2830
  '- 避免界面加载时跳变添加的过渡遮罩。',
2525
2831
  '- 修复二级右键菜单消失延迟。',
@@ -2529,7 +2835,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2529
2835
  '- Layout details refined in the left navigation.',
2530
2836
  '- Workspace folder icons stay visible on hover.',
2531
2837
  '- Archived sessions show a strikethrough.',
2532
- '- No divider between the session header and the body; softened transition.',
2533
2838
  '- Multiple-choice dialog details refined.',
2534
2839
  '- A transition cover added to avoid layout jumps on startup.',
2535
2840
  '- Fixed the delay when closing a second-level context menu.',
@@ -2539,8 +2844,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2539
2844
  h('p', { className: 'dcc-meta' },
2540
2845
  /* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
2541
2846
  zh
2542
- ? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc2 测试`
2543
- : `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc2`),
2847
+ ? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc.3 测试`
2848
+ : `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc.3`),
2544
2849
  h('button', {
2545
2850
  type: 'button',
2546
2851
  className: 'dcc-reset',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ui-alt",
3
- "version": "0.2.249",
3
+ "version": "0.2.343",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。",