dsh-ui-alt 0.2.343 → 0.2.401

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 +5 -4
  2. package/client.js +455 -12
  3. 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
- - 十个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
132
+ - 十一个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
133
133
  - `installNewSessionRow()`:克隆宿主的「新会话」按钮成导航行,点击转发给原按钮。
134
134
  - `installNavToggle()`:导航下方插入展开/收起箭头,点击切换 `data-dcc-nav` 并写回偏好。
135
135
  - `installSettingsBackButton()`:设置面板左上角插入返回按钮,点击触发原关闭按钮。
@@ -140,6 +140,7 @@ dsh-ui-alt/
140
140
  - `installMenuOrigin()`:记录点击坐标,让菜单从点击处展开。
141
141
  - `installDialogExit()`:接管对话框移除,补一段退场动画。
142
142
  - `installBootCover()`:启动时的过渡遮罩。
143
+ - `installReloadMenuItem()`:在标题栏三点菜单末尾追加「重载前端界面」项。
143
144
  - 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
144
145
 
145
146
  ## 开发
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.343';
10
- const UPDATED = '2026-11-14';
9
+ const VERSION = '0.2.401';
10
+ const UPDATED = '2026-11-15';
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: true,
22
+ settingsFullscreen: false,
23
23
  hideHoverCard: true,
24
24
  hideRowButtons: true,
25
25
  headerFade: true,
@@ -740,7 +740,7 @@ html[data-dcc-dot="on"] [class*="_sessionRow"] {
740
740
  html[data-dcc-dot="on"] [class*="_sessionRow"]::before {
741
741
  content: "";
742
742
  position: absolute;
743
- left: calc(var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset) + var(--dsh-workspace-indent, 0px) + 8px - 2px);
743
+ left: calc(var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset) + var(--dsh-workspace-indent, 0px) + 8px - 5px);
744
744
  top: 50%;
745
745
  width: 4px;
746
746
  height: 4px;
@@ -750,18 +750,45 @@ html[data-dcc-dot="on"] [class*="_sessionRow"]::before {
750
750
  opacity: .35;
751
751
  pointer-events: none;
752
752
  }
753
+
754
+ /* slot 里已经有状态图标(运行中的加载圈、结束标记之类)时,
755
+ 不再画会话前圆点,避免两个标记并排叠在一起。 */
756
+ html[data-dcc-dot="on"] [class*="_sessionRow"]:has([class*="_slot"] svg)::before {
757
+ display: none !important;
758
+ }
753
759
  /* 与 archive-manager 的收藏星标共存:星标占用的正是同一个 16px 前导位置。
754
760
  星标在行悬停时总会出现(未收藏是空心、可点),已收藏则常驻,
755
761
  两种情况下都不再画自身的小圆点,避免与星标叠在一起。 */
756
- html[data-dcc-dot="on"] [class*="_sessionRow"]:hover:has(.dsham_starSlot)::before,
762
+ /* 悬停规避只在「隐藏会话悬停多余按钮」关着时才需要——
763
+ 那个开关打开后,未收藏的星标根本不会出现,圆点不必让位。
764
+ 已收藏的星标是常驻的,所以这一条不受开关影响。 */
765
+ html[data-dcc-dot="on"][data-dcc-row-buttons="off"] [class*="_sessionRow"]:hover:has(.dsham_starSlot)::before,
757
766
  html[data-dcc-dot="on"] [class*="_sessionRow"]:has(.dsham_starSlot[data-favorited="true"])::before {
758
767
  display: none;
759
768
  }
760
- /* 未收藏时的空心星(悬停才出现):压到与会话标题同色,不再用偏亮的 label-primary。
761
- 已收藏的实心金星保持 archive-manager 原色,不做处理。 */
762
- html[data-dcc-enabled="on"] [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) .dsham_rowStar {
763
- color: var(--dsw-alias-label-secondary) !important;
769
+ /* 收藏星标是绝对定位(left: 8px),要左移 1px 必须写 7px——
770
+ 直接写 left: -1px 会替换掉原来的基准,把它甩到行外。 */
771
+ html[data-dcc-radius="on"] [class*="_sessionRow"] .dsham_starSlot {
772
+ left: 7px !important;
773
+ }
774
+
775
+ /* 悬停时才出现的收藏按钮(未收藏的空心星)跟着「隐藏会话悬停多余按钮」一起隐藏,
776
+ 已收藏的实心星保持显示——那是用户自己点亮的状态,不应该藏起来。 */
777
+ html[data-dcc-row-buttons="on"] [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) {
778
+ display: none !important;
764
779
  }
780
+ /* 工作区行和会话行左侧的图标统一左移 2px。
781
+ 宿主用 padding-inline-start + gap 排列行内图标,所以调行的起始内边距
782
+ 就能一次对齐这一列——文件夹、圆点、加载圈、星标、第三方插件加的图标
783
+ 全都跟着走,不用逐个类名去点。 */
784
+ html[data-dcc-radius="on"] [class*="_projectRow"],
785
+ html[data-dcc-radius="on"] [class*="_sessionRow"] {
786
+ padding-inline-start: calc(
787
+ var(--dsh-sidebar-row-padding) - var(--dsh-sidebar-paint-inset)
788
+ + var(--dsh-workspace-indent, 0px) - 2px
789
+ ) !important;
790
+ }
791
+
765
792
  /* 「展开其余 N 个会话 / 收起」比工作区标题更淡 */
766
793
  html[data-dcc-dim="on"] [class*="_sessionOverflowButton"] {
767
794
  color: var(--dsw-alias-label-tertiary) !important;
@@ -771,6 +798,25 @@ html[data-dcc-dim="on"] [class*="_sessionOverflowButton"]:hover {
771
798
  opacity: .9 !important;
772
799
  }
773
800
 
801
+ /* 工作区行左侧的图标统一尺寸和位置,跟着「减小圆角与间距」走。
802
+ 宿主的文件夹图标是 16px,行高 32px,缩到 14px 后与 13px 的标题更协调。
803
+ 其他插件在这个位置放的图标(自定义 svg、img、字符等)也一并按同一套
804
+ 尺寸和偏移处理,保证整列左边缘对齐。 */
805
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_folder"] svg,
806
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_folder"] img,
807
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_leading"] svg,
808
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_leading"] img,
809
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_iconSlot"] svg,
810
+ html[data-dcc-radius="on"] [class*="_projectRow"] [class*="_iconSlot"] img {
811
+ width: 14px !important;
812
+ height: 14px !important;
813
+ /* 位置上移 1px 与文字基线对齐(横向由行的 padding 统一处理) */
814
+ position: relative !important;
815
+ top: -1px !important;
816
+ /* 非正方形图标按比例缩,不拉伸 */
817
+ object-fit: contain !important;
818
+ }
819
+
774
820
  /* ---------- 工作区行:悬停时不换成展开箭头,保持文件夹图标 ---------- */
775
821
  /* 宿主默认:hover 时 .chevron 显示、.folder 隐藏(Rows.module.css)。这里反着压回去。 */
776
822
  html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_folder"] {
@@ -957,6 +1003,100 @@ html[data-dcc-always-show="on"] .dcc-segmented {
957
1003
  }
958
1004
 
959
1005
  /* 溢出菜单:对齐宿主菜单的尺寸与层级(圆角 12、内距 6、项高 32、项圆角 8) */
1006
+ /* 会话正文渐显:切换会话后,正文列和轮次标记一起淡入。
1007
+ 由脚本在加载提示消失后重播——容器本身不重建,单靠 CSS 动画只播一次。
1008
+ 归在「优化加载界面」里,属始终开启项,不受动画开关控制。 */
1009
+ html[data-dcc-enabled="on"] [data-dcc-fade-in] {
1010
+ animation: dcc-content-in .26s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
1011
+ }
1012
+ @keyframes dcc-content-in {
1013
+ from { opacity: 0; }
1014
+ to { opacity: 1; }
1015
+ }
1016
+
1017
+ /* ===== BOOT-HINT: 宿主加载页适配(高耦合,见 installBootHint 的注释)=====
1018
+ 只藏旋转圈。hint 居中和 HARNESS 隐藏必须在同一帧完成,放在脚本里做。
1019
+ 宿主加载页若改版,整块删掉即可,不影响其它样式。 */
1020
+ /* 脚本处理完之前先整体不可见:宿主第一帧渲染的是原始布局,
1021
+ 如果直接可见会露出一瞬的 HARNESS + Loading 并排。空一帧比错一帧好。
1022
+ 处理完由脚本打上 data-dcc-boot-ready,恢复正常显示。 */
1023
+ html[data-dcc-enabled="on"] [data-dsh-boot]:not([data-dcc-boot-ready]) {
1024
+ visibility: hidden;
1025
+ }
1026
+ /* 兜底:万一脚本没跑(插件未加载等),两秒后无论如何都显示出来,
1027
+ 避免加载页永久不可见。 */
1028
+ html[data-dcc-enabled="on"] [data-dsh-boot] {
1029
+ animation: dcc-boot-reveal 0s linear 2s forwards;
1030
+ }
1031
+ @keyframes dcc-boot-reveal {
1032
+ to { visibility: visible; }
1033
+ }
1034
+ html[data-dcc-enabled="on"] [data-dsh-boot] [data-dsh-boot-spinner],
1035
+ html[data-dcc-enabled="on"] [data-dsh-boot] [class*="_spinner"] {
1036
+ display: none !important;
1037
+ }
1038
+ /* ===== BOOT-HINT END ===== */
1039
+
1040
+ /* 会话切换时的「载入历史」提示:挪到正文中心,鲸鱼在上、文字在下。
1041
+ 文字内容由宿主写入,这里只改排版,不替换文案。 */
1042
+ html[data-dcc-enabled="on"] [class*="_hint"] {
1043
+ position: fixed !important;
1044
+ /* left/top 由脚本按正文区域的中心算出来写上去 */
1045
+ transform: translate(-50%, -50%) !important;
1046
+ display: flex !important;
1047
+ flex-direction: column !important;
1048
+ align-items: center !important;
1049
+ gap: 10px !important;
1050
+ margin: 0 !important;
1051
+ color: var(--dsw-alias-label-tertiary) !important;
1052
+ font-size: 13px !important;
1053
+ white-space: nowrap !important;
1054
+ pointer-events: none !important;
1055
+ }
1056
+ html[data-dcc-enabled="on"] [data-dcc-hint-fish] {
1057
+ width: 56px;
1058
+ height: auto;
1059
+ opacity: .32;
1060
+ flex: none;
1061
+ }
1062
+
1063
+ /* 追加到宿主菜单末尾的「重载前端界面」:外观对齐宿主自己的菜单项,
1064
+ 高度、内边距、字号都按它的规格来。 */
1065
+ .dcc-menu-extra {
1066
+ display: flex;
1067
+ align-items: center;
1068
+ gap: 6px;
1069
+ width: 100%;
1070
+ min-height: 32px;
1071
+ padding: 0 10px;
1072
+ border: 0;
1073
+ border-radius: var(--dsw-radius-sm, 8px);
1074
+ background: transparent;
1075
+ color: var(--dsw-alias-label-primary);
1076
+ font: inherit;
1077
+ font-size: 13px;
1078
+ text-align: left;
1079
+ white-space: nowrap;
1080
+ cursor: pointer;
1081
+ }
1082
+ .dcc-menu-extra:hover {
1083
+ background: var(--dsw-alias-interactive-bg-hover);
1084
+ }
1085
+ .dcc-menu-extra > span {
1086
+ /* 图标左移后文字跟着走一点,和宿主菜单项的文字左边缘对齐 */
1087
+ position: relative;
1088
+ left: -2px;
1089
+ }
1090
+ .dcc-menu-extra-icon {
1091
+ display: block;
1092
+ width: 16px;
1093
+ height: 16px;
1094
+ flex: none;
1095
+ /* 和宿主菜单项的图标左边缘对齐(宿主的图标比 16px 小的会儿再偏一点) */
1096
+ position: relative;
1097
+ left: -2px;
1098
+ }
1099
+
960
1100
  .dcc-seg-menu {
961
1101
  position: fixed;
962
1102
  z-index: 2147483000;
@@ -2066,6 +2206,301 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2066
2206
  };
2067
2207
  }
2068
2208
 
2209
+ /**
2210
+ * 切换会话时正文会短暂显示一行「载入历史」提示(宿主的 _hint)。
2211
+ * 它默认贴在左上角,这里把它挪到正文中心,并在文字上方加一个鲸鱼图标,
2212
+ * 和启动遮罩的观感统一。文字内容不写死——只包一层容器,原文照读。
2213
+ */
2214
+ function installHistoryHint() {
2215
+ let observer = null;
2216
+ let rafId = 0;
2217
+
2218
+ const decorate = () => {
2219
+ const hint = document.querySelector('[class*="_hint"]');
2220
+ if (hint === null) return;
2221
+ /* 加载页的 hint 归 installBootHint 管,这里跳过,避免两个模块
2222
+ 对同一个元素各改一半。 */
2223
+ if (hint.closest('[data-dsh-boot]') !== null) return;
2224
+ if (hint.querySelector('[data-dcc-hint-fish]') !== null) return;
2225
+
2226
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
2227
+ svg.setAttribute('viewBox', '0 0 23.16 17.04');
2228
+ svg.setAttribute('data-dcc-hint-fish', '');
2229
+ svg.setAttribute('aria-hidden', 'true');
2230
+ const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2231
+ shape.setAttribute('d', FISH_LOGO_PATH);
2232
+ const darkNow = document.body.hasAttribute('data-ds-dark-theme')
2233
+ || document.documentElement.hasAttribute('data-ds-dark-theme');
2234
+ shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
2235
+ svg.appendChild(shape);
2236
+ hint.insertBefore(svg, hint.firstChild);
2237
+
2238
+ /* 宿主加载页的适配在 installBootHint 里独立处理,这里只负责会话界面的情况 */
2239
+ center(hint);
2240
+ };
2241
+ /* 按正文区域(而不是视口)的中心定位:侧栏展开时两者差一截。 */
2242
+ const center = (hint) => {
2243
+ /* 加载页里的 hint 由 installBootHint 单独居中,这里跳过。 */
2244
+ if (hint.closest('[data-dsh-boot]') !== null) return;
2245
+ const host = document.querySelector('[data-conversation-scroll]');
2246
+ if (host === null) return;
2247
+ const rect = host.getBoundingClientRect();
2248
+ if (rect.width === 0 || rect.height === 0) return;
2249
+ hint.style.left = rect.left + rect.width / 2 + 'px';
2250
+ /* 正文区的几何中心偏下——底部有输入框占位,视觉中心要高一些 */
2251
+ hint.style.top = rect.top + rect.height / 2 - 64 + 'px';
2252
+ };
2253
+
2254
+ /* 切换会话时正文是整体换掉的,但容器本身常驻,
2255
+ animation 只播一次,之后再切就看不到了。这里在提示消失后
2256
+ 手动重播一次:先摘掉动画类、强制重排、再挂回去。 */
2257
+ let lastHadHint = false;
2258
+ const replayFade = () => {
2259
+
2260
+ const targets = [
2261
+ document.querySelector('[class*="_column"]'),
2262
+ document.querySelector('[class*="_marks"]'),
2263
+ ].filter((el) => el !== null && el.getBoundingClientRect().height > 0);
2264
+ if (targets.length === 0) return;
2265
+ for (const el of targets) el.removeAttribute('data-dcc-fade-in');
2266
+ /* 读一次布局,让移除生效,再挂回去才会重播 */
2267
+ void document.body.offsetHeight;
2268
+ for (const el of targets) el.setAttribute('data-dcc-fade-in', '');
2269
+ };
2270
+
2271
+ const watchHint = () => {
2272
+ /* 只看会话界面里的提示——加载页也有同一个 _hint,它消失不表示
2273
+ 正文就位,跟着触发会白跑一次(虽然 targets 为空会直接返回)。 */
2274
+ const hint = document.querySelector('[class*="_hint"]');
2275
+ const hasHint = hint !== null && hint.closest('[data-dsh-boot]') === null;
2276
+ /* 由「有提示」变成「没提示」,说明这一轮内容已经就位 */
2277
+ if (lastHadHint && !hasHint) replayFade();
2278
+ lastHadHint = hasHint;
2279
+ };
2280
+
2281
+ const schedule = () => {
2282
+ if (rafId !== 0) return;
2283
+ rafId = window.requestAnimationFrame(() => {
2284
+ rafId = 0;
2285
+ if (document.documentElement.dataset.dccEnabled !== 'on') return;
2286
+ decorate();
2287
+ watchHint();
2288
+ });
2289
+ };
2290
+
2291
+ observer = new MutationObserver(schedule);
2292
+ observer.observe(document.body, { childList: true, subtree: true });
2293
+
2294
+ return () => {
2295
+ observer.disconnect();
2296
+ if (rafId !== 0) window.cancelAnimationFrame(rafId);
2297
+ for (const el of document.querySelectorAll('[data-dcc-hint-fish]')) el.remove();
2298
+ for (const el of document.querySelectorAll('[data-dcc-fade-in]')) el.removeAttribute('data-dcc-fade-in');
2299
+ };
2300
+ }
2301
+
2302
+ /**
2303
+ * 宿主加载页(开机时的 "Loading plugins…" 那一屏)的外观适配。
2304
+ *
2305
+ * ⚠️ 这是一块**高耦合**的补丁,和下面这些宿主实现细节绑死:
2306
+ *
2307
+ * | 依赖 | 用途 |
2308
+ * | ------------------------ | -------------------------------- |
2309
+ * | [data-dsh-boot] | 加载页根节点,用来界定作用范围 |
2310
+ * | [class*="_hint"] | 提示文字,和会话界面的载入提示共用 |
2311
+ * | [data-dsh-boot-spinner] | 旋转圈 |
2312
+ * | [class*="_spinner"] | 旋转圈(备用选择器) |
2313
+ * | 文本含 "HARNESS" | 要隐藏的品牌字样 |
2314
+ *
2315
+ * 做两件事:
2316
+ * 1. 把提示文字挪到视口正中(宿主原本让它和 HARNESS 并排)
2317
+ * 2. 隐藏 HARNESS 字样和旋转圈,只留鲸鱼 + 提示文字
2318
+ *
2319
+ * 第 1 点必须和 HARNESS 的隐藏**同一帧**完成——如果只把文字改成
2320
+ * fixed 居中、HARNESS 晚一帧才藏,中间会露出两者叠在屏幕中间一瞬间。
2321
+ *
2322
+ * 失效表现:宿主改版后,加载页恢复原样,不报错,也不影响其它功能。
2323
+ *
2324
+ * 要整体移除时:删掉本函数 + 调用处 removeBootHint + 下面对应的
2325
+ * CSS(搜 BOOT-HINT),不会牵连别的模块。
2326
+ */
2327
+ function installBootHint() {
2328
+ let observer = null;
2329
+ let rafId = 0;
2330
+
2331
+ const apply = () => {
2332
+ const boot = document.querySelector('[data-dsh-boot]');
2333
+ if (boot === null) return;
2334
+
2335
+ const hint = boot.querySelector('[class*="_hint"]');
2336
+ if (hint !== null && hint.getAttribute('data-dcc-boot-hint') === null) {
2337
+ hint.setAttribute('data-dcc-boot-hint', '');
2338
+
2339
+ /* 鲸鱼图标放在提示文字上方,和会话界面的载入提示同一套做法 */
2340
+ const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
2341
+ svg.setAttribute('viewBox', '0 0 23.16 17.04');
2342
+ svg.setAttribute('data-dcc-hint-fish', '');
2343
+ svg.setAttribute('aria-hidden', 'true');
2344
+ const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2345
+ shape.setAttribute('d', FISH_LOGO_PATH);
2346
+ const darkNow = document.body.hasAttribute('data-ds-dark-theme')
2347
+ || document.documentElement.hasAttribute('data-ds-dark-theme');
2348
+ shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
2349
+ svg.appendChild(shape);
2350
+ hint.insertBefore(svg, hint.firstChild);
2351
+
2352
+ hint.style.position = 'fixed';
2353
+ hint.style.top = '50%';
2354
+ hint.style.left = '50%';
2355
+ hint.style.transform = 'translate(-50%, -50%)';
2356
+ }
2357
+
2358
+ /* HARNESS 按文字内容匹配,不认类名——它没有稳定的类名可用。
2359
+ 用正则而非全等:实际的 textContent 常带空格或标点。 */
2360
+ for (const el of boot.querySelectorAll('*')) {
2361
+ if (el.getAttribute('data-dcc-boot-brand') !== null) continue;
2362
+ if (!/HARNESS/i.test(el.textContent || '')) continue;
2363
+ /* 只藏最内层那个,避免把整块容器一起藏掉 */
2364
+ const inner = [...el.querySelectorAll('*')].filter(
2365
+ (c) => /HARNESS/i.test(c.textContent || ''),
2366
+ );
2367
+ if (inner.length > 0) continue;
2368
+ el.setAttribute('data-dcc-boot-brand', '');
2369
+ el.style.display = 'none';
2370
+ }
2371
+
2372
+ /* 处理完了,放行显示 */
2373
+ boot.setAttribute('data-dcc-boot-ready', '');
2374
+ };
2375
+
2376
+ const schedule = () => {
2377
+ if (rafId !== 0) return;
2378
+ rafId = window.requestAnimationFrame(() => {
2379
+ rafId = 0;
2380
+ if (document.documentElement.dataset.dccEnabled !== 'on') return;
2381
+ apply();
2382
+ });
2383
+ };
2384
+
2385
+ observer = new MutationObserver(schedule);
2386
+ observer.observe(document.body, { childList: true, subtree: true });
2387
+
2388
+ return () => {
2389
+ observer.disconnect();
2390
+ if (rafId !== 0) window.cancelAnimationFrame(rafId);
2391
+ /* 还原被本模块改过的东西,避免卸载后留下半截样式 */
2392
+ for (const el of document.querySelectorAll('[data-dcc-boot-hint]')) {
2393
+ el.removeAttribute('data-dcc-boot-hint');
2394
+ el.style.position = '';
2395
+ el.style.top = '';
2396
+ el.style.left = '';
2397
+ el.style.transform = '';
2398
+ }
2399
+ for (const el of document.querySelectorAll('[data-dcc-boot-brand]')) {
2400
+ el.removeAttribute('data-dcc-boot-brand');
2401
+ el.style.display = '';
2402
+ }
2403
+ for (const el of document.querySelectorAll('[data-dcc-boot-ready]')) {
2404
+ el.removeAttribute('data-dcc-boot-ready');
2405
+ }
2406
+ for (const el of document.querySelectorAll('[data-dcc-hint-fish]')) el.remove();
2407
+ };
2408
+ }
2409
+
2410
+ /**
2411
+ * 在会话标题栏右上角的「⋯」菜单末尾追加一项「重载前端界面」。
2412
+ * 那个菜单是宿主 React 渲染的,插不进去子节点,只能在它打开后
2413
+ * 往 DOM 里补一个外观一致的按钮,点击等价于 location.reload()。
2414
+ */
2415
+ function installReloadMenuItem() {
2416
+ const MENU = '[role="menu"]';
2417
+ let observer = null;
2418
+ let timer = null;
2419
+
2420
+ const findMenu = () => {
2421
+ const host = document.querySelector('[class*="_headerUtilities"]');
2422
+ if (host === null) return null;
2423
+ const hostRect = host.getBoundingClientRect();
2424
+ const menus = document.querySelectorAll(MENU);
2425
+ for (let i = 0; i < menus.length; i += 1) {
2426
+ const menu = menus[i];
2427
+ if (menu.querySelector('[data-dcc-reload-item]') !== null) continue;
2428
+ /* 只认贴在标题栏下方展开的那个菜单:它的顶边要落在工具区的下方附近。
2429
+ 头像菜单、子菜单的顶边都在其它位置,会被排除掉。 */
2430
+ const rect = menu.getBoundingClientRect();
2431
+ if (rect.width === 0 || rect.height === 0) continue;
2432
+ if (rect.top < hostRect.top - 4) continue;
2433
+ if (rect.top > hostRect.bottom + 24) continue;
2434
+ if (rect.right < hostRect.left - 8) continue;
2435
+ return menu;
2436
+ }
2437
+ return null;
2438
+ };
2439
+
2440
+ const addItem = () => {
2441
+ const menu = findMenu();
2442
+ if (menu === null) return;
2443
+ if (menu.querySelector('[data-dcc-reload-item]') !== null) return;
2444
+
2445
+ const item = document.createElement('button');
2446
+ item.type = 'button';
2447
+ item.setAttribute('data-dcc-reload-item', '');
2448
+ item.className = 'dcc-menu-extra';
2449
+
2450
+ /* 刷新图标:一个带箭头的圆,和工具栏那个刷新按钮同一套语义 */
2451
+ const icon = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
2452
+ icon.setAttribute('viewBox', '0 0 16 16');
2453
+ icon.setAttribute('class', 'dcc-menu-extra-icon');
2454
+ icon.setAttribute('aria-hidden', 'true');
2455
+ const arc = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2456
+ arc.setAttribute('d', 'M13 8a5 5 0 1 1-1.46-3.54');
2457
+ arc.setAttribute('fill', 'none');
2458
+ arc.setAttribute('stroke', 'currentColor');
2459
+ arc.setAttribute('stroke-width', '1.4');
2460
+ arc.setAttribute('stroke-linecap', 'round');
2461
+ const tip = document.createElementNS('http://www.w3.org/2000/svg', 'path');
2462
+ tip.setAttribute('d', 'M13 2.6V5.2h-2.6');
2463
+ tip.setAttribute('fill', 'none');
2464
+ tip.setAttribute('stroke', 'currentColor');
2465
+ tip.setAttribute('stroke-width', '1.4');
2466
+ tip.setAttribute('stroke-linecap', 'round');
2467
+ tip.setAttribute('stroke-linejoin', 'round');
2468
+ icon.append(arc, tip);
2469
+
2470
+ const label = document.createElement('span');
2471
+ label.textContent = isZh() ? '重载前端界面' : 'Reload frontend';
2472
+ item.append(icon, label);
2473
+ item.addEventListener('click', (event) => {
2474
+ event.stopPropagation();
2475
+ window.setTimeout(() => window.location.reload(), 0);
2476
+ });
2477
+ /* 宿主的菜单项都在内层滚动容器里,加在外层会错位。 */
2478
+ const viewport = menu.querySelector('[class*="_viewport"]') || menu;
2479
+ viewport.appendChild(item);
2480
+ };
2481
+
2482
+ /* 用 rAF 而不是延时:菜单一出现,下一帧就把项补上,
2483
+ 不会出现「菜单先显示、项晚半拍才冒出来」的情况。 */
2484
+ let rafId = 0;
2485
+ const schedule = () => {
2486
+ if (rafId !== 0) return;
2487
+ rafId = window.requestAnimationFrame(() => {
2488
+ rafId = 0;
2489
+ if (document.documentElement.dataset.dccEnabled !== 'on') return;
2490
+ addItem();
2491
+ });
2492
+ };
2493
+
2494
+ observer = new MutationObserver(schedule);
2495
+ observer.observe(document.body, { childList: true, subtree: true });
2496
+
2497
+ return () => {
2498
+ observer.disconnect();
2499
+ if (rafId !== 0) window.cancelAnimationFrame(rafId);
2500
+ for (const el of document.querySelectorAll('[data-dcc-reload-item]')) el.remove();
2501
+ };
2502
+ }
2503
+
2069
2504
  /**
2070
2505
  * 在输入框下方的状态行里显示账户余额,走宿主的账户接口
2071
2506
  * (ctx.remote.account.getBalance)。取不到就静默不显示,不影响其他功能。
@@ -2646,7 +3081,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2646
3081
  h('div', { className: 'dcc-group dcc-primary' },
2647
3082
  h(Row, {
2648
3083
  title: zh ? '总开关' : 'Master switch',
2649
- desc: zh ? '关闭后将禁用全部修改,包括始终启用的部分界面修复功能。\n打开和关闭会重载前端界面,不影响正在运行的任务。' : 'Turning it off disables every change, including the always-on UI fixes.\nToggling it reloads the UI; running tasks are not affected.',
3084
+ 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
3085
  checked: prefs.enabled,
2651
3086
  onChange: update('enabled'),
2652
3087
  }),
@@ -2827,8 +3262,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2827
3262
  '- 工作区文件夹悬停时保留图标。',
2828
3263
  '- 已归档会话显示删除线。',
2829
3264
  '- 选择题弹窗细节优化。',
2830
- '- 避免界面加载时跳变添加的过渡遮罩。',
3265
+ '- 优化加载界面,正文切换时渐显。',
2831
3266
  '- 修复二级右键菜单消失延迟。',
3267
+ '- 顶栏更多菜单添加"重载前端界面"按钮,卡顿时可重载界面,不会中断任务。',
2832
3268
  ].join('\n')
2833
3269
  : [
2834
3270
  'These small fixes and improvements are always on unless the master switch is off.',
@@ -2836,8 +3272,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2836
3272
  '- Workspace folder icons stay visible on hover.',
2837
3273
  '- Archived sessions show a strikethrough.',
2838
3274
  '- Multiple-choice dialog details refined.',
2839
- '- A transition cover added to avoid layout jumps on startup.',
3275
+ '- Refined the loading screen and added a fade-in when the conversation content changes.',
2840
3276
  '- Fixed the delay when closing a second-level context menu.',
3277
+ '- Added a "Reload frontend" button to the top-bar overflow menu; reloads the UI when it lags, without interrupting tasks.',
2841
3278
  ].join('\n'),
2842
3279
  })),
2843
3280
  h('div', { className: 'dcc-meta-row' },
@@ -2903,6 +3340,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2903
3340
  const removeBootCover = installBootCover(readPrefs());
2904
3341
  const removePluginPin = installNavToggle();
2905
3342
  const removeMenuOrigin = installMenuOrigin();
3343
+ const removeReloadItem = installReloadMenuItem();
3344
+ const removeHistoryHint = installHistoryHint();
3345
+ const removeBootHint = installBootHint();
2906
3346
  const removeDialogExit = installDialogExit();
2907
3347
  return () => {
2908
3348
  removeCss();
@@ -2915,6 +3355,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2915
3355
  removeBootCover();
2916
3356
  removePluginPin();
2917
3357
  removeMenuOrigin();
3358
+ removeReloadItem();
3359
+ removeHistoryHint();
3360
+ removeBootHint();
2918
3361
  removeDialogExit();
2919
3362
  const root = document.documentElement;
2920
3363
  delete root.dataset.dccRadius;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ui-alt",
3
- "version": "0.2.343",
3
+ "version": "0.2.401",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。",