dsh-ui-alt 0.2.424 → 0.2.445
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/client.js +218 -288
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -19,11 +19,11 @@
|
|
|
19
19
|
| 开关 | 默认 | 效果 |
|
|
20
20
|
| --- | --- | --- |
|
|
21
21
|
| 减小圆角与间距 | 开 | 缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效 |
|
|
22
|
+
| 增加设置窗口尺寸 | 关 | 增加设置窗口的最大宽度和高度上限,以增加可视范围 |
|
|
22
23
|
| Windows 默认使用微软雅黑字体 | 关 | 将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响 |
|
|
23
24
|
| 降低深色模式文字亮度 | 开 | 略微降低深色模式文字亮度,避免纯白文字过于刺眼 |
|
|
24
25
|
| 为菜单和窗口添加动画 | 开 | 为菜单、对话框和压暗遮罩添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画 |
|
|
25
26
|
| 禁用菜单模糊效果 | 开 | 禁用原版菜单聊胜于无的模糊效果,增加流畅度和整体感 |
|
|
26
|
-
| 设置面板全屏 | 关 | 使用非窗口化的设置页面 |
|
|
27
27
|
|
|
28
28
|
**导航和工作区**
|
|
29
29
|
|
|
@@ -132,7 +132,6 @@ dsh-ui-alt/
|
|
|
132
132
|
- 十三个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
|
|
133
133
|
- `installNewSessionRow()`:克隆宿主的「新会话」按钮成导航行,点击转发给原按钮。
|
|
134
134
|
- `installNavToggle()`:导航下方插入展开/收起箭头,点击切换 `data-dcc-nav` 并写回偏好。
|
|
135
|
-
- `installSettingsBackButton()`:设置面板左上角插入返回按钮,点击触发原关闭按钮。
|
|
136
135
|
- `installViewSwitcher()`:把视图标签行换成一个下拉按钮,展开后列出全部视图。
|
|
137
136
|
- `installBalancePill()`:在状态行显示账户余额,每 40 秒刷新一次。
|
|
138
137
|
- `installRowActionFilter()`:悬停会话行时只保留菜单和置顶按钮。
|
|
@@ -143,6 +142,7 @@ dsh-ui-alt/
|
|
|
143
142
|
- `installReloadMenuItem()`:在标题栏三点菜单末尾追加「重载前端界面」项。
|
|
144
143
|
- `installHistoryHint()`:会话切换时把「载入历史」提示移到正文中心,并在文字上方加鲸鱼图标。
|
|
145
144
|
- `installBootHint()`:宿主加载页适配——提示文字居中、隐藏品牌字样与旋转圈。
|
|
145
|
+
- `installFirstRunNotice()`:首次安装后弹出一条提示,告知重启一次前端界面可确保功能完整生效。
|
|
146
146
|
- 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
|
|
147
147
|
|
|
148
148
|
## 开发
|
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.
|
|
10
|
-
const UPDATED = '2026-11-
|
|
9
|
+
const VERSION = '0.2.445';
|
|
10
|
+
const UPDATED = '2026-11-19';
|
|
11
11
|
const DEFAULTS = {
|
|
12
12
|
radiusDensity: true,
|
|
13
13
|
invertNewSession: true,
|
|
@@ -19,7 +19,6 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
uiTransition: true,
|
|
20
20
|
disableMenuBlur: true,
|
|
21
21
|
sessionDot: false,
|
|
22
|
-
settingsFullscreen: false,
|
|
23
22
|
hideHoverCard: true,
|
|
24
23
|
hideRowButtons: true,
|
|
25
24
|
headerFade: true,
|
|
@@ -32,6 +31,7 @@ window.__ModuleLoader__.load({
|
|
|
32
31
|
balanceDecimals: 2,
|
|
33
32
|
pointerNormalize: true,
|
|
34
33
|
textSelectLimit: true,
|
|
34
|
+
settingsWide: false,
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const isZh = () => {
|
|
@@ -65,10 +65,10 @@ window.__ModuleLoader__.load({
|
|
|
65
65
|
root.dataset.dccLogo = prefs.hideLogo ? 'hidden' : 'shown';
|
|
66
66
|
root.dataset.dccDot = prefs.sessionDot ? 'on' : 'off';
|
|
67
67
|
root.dataset.dccFont = prefs.winFont ? 'on' : 'off';
|
|
68
|
+
root.dataset.dccSettingsWide = prefs.settingsWide ? 'on' : 'off';
|
|
68
69
|
root.dataset.dccTextDim = prefs.softenDarkText ? 'on' : 'off';
|
|
69
70
|
root.dataset.dccTransition = prefs.uiTransition ? 'on' : 'off';
|
|
70
71
|
root.dataset.dccMenuBlur = prefs.disableMenuBlur ? 'on' : 'off';
|
|
71
|
-
root.dataset.dccFull = prefs.settingsFullscreen ? 'on' : 'off';
|
|
72
72
|
root.dataset.dccHover = prefs.hideHoverCard ? 'off' : 'on';
|
|
73
73
|
root.dataset.dccRowButtons = prefs.hideRowButtons ? 'on' : 'off';
|
|
74
74
|
root.dataset.dccHeaderFade = prefs.headerFade ? 'on' : 'off';
|
|
@@ -225,6 +225,8 @@ body[data-ds-dark-theme] .dcc-boot-cover {
|
|
|
225
225
|
font-size: 13px;
|
|
226
226
|
line-height: 20px;
|
|
227
227
|
color: var(--dsw-alias-label-secondary);
|
|
228
|
+
/* 文案里用 \n 分段,需要它才真的换行 */
|
|
229
|
+
white-space: pre-line;
|
|
228
230
|
}
|
|
229
231
|
.dcc-modal-actions {
|
|
230
232
|
display: flex;
|
|
@@ -244,6 +246,16 @@ body[data-ds-dark-theme] .dcc-boot-cover {
|
|
|
244
246
|
cursor: pointer;
|
|
245
247
|
}
|
|
246
248
|
.dcc-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
249
|
+
/* 主操作:实底强调色,和宿主的主按钮一致 */
|
|
250
|
+
.dcc-modal-cta {
|
|
251
|
+
border-color: transparent;
|
|
252
|
+
background: var(--dsw-alias-label-primary);
|
|
253
|
+
color: var(--dsw-alias-label-primary-foreground);
|
|
254
|
+
}
|
|
255
|
+
.dcc-modal-cta:hover {
|
|
256
|
+
background: var(--dsw-alias-label-primary);
|
|
257
|
+
opacity: .88;
|
|
258
|
+
}
|
|
247
259
|
/* 破坏性操作:常态无底色、文字红;悬停补一层淡红 */
|
|
248
260
|
.dcc-modal-primary {
|
|
249
261
|
border-color: transparent;
|
|
@@ -640,17 +652,40 @@ html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
|
|
|
640
652
|
display: none !important;
|
|
641
653
|
}
|
|
642
654
|
|
|
643
|
-
/*
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
655
|
+
/* 快照里的遮罩:
|
|
656
|
+
① 不要重播淡入——它是退场快照的一部分,应该跟着外层一起淡出。
|
|
657
|
+
特异性必须压过下面那条入场规则,否则会重播淡入、闪出白底。
|
|
658
|
+
② 去掉 backdrop-filter。宿主遮罩靠它做模糊,但带 backdrop-filter 的元素
|
|
659
|
+
在父级播 opacity 动画时,合成层会重新分配,中间闪一帧——
|
|
660
|
+
退场那 200ms 看起来就是「暗层闪了一下」。
|
|
661
|
+
快照本来就在整体淡出,模糊没有意义,去掉最干净。
|
|
662
|
+
③ 伪元素也要停。宿主的 Modal(退出登录、额度提示这些都用它)把压暗层
|
|
663
|
+
画在遮罩的 ::after 上:
|
|
664
|
+
._mask_xxx { backdrop-filter: ... }
|
|
665
|
+
._mask_xxx::after { background: var(--dsw-alias-bg-mask-1);
|
|
666
|
+
animation: _modalEnter ... }
|
|
667
|
+
只停遮罩本体的 animation,::after 仍会在克隆重新入树时从 0 重播淡入,
|
|
668
|
+
叠加到外层的 dcc-fade-out 上,就是「渐隐到一半又变暗,然后再消失」。
|
|
669
|
+
克隆只是 200ms 的退场快照,伪元素保持静止、跟着整层一起淡出即可。
|
|
670
|
+
不要改定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
|
|
671
|
+
html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"] {
|
|
672
|
+
animation: none !important;
|
|
673
|
+
-webkit-backdrop-filter: none !important;
|
|
674
|
+
backdrop-filter: none !important;
|
|
675
|
+
}
|
|
676
|
+
html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::before,
|
|
677
|
+
html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::after {
|
|
648
678
|
animation: none !important;
|
|
649
679
|
}
|
|
650
680
|
|
|
651
681
|
/* 压暗遮罩的入场:从透明淡到实,时长与退场的 dcc-fade-out 对齐。
|
|
652
|
-
带 !important,避免被其他插件的通配符动效规则压平。
|
|
653
|
-
|
|
682
|
+
带 !important,避免被其他插件的通配符动效规则压平。
|
|
683
|
+
|
|
684
|
+
_mask 这个类名在宿主的 6 个以上模块里都有(对话、附件、聊天…),
|
|
685
|
+
只对「紧挨着 dialog 的那一个」生效——Modal 的结构是
|
|
686
|
+
<div class=root><div class=mask/><div class=dialog/></div>,
|
|
687
|
+
用相邻兄弟选择器锁定,别的 mask 不碰。 */
|
|
688
|
+
html[data-dcc-transition="on"] [class*="_mask"]:has(+ [role="dialog"]) {
|
|
654
689
|
animation: dcc-fade-in .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
655
690
|
}
|
|
656
691
|
|
|
@@ -796,15 +831,14 @@ html[data-dcc-dim="on"] [class*="_sessionOverflowButton"]:hover {
|
|
|
796
831
|
宿主的文件夹图标是 16px,行高 32px,缩到 14px 后与 13px 的标题更协调。
|
|
797
832
|
其他插件在这个位置放的图标(自定义 svg、img、字符等)也一并按同一套
|
|
798
833
|
尺寸和偏移处理,保证整列左边缘对齐。 */
|
|
834
|
+
/* 宿主的工作区行图标容器叫 folderActive(Rows.module.css),
|
|
835
|
+
[class*="_folder"] 能匹配到它。_leading 在别的模块里有,但
|
|
836
|
+
Rows.module.css 里没有,写成 _projectRow ._leading 是条空规则,已删。 */
|
|
799
837
|
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_folder"] svg,
|
|
800
|
-
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_folder"] img
|
|
801
|
-
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_leading"] svg,
|
|
802
|
-
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_leading"] img,
|
|
803
|
-
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_iconSlot"] svg,
|
|
804
|
-
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_iconSlot"] img {
|
|
838
|
+
html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_folder"] img {
|
|
805
839
|
width: 14px !important;
|
|
806
840
|
height: 14px !important;
|
|
807
|
-
/*
|
|
841
|
+
/* 上移 1px 与文字基线对齐 */
|
|
808
842
|
position: relative !important;
|
|
809
843
|
top: -1px !important;
|
|
810
844
|
/* 非正方形图标按比例缩,不拉伸 */
|
|
@@ -822,8 +856,10 @@ html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_chevron"] {
|
|
|
822
856
|
|
|
823
857
|
/* ---------- 工作区:标题与会话都小一号,并同步收一点行高 ----------
|
|
824
858
|
归在「紧凑圆角与密度」开关下:密度本来就是一整套,字号不再单独开一项。 */
|
|
825
|
-
/*
|
|
826
|
-
|
|
859
|
+
/* 「工作区」分组标题:更小、更弱,并与下方项目行左对齐。
|
|
860
|
+
_sectionHeader 在宿主的任务页、模型设置页也用了同一个名字,
|
|
861
|
+
限定在侧栏的滚动区域内,避免误伤那两处。 */
|
|
862
|
+
html[data-dcc-radius="on"] [data-sidebar-scrollport] [class*="_sectionHeader"] {
|
|
827
863
|
height: 30px !important;
|
|
828
864
|
margin-bottom: 2px !important;
|
|
829
865
|
}
|
|
@@ -858,13 +894,9 @@ html[data-dcc-radius="on"] [class*="_trigger"][data-signed-out="false"] [class*=
|
|
|
858
894
|
}
|
|
859
895
|
|
|
860
896
|
/* ---------- 工作区 / 会话行的悬停提示卡片 ---------- */
|
|
861
|
-
/*
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
html[data-dcc-hover="off"] [class*="_preview_bgejw"],
|
|
865
|
-
html[data-dcc-hover="off"] [class*="_bridge_bgejw"] {
|
|
866
|
-
display: none !important;
|
|
867
|
-
}
|
|
897
|
+
/* 隐藏规则在上面的 [style*="--dsh-hover-preview-fade"] 处,
|
|
898
|
+
那条用宿主自带的 CSS 变量定位,比类名稳定——
|
|
899
|
+
宿主 HoverCard 的哈希(bgejw)会随构建变化,写死迟早失效。 */
|
|
868
900
|
|
|
869
901
|
/* ---------- 会话行悬停按钮 ---------- */
|
|
870
902
|
/* 悬停时行尾会冒出一排按钮:「…」菜单在 rowActions 里,其余(宿主归档、以及各插件
|
|
@@ -1076,6 +1108,7 @@ html[data-dcc-enabled="on"] [data-dsh-boot] [data-dcc-hint-fish] {
|
|
|
1076
1108
|
flex: none;
|
|
1077
1109
|
}
|
|
1078
1110
|
|
|
1111
|
+
|
|
1079
1112
|
/* 追加到宿主菜单末尾的「重载前端界面」:外观对齐宿主自己的菜单项,
|
|
1080
1113
|
高度、内边距、字号都按它的规格来。 */
|
|
1081
1114
|
.dcc-menu-extra {
|
|
@@ -1410,37 +1443,21 @@ html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) nav[class*="_panelLis
|
|
|
1410
1443
|
box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07) !important;
|
|
1411
1444
|
}
|
|
1412
1445
|
|
|
1413
|
-
/*
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
}
|
|
1427
|
-
/* 只在窗口足够宽时锁定两列布局,窄窗口沿用宿主自己的单列布局 */
|
|
1428
|
-
@media (min-width: 720px) {
|
|
1429
|
-
html[data-dcc-full="on"] [class*="_overlay"]:has([class*="_navTitle"]) > [class*="_panel"] {
|
|
1430
|
-
grid-template-columns: 220px minmax(0, 1fr) !important;
|
|
1431
|
-
}
|
|
1432
|
-
}
|
|
1433
|
-
/* 全屏时不需要遮罩,去掉它会露出标题栏下方的一条描边 */
|
|
1434
|
-
html[data-dcc-full="on"] [class*="_overlay"]:has([class*="_navTitle"]) [class*="_mask"] {
|
|
1435
|
-
display: none !important;
|
|
1436
|
-
}
|
|
1437
|
-
html[data-dcc-full="on"] [class*="_overlay"]:has([class*="_navTitle"]) [class*="_close"] {
|
|
1438
|
-
display: none !important;
|
|
1439
|
-
}
|
|
1440
|
-
html[data-dcc-full="on"] [class*="_overlay"]:has([class*="_navTitle"]) [class*="_navTitle"] {
|
|
1441
|
-
padding-left: 52px !important;
|
|
1442
|
-
/* 手型由脚本按文字实际矩形设置,见 installSettingsBackButton */
|
|
1446
|
+
/* 设置面板默认 800×800(宿主 SettingsRoot.module.css 里写死的),
|
|
1447
|
+
打开这个开关后放宽到 1200×900,长描述和表单不再频繁换行或被滚动截断。
|
|
1448
|
+
|
|
1449
|
+
宽度上限和最大宽度要一起放宽:宿主原值是 calc(100vw - 48px),
|
|
1450
|
+
不改的话窄窗口下会被这条先钳住,改动看不出效果。
|
|
1451
|
+
|
|
1452
|
+
高度只改上限,边距沿用宿主的:它写的是
|
|
1453
|
+
min(800px, calc(100vh - 2 * max(24px, var(--dsh-frame-overlay-top, 24px)))),
|
|
1454
|
+
max-height 那半句原样搬过来,只把 800px 换成 900px。 */
|
|
1455
|
+
html[data-dcc-settings-wide="on"] [class*="_overlay"]:has([class*="_navTitle"]) > [class*="_panel"] {
|
|
1456
|
+
width: 1200px !important;
|
|
1457
|
+
max-width: calc(100vw - 96px) !important;
|
|
1458
|
+
height: min(900px, calc(100vh - 2 * max(24px, var(--dsh-frame-overlay-top, 24px)))) !important;
|
|
1443
1459
|
}
|
|
1460
|
+
|
|
1444
1461
|
/* 设置导航项:略矮一点,归「减小圆角与间距」管 */
|
|
1445
1462
|
html[data-dcc-radius="on"] [class*="_overlay"]:has([class*="_navTitle"]) [class*="_navCell"] {
|
|
1446
1463
|
position: relative;
|
|
@@ -1448,39 +1465,6 @@ html[data-dcc-radius="on"] [class*="_overlay"]:has([class*="_navTitle"]) [class*
|
|
|
1448
1465
|
padding-top: 8px !important;
|
|
1449
1466
|
padding-bottom: 8px !important;
|
|
1450
1467
|
}
|
|
1451
|
-
html[data-dcc-full="on"] .dcc-settings-back {
|
|
1452
|
-
position: absolute;
|
|
1453
|
-
left: 14px;
|
|
1454
|
-
top: 0;
|
|
1455
|
-
z-index: 2;
|
|
1456
|
-
display: inline-flex;
|
|
1457
|
-
align-items: center;
|
|
1458
|
-
justify-content: center;
|
|
1459
|
-
width: 28px;
|
|
1460
|
-
height: 24px;
|
|
1461
|
-
padding: 0;
|
|
1462
|
-
border: 0;
|
|
1463
|
-
border-radius: var(--dsw-radius-sm);
|
|
1464
|
-
background: transparent;
|
|
1465
|
-
color: var(--dsw-alias-label-primary);
|
|
1466
|
-
cursor: pointer;
|
|
1467
|
-
transition: background-color .15s;
|
|
1468
|
-
}
|
|
1469
|
-
/* hover 也带上同样的前缀:基础规则现在是 html[data-dcc-full="on"] .dcc-settings-back
|
|
1470
|
-
(0,2,1),比裸的 .dcc-settings-back:hover(0,2,0)高,不加前缀底色会被压回去。 */
|
|
1471
|
-
html[data-dcc-full="on"] .dcc-settings-back:hover {
|
|
1472
|
-
background: var(--dsw-alias-interactive-bg-hover);
|
|
1473
|
-
}
|
|
1474
|
-
/* 悬停「设置」标题时,左侧箭头一起高亮。
|
|
1475
|
-
标题盒子撑满整行,:hover 会连空白一起算,所以这里认脚本按文字矩形写的属性。 */
|
|
1476
|
-
html[data-dcc-full="on"] [class*="_overlay"]:has([class*="_navTitle"][data-dcc-hot="on"]) .dcc-settings-back {
|
|
1477
|
-
background: var(--dsw-alias-interactive-bg-hover);
|
|
1478
|
-
}
|
|
1479
|
-
/* 非全屏时用宿主自己的关闭按钮,自绘的返回箭头不出现 */
|
|
1480
|
-
html[data-dcc-full="off"] .dcc-settings-back {
|
|
1481
|
-
display: none !important;
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
1468
|
/* ---------- 左上角品牌区 ---------- */
|
|
1485
1469
|
html[data-dcc-logo="hidden"] [class*="_brand"]:not([class*="_brandMark"]):not([class*="_brandName"]):not([class*="_brandIdentity"]),
|
|
1486
1470
|
html[data-dcc-logo="hidden"] [class*="_railMark"] {
|
|
@@ -1518,14 +1502,22 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1518
1502
|
if (wrapper !== null) wrapper.remove();
|
|
1519
1503
|
if (clone !== null) clone.remove();
|
|
1520
1504
|
|
|
1521
|
-
/*
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1505
|
+
/* 外层:照抄宿主导航项外层的类。
|
|
1506
|
+
panelEntryWide 必须带上——它决定行的宽度和右侧留白,少了整行错位。
|
|
1507
|
+
|
|
1508
|
+
但 panelEntryActive 要排除:那是「当前页面」的标记,
|
|
1509
|
+
取决于克隆时停在哪个页面。如果当时停在插件页,
|
|
1510
|
+
「插件」那一行带这个类,抄过来会让新会话行常亮
|
|
1511
|
+
(.panelEntryActive 的 background-color 是 interactive-bg-hover)。
|
|
1512
|
+
这个 bug 只在「插件页是新会话行创建时的当前页」时出现,
|
|
1513
|
+
所以看起来像随机发作。 */
|
|
1525
1514
|
const entry = row.parentElement;
|
|
1526
1515
|
wrapper = document.createElement('div');
|
|
1527
1516
|
if (entry !== null) {
|
|
1528
|
-
for (const name of entry.classList)
|
|
1517
|
+
for (const name of entry.classList) {
|
|
1518
|
+
if (name.includes('_panelEntryActive')) continue;
|
|
1519
|
+
wrapper.classList.add(name);
|
|
1520
|
+
}
|
|
1529
1521
|
}
|
|
1530
1522
|
wrapper.setAttribute('data-dcc-newrow-wrap', '');
|
|
1531
1523
|
|
|
@@ -1641,190 +1633,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1641
1633
|
};
|
|
1642
1634
|
}
|
|
1643
1635
|
|
|
1644
|
-
|
|
1645
|
-
/**
|
|
1646
|
-
* 设置面板左上角的返回按钮:点击触发原关闭按钮,保留原关闭逻辑。
|
|
1647
|
-
* 面板挂载时走 requestAnimationFrame 在下一帧补上,不让按钮比面板慢一拍;
|
|
1648
|
-
* 其它 DOM 变动仍用 350ms 兜底,避免流式输出时每帧都做全局查询。
|
|
1649
|
-
*/
|
|
1650
|
-
function installSettingsBackButton() {
|
|
1651
|
-
let btn = null;
|
|
1652
|
-
let observer = null;
|
|
1653
|
-
let timer = null;
|
|
1654
|
-
let rafId = 0;
|
|
1655
|
-
|
|
1656
|
-
const findPanel = () => {
|
|
1657
|
-
const title = document.querySelector('[class*="_navTitle"]');
|
|
1658
|
-
return title === null ? null : title.parentElement;
|
|
1659
|
-
};
|
|
1660
|
-
|
|
1661
|
-
/**
|
|
1662
|
-
* 按钮垂直位置按「标题文字的实际矩形」算——容器带 padding 时,
|
|
1663
|
-
* 盒子中心和文字中心并不重合。
|
|
1664
|
-
* 入场动画会给面板挂 transform,rect 是缩放后的,所以再除以缩放比
|
|
1665
|
-
* 还原成布局坐标,动画前后算出来的值才一致。
|
|
1666
|
-
*/
|
|
1667
|
-
const align = () => {
|
|
1668
|
-
if (btn === null || !btn.isConnected || btn.offsetParent === null) return;
|
|
1669
|
-
const title = document.querySelector('[class*="_navTitle"]');
|
|
1670
|
-
if (title === null) return;
|
|
1671
|
-
const range = document.createRange();
|
|
1672
|
-
range.selectNodeContents(title);
|
|
1673
|
-
const rects = range.getClientRects();
|
|
1674
|
-
if (rects.length === 0) return;
|
|
1675
|
-
const textRect = rects[0];
|
|
1676
|
-
const panel = btn.offsetParent;
|
|
1677
|
-
const panelRect = panel.getBoundingClientRect();
|
|
1678
|
-
const scale = panel.offsetHeight > 0 ? panelRect.height / panel.offsetHeight : 1;
|
|
1679
|
-
const centerY = (textRect.top + textRect.height / 2 - panelRect.top) / (scale > 0 ? scale : 1);
|
|
1680
|
-
btn.style.top = `${Math.round(centerY - btn.offsetHeight / 2)}px`;
|
|
1681
|
-
};
|
|
1682
|
-
|
|
1683
|
-
const closePanel = (panel) => {
|
|
1684
|
-
const close = panel.querySelector('[class*="_header"] [class*="_close"]');
|
|
1685
|
-
if (close !== null) close.click();
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
const ensure = () => {
|
|
1689
|
-
/* 总开关关闭时自绘按钮也要撤掉,否则会留下一个没有样式的裸按钮 */
|
|
1690
|
-
if (document.documentElement.dataset.dccEnabled !== 'on') {
|
|
1691
|
-
if (btn !== null) btn.remove();
|
|
1692
|
-
btn = null;
|
|
1693
|
-
return;
|
|
1694
|
-
}
|
|
1695
|
-
const panel = findPanel();
|
|
1696
|
-
if (panel === null) {
|
|
1697
|
-
if (btn !== null) btn.remove();
|
|
1698
|
-
btn = null;
|
|
1699
|
-
return;
|
|
1700
|
-
}
|
|
1701
|
-
if (btn !== null && btn.isConnected && btn.parentElement === panel) {
|
|
1702
|
-
align();
|
|
1703
|
-
return;
|
|
1704
|
-
}
|
|
1705
|
-
if (btn !== null) btn.remove();
|
|
1706
|
-
btn = document.createElement('button');
|
|
1707
|
-
btn.type = 'button';
|
|
1708
|
-
btn.className = 'dcc-settings-back';
|
|
1709
|
-
btn.setAttribute('aria-label', isZh() ? '返回' : 'Back');
|
|
1710
|
-
btn.title = isZh() ? '返回' : 'Back';
|
|
1711
|
-
btn.innerHTML = '<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true">'
|
|
1712
|
-
+ '<path d="M10 3 5 8l5 5" fill="none" stroke="currentColor" stroke-width="1.6"'
|
|
1713
|
-
+ ' stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
1714
|
-
btn.addEventListener('click', () => closePanel(panel));
|
|
1715
|
-
panel.appendChild(btn);
|
|
1716
|
-
align();
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
const insertSoon = () => {
|
|
1720
|
-
if (rafId !== 0) return;
|
|
1721
|
-
rafId = window.requestAnimationFrame(() => {
|
|
1722
|
-
rafId = 0;
|
|
1723
|
-
ensure();
|
|
1724
|
-
/* 万一这一帧面板还没挂完,退回原来的兜底节奏 */
|
|
1725
|
-
if (btn === null && timer === null) {
|
|
1726
|
-
timer = window.setTimeout(() => {
|
|
1727
|
-
timer = null;
|
|
1728
|
-
ensure();
|
|
1729
|
-
}, 350);
|
|
1730
|
-
}
|
|
1731
|
-
});
|
|
1732
|
-
};
|
|
1733
|
-
|
|
1734
|
-
const schedule = (records) => {
|
|
1735
|
-
/* 面板是「新增了包含 _navTitle 的节点」,这类变动要求下一帧就有按钮 */
|
|
1736
|
-
for (const record of records) {
|
|
1737
|
-
for (const node of record.addedNodes) {
|
|
1738
|
-
if (node.nodeType !== 1) continue;
|
|
1739
|
-
if (node.matches('[class*="_navTitle"]') || node.querySelector('[class*="_navTitle"]') !== null) {
|
|
1740
|
-
insertSoon();
|
|
1741
|
-
return;
|
|
1742
|
-
}
|
|
1743
|
-
}
|
|
1744
|
-
}
|
|
1745
|
-
if (timer !== null) return;
|
|
1746
|
-
timer = window.setTimeout(() => {
|
|
1747
|
-
timer = null;
|
|
1748
|
-
ensure();
|
|
1749
|
-
}, 350);
|
|
1750
|
-
};
|
|
1751
|
-
|
|
1752
|
-
/* 标题元素被撑满整行,空白处也在它盒子里;只有落在文字实际矩形上才算点击。
|
|
1753
|
-
左侧再放宽一点,把标题与返回箭头之间那段 padding 空隙也算进来。 */
|
|
1754
|
-
const LABEL_LEFT_SLACK = 14;
|
|
1755
|
-
const hitsLabel = (title, event) => {
|
|
1756
|
-
const range = document.createRange();
|
|
1757
|
-
range.selectNodeContents(title);
|
|
1758
|
-
const rects = range.getClientRects();
|
|
1759
|
-
for (let i = 0; i < rects.length; i += 1) {
|
|
1760
|
-
const rect = rects[i];
|
|
1761
|
-
if (event.clientX >= rect.left - LABEL_LEFT_SLACK && event.clientX <= rect.right
|
|
1762
|
-
&& event.clientY >= rect.top && event.clientY <= rect.bottom) return true;
|
|
1763
|
-
}
|
|
1764
|
-
return false;
|
|
1765
|
-
};
|
|
1766
|
-
|
|
1767
|
-
/* 点面板标题(「设置」这几个字)也能返回;用委托,面板重渲染不会丢监听 */
|
|
1768
|
-
const onClick = (event) => {
|
|
1769
|
-
if (document.documentElement.dataset.dccFull !== 'on') return;
|
|
1770
|
-
const target = event.target;
|
|
1771
|
-
if (!(target instanceof Element)) return;
|
|
1772
|
-
const title = target.closest('[class*="_navTitle"]');
|
|
1773
|
-
if (title === null || title.parentElement === null) return;
|
|
1774
|
-
if (!hitsLabel(title, event)) return;
|
|
1775
|
-
closePanel(title.parentElement);
|
|
1776
|
-
};
|
|
1777
|
-
|
|
1778
|
-
/* 手型和高亮都只跟着文字走:整行都是标题的盒子,空白不该有可点反馈 */
|
|
1779
|
-
let cursorTitle = null;
|
|
1780
|
-
const clearHot = () => {
|
|
1781
|
-
if (cursorTitle === null) return;
|
|
1782
|
-
cursorTitle.style.cursor = '';
|
|
1783
|
-
cursorTitle.dataset.dccHot = 'off';
|
|
1784
|
-
cursorTitle = null;
|
|
1785
|
-
};
|
|
1786
|
-
const onMove = (event) => {
|
|
1787
|
-
if (document.documentElement.dataset.dccFull !== 'on') {
|
|
1788
|
-
clearHot();
|
|
1789
|
-
return;
|
|
1790
|
-
}
|
|
1791
|
-
const target = event.target;
|
|
1792
|
-
const title = target instanceof Element ? target.closest('[class*="_navTitle"]') : null;
|
|
1793
|
-
if (title === null) {
|
|
1794
|
-
clearHot();
|
|
1795
|
-
return;
|
|
1796
|
-
}
|
|
1797
|
-
const hot = hitsLabel(title, event);
|
|
1798
|
-
const want = hot ? 'pointer' : '';
|
|
1799
|
-
if (title.style.cursor !== want) title.style.cursor = want;
|
|
1800
|
-
const wantHot = hot ? 'on' : 'off';
|
|
1801
|
-
if (title.dataset.dccHot !== wantHot) title.dataset.dccHot = wantHot;
|
|
1802
|
-
cursorTitle = title;
|
|
1803
|
-
};
|
|
1804
|
-
|
|
1805
|
-
ensure();
|
|
1806
|
-
observer = new MutationObserver(schedule);
|
|
1807
|
-
observer.observe(document.body, { childList: true, subtree: true });
|
|
1808
|
-
document.addEventListener('click', onClick, true);
|
|
1809
|
-
document.addEventListener('mousemove', onMove, true);
|
|
1810
|
-
/* 设置面板全屏 / 窗口模式切换后,返回按钮要重新对齐位置 */
|
|
1811
|
-
const onPrefs = (event) => {
|
|
1812
|
-
if (event.detail && event.detail.key === 'settingsFullscreen') ensure();
|
|
1813
|
-
};
|
|
1814
|
-
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
1815
|
-
|
|
1816
|
-
return () => {
|
|
1817
|
-
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
1818
|
-
observer.disconnect();
|
|
1819
|
-
if (timer !== null) clearTimeout(timer);
|
|
1820
|
-
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
1821
|
-
document.removeEventListener('click', onClick, true);
|
|
1822
|
-
document.removeEventListener('mousemove', onMove, true);
|
|
1823
|
-
if (cursorTitle !== null) clearHot();
|
|
1824
|
-
if (btn !== null) btn.remove();
|
|
1825
|
-
};
|
|
1826
|
-
}
|
|
1827
|
-
|
|
1828
1636
|
/**
|
|
1829
1637
|
* 会话行悬停时只留「…」菜单和置顶按钮,其余(宿主的归档、各插件加的)隐藏。
|
|
1830
1638
|
* 按钮上只有共用的 iconButton 类,所以按 data-context-menu-trigger 和 aria-label
|
|
@@ -2358,6 +2166,129 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2358
2166
|
};
|
|
2359
2167
|
}
|
|
2360
2168
|
|
|
2169
|
+
/**
|
|
2170
|
+
* 安装/更新/降级后的重载提示。
|
|
2171
|
+
*
|
|
2172
|
+
* 插件是运行期动态注入的,有些宿主元素在注入那一刻还没渲染出来,
|
|
2173
|
+
* 少数依赖它们的模块(视图切换控件、新会话行克隆)可能来不及建立。
|
|
2174
|
+
* 重新载入一次就都正常了。
|
|
2175
|
+
*
|
|
2176
|
+
* 判定用 localStorage 里的版本标记:
|
|
2177
|
+
* 标记缺失 → 首次安装
|
|
2178
|
+
* 标记不等于当前 → 升级或降级
|
|
2179
|
+
* 两种情况都提示;标记相同则不打扰。
|
|
2180
|
+
*
|
|
2181
|
+
* 不自动刷新——那会在用户正用着的时候把页面抽走。
|
|
2182
|
+
* 弹一个对话框,把决定权交回给用户。
|
|
2183
|
+
*/
|
|
2184
|
+
function installFirstRunNotice() {
|
|
2185
|
+
const KEY = 'dsh-ui-alt:installed';
|
|
2186
|
+
let last = null;
|
|
2187
|
+
try {
|
|
2188
|
+
last = localStorage.getItem(KEY);
|
|
2189
|
+
localStorage.setItem(KEY, VERSION);
|
|
2190
|
+
} catch {
|
|
2191
|
+
/* 存储不可用时不提示,也不影响其它功能 */
|
|
2192
|
+
return () => {};
|
|
2193
|
+
}
|
|
2194
|
+
if (last === VERSION) return () => {};
|
|
2195
|
+
|
|
2196
|
+
let modal = null;
|
|
2197
|
+
let timer = 0;
|
|
2198
|
+
|
|
2199
|
+
/* 界面是否真的画出来了。启动遮罩和这个弹窗都靠它判断——
|
|
2200
|
+
遮罩还没收走(宿主的加载页还在)时弹窗会浮在一片空黑上,
|
|
2201
|
+
看不到被压暗的界面,观感像「背景是纯黑」。 */
|
|
2202
|
+
const ready = () => {
|
|
2203
|
+
const sidebar = document.querySelector('[class*="_root"]:has(nav[class*="_panelList"])');
|
|
2204
|
+
if (sidebar === null) return false;
|
|
2205
|
+
const rect = sidebar.getBoundingClientRect();
|
|
2206
|
+
return rect.width > 100 && rect.height > 100;
|
|
2207
|
+
};
|
|
2208
|
+
|
|
2209
|
+
/* 轮询等待界面就绪,最多等 20 秒;超时也弹,总比一直不提示好 */
|
|
2210
|
+
let waited = 0;
|
|
2211
|
+
const waitReady = () => {
|
|
2212
|
+
timer = 0;
|
|
2213
|
+
if (modal !== null) return;
|
|
2214
|
+
if (ready() || waited >= 20000) { show(); return; }
|
|
2215
|
+
waited += 200;
|
|
2216
|
+
timer = window.setTimeout(waitReady, 200);
|
|
2217
|
+
};
|
|
2218
|
+
timer = window.setTimeout(waitReady, 1000);
|
|
2219
|
+
|
|
2220
|
+
const close = () => {
|
|
2221
|
+
if (modal !== null) { modal.remove(); modal = null; }
|
|
2222
|
+
document.removeEventListener('keydown', onKey, true);
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const onKey = (event) => {
|
|
2226
|
+
if (event.key === 'Escape') close();
|
|
2227
|
+
};
|
|
2228
|
+
|
|
2229
|
+
function show() {
|
|
2230
|
+
timer = 0;
|
|
2231
|
+
if (modal !== null) return;
|
|
2232
|
+
|
|
2233
|
+
modal = document.createElement('div');
|
|
2234
|
+
modal.className = 'dcc-modal';
|
|
2235
|
+
modal.setAttribute('role', 'dialog');
|
|
2236
|
+
modal.setAttribute('aria-modal', 'true');
|
|
2237
|
+
modal.setAttribute('aria-label', isZh() ? 'UI 改进' : 'UI improvements');
|
|
2238
|
+
|
|
2239
|
+
const mask = document.createElement('div');
|
|
2240
|
+
mask.className = 'dcc-modal-mask';
|
|
2241
|
+
|
|
2242
|
+
const card = document.createElement('div');
|
|
2243
|
+
card.className = 'dcc-modal-card';
|
|
2244
|
+
|
|
2245
|
+
const content = document.createElement('div');
|
|
2246
|
+
content.className = 'dcc-modal-content';
|
|
2247
|
+
|
|
2248
|
+
const title = document.createElement('div');
|
|
2249
|
+
title.className = 'dcc-modal-title';
|
|
2250
|
+
title.textContent = isZh() ? 'UI 改进' : 'UI improvements';
|
|
2251
|
+
|
|
2252
|
+
const body = document.createElement('div');
|
|
2253
|
+
body.className = 'dcc-modal-body';
|
|
2254
|
+
body.textContent = isZh()
|
|
2255
|
+
? '安装/更新完成。需要重新载入一次前端界面,确保功能正常生效。\n此操作不会影响运行中的任务。'
|
|
2256
|
+
: 'Installed/updated. Reload the frontend once so every feature takes effect.\nRunning tasks are not affected.';
|
|
2257
|
+
|
|
2258
|
+
content.append(title, body);
|
|
2259
|
+
|
|
2260
|
+
const actions = document.createElement('div');
|
|
2261
|
+
actions.className = 'dcc-modal-actions';
|
|
2262
|
+
|
|
2263
|
+
const later = document.createElement('button');
|
|
2264
|
+
later.type = 'button';
|
|
2265
|
+
later.className = 'dcc-modal-btn';
|
|
2266
|
+
later.textContent = isZh() ? '稍后自行重启' : 'Restart later';
|
|
2267
|
+
later.addEventListener('click', close);
|
|
2268
|
+
|
|
2269
|
+
const reload = document.createElement('button');
|
|
2270
|
+
reload.type = 'button';
|
|
2271
|
+
reload.className = 'dcc-modal-btn dcc-modal-cta';
|
|
2272
|
+
reload.textContent = isZh() ? '立即重载' : 'Reload now';
|
|
2273
|
+
reload.addEventListener('click', () => {
|
|
2274
|
+
window.location.reload();
|
|
2275
|
+
});
|
|
2276
|
+
|
|
2277
|
+
actions.append(later, reload);
|
|
2278
|
+
card.append(content, actions);
|
|
2279
|
+
modal.append(mask, card);
|
|
2280
|
+
document.body.appendChild(modal);
|
|
2281
|
+
/* Esc 关闭:用捕获阶段,先于宿主自己的 Esc 处理 */
|
|
2282
|
+
document.addEventListener('keydown', onKey, true);
|
|
2283
|
+
reload.focus();
|
|
2284
|
+
}
|
|
2285
|
+
|
|
2286
|
+
return () => {
|
|
2287
|
+
if (timer !== 0) window.clearTimeout(timer);
|
|
2288
|
+
close();
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
|
|
2361
2292
|
/**
|
|
2362
2293
|
* 宿主加载页(开机时的 "Loading plugins…" 那一屏)的外观适配。
|
|
2363
2294
|
*
|
|
@@ -3177,10 +3108,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3177
3108
|
onChange: update('disableMenuBlur'),
|
|
3178
3109
|
}),
|
|
3179
3110
|
h(Row, {
|
|
3180
|
-
title: zh ? '
|
|
3181
|
-
desc: zh ? '
|
|
3182
|
-
checked: prefs.
|
|
3183
|
-
onChange: update('
|
|
3111
|
+
title: zh ? '增加设置窗口尺寸' : 'Larger settings panel',
|
|
3112
|
+
desc: zh ? '增加设置窗口的最大宽度和高度上限,以增加可视范围。' : 'Raises the settings panel maximum width and height caps for more visible content.',
|
|
3113
|
+
checked: prefs.settingsWide,
|
|
3114
|
+
onChange: update('settingsWide'),
|
|
3184
3115
|
}),
|
|
3185
3116
|
h(Row, {
|
|
3186
3117
|
title: zh ? 'Windows 默认使用微软雅黑字体' : 'Use Microsoft YaHei by default on Windows',
|
|
@@ -3340,8 +3271,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3340
3271
|
h('p', { className: 'dcc-meta' },
|
|
3341
3272
|
/* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
|
|
3342
3273
|
zh
|
|
3343
|
-
? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc.
|
|
3344
|
-
: `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc.
|
|
3274
|
+
? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc.5 测试`
|
|
3275
|
+
: `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc.5`),
|
|
3345
3276
|
h('button', {
|
|
3346
3277
|
type: 'button',
|
|
3347
3278
|
className: 'dcc-reset',
|
|
@@ -3391,7 +3322,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3391
3322
|
removeCss = () => tag.remove();
|
|
3392
3323
|
}
|
|
3393
3324
|
const removeNewSessionRow = installNewSessionRow();
|
|
3394
|
-
const removeSettingsBack = installSettingsBackButton();
|
|
3395
3325
|
const removeRowActionFilter = installRowActionFilter();
|
|
3396
3326
|
const removeHoverCardBlocker = installHoverCardBlocker();
|
|
3397
3327
|
const removeViewSwitcher = installViewSwitcher();
|
|
@@ -3402,12 +3332,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3402
3332
|
const removeReloadItem = installReloadMenuItem();
|
|
3403
3333
|
const removeHistoryHint = installHistoryHint();
|
|
3404
3334
|
const removeBootHint = installBootHint();
|
|
3335
|
+
const removeFirstRun = installFirstRunNotice();
|
|
3405
3336
|
const removeDialogExit = installDialogExit();
|
|
3406
3337
|
return () => {
|
|
3407
3338
|
removeCss();
|
|
3408
3339
|
removeNewSessionRow();
|
|
3409
|
-
|
|
3410
|
-
removeRowActionFilter();
|
|
3340
|
+
removeRowActionFilter();
|
|
3411
3341
|
removeHoverCardBlocker();
|
|
3412
3342
|
removeViewSwitcher();
|
|
3413
3343
|
removeBalance();
|
|
@@ -3417,6 +3347,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3417
3347
|
removeReloadItem();
|
|
3418
3348
|
removeHistoryHint();
|
|
3419
3349
|
removeBootHint();
|
|
3350
|
+
removeFirstRun();
|
|
3420
3351
|
removeDialogExit();
|
|
3421
3352
|
const root = document.documentElement;
|
|
3422
3353
|
delete root.dataset.dccRadius;
|
|
@@ -3429,7 +3360,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
3429
3360
|
delete root.dataset.dccTextDim;
|
|
3430
3361
|
delete root.dataset.dccTransition;
|
|
3431
3362
|
delete root.dataset.dccMenuBlur;
|
|
3432
|
-
delete root.dataset.dccFull;
|
|
3433
3363
|
delete root.dataset.dccHover;
|
|
3434
3364
|
delete root.dataset.dccRowButtons;
|
|
3435
3365
|
delete root.dataset.dccCompactHeader;
|