dsh-ui-alt 0.2.13 → 0.2.17

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 +1 -1
  2. package/client.js +43 -36
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -11,7 +11,7 @@
11
11
  | 开关 | 默认 | 效果 |
12
12
  | --- | --- | --- |
13
13
  | 隐藏左上角 Logo | 关 | 隐藏侧栏顶部的 Logo |
14
- | Windows 默认微软雅黑字体 | 关 | Windows 端默认字体改为微软雅黑,低分辨率屏幕 200% 以下缩放带 hinting,更锐利;手动设置字体或 macOS 不受影响 |
14
+ | Windows 默认微软雅黑字体 | 关 | 将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响 |
15
15
 
16
16
  **布局**
17
17
 
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.13';
10
- const UPDATED = '2026-11-09';
9
+ const VERSION = '0.2.17';
10
+ const UPDATED = '2026-11-11';
11
11
  const DEFAULTS = {
12
12
  radiusDensity: true,
13
13
  invertNewSession: true,
@@ -164,8 +164,12 @@ html[data-dcc-radius="on"] body {
164
164
  --dsw-shadow-lv2: 0 2px 6px rgba(0, 0, 0, .05) !important;
165
165
  --dsw-shadow-lv3: 0 8px 24px rgba(0, 0, 0, .10) !important;
166
166
  }
167
+ /* 宿主只在 _preview / _media 这两个浮层上单独定义了这个变量,压住它们本身即可。
168
+ 早先用 body * 给每个元素都写一遍,会把这套声明的失效范围放大到全文档,
169
+ 悬停/滚动时样式重算明显变慢,已收窄。 */
167
170
  html[data-dcc-radius="on"] body,
168
- html[data-dcc-radius="on"] body * {
171
+ html[data-dcc-radius="on"] [class*="_preview_"],
172
+ html[data-dcc-radius="on"] [class*="_media_"] {
169
173
  --dsw-elevation-panel: var(--dsw-elevation-stroke), 0 2px 6px rgba(0, 0, 0, .04) !important;
170
174
  }
171
175
 
@@ -863,8 +867,6 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
863
867
  * 认人:菜单按钮带前者,置顶按钮的 aria-label 里是「置顶会话 / 取消置顶 / pin」。
864
868
  */
865
869
  function installRowActionFilter() {
866
- let observer = null;
867
- let timer = null;
868
870
  let lastRow = null;
869
871
 
870
872
  const isPinButton = (btn) => /置顶|pin/i.test(btn.getAttribute('aria-label') || '');
@@ -887,6 +889,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
887
889
  }
888
890
  };
889
891
 
892
+ /* 只在这里处理:指针进入哪一行就标记哪一行。
893
+ 早先还挂了一个 MutationObserver 定期全量扫描,滚动时虚拟列表频繁改 DOM,
894
+ 每 400ms 扫一遍所有会话行,反而成了新的卡顿源,已移除。 */
890
895
  const onPointer = (event) => {
891
896
  if (document.documentElement.dataset.dccRowButtons !== 'on') return;
892
897
  const target = event.target;
@@ -897,42 +902,42 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
897
902
  filterRow(row);
898
903
  };
899
904
 
900
- /* 兜底:行是复用的,按钮可能在后来的渲染里才挂上去,定期把没扫过的行补一遍 */
901
- const sweep = () => {
902
- if (document.documentElement.dataset.dccRowButtons !== 'on') return;
903
- const rows = document.querySelectorAll('[class*="_sessionRow"]:not([data-dcc-scanned])');
904
- for (const row of rows) {
905
- filterRow(row);
906
- row.setAttribute('data-dcc-scanned', '');
907
- }
908
- };
909
-
910
- const schedule = () => {
911
- if (timer !== null) return;
912
- timer = window.setTimeout(() => {
913
- timer = null;
914
- lastRow = null;
915
- sweep();
916
- }, 400);
917
- };
918
-
919
905
  document.addEventListener('pointerover', onPointer, true);
920
906
  document.addEventListener('focusin', onPointer, true);
921
- sweep();
922
- observer = new MutationObserver(schedule);
923
- observer.observe(document.body, { childList: true, subtree: true });
924
-
925
907
  return () => {
926
908
  document.removeEventListener('pointerover', onPointer, true);
927
909
  document.removeEventListener('focusin', onPointer, true);
928
- observer.disconnect();
929
- if (timer !== null) clearTimeout(timer);
930
- const marked = document.querySelectorAll('[data-dcc-hidden], [data-dcc-scanned]');
931
- for (const el of marked) {
932
- el.removeAttribute('data-dcc-hidden');
933
- el.removeAttribute('data-dcc-scanned');
934
- }
910
+ const marked = document.querySelectorAll('[data-dcc-hidden]');
911
+ for (const el of marked) el.removeAttribute('data-dcc-hidden');
912
+ };
913
+ }
914
+
915
+ /**
916
+ * 「移除工作区与会话悬停提示」不能只把卡片藏起来:
917
+ * 宿主仍在监听「进入行」这件事,800ms 后照样渲染卡片内容、做 fixed 定位,
918
+ * 卡顿正是从这里来的。这里在捕获阶段截住「从行外进入行」的那一次 pointerover,
919
+ * React 收不到事件,卡片根本不会打开。
920
+ * 行内元素之间的移动照常放行,所以按钮的 Tooltip 不受影响。
921
+ */
922
+ function installHoverCardBlocker() {
923
+ const ROW = '[class*="_sessionRow"], [class*="_projectRow"], [class*="_searchResultRow"]';
924
+
925
+ const onOver = (event) => {
926
+ if (document.documentElement.dataset.dccHover !== 'off') return;
927
+ const target = event.target;
928
+ if (!(target instanceof Element)) return;
929
+ const row = target.closest(ROW);
930
+ if (row === null) return;
931
+ /* 已经在行内移动,不是「进入」,放行给宿主 */
932
+ const related = event.relatedTarget;
933
+ if (related instanceof Node && row.contains(related)) return;
934
+ event.stopPropagation();
935
935
  };
936
+
937
+ /* 放在 window 捕获阶段:这是事件流最早的位置,先于 React 挂在 root 容器上的
938
+ onPointerOverCapture,才能保证宿主那一层完全收不到「进入行」这件事。 */
939
+ window.addEventListener('pointerover', onOver, true);
940
+ return () => window.removeEventListener('pointerover', onOver, true);
936
941
  }
937
942
 
938
943
  function Switch(props) {
@@ -980,7 +985,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
980
985
  }),
981
986
  h(Row, {
982
987
  title: zh ? 'Windows 默认微软雅黑字体' : 'Microsoft YaHei on Windows',
983
- desc: zh ? '将 Windows 端默认字体改为微软雅黑,使文字在低分辨率屏幕 200% 以下缩放带有 hinting,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响。' : 'Use Microsoft YaHei as the default Windows font so text keeps hinting — and stays sharp — at display scaling below 200%. Has no effect if you set a font manually, or on macOS.',
988
+ desc: zh ? '将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。若手动设置了字体,或使用 macOS 端,则不受影响。' : 'Use Microsoft YaHei as the default Windows font. It carries hinting, which keeps text sharp below 200% display scaling. Has no effect if you set a font manually, or on macOS.',
984
989
  checked: prefs.winFont,
985
990
  onChange: update('winFont'),
986
991
  })),
@@ -1068,12 +1073,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1068
1073
  const removeNavToggle = installNavToggle();
1069
1074
  const removeSettingsBack = installSettingsBackButton();
1070
1075
  const removeRowActionFilter = installRowActionFilter();
1076
+ const removeHoverCardBlocker = installHoverCardBlocker();
1071
1077
  return () => {
1072
1078
  removeCss();
1073
1079
  removeNewSessionRow();
1074
1080
  removeNavToggle();
1075
1081
  removeSettingsBack();
1076
1082
  removeRowActionFilter();
1083
+ removeHoverCardBlocker();
1077
1084
  const root = document.documentElement;
1078
1085
  delete root.dataset.dccRadius;
1079
1086
  delete root.dataset.dccNew;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ui-alt",
3
- "version": "0.2.13",
3
+ "version": "0.2.17",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "在保持原版 UI 大风格不变的情况下,进行减小圆角、紧凑化、秩序化、整洁化改进。使 UI 视觉更加冷静、专业、高效。多数改动可在设置中单独开关。",