dsh-ui-alt 0.2.401 → 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 +3 -1
- package/client.js +92 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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()`:设置面板左上角插入返回按钮,点击触发原关闭按钮。
|
|
@@ -141,6 +141,8 @@ dsh-ui-alt/
|
|
|
141
141
|
- `installDialogExit()`:接管对话框移除,补一段退场动画。
|
|
142
142
|
- `installBootCover()`:启动时的过渡遮罩。
|
|
143
143
|
- `installReloadMenuItem()`:在标题栏三点菜单末尾追加「重载前端界面」项。
|
|
144
|
+
- `installHistoryHint()`:会话切换时把「载入历史」提示移到正文中心,并在文字上方加鲸鱼图标。
|
|
145
|
+
- `installBootHint()`:宿主加载页适配——提示文字居中、隐藏品牌字样与旋转圈。
|
|
144
146
|
- 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
|
|
145
147
|
|
|
146
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,
|
|
@@ -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
|
/* 侧栏滚动下放:整块滚动容器不再滚动,改成纵向布局;
|
|
@@ -928,7 +922,9 @@ html[data-dcc-enabled="on"][data-dcc-header-fade="on"]:has([data-conversation-ta
|
|
|
928
922
|
/* 宿主自带的「更多」按钮:只在紧凑化开启时隐藏——那时标签行被本插件的
|
|
929
923
|
下拉按钮取代,宿主这个按钮用不上。紧凑化关闭时标签行是原版的,
|
|
930
924
|
这个按钮必须留着,否则视图被裁掉后无法访问。 */
|
|
931
|
-
|
|
925
|
+
/* 限定在会话标题栏内:_viewsMoreAnchor 是宿主标签行专用的类,
|
|
926
|
+
但同一套渲染也可能被别处复用,加上 :has 限定确保只作用于有标签行的标题栏。 */
|
|
927
|
+
html[data-dcc-enabled="on"][data-dcc-compact-header="on"] [class*="_header"]:has([data-conversation-tabs]) [class*="_viewsMoreAnchor"] {
|
|
932
928
|
display: none !important;
|
|
933
929
|
}
|
|
934
930
|
/* 开关关掉时,自绘的分段控件不出现,标签行恢复原样 */
|
|
@@ -973,7 +969,9 @@ html[data-dcc-always-show="on"] .dcc-segmented {
|
|
|
973
969
|
color: var(--dsw-alias-label-secondary);
|
|
974
970
|
font: inherit;
|
|
975
971
|
font-size: 12px;
|
|
976
|
-
|
|
972
|
+
/* 行高不能是 1:中文字体的下方部分会超出行盒,被 label 的
|
|
973
|
+
overflow: hidden 裁掉一截。留一点余量。 */
|
|
974
|
+
line-height: 1.35;
|
|
977
975
|
white-space: nowrap;
|
|
978
976
|
cursor: pointer;
|
|
979
977
|
transition: background-color .12s, color .12s;
|
|
@@ -1488,6 +1486,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1488
1486
|
const findNav = () => document.querySelector('nav[class*="_panelList"]');
|
|
1489
1487
|
const findOriginal = () => document.querySelector('button[class*="_newSession"]');
|
|
1490
1488
|
let clone = null;
|
|
1489
|
+
/* 宿主的导航项是两层:外层 _panelEntry 负责悬停底色和圆角,
|
|
1490
|
+
内层 _panelRow 是按钮本体。克隆必须保持同样的层级,
|
|
1491
|
+
把两层的类压在同一个元素上市,悬停底色会画错位置。 */
|
|
1492
|
+
let wrapper = null;
|
|
1491
1493
|
let observer = null;
|
|
1492
1494
|
let timer = null;
|
|
1493
1495
|
let rafId = 0;
|
|
@@ -1495,38 +1497,59 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1495
1497
|
const build = (nav, orig) => {
|
|
1496
1498
|
const row = nav.querySelector('button[class*="_panelRow"]');
|
|
1497
1499
|
if (row === null) return false;
|
|
1500
|
+
if (wrapper !== null) wrapper.remove();
|
|
1498
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
|
+
/* 内层:完整照抄按钮本体的类 */
|
|
1499
1515
|
clone = document.createElement('button');
|
|
1500
1516
|
clone.type = 'button';
|
|
1501
1517
|
clone.setAttribute('data-dcc-newrow', '');
|
|
1502
|
-
|
|
1503
|
-
克隆行是裸 button,少了这层包裹,悬停就会比别的导航行浅一档,
|
|
1504
|
-
所以把父级的 panelEntry 类一并复制过来。 */
|
|
1505
|
-
const entry = row.parentElement;
|
|
1506
|
-
const entryClasses = entry === null
|
|
1507
|
-
? []
|
|
1508
|
-
: [...entry.classList].filter((name) => name.includes('_panelEntry'));
|
|
1509
|
-
clone.className = [...row.classList].join(' ')
|
|
1510
|
-
+ ' dcc-newrow'
|
|
1511
|
-
+ (entryClasses.length > 0 ? ' ' + entryClasses.join(' ') : '');
|
|
1518
|
+
clone.className = [...row.classList].join(' ') + ' dcc-newrow';
|
|
1512
1519
|
const aria = orig.getAttribute('aria-label');
|
|
1513
1520
|
if (aria !== null) clone.setAttribute('aria-label', aria);
|
|
1514
|
-
|
|
1515
|
-
content.className = 'dcc-newrow-content';
|
|
1521
|
+
/* 图标包裹层:完整照抄 panelGlyph 的类,尺寸和居中都在它身上 */
|
|
1516
1522
|
const icon = orig.querySelector('svg');
|
|
1517
|
-
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 类——字号、颜色、溢出省略都在它身上 */
|
|
1518
1537
|
const label = document.createElement('span');
|
|
1519
|
-
|
|
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';
|
|
1520
1543
|
const text = orig.querySelector('[class*="_newSessionLabel"]');
|
|
1521
1544
|
label.textContent = text !== null && text.textContent !== '' ? text.textContent : (isZh() ? '新会话' : 'New session');
|
|
1522
|
-
|
|
1523
|
-
clone.appendChild(content);
|
|
1545
|
+
clone.appendChild(label);
|
|
1524
1546
|
clone.addEventListener('click', (event) => {
|
|
1525
1547
|
event.preventDefault();
|
|
1526
1548
|
const current = findOriginal();
|
|
1527
1549
|
if (current !== null) current.click();
|
|
1528
1550
|
});
|
|
1529
|
-
|
|
1551
|
+
wrapper.appendChild(clone);
|
|
1552
|
+
nav.insertBefore(wrapper, nav.firstElementChild);
|
|
1530
1553
|
return true;
|
|
1531
1554
|
};
|
|
1532
1555
|
|
|
@@ -1537,6 +1560,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1537
1560
|
/* 开关关掉时彻底还原:移除克隆行、去掉原按钮上的标记,
|
|
1538
1561
|
让它回到宿主本来的样子,而不是仅靠 CSS 隐藏 */
|
|
1539
1562
|
if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccNew !== 'on') {
|
|
1563
|
+
if (wrapper !== null) {
|
|
1564
|
+
wrapper.remove();
|
|
1565
|
+
wrapper = null;
|
|
1566
|
+
}
|
|
1540
1567
|
if (clone !== null) {
|
|
1541
1568
|
clone.remove();
|
|
1542
1569
|
clone = null;
|
|
@@ -1545,8 +1572,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1545
1572
|
return false;
|
|
1546
1573
|
}
|
|
1547
1574
|
if (orig.getAttribute('data-dcc-original') === null) orig.setAttribute('data-dcc-original', '');
|
|
1548
|
-
if (clone === null || !
|
|
1549
|
-
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);
|
|
1550
1577
|
/* 宿主文字(语言切换等)变化时,克隆行跟着更新 */
|
|
1551
1578
|
const label = clone.querySelector('.dcc-newrow-label');
|
|
1552
1579
|
const text = orig.querySelector('[class*="_newSessionLabel"]');
|
|
@@ -1589,6 +1616,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1589
1616
|
window.removeEventListener('dcc-newsession-pref', onPref);
|
|
1590
1617
|
if (timer !== null) clearTimeout(timer);
|
|
1591
1618
|
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
1619
|
+
if (wrapper !== null) wrapper.remove();
|
|
1592
1620
|
if (clone !== null) clone.remove();
|
|
1593
1621
|
const orig = findOriginal();
|
|
1594
1622
|
if (orig !== null) orig.removeAttribute('data-dcc-original');
|
|
@@ -1931,6 +1959,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1931
1959
|
let bar = null;
|
|
1932
1960
|
let observer = null;
|
|
1933
1961
|
let timer = null;
|
|
1962
|
+
let prefTimer = null;
|
|
1963
|
+
let rafId = 0;
|
|
1934
1964
|
/* 正在淡出的旧控件被临时挂到 body 上,卸载时要一起收走 */
|
|
1935
1965
|
const ghosts = new Set();
|
|
1936
1966
|
|
|
@@ -2191,7 +2221,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2191
2221
|
if (!event.detail) return;
|
|
2192
2222
|
const key = event.detail.key;
|
|
2193
2223
|
if (key !== 'compactHeader' && key !== 'compactHeaderFull') return;
|
|
2194
|
-
|
|
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);
|
|
2195
2232
|
};
|
|
2196
2233
|
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
2197
2234
|
|
|
@@ -2199,6 +2236,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
2199
2236
|
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
2200
2237
|
observer.disconnect();
|
|
2201
2238
|
if (timer !== null) clearTimeout(timer);
|
|
2239
|
+
if (prefTimer !== null) clearTimeout(prefTimer);
|
|
2240
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2202
2241
|
closeSegMenu();
|
|
2203
2242
|
if (bar !== null) bar.remove();
|
|
2204
2243
|
for (const ghost of ghosts) ghost.remove();
|