dsh-ui-alt 0.2.343 → 0.2.422
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 +7 -4
- package/client.js +545 -63
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
| 操作 | 说明 |
|
|
12
12
|
| --- | --- |
|
|
13
|
-
| 总开关 |
|
|
13
|
+
| 总开关 | 关闭后将禁用全部修改,包括始终启用的基础改进;打开和关闭会重载前端界面,不影响正在运行的任务 |
|
|
14
14
|
| 重载前端界面 | 调整本插件设置后建议执行一次。使用了其他修改前端界面类的插件也可以在此处重载。只影响前端,不影响正在运行的任务 |
|
|
15
15
|
| 重置设置 | 把本插件的所有设置项恢复为默认值,确认后自动重载界面 |
|
|
16
16
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
| 降低深色模式文字亮度 | 开 | 略微降低深色模式文字亮度,避免纯白文字过于刺眼 |
|
|
24
24
|
| 为菜单和窗口添加动画 | 开 | 为菜单、对话框和压暗遮罩添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画 |
|
|
25
25
|
| 禁用菜单模糊效果 | 开 | 禁用原版菜单聊胜于无的模糊效果,增加流畅度和整体感 |
|
|
26
|
-
| 设置面板全屏 |
|
|
26
|
+
| 设置面板全屏 | 关 | 使用非窗口化的设置页面 |
|
|
27
27
|
|
|
28
28
|
**导航和工作区**
|
|
29
29
|
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
|
|
66
66
|
| 项 | 说明 |
|
|
67
67
|
| --- | --- |
|
|
68
|
-
| 基础细节改进和修复 |
|
|
68
|
+
| 基础细节改进和修复 | 这些基础修复和改进影响很小,会始终启用,除非关闭总开关:左侧导航栏布局细节、工作区文件夹悬停保留图标、已归档会话删除线、选择题弹窗细节、优化加载界面、二级右键菜单消失延迟、顶栏三点菜单内的刷新前端界面按钮 |
|
|
69
69
|
|
|
70
70
|
另有一些不挂开关的固定样式:设置导航列宽 220px、归档会话标题画删除线、选择题选中项的序号反色高亮、浅色主题下选中会话背景加强、工作区行悬停时保持文件夹图标。
|
|
71
71
|
|
|
@@ -129,7 +129,7 @@ dsh-ui-alt/
|
|
|
129
129
|
|
|
130
130
|
- 预置数据:`STORAGE_KEY`、`DEFAULTS`、`readPrefs()` / `applyPrefs()` / `savePrefs()`。
|
|
131
131
|
- 一大段 `css` 字符串,全部按 `html[data-dcc-*]` 条件生效;设置页自身样式用 `.dcc-*` 前缀。
|
|
132
|
-
-
|
|
132
|
+
- 十三个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
|
|
133
133
|
- `installNewSessionRow()`:克隆宿主的「新会话」按钮成导航行,点击转发给原按钮。
|
|
134
134
|
- `installNavToggle()`:导航下方插入展开/收起箭头,点击切换 `data-dcc-nav` 并写回偏好。
|
|
135
135
|
- `installSettingsBackButton()`:设置面板左上角插入返回按钮,点击触发原关闭按钮。
|
|
@@ -140,6 +140,9 @@ dsh-ui-alt/
|
|
|
140
140
|
- `installMenuOrigin()`:记录点击坐标,让菜单从点击处展开。
|
|
141
141
|
- `installDialogExit()`:接管对话框移除,补一段退场动画。
|
|
142
142
|
- `installBootCover()`:启动时的过渡遮罩。
|
|
143
|
+
- `installReloadMenuItem()`:在标题栏三点菜单末尾追加「重载前端界面」项。
|
|
144
|
+
- `installHistoryHint()`:会话切换时把「载入历史」提示移到正文中心,并在文字上方加鲸鱼图标。
|
|
145
|
+
- `installBootHint()`:宿主加载页适配——提示文字居中、隐藏品牌字样与旋转圈。
|
|
143
146
|
- 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
|
|
144
147
|
|
|
145
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.422';
|
|
10
|
+
const UPDATED = '2026-11-17';
|
|
11
11
|
const DEFAULTS = {
|
|
12
12
|
radiusDensity: true,
|
|
13
13
|
invertNewSession: true,
|
|
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
uiTransition: true,
|
|
20
20
|
disableMenuBlur: true,
|
|
21
21
|
sessionDot: false,
|
|
22
|
-
settingsFullscreen:
|
|
22
|
+
settingsFullscreen: false,
|
|
23
23
|
hideHoverCard: true,
|
|
24
24
|
hideRowButtons: true,
|
|
25
25
|
headerFade: true,
|
|
@@ -335,13 +335,10 @@ html[data-dcc-radius="on"] [class*="_trailing"] > [class*="_primary"] svg {
|
|
|
335
335
|
}
|
|
336
336
|
/* 输入框左下角的「+」:宿主是 999px 圆形,同样收成小圆角方形;
|
|
337
337
|
底色也去掉,只在悬停时给出来(宿主的原始底色就是这一档)。 */
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
html[data-dcc-radius="on"] button[class*="_add"]:hover {
|
|
343
|
-
background: var(--dsw-specific-selector) !important;
|
|
344
|
-
}
|
|
338
|
+
/* 输入框左下角「+」按钮的圆角与底色收尾已移除。
|
|
339
|
+
_add 这个片段太泛滥:宿主的工具栏用的是 _addGroup / _addPrimary / _addMore,
|
|
340
|
+
全都含 _add,逐个排除既啰嗦又容易漏(_addMore 就漏过一次)。
|
|
341
|
+
这个按钮只是个小细节,不值得为它承担误伤工具栏的风险。
|
|
345
342
|
|
|
346
343
|
/* 主内容区左上角的大圆角(Windows 标题栏) */
|
|
347
344
|
html[data-dcc-radius="on"][data-windows-titlebar] [class*="_centerCol"] {
|
|
@@ -384,30 +381,26 @@ html[data-dcc-new="on"] [class*="_scrollRegion"] {
|
|
|
384
381
|
html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) button[data-dcc-original] {
|
|
385
382
|
display: flex !important;
|
|
386
383
|
}
|
|
387
|
-
html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"])
|
|
384
|
+
html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) [data-dcc-newrow-wrap] {
|
|
388
385
|
display: none !important;
|
|
389
386
|
}
|
|
390
|
-
html[data-dcc-new="off"]
|
|
387
|
+
html[data-dcc-new="off"] [data-dcc-newrow-wrap] {
|
|
391
388
|
display: none !important;
|
|
392
389
|
}
|
|
393
|
-
/*
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
html[data-dcc-new="on"] button[data-dcc-newrow] {
|
|
397
|
-
|
|
390
|
+
/* 原版新会话的图标是 14px,其它导航项是 16px。
|
|
391
|
+
图标小、包裹层就窄,整行的图标和文字都跟着左移或右偏。
|
|
392
|
+
最省事的办法就是把图标放大到 16px,尺寸和别的行完全一致。 */
|
|
393
|
+
html[data-dcc-new="on"] button[data-dcc-newrow] svg {
|
|
394
|
+
width: 16px !important;
|
|
395
|
+
height: 16px !important;
|
|
398
396
|
}
|
|
399
|
-
.dcc-newrow-
|
|
400
|
-
display: flex;
|
|
397
|
+
.dcc-newrow-glyph {
|
|
398
|
+
display: inline-flex;
|
|
401
399
|
align-items: center;
|
|
402
|
-
justify-content:
|
|
403
|
-
gap: calc(var(--dsh-sidebar-label-gap) + 2px);
|
|
404
|
-
flex: 1;
|
|
405
|
-
min-width: 0;
|
|
406
|
-
}
|
|
407
|
-
.dcc-newrow-content svg {
|
|
408
|
-
width: 16px;
|
|
409
|
-
height: 16px;
|
|
400
|
+
justify-content: center;
|
|
410
401
|
flex: none;
|
|
402
|
+
}
|
|
403
|
+
.dcc-newrow-glyph svg {
|
|
411
404
|
color: inherit;
|
|
412
405
|
}
|
|
413
406
|
.dcc-newrow-label {
|
|
@@ -440,14 +433,15 @@ html[data-dcc-collapse="on"][data-dcc-logo="shown"] [class*="_logoRow"] {
|
|
|
440
433
|
}
|
|
441
434
|
|
|
442
435
|
|
|
443
|
-
/*
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
436
|
+
/* sticky 只在「导航折叠」开启时生效。
|
|
437
|
+
那时 _panelList 不参与滚动(滚动收在 _listArea 里),这一行本来也不会跑掉,
|
|
438
|
+
sticky 只是保险。折叠关闭时侧栏整块滚动,而这一行没有自己的背景
|
|
439
|
+
(底色交给宿主的 _panelEntry),sticky 会让下方内容从它下面穿过去——
|
|
440
|
+
那种情况下让它跟着滚,和宿主原版行为一致。 */
|
|
441
|
+
html[data-dcc-collapse="on"] [data-dcc-newrow-wrap] {
|
|
447
442
|
position: sticky;
|
|
448
443
|
top: 0;
|
|
449
444
|
z-index: 3;
|
|
450
|
-
background: var(--dsw-specific-sidebar-fill, var(--dsw-alias-bg-layer-1));
|
|
451
445
|
}
|
|
452
446
|
|
|
453
447
|
/* 侧栏滚动下放:整块滚动容器不再滚动,改成纵向布局;
|
|
@@ -740,7 +734,7 @@ html[data-dcc-dot="on"] [class*="_sessionRow"] {
|
|
|
740
734
|
html[data-dcc-dot="on"] [class*="_sessionRow"]::before {
|
|
741
735
|
content: "";
|
|
742
736
|
position: absolute;
|
|
743
|
-
left: calc(var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset) + var(--dsh-workspace-indent, 0px) + 8px -
|
|
737
|
+
left: calc(var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset) + var(--dsh-workspace-indent, 0px) + 8px - 5px);
|
|
744
738
|
top: 50%;
|
|
745
739
|
width: 4px;
|
|
746
740
|
height: 4px;
|
|
@@ -750,18 +744,45 @@ html[data-dcc-dot="on"] [class*="_sessionRow"]::before {
|
|
|
750
744
|
opacity: .35;
|
|
751
745
|
pointer-events: none;
|
|
752
746
|
}
|
|
747
|
+
|
|
748
|
+
/* slot 里已经有状态图标(运行中的加载圈、结束标记之类)时,
|
|
749
|
+
不再画会话前圆点,避免两个标记并排叠在一起。 */
|
|
750
|
+
html[data-dcc-dot="on"] [class*="_sessionRow"]:has([class*="_slot"] svg)::before {
|
|
751
|
+
display: none !important;
|
|
752
|
+
}
|
|
753
753
|
/* 与 archive-manager 的收藏星标共存:星标占用的正是同一个 16px 前导位置。
|
|
754
754
|
星标在行悬停时总会出现(未收藏是空心、可点),已收藏则常驻,
|
|
755
755
|
两种情况下都不再画自身的小圆点,避免与星标叠在一起。 */
|
|
756
|
-
|
|
756
|
+
/* 悬停规避只在「隐藏会话悬停多余按钮」关着时才需要——
|
|
757
|
+
那个开关打开后,未收藏的星标根本不会出现,圆点不必让位。
|
|
758
|
+
已收藏的星标是常驻的,所以这一条不受开关影响。 */
|
|
759
|
+
html[data-dcc-dot="on"][data-dcc-row-buttons="off"] [class*="_sessionRow"]:hover:has(.dsham_starSlot)::before,
|
|
757
760
|
html[data-dcc-dot="on"] [class*="_sessionRow"]:has(.dsham_starSlot[data-favorited="true"])::before {
|
|
758
761
|
display: none;
|
|
759
762
|
}
|
|
760
|
-
/*
|
|
761
|
-
|
|
762
|
-
html[data-dcc-
|
|
763
|
-
|
|
763
|
+
/* 收藏星标是绝对定位(left: 8px),要左移 1px 必须写 7px——
|
|
764
|
+
直接写 left: -1px 会替换掉原来的基准,把它甩到行外。 */
|
|
765
|
+
html[data-dcc-radius="on"] [class*="_sessionRow"] .dsham_starSlot {
|
|
766
|
+
left: 7px !important;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/* 悬停时才出现的收藏按钮(未收藏的空心星)跟着「隐藏会话悬停多余按钮」一起隐藏,
|
|
770
|
+
已收藏的实心星保持显示——那是用户自己点亮的状态,不应该藏起来。 */
|
|
771
|
+
html[data-dcc-row-buttons="on"] [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) {
|
|
772
|
+
display: none !important;
|
|
773
|
+
}
|
|
774
|
+
/* 工作区行和会话行左侧的图标统一左移 2px。
|
|
775
|
+
宿主用 padding-inline-start + gap 排列行内图标,所以调行的起始内边距
|
|
776
|
+
就能一次对齐这一列——文件夹、圆点、加载圈、星标、第三方插件加的图标
|
|
777
|
+
全都跟着走,不用逐个类名去点。 */
|
|
778
|
+
html[data-dcc-radius="on"] [class*="_projectRow"],
|
|
779
|
+
html[data-dcc-radius="on"] [class*="_sessionRow"] {
|
|
780
|
+
padding-inline-start: calc(
|
|
781
|
+
var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset)
|
|
782
|
+
+ var(--dsh-workspace-indent, 0px) - 2px
|
|
783
|
+
) !important;
|
|
764
784
|
}
|
|
785
|
+
|
|
765
786
|
/* 「展开其余 N 个会话 / 收起」比工作区标题更淡 */
|
|
766
787
|
html[data-dcc-dim="on"] [class*="_sessionOverflowButton"] {
|
|
767
788
|
color: var(--dsw-alias-label-tertiary) !important;
|
|
@@ -771,6 +792,25 @@ html[data-dcc-dim="on"] [class*="_sessionOverflowButton"]:hover {
|
|
|
771
792
|
opacity: .9 !important;
|
|
772
793
|
}
|
|
773
794
|
|
|
795
|
+
/* 工作区行左侧的图标统一尺寸和位置,跟着「减小圆角与间距」走。
|
|
796
|
+
宿主的文件夹图标是 16px,行高 32px,缩到 14px 后与 13px 的标题更协调。
|
|
797
|
+
其他插件在这个位置放的图标(自定义 svg、img、字符等)也一并按同一套
|
|
798
|
+
尺寸和偏移处理,保证整列左边缘对齐。 */
|
|
799
|
+
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 {
|
|
805
|
+
width: 14px !important;
|
|
806
|
+
height: 14px !important;
|
|
807
|
+
/* 位置上移 1px 与文字基线对齐(横向由行的 padding 统一处理) */
|
|
808
|
+
position: relative !important;
|
|
809
|
+
top: -1px !important;
|
|
810
|
+
/* 非正方形图标按比例缩,不拉伸 */
|
|
811
|
+
object-fit: contain !important;
|
|
812
|
+
}
|
|
813
|
+
|
|
774
814
|
/* ---------- 工作区行:悬停时不换成展开箭头,保持文件夹图标 ---------- */
|
|
775
815
|
/* 宿主默认:hover 时 .chevron 显示、.folder 隐藏(Rows.module.css)。这里反着压回去。 */
|
|
776
816
|
html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_folder"] {
|
|
@@ -882,7 +922,9 @@ html[data-dcc-enabled="on"][data-dcc-header-fade="on"]:has([data-conversation-ta
|
|
|
882
922
|
/* 宿主自带的「更多」按钮:只在紧凑化开启时隐藏——那时标签行被本插件的
|
|
883
923
|
下拉按钮取代,宿主这个按钮用不上。紧凑化关闭时标签行是原版的,
|
|
884
924
|
这个按钮必须留着,否则视图被裁掉后无法访问。 */
|
|
885
|
-
|
|
925
|
+
/* 限定在会话标题栏内:_viewsMoreAnchor 是宿主标签行专用的类,
|
|
926
|
+
但同一套渲染也可能被别处复用,加上 :has 限定确保只作用于有标签行的标题栏。 */
|
|
927
|
+
html[data-dcc-enabled="on"][data-dcc-compact-header="on"] [class*="_header"]:has([data-conversation-tabs]) [class*="_viewsMoreAnchor"] {
|
|
886
928
|
display: none !important;
|
|
887
929
|
}
|
|
888
930
|
/* 开关关掉时,自绘的分段控件不出现,标签行恢复原样 */
|
|
@@ -927,7 +969,9 @@ html[data-dcc-always-show="on"] .dcc-segmented {
|
|
|
927
969
|
color: var(--dsw-alias-label-secondary);
|
|
928
970
|
font: inherit;
|
|
929
971
|
font-size: 12px;
|
|
930
|
-
|
|
972
|
+
/* 行高不能是 1:中文字体的下方部分会超出行盒,被 label 的
|
|
973
|
+
overflow: hidden 裁掉一截。留一点余量。 */
|
|
974
|
+
line-height: 1.35;
|
|
931
975
|
white-space: nowrap;
|
|
932
976
|
cursor: pointer;
|
|
933
977
|
transition: background-color .12s, color .12s;
|
|
@@ -957,6 +1001,100 @@ html[data-dcc-always-show="on"] .dcc-segmented {
|
|
|
957
1001
|
}
|
|
958
1002
|
|
|
959
1003
|
/* 溢出菜单:对齐宿主菜单的尺寸与层级(圆角 12、内距 6、项高 32、项圆角 8) */
|
|
1004
|
+
/* 会话正文渐显:切换会话后,正文列和轮次标记一起淡入。
|
|
1005
|
+
由脚本在加载提示消失后重播——容器本身不重建,单靠 CSS 动画只播一次。
|
|
1006
|
+
归在「优化加载界面」里,属始终开启项,不受动画开关控制。 */
|
|
1007
|
+
html[data-dcc-enabled="on"] [data-dcc-fade-in] {
|
|
1008
|
+
animation: dcc-content-in .26s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
|
|
1009
|
+
}
|
|
1010
|
+
@keyframes dcc-content-in {
|
|
1011
|
+
from { opacity: 0; }
|
|
1012
|
+
to { opacity: 1; }
|
|
1013
|
+
}
|
|
1014
|
+
|
|
1015
|
+
/* ===== BOOT-HINT: 宿主加载页适配(高耦合,见 installBootHint 的注释)=====
|
|
1016
|
+
只藏旋转圈。hint 居中和 HARNESS 隐藏必须在同一帧完成,放在脚本里做。
|
|
1017
|
+
宿主加载页若改版,整块删掉即可,不影响其它样式。 */
|
|
1018
|
+
/* 脚本处理完之前先整体不可见:宿主第一帧渲染的是原始布局,
|
|
1019
|
+
如果直接可见会露出一瞬的 HARNESS + Loading 并排。空一帧比错一帧好。
|
|
1020
|
+
处理完由脚本打上 data-dcc-boot-ready,恢复正常显示。 */
|
|
1021
|
+
html[data-dcc-enabled="on"] [data-dsh-boot]:not([data-dcc-boot-ready]) {
|
|
1022
|
+
visibility: hidden;
|
|
1023
|
+
}
|
|
1024
|
+
/* 兜底:万一脚本没跑(插件未加载等),两秒后无论如何都显示出来,
|
|
1025
|
+
避免加载页永久不可见。 */
|
|
1026
|
+
html[data-dcc-enabled="on"] [data-dsh-boot] {
|
|
1027
|
+
animation: dcc-boot-reveal 0s linear 2s forwards;
|
|
1028
|
+
}
|
|
1029
|
+
@keyframes dcc-boot-reveal {
|
|
1030
|
+
to { visibility: visible; }
|
|
1031
|
+
}
|
|
1032
|
+
html[data-dcc-enabled="on"] [data-dsh-boot] [data-dsh-boot-spinner],
|
|
1033
|
+
html[data-dcc-enabled="on"] [data-dsh-boot] [class*="_spinner"] {
|
|
1034
|
+
display: none !important;
|
|
1035
|
+
}
|
|
1036
|
+
/* ===== BOOT-HINT END ===== */
|
|
1037
|
+
|
|
1038
|
+
/* 会话切换时的「载入历史」提示:挪到正文中心,鲸鱼在上、文字在下。
|
|
1039
|
+
文字内容由宿主写入,这里只改排版,不替换文案。 */
|
|
1040
|
+
html[data-dcc-enabled="on"] [class*="_hint"] {
|
|
1041
|
+
position: fixed !important;
|
|
1042
|
+
/* left/top 由脚本按正文区域的中心算出来写上去 */
|
|
1043
|
+
transform: translate(-50%, -50%) !important;
|
|
1044
|
+
display: flex !important;
|
|
1045
|
+
flex-direction: column !important;
|
|
1046
|
+
align-items: center !important;
|
|
1047
|
+
gap: 10px !important;
|
|
1048
|
+
margin: 0 !important;
|
|
1049
|
+
color: var(--dsw-alias-label-tertiary) !important;
|
|
1050
|
+
font-size: 13px !important;
|
|
1051
|
+
white-space: nowrap !important;
|
|
1052
|
+
pointer-events: none !important;
|
|
1053
|
+
}
|
|
1054
|
+
html[data-dcc-enabled="on"] [data-dcc-hint-fish] {
|
|
1055
|
+
width: 56px;
|
|
1056
|
+
height: auto;
|
|
1057
|
+
opacity: .32;
|
|
1058
|
+
flex: none;
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1061
|
+
/* 追加到宿主菜单末尾的「重载前端界面」:外观对齐宿主自己的菜单项,
|
|
1062
|
+
高度、内边距、字号都按它的规格来。 */
|
|
1063
|
+
.dcc-menu-extra {
|
|
1064
|
+
display: flex;
|
|
1065
|
+
align-items: center;
|
|
1066
|
+
gap: 6px;
|
|
1067
|
+
width: 100%;
|
|
1068
|
+
min-height: 32px;
|
|
1069
|
+
padding: 0 10px;
|
|
1070
|
+
border: 0;
|
|
1071
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
1072
|
+
background: transparent;
|
|
1073
|
+
color: var(--dsw-alias-label-primary);
|
|
1074
|
+
font: inherit;
|
|
1075
|
+
font-size: 13px;
|
|
1076
|
+
text-align: left;
|
|
1077
|
+
white-space: nowrap;
|
|
1078
|
+
cursor: pointer;
|
|
1079
|
+
}
|
|
1080
|
+
.dcc-menu-extra:hover {
|
|
1081
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
1082
|
+
}
|
|
1083
|
+
.dcc-menu-extra > span {
|
|
1084
|
+
/* 图标左移后文字跟着走一点,和宿主菜单项的文字左边缘对齐 */
|
|
1085
|
+
position: relative;
|
|
1086
|
+
left: -2px;
|
|
1087
|
+
}
|
|
1088
|
+
.dcc-menu-extra-icon {
|
|
1089
|
+
display: block;
|
|
1090
|
+
width: 16px;
|
|
1091
|
+
height: 16px;
|
|
1092
|
+
flex: none;
|
|
1093
|
+
/* 和宿主菜单项的图标左边缘对齐(宿主的图标比 16px 小的会儿再偏一点) */
|
|
1094
|
+
position: relative;
|
|
1095
|
+
left: -2px;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
960
1098
|
.dcc-seg-menu {
|
|
961
1099
|
position: fixed;
|
|
962
1100
|
z-index: 2147483000;
|
|
@@ -1348,6 +1486,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1348
1486
|
const findNav = () => document.querySelector('nav[class*="_panelList"]');
|
|
1349
1487
|
const findOriginal = () => document.querySelector('button[class*="_newSession"]');
|
|
1350
1488
|
let clone = null;
|
|
1489
|
+
/* 宿主的导航项是两层:外层 _panelEntry 负责悬停底色和圆角,
|
|
1490
|
+
内层 _panelRow 是按钮本体。克隆必须保持同样的层级,
|
|
1491
|
+
把两层的类压在同一个元素上市,悬停底色会画错位置。 */
|
|
1492
|
+
let wrapper = null;
|
|
1351
1493
|
let observer = null;
|
|
1352
1494
|
let timer = null;
|
|
1353
1495
|
let rafId = 0;
|
|
@@ -1355,38 +1497,59 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1355
1497
|
const build = (nav, orig) => {
|
|
1356
1498
|
const row = nav.querySelector('button[class*="_panelRow"]');
|
|
1357
1499
|
if (row === null) return false;
|
|
1500
|
+
if (wrapper !== null) wrapper.remove();
|
|
1358
1501
|
if (clone !== null) clone.remove();
|
|
1502
|
+
|
|
1503
|
+
/* 外层:完整照抄宿主导航项外层的类。
|
|
1504
|
+
之前排除了 panelEntryActive(怕常亮)和 panelEntryWide(以为没用),
|
|
1505
|
+
结果是布局对不上——panelEntryWide 决定了行的宽度和右侧留白,
|
|
1506
|
+
少了它整行都错位。active 类只在别处加,克隆时本来就不会有。 */
|
|
1507
|
+
const entry = row.parentElement;
|
|
1508
|
+
wrapper = document.createElement('div');
|
|
1509
|
+
if (entry !== null) {
|
|
1510
|
+
for (const name of entry.classList) wrapper.classList.add(name);
|
|
1511
|
+
}
|
|
1512
|
+
wrapper.setAttribute('data-dcc-newrow-wrap', '');
|
|
1513
|
+
|
|
1514
|
+
/* 内层:完整照抄按钮本体的类 */
|
|
1359
1515
|
clone = document.createElement('button');
|
|
1360
1516
|
clone.type = 'button';
|
|
1361
1517
|
clone.setAttribute('data-dcc-newrow', '');
|
|
1362
|
-
|
|
1363
|
-
克隆行是裸 button,少了这层包裹,悬停就会比别的导航行浅一档,
|
|
1364
|
-
所以把父级的 panelEntry 类一并复制过来。 */
|
|
1365
|
-
const entry = row.parentElement;
|
|
1366
|
-
const entryClasses = entry === null
|
|
1367
|
-
? []
|
|
1368
|
-
: [...entry.classList].filter((name) => name.includes('_panelEntry'));
|
|
1369
|
-
clone.className = [...row.classList].join(' ')
|
|
1370
|
-
+ ' dcc-newrow'
|
|
1371
|
-
+ (entryClasses.length > 0 ? ' ' + entryClasses.join(' ') : '');
|
|
1518
|
+
clone.className = [...row.classList].join(' ') + ' dcc-newrow';
|
|
1372
1519
|
const aria = orig.getAttribute('aria-label');
|
|
1373
1520
|
if (aria !== null) clone.setAttribute('aria-label', aria);
|
|
1374
|
-
|
|
1375
|
-
content.className = 'dcc-newrow-content';
|
|
1521
|
+
/* 图标包裹层:完整照抄 panelGlyph 的类,尺寸和居中都在它身上 */
|
|
1376
1522
|
const icon = orig.querySelector('svg');
|
|
1377
|
-
if (icon !== null)
|
|
1523
|
+
if (icon !== null) {
|
|
1524
|
+
const source = row.querySelector('[class*="_panelGlyph"]');
|
|
1525
|
+
const glyph = document.createElement('span');
|
|
1526
|
+
if (source !== null) {
|
|
1527
|
+
for (const name of source.classList) glyph.classList.add(name);
|
|
1528
|
+
} else {
|
|
1529
|
+
glyph.className = 'dcc-newrow-glyph';
|
|
1530
|
+
}
|
|
1531
|
+
glyph.setAttribute('aria-hidden', 'true');
|
|
1532
|
+
glyph.appendChild(icon.cloneNode(true));
|
|
1533
|
+
clone.appendChild(glyph);
|
|
1534
|
+
}
|
|
1535
|
+
|
|
1536
|
+
/* 标题也用宿主的 panelTitle 类——字号、颜色、溢出省略都在它身上 */
|
|
1378
1537
|
const label = document.createElement('span');
|
|
1379
|
-
|
|
1538
|
+
const titleSource = row.querySelector('[class*="_panelTitle"]');
|
|
1539
|
+
if (titleSource !== null) {
|
|
1540
|
+
for (const name of titleSource.classList) label.classList.add(name);
|
|
1541
|
+
}
|
|
1542
|
+
if (label.classList.length === 0) label.className = 'dcc-newrow-label';
|
|
1380
1543
|
const text = orig.querySelector('[class*="_newSessionLabel"]');
|
|
1381
1544
|
label.textContent = text !== null && text.textContent !== '' ? text.textContent : (isZh() ? '新会话' : 'New session');
|
|
1382
|
-
|
|
1383
|
-
clone.appendChild(content);
|
|
1545
|
+
clone.appendChild(label);
|
|
1384
1546
|
clone.addEventListener('click', (event) => {
|
|
1385
1547
|
event.preventDefault();
|
|
1386
1548
|
const current = findOriginal();
|
|
1387
1549
|
if (current !== null) current.click();
|
|
1388
1550
|
});
|
|
1389
|
-
|
|
1551
|
+
wrapper.appendChild(clone);
|
|
1552
|
+
nav.insertBefore(wrapper, nav.firstElementChild);
|
|
1390
1553
|
return true;
|
|
1391
1554
|
};
|
|
1392
1555
|
|
|
@@ -1397,6 +1560,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1397
1560
|
/* 开关关掉时彻底还原:移除克隆行、去掉原按钮上的标记,
|
|
1398
1561
|
让它回到宿主本来的样子,而不是仅靠 CSS 隐藏 */
|
|
1399
1562
|
if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccNew !== 'on') {
|
|
1563
|
+
if (wrapper !== null) {
|
|
1564
|
+
wrapper.remove();
|
|
1565
|
+
wrapper = null;
|
|
1566
|
+
}
|
|
1400
1567
|
if (clone !== null) {
|
|
1401
1568
|
clone.remove();
|
|
1402
1569
|
clone = null;
|
|
@@ -1405,8 +1572,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1405
1572
|
return false;
|
|
1406
1573
|
}
|
|
1407
1574
|
if (orig.getAttribute('data-dcc-original') === null) orig.setAttribute('data-dcc-original', '');
|
|
1408
|
-
if (clone === null || !
|
|
1409
|
-
if (!nav.contains(
|
|
1575
|
+
if (wrapper === null || clone === null || !wrapper.isConnected) return build(nav, orig);
|
|
1576
|
+
if (!nav.contains(wrapper)) nav.insertBefore(wrapper, nav.firstElementChild);
|
|
1410
1577
|
/* 宿主文字(语言切换等)变化时,克隆行跟着更新 */
|
|
1411
1578
|
const label = clone.querySelector('.dcc-newrow-label');
|
|
1412
1579
|
const text = orig.querySelector('[class*="_newSessionLabel"]');
|
|
@@ -1449,6 +1616,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1449
1616
|
window.removeEventListener('dcc-newsession-pref', onPref);
|
|
1450
1617
|
if (timer !== null) clearTimeout(timer);
|
|
1451
1618
|
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
1619
|
+
if (wrapper !== null) wrapper.remove();
|
|
1452
1620
|
if (clone !== null) clone.remove();
|
|
1453
1621
|
const orig = findOriginal();
|
|
1454
1622
|
if (orig !== null) orig.removeAttribute('data-dcc-original');
|
|
@@ -1791,6 +1959,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1791
1959
|
let bar = null;
|
|
1792
1960
|
let observer = null;
|
|
1793
1961
|
let timer = null;
|
|
1962
|
+
let prefTimer = null;
|
|
1963
|
+
let rafId = 0;
|
|
1794
1964
|
/* 正在淡出的旧控件被临时挂到 body 上,卸载时要一起收走 */
|
|
1795
1965
|
const ghosts = new Set();
|
|
1796
1966
|
|
|
@@ -2051,7 +2221,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2051
2221
|
if (!event.detail) return;
|
|
2052
2222
|
const key = event.detail.key;
|
|
2053
2223
|
if (key !== 'compactHeader' && key !== 'compactHeaderFull') return;
|
|
2054
|
-
|
|
2224
|
+
if (prefTimer !== null) clearTimeout(prefTimer);
|
|
2225
|
+
prefTimer = window.setTimeout(() => {
|
|
2226
|
+
prefTimer = null;
|
|
2227
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2228
|
+
rafId = 0;
|
|
2229
|
+
ensure();
|
|
2230
|
+
});
|
|
2231
|
+
}, 0);
|
|
2055
2232
|
};
|
|
2056
2233
|
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
2057
2234
|
|
|
@@ -2059,6 +2236,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2059
2236
|
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
2060
2237
|
observer.disconnect();
|
|
2061
2238
|
if (timer !== null) clearTimeout(timer);
|
|
2239
|
+
if (prefTimer !== null) clearTimeout(prefTimer);
|
|
2240
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2062
2241
|
closeSegMenu();
|
|
2063
2242
|
if (bar !== null) bar.remove();
|
|
2064
2243
|
for (const ghost of ghosts) ghost.remove();
|
|
@@ -2066,6 +2245,301 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2066
2245
|
};
|
|
2067
2246
|
}
|
|
2068
2247
|
|
|
2248
|
+
/**
|
|
2249
|
+
* 切换会话时正文会短暂显示一行「载入历史」提示(宿主的 _hint)。
|
|
2250
|
+
* 它默认贴在左上角,这里把它挪到正文中心,并在文字上方加一个鲸鱼图标,
|
|
2251
|
+
* 和启动遮罩的观感统一。文字内容不写死——只包一层容器,原文照读。
|
|
2252
|
+
*/
|
|
2253
|
+
function installHistoryHint() {
|
|
2254
|
+
let observer = null;
|
|
2255
|
+
let rafId = 0;
|
|
2256
|
+
|
|
2257
|
+
const decorate = () => {
|
|
2258
|
+
const hint = document.querySelector('[class*="_hint"]');
|
|
2259
|
+
if (hint === null) return;
|
|
2260
|
+
/* 加载页的 hint 归 installBootHint 管,这里跳过,避免两个模块
|
|
2261
|
+
对同一个元素各改一半。 */
|
|
2262
|
+
if (hint.closest('[data-dsh-boot]') !== null) return;
|
|
2263
|
+
if (hint.querySelector('[data-dcc-hint-fish]') !== null) return;
|
|
2264
|
+
|
|
2265
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
2266
|
+
svg.setAttribute('viewBox', '0 0 23.16 17.04');
|
|
2267
|
+
svg.setAttribute('data-dcc-hint-fish', '');
|
|
2268
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
2269
|
+
const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
2270
|
+
shape.setAttribute('d', FISH_LOGO_PATH);
|
|
2271
|
+
const darkNow = document.body.hasAttribute('data-ds-dark-theme')
|
|
2272
|
+
|| document.documentElement.hasAttribute('data-ds-dark-theme');
|
|
2273
|
+
shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
|
|
2274
|
+
svg.appendChild(shape);
|
|
2275
|
+
hint.insertBefore(svg, hint.firstChild);
|
|
2276
|
+
|
|
2277
|
+
/* 宿主加载页的适配在 installBootHint 里独立处理,这里只负责会话界面的情况 */
|
|
2278
|
+
center(hint);
|
|
2279
|
+
};
|
|
2280
|
+
/* 按正文区域(而不是视口)的中心定位:侧栏展开时两者差一截。 */
|
|
2281
|
+
const center = (hint) => {
|
|
2282
|
+
/* 加载页里的 hint 由 installBootHint 单独居中,这里跳过。 */
|
|
2283
|
+
if (hint.closest('[data-dsh-boot]') !== null) return;
|
|
2284
|
+
const host = document.querySelector('[data-conversation-scroll]');
|
|
2285
|
+
if (host === null) return;
|
|
2286
|
+
const rect = host.getBoundingClientRect();
|
|
2287
|
+
if (rect.width === 0 || rect.height === 0) return;
|
|
2288
|
+
hint.style.left = rect.left + rect.width / 2 + 'px';
|
|
2289
|
+
/* 正文区的几何中心偏下——底部有输入框占位,视觉中心要高一些 */
|
|
2290
|
+
hint.style.top = rect.top + rect.height / 2 - 64 + 'px';
|
|
2291
|
+
};
|
|
2292
|
+
|
|
2293
|
+
/* 切换会话时正文是整体换掉的,但容器本身常驻,
|
|
2294
|
+
animation 只播一次,之后再切就看不到了。这里在提示消失后
|
|
2295
|
+
手动重播一次:先摘掉动画类、强制重排、再挂回去。 */
|
|
2296
|
+
let lastHadHint = false;
|
|
2297
|
+
const replayFade = () => {
|
|
2298
|
+
|
|
2299
|
+
const targets = [
|
|
2300
|
+
document.querySelector('[class*="_column"]'),
|
|
2301
|
+
document.querySelector('[class*="_marks"]'),
|
|
2302
|
+
].filter((el) => el !== null && el.getBoundingClientRect().height > 0);
|
|
2303
|
+
if (targets.length === 0) return;
|
|
2304
|
+
for (const el of targets) el.removeAttribute('data-dcc-fade-in');
|
|
2305
|
+
/* 读一次布局,让移除生效,再挂回去才会重播 */
|
|
2306
|
+
void document.body.offsetHeight;
|
|
2307
|
+
for (const el of targets) el.setAttribute('data-dcc-fade-in', '');
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
const watchHint = () => {
|
|
2311
|
+
/* 只看会话界面里的提示——加载页也有同一个 _hint,它消失不表示
|
|
2312
|
+
正文就位,跟着触发会白跑一次(虽然 targets 为空会直接返回)。 */
|
|
2313
|
+
const hint = document.querySelector('[class*="_hint"]');
|
|
2314
|
+
const hasHint = hint !== null && hint.closest('[data-dsh-boot]') === null;
|
|
2315
|
+
/* 由「有提示」变成「没提示」,说明这一轮内容已经就位 */
|
|
2316
|
+
if (lastHadHint && !hasHint) replayFade();
|
|
2317
|
+
lastHadHint = hasHint;
|
|
2318
|
+
};
|
|
2319
|
+
|
|
2320
|
+
const schedule = () => {
|
|
2321
|
+
if (rafId !== 0) return;
|
|
2322
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2323
|
+
rafId = 0;
|
|
2324
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') return;
|
|
2325
|
+
decorate();
|
|
2326
|
+
watchHint();
|
|
2327
|
+
});
|
|
2328
|
+
};
|
|
2329
|
+
|
|
2330
|
+
observer = new MutationObserver(schedule);
|
|
2331
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2332
|
+
|
|
2333
|
+
return () => {
|
|
2334
|
+
observer.disconnect();
|
|
2335
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2336
|
+
for (const el of document.querySelectorAll('[data-dcc-hint-fish]')) el.remove();
|
|
2337
|
+
for (const el of document.querySelectorAll('[data-dcc-fade-in]')) el.removeAttribute('data-dcc-fade-in');
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
/**
|
|
2342
|
+
* 宿主加载页(开机时的 "Loading plugins…" 那一屏)的外观适配。
|
|
2343
|
+
*
|
|
2344
|
+
* ⚠️ 这是一块**高耦合**的补丁,和下面这些宿主实现细节绑死:
|
|
2345
|
+
*
|
|
2346
|
+
* | 依赖 | 用途 |
|
|
2347
|
+
* | ------------------------ | -------------------------------- |
|
|
2348
|
+
* | [data-dsh-boot] | 加载页根节点,用来界定作用范围 |
|
|
2349
|
+
* | [class*="_hint"] | 提示文字,和会话界面的载入提示共用 |
|
|
2350
|
+
* | [data-dsh-boot-spinner] | 旋转圈 |
|
|
2351
|
+
* | [class*="_spinner"] | 旋转圈(备用选择器) |
|
|
2352
|
+
* | 文本含 "HARNESS" | 要隐藏的品牌字样 |
|
|
2353
|
+
*
|
|
2354
|
+
* 做两件事:
|
|
2355
|
+
* 1. 把提示文字挪到视口正中(宿主原本让它和 HARNESS 并排)
|
|
2356
|
+
* 2. 隐藏 HARNESS 字样和旋转圈,只留鲸鱼 + 提示文字
|
|
2357
|
+
*
|
|
2358
|
+
* 第 1 点必须和 HARNESS 的隐藏**同一帧**完成——如果只把文字改成
|
|
2359
|
+
* fixed 居中、HARNESS 晚一帧才藏,中间会露出两者叠在屏幕中间一瞬间。
|
|
2360
|
+
*
|
|
2361
|
+
* 失效表现:宿主改版后,加载页恢复原样,不报错,也不影响其它功能。
|
|
2362
|
+
*
|
|
2363
|
+
* 要整体移除时:删掉本函数 + 调用处 removeBootHint + 下面对应的
|
|
2364
|
+
* CSS(搜 BOOT-HINT),不会牵连别的模块。
|
|
2365
|
+
*/
|
|
2366
|
+
function installBootHint() {
|
|
2367
|
+
let observer = null;
|
|
2368
|
+
let rafId = 0;
|
|
2369
|
+
|
|
2370
|
+
const apply = () => {
|
|
2371
|
+
const boot = document.querySelector('[data-dsh-boot]');
|
|
2372
|
+
if (boot === null) return;
|
|
2373
|
+
|
|
2374
|
+
const hint = boot.querySelector('[class*="_hint"]');
|
|
2375
|
+
if (hint !== null && hint.getAttribute('data-dcc-boot-hint') === null) {
|
|
2376
|
+
hint.setAttribute('data-dcc-boot-hint', '');
|
|
2377
|
+
|
|
2378
|
+
/* 鲸鱼图标放在提示文字上方,和会话界面的载入提示同一套做法 */
|
|
2379
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
2380
|
+
svg.setAttribute('viewBox', '0 0 23.16 17.04');
|
|
2381
|
+
svg.setAttribute('data-dcc-hint-fish', '');
|
|
2382
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
2383
|
+
const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
2384
|
+
shape.setAttribute('d', FISH_LOGO_PATH);
|
|
2385
|
+
const darkNow = document.body.hasAttribute('data-ds-dark-theme')
|
|
2386
|
+
|| document.documentElement.hasAttribute('data-ds-dark-theme');
|
|
2387
|
+
shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
|
|
2388
|
+
svg.appendChild(shape);
|
|
2389
|
+
hint.insertBefore(svg, hint.firstChild);
|
|
2390
|
+
|
|
2391
|
+
hint.style.position = 'fixed';
|
|
2392
|
+
hint.style.top = '50%';
|
|
2393
|
+
hint.style.left = '50%';
|
|
2394
|
+
hint.style.transform = 'translate(-50%, -50%)';
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/* HARNESS 按文字内容匹配,不认类名——它没有稳定的类名可用。
|
|
2398
|
+
用正则而非全等:实际的 textContent 常带空格或标点。 */
|
|
2399
|
+
for (const el of boot.querySelectorAll('*')) {
|
|
2400
|
+
if (el.getAttribute('data-dcc-boot-brand') !== null) continue;
|
|
2401
|
+
if (!/HARNESS/i.test(el.textContent || '')) continue;
|
|
2402
|
+
/* 只藏最内层那个,避免把整块容器一起藏掉 */
|
|
2403
|
+
const inner = [...el.querySelectorAll('*')].filter(
|
|
2404
|
+
(c) => /HARNESS/i.test(c.textContent || ''),
|
|
2405
|
+
);
|
|
2406
|
+
if (inner.length > 0) continue;
|
|
2407
|
+
el.setAttribute('data-dcc-boot-brand', '');
|
|
2408
|
+
el.style.display = 'none';
|
|
2409
|
+
}
|
|
2410
|
+
|
|
2411
|
+
/* 处理完了,放行显示 */
|
|
2412
|
+
boot.setAttribute('data-dcc-boot-ready', '');
|
|
2413
|
+
};
|
|
2414
|
+
|
|
2415
|
+
const schedule = () => {
|
|
2416
|
+
if (rafId !== 0) return;
|
|
2417
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2418
|
+
rafId = 0;
|
|
2419
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') return;
|
|
2420
|
+
apply();
|
|
2421
|
+
});
|
|
2422
|
+
};
|
|
2423
|
+
|
|
2424
|
+
observer = new MutationObserver(schedule);
|
|
2425
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2426
|
+
|
|
2427
|
+
return () => {
|
|
2428
|
+
observer.disconnect();
|
|
2429
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2430
|
+
/* 还原被本模块改过的东西,避免卸载后留下半截样式 */
|
|
2431
|
+
for (const el of document.querySelectorAll('[data-dcc-boot-hint]')) {
|
|
2432
|
+
el.removeAttribute('data-dcc-boot-hint');
|
|
2433
|
+
el.style.position = '';
|
|
2434
|
+
el.style.top = '';
|
|
2435
|
+
el.style.left = '';
|
|
2436
|
+
el.style.transform = '';
|
|
2437
|
+
}
|
|
2438
|
+
for (const el of document.querySelectorAll('[data-dcc-boot-brand]')) {
|
|
2439
|
+
el.removeAttribute('data-dcc-boot-brand');
|
|
2440
|
+
el.style.display = '';
|
|
2441
|
+
}
|
|
2442
|
+
for (const el of document.querySelectorAll('[data-dcc-boot-ready]')) {
|
|
2443
|
+
el.removeAttribute('data-dcc-boot-ready');
|
|
2444
|
+
}
|
|
2445
|
+
for (const el of document.querySelectorAll('[data-dcc-hint-fish]')) el.remove();
|
|
2446
|
+
};
|
|
2447
|
+
}
|
|
2448
|
+
|
|
2449
|
+
/**
|
|
2450
|
+
* 在会话标题栏右上角的「⋯」菜单末尾追加一项「重载前端界面」。
|
|
2451
|
+
* 那个菜单是宿主 React 渲染的,插不进去子节点,只能在它打开后
|
|
2452
|
+
* 往 DOM 里补一个外观一致的按钮,点击等价于 location.reload()。
|
|
2453
|
+
*/
|
|
2454
|
+
function installReloadMenuItem() {
|
|
2455
|
+
const MENU = '[role="menu"]';
|
|
2456
|
+
let observer = null;
|
|
2457
|
+
let timer = null;
|
|
2458
|
+
|
|
2459
|
+
const findMenu = () => {
|
|
2460
|
+
const host = document.querySelector('[class*="_headerUtilities"]');
|
|
2461
|
+
if (host === null) return null;
|
|
2462
|
+
const hostRect = host.getBoundingClientRect();
|
|
2463
|
+
const menus = document.querySelectorAll(MENU);
|
|
2464
|
+
for (let i = 0; i < menus.length; i += 1) {
|
|
2465
|
+
const menu = menus[i];
|
|
2466
|
+
if (menu.querySelector('[data-dcc-reload-item]') !== null) continue;
|
|
2467
|
+
/* 只认贴在标题栏下方展开的那个菜单:它的顶边要落在工具区的下方附近。
|
|
2468
|
+
头像菜单、子菜单的顶边都在其它位置,会被排除掉。 */
|
|
2469
|
+
const rect = menu.getBoundingClientRect();
|
|
2470
|
+
if (rect.width === 0 || rect.height === 0) continue;
|
|
2471
|
+
if (rect.top < hostRect.top - 4) continue;
|
|
2472
|
+
if (rect.top > hostRect.bottom + 24) continue;
|
|
2473
|
+
if (rect.right < hostRect.left - 8) continue;
|
|
2474
|
+
return menu;
|
|
2475
|
+
}
|
|
2476
|
+
return null;
|
|
2477
|
+
};
|
|
2478
|
+
|
|
2479
|
+
const addItem = () => {
|
|
2480
|
+
const menu = findMenu();
|
|
2481
|
+
if (menu === null) return;
|
|
2482
|
+
if (menu.querySelector('[data-dcc-reload-item]') !== null) return;
|
|
2483
|
+
|
|
2484
|
+
const item = document.createElement('button');
|
|
2485
|
+
item.type = 'button';
|
|
2486
|
+
item.setAttribute('data-dcc-reload-item', '');
|
|
2487
|
+
item.className = 'dcc-menu-extra';
|
|
2488
|
+
|
|
2489
|
+
/* 刷新图标:一个带箭头的圆,和工具栏那个刷新按钮同一套语义 */
|
|
2490
|
+
const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
2491
|
+
icon.setAttribute('viewBox', '0 0 16 16');
|
|
2492
|
+
icon.setAttribute('class', 'dcc-menu-extra-icon');
|
|
2493
|
+
icon.setAttribute('aria-hidden', 'true');
|
|
2494
|
+
const arc = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
2495
|
+
arc.setAttribute('d', 'M13 8a5 5 0 1 1-1.46-3.54');
|
|
2496
|
+
arc.setAttribute('fill', 'none');
|
|
2497
|
+
arc.setAttribute('stroke', 'currentColor');
|
|
2498
|
+
arc.setAttribute('stroke-width', '1.4');
|
|
2499
|
+
arc.setAttribute('stroke-linecap', 'round');
|
|
2500
|
+
const tip = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
2501
|
+
tip.setAttribute('d', 'M13 2.6V5.2h-2.6');
|
|
2502
|
+
tip.setAttribute('fill', 'none');
|
|
2503
|
+
tip.setAttribute('stroke', 'currentColor');
|
|
2504
|
+
tip.setAttribute('stroke-width', '1.4');
|
|
2505
|
+
tip.setAttribute('stroke-linecap', 'round');
|
|
2506
|
+
tip.setAttribute('stroke-linejoin', 'round');
|
|
2507
|
+
icon.append(arc, tip);
|
|
2508
|
+
|
|
2509
|
+
const label = document.createElement('span');
|
|
2510
|
+
label.textContent = isZh() ? '重载前端界面' : 'Reload frontend';
|
|
2511
|
+
item.append(icon, label);
|
|
2512
|
+
item.addEventListener('click', (event) => {
|
|
2513
|
+
event.stopPropagation();
|
|
2514
|
+
window.setTimeout(() => window.location.reload(), 0);
|
|
2515
|
+
});
|
|
2516
|
+
/* 宿主的菜单项都在内层滚动容器里,加在外层会错位。 */
|
|
2517
|
+
const viewport = menu.querySelector('[class*="_viewport"]') || menu;
|
|
2518
|
+
viewport.appendChild(item);
|
|
2519
|
+
};
|
|
2520
|
+
|
|
2521
|
+
/* 用 rAF 而不是延时:菜单一出现,下一帧就把项补上,
|
|
2522
|
+
不会出现「菜单先显示、项晚半拍才冒出来」的情况。 */
|
|
2523
|
+
let rafId = 0;
|
|
2524
|
+
const schedule = () => {
|
|
2525
|
+
if (rafId !== 0) return;
|
|
2526
|
+
rafId = window.requestAnimationFrame(() => {
|
|
2527
|
+
rafId = 0;
|
|
2528
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') return;
|
|
2529
|
+
addItem();
|
|
2530
|
+
});
|
|
2531
|
+
};
|
|
2532
|
+
|
|
2533
|
+
observer = new MutationObserver(schedule);
|
|
2534
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2535
|
+
|
|
2536
|
+
return () => {
|
|
2537
|
+
observer.disconnect();
|
|
2538
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2539
|
+
for (const el of document.querySelectorAll('[data-dcc-reload-item]')) el.remove();
|
|
2540
|
+
};
|
|
2541
|
+
}
|
|
2542
|
+
|
|
2069
2543
|
/**
|
|
2070
2544
|
* 在输入框下方的状态行里显示账户余额,走宿主的账户接口
|
|
2071
2545
|
* (ctx.remote.account.getBalance)。取不到就静默不显示,不影响其他功能。
|
|
@@ -2646,7 +3120,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2646
3120
|
h('div', { className: 'dcc-group dcc-primary' },
|
|
2647
3121
|
h(Row, {
|
|
2648
3122
|
title: zh ? '总开关' : 'Master switch',
|
|
2649
|
-
desc: zh ? '
|
|
3123
|
+
desc: zh ? '关闭后将禁用全部修改,包括始终启用的基础改进。\n打开和关闭会重载前端界面,不影响正在运行的任务。' : 'Turning it off disables every change, including the always-on base fixes.\nToggling it reloads the UI; running tasks are not affected.',
|
|
2650
3124
|
checked: prefs.enabled,
|
|
2651
3125
|
onChange: update('enabled'),
|
|
2652
3126
|
}),
|
|
@@ -2827,8 +3301,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2827
3301
|
'- 工作区文件夹悬停时保留图标。',
|
|
2828
3302
|
'- 已归档会话显示删除线。',
|
|
2829
3303
|
'- 选择题弹窗细节优化。',
|
|
2830
|
-
'-
|
|
3304
|
+
'- 优化加载界面,正文切换时渐显。',
|
|
2831
3305
|
'- 修复二级右键菜单消失延迟。',
|
|
3306
|
+
'- 顶栏更多菜单添加"重载前端界面"按钮,卡顿时可重载界面,不会中断任务。',
|
|
2832
3307
|
].join('\n')
|
|
2833
3308
|
: [
|
|
2834
3309
|
'These small fixes and improvements are always on unless the master switch is off.',
|
|
@@ -2836,8 +3311,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2836
3311
|
'- Workspace folder icons stay visible on hover.',
|
|
2837
3312
|
'- Archived sessions show a strikethrough.',
|
|
2838
3313
|
'- Multiple-choice dialog details refined.',
|
|
2839
|
-
'-
|
|
3314
|
+
'- Refined the loading screen and added a fade-in when the conversation content changes.',
|
|
2840
3315
|
'- Fixed the delay when closing a second-level context menu.',
|
|
3316
|
+
'- Added a "Reload frontend" button to the top-bar overflow menu; reloads the UI when it lags, without interrupting tasks.',
|
|
2841
3317
|
].join('\n'),
|
|
2842
3318
|
})),
|
|
2843
3319
|
h('div', { className: 'dcc-meta-row' },
|
|
@@ -2903,6 +3379,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2903
3379
|
const removeBootCover = installBootCover(readPrefs());
|
|
2904
3380
|
const removePluginPin = installNavToggle();
|
|
2905
3381
|
const removeMenuOrigin = installMenuOrigin();
|
|
3382
|
+
const removeReloadItem = installReloadMenuItem();
|
|
3383
|
+
const removeHistoryHint = installHistoryHint();
|
|
3384
|
+
const removeBootHint = installBootHint();
|
|
2906
3385
|
const removeDialogExit = installDialogExit();
|
|
2907
3386
|
return () => {
|
|
2908
3387
|
removeCss();
|
|
@@ -2915,6 +3394,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2915
3394
|
removeBootCover();
|
|
2916
3395
|
removePluginPin();
|
|
2917
3396
|
removeMenuOrigin();
|
|
3397
|
+
removeReloadItem();
|
|
3398
|
+
removeHistoryHint();
|
|
3399
|
+
removeBootHint();
|
|
2918
3400
|
removeDialogExit();
|
|
2919
3401
|
const root = document.documentElement;
|
|
2920
3402
|
delete root.dataset.dccRadius;
|