dsh-ui-alt 0.2.437 → 0.2.446

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 +2 -1
  2. package/client.js +186 -14
  3. 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
- - 十二个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
132
+ - 十三个 DOM 注入函数,各自带总开关守卫;需要跟随宿主重渲染的还带一个监听 `body` 的 `MutationObserver`(350–400ms 防抖):
133
133
  - `installNewSessionRow()`:克隆宿主的「新会话」按钮成导航行,点击转发给原按钮。
134
134
  - `installNavToggle()`:导航下方插入展开/收起箭头,点击切换 `data-dcc-nav` 并写回偏好。
135
135
  - `installViewSwitcher()`:把视图标签行换成一个下拉按钮,展开后列出全部视图。
@@ -142,6 +142,7 @@ dsh-ui-alt/
142
142
  - `installReloadMenuItem()`:在标题栏三点菜单末尾追加「重载前端界面」项。
143
143
  - `installHistoryHint()`:会话切换时把「载入历史」提示移到正文中心,并在文字上方加鲸鱼图标。
144
144
  - `installBootHint()`:宿主加载页适配——提示文字居中、隐藏品牌字样与旋转圈。
145
+ - `installFirstRunNotice()`:首次安装后弹出一条提示,告知重启一次前端界面可确保功能完整生效。
145
146
  - 设置页组件:`Section`(标题 + 说明 + 开关行)、`Switch`、`Row`、`SectionIcon`。
146
147
 
147
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.437';
10
- const UPDATED = '2026-11-19';
9
+ const VERSION = '0.2.446';
10
+ const UPDATED = '2026-11-23';
11
11
  const DEFAULTS = {
12
12
  radiusDensity: true,
13
13
  invertNewSession: true,
@@ -209,8 +209,12 @@ body[data-ds-dark-theme] .dcc-boot-cover {
209
209
  border-radius: var(--dsw-radius-lg, 12px);
210
210
  background: var(--dsw-alias-bg-layer-1);
211
211
  box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
212
+ /* 入场动画跟「为菜单和窗口添加动画」开关走:关掉时直接出现 */
212
213
  animation: dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
213
214
  }
215
+ html[data-dcc-transition="off"] .dcc-modal-card {
216
+ animation: none !important;
217
+ }
214
218
  .dcc-modal-content {
215
219
  padding: 18px 20px 4px;
216
220
  }
@@ -225,6 +229,8 @@ body[data-ds-dark-theme] .dcc-boot-cover {
225
229
  font-size: 13px;
226
230
  line-height: 20px;
227
231
  color: var(--dsw-alias-label-secondary);
232
+ /* 文案里用 \n 分段,需要它才真的换行 */
233
+ white-space: pre-line;
228
234
  }
229
235
  .dcc-modal-actions {
230
236
  display: flex;
@@ -244,6 +250,16 @@ body[data-ds-dark-theme] .dcc-boot-cover {
244
250
  cursor: pointer;
245
251
  }
246
252
  .dcc-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
253
+ /* 主操作:实底强调色,和宿主的主按钮一致 */
254
+ .dcc-modal-cta {
255
+ border-color: transparent;
256
+ background: var(--dsw-alias-label-primary);
257
+ color: var(--dsw-alias-label-primary-foreground);
258
+ }
259
+ .dcc-modal-cta:hover {
260
+ background: var(--dsw-alias-label-primary);
261
+ opacity: .88;
262
+ }
247
263
  /* 破坏性操作:常态无底色、文字红;悬停补一层淡红 */
248
264
  .dcc-modal-primary {
249
265
  border-color: transparent;
@@ -640,11 +656,29 @@ html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
640
656
  display: none !important;
641
657
  }
642
658
 
643
- /* 快照里的遮罩不要重播淡入——它是退场快照的一部分,
644
- 应该跟着外层一起淡出,否则看起来遮罩一直不消失。 */
645
- /* 特异性必须压过下面那条入场规则,否则快照里的遮罩会重播淡入、闪出白底。
646
- 不要改它的定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
647
- html[data-dcc-transition="on"] [data-dcc-dialog-clone] [class*="_mask"] {
659
+ /* 快照里的遮罩:
660
+ ① 不要重播淡入——它是退场快照的一部分,应该跟着外层一起淡出。
661
+ 特异性必须压过下面那条入场规则,否则会重播淡入、闪出白底。
662
+ ② 去掉 backdrop-filter。宿主遮罩靠它做模糊,但带 backdrop-filter 的元素
663
+ 在父级播 opacity 动画时,合成层会重新分配,中间闪一帧——
664
+ 退场那 200ms 看起来就是「暗层闪了一下」。
665
+ 快照本来就在整体淡出,模糊没有意义,去掉最干净。
666
+ ③ 伪元素也要停。宿主的 Modal(退出登录、额度提示这些都用它)把压暗层
667
+ 画在遮罩的 ::after 上:
668
+ ._mask_xxx { backdrop-filter: ... }
669
+ ._mask_xxx::after { background: var(--dsw-alias-bg-mask-1);
670
+ animation: _modalEnter ... }
671
+ 只停遮罩本体的 animation,::after 仍会在克隆重新入树时从 0 重播淡入,
672
+ 叠加到外层的 dcc-fade-out 上,就是「渐隐到一半又变暗,然后再消失」。
673
+ 克隆只是 200ms 的退场快照,伪元素保持静止、跟着整层一起淡出即可。
674
+ 不要改定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
675
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"] {
676
+ animation: none !important;
677
+ -webkit-backdrop-filter: none !important;
678
+ backdrop-filter: none !important;
679
+ }
680
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::before,
681
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::after {
648
682
  animation: none !important;
649
683
  }
650
684
 
@@ -1078,6 +1112,7 @@ html[data-dcc-enabled="on"] [data-dsh-boot] [data-dcc-hint-fish] {
1078
1112
  flex: none;
1079
1113
  }
1080
1114
 
1115
+
1081
1116
  /* 追加到宿主菜单末尾的「重载前端界面」:外观对齐宿主自己的菜单项,
1082
1117
  高度、内边距、字号都按它的规格来。 */
1083
1118
  .dcc-menu-extra {
@@ -1471,14 +1506,22 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1471
1506
  if (wrapper !== null) wrapper.remove();
1472
1507
  if (clone !== null) clone.remove();
1473
1508
 
1474
- /* 外层:完整照抄宿主导航项外层的类。
1475
- 之前排除了 panelEntryActive(怕常亮)和 panelEntryWide(以为没用),
1476
- 结果是布局对不上——panelEntryWide 决定了行的宽度和右侧留白,
1477
- 少了它整行都错位。active 类只在别处加,克隆时本来就不会有。 */
1509
+ /* 外层:照抄宿主导航项外层的类。
1510
+ panelEntryWide 必须带上——它决定行的宽度和右侧留白,少了整行错位。
1511
+
1512
+ 但 panelEntryActive 要排除:那是「当前页面」的标记,
1513
+ 取决于克隆时停在哪个页面。如果当时停在插件页,
1514
+ 「插件」那一行带这个类,抄过来会让新会话行常亮
1515
+ (.panelEntryActive 的 background-color 是 interactive-bg-hover)。
1516
+ 这个 bug 只在「插件页是新会话行创建时的当前页」时出现,
1517
+ 所以看起来像随机发作。 */
1478
1518
  const entry = row.parentElement;
1479
1519
  wrapper = document.createElement('div');
1480
1520
  if (entry !== null) {
1481
- for (const name of entry.classList) wrapper.classList.add(name);
1521
+ for (const name of entry.classList) {
1522
+ if (name.includes('_panelEntryActive')) continue;
1523
+ wrapper.classList.add(name);
1524
+ }
1482
1525
  }
1483
1526
  wrapper.setAttribute('data-dcc-newrow-wrap', '');
1484
1527
 
@@ -1912,8 +1955,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1912
1955
  menu.appendChild(entry);
1913
1956
  });
1914
1957
  document.body.appendChild(menu);
1915
- menu.style.transformOrigin = 'top right';
1916
- menu.style.animation = 'dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1))';
1958
+ /* 视图菜单属于「菜单」,跟「为菜单和窗口添加动画」这个开关走:
1959
+ 关掉时直接出现,不再缩放淡入。 */
1960
+ if (document.documentElement.dataset.dccTransition === 'on') {
1961
+ menu.style.transformOrigin = 'top right';
1962
+ menu.style.animation = 'dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1))';
1963
+ }
1917
1964
  segMenu = menu;
1918
1965
  segMenuAnchor = more;
1919
1966
  more.setAttribute('data-open', 'true');
@@ -2127,6 +2174,129 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2127
2174
  };
2128
2175
  }
2129
2176
 
2177
+ /**
2178
+ * 安装/更新/降级后的重载提示。
2179
+ *
2180
+ * 插件是运行期动态注入的,有些宿主元素在注入那一刻还没渲染出来,
2181
+ * 少数依赖它们的模块(视图切换控件、新会话行克隆)可能来不及建立。
2182
+ * 重新载入一次就都正常了。
2183
+ *
2184
+ * 判定用 localStorage 里的版本标记:
2185
+ * 标记缺失 → 首次安装
2186
+ * 标记不等于当前 → 升级或降级
2187
+ * 两种情况都提示;标记相同则不打扰。
2188
+ *
2189
+ * 不自动刷新——那会在用户正用着的时候把页面抽走。
2190
+ * 弹一个对话框,把决定权交回给用户。
2191
+ */
2192
+ function installFirstRunNotice() {
2193
+ const KEY = 'dsh-ui-alt:installed';
2194
+ let last = null;
2195
+ try {
2196
+ last = localStorage.getItem(KEY);
2197
+ localStorage.setItem(KEY, VERSION);
2198
+ } catch {
2199
+ /* 存储不可用时不提示,也不影响其它功能 */
2200
+ return () => {};
2201
+ }
2202
+ if (last === VERSION) return () => {};
2203
+
2204
+ let modal = null;
2205
+ let timer = 0;
2206
+
2207
+ /* 界面是否真的画出来了。启动遮罩和这个弹窗都靠它判断——
2208
+ 遮罩还没收走(宿主的加载页还在)时弹窗会浮在一片空黑上,
2209
+ 看不到被压暗的界面,观感像「背景是纯黑」。 */
2210
+ const ready = () => {
2211
+ const sidebar = document.querySelector('[class*="_root"]:has(nav[class*="_panelList"])');
2212
+ if (sidebar === null) return false;
2213
+ const rect = sidebar.getBoundingClientRect();
2214
+ return rect.width > 100 && rect.height > 100;
2215
+ };
2216
+
2217
+ /* 轮询等待界面就绪,最多等 20 秒;超时也弹,总比一直不提示好 */
2218
+ let waited = 0;
2219
+ const waitReady = () => {
2220
+ timer = 0;
2221
+ if (modal !== null) return;
2222
+ if (ready() || waited >= 20000) { show(); return; }
2223
+ waited += 200;
2224
+ timer = window.setTimeout(waitReady, 200);
2225
+ };
2226
+ timer = window.setTimeout(waitReady, 1000);
2227
+
2228
+ const close = () => {
2229
+ if (modal !== null) { modal.remove(); modal = null; }
2230
+ document.removeEventListener('keydown', onKey, true);
2231
+ };
2232
+
2233
+ const onKey = (event) => {
2234
+ if (event.key === 'Escape') close();
2235
+ };
2236
+
2237
+ function show() {
2238
+ timer = 0;
2239
+ if (modal !== null) return;
2240
+
2241
+ modal = document.createElement('div');
2242
+ modal.className = 'dcc-modal';
2243
+ modal.setAttribute('role', 'dialog');
2244
+ modal.setAttribute('aria-modal', 'true');
2245
+ modal.setAttribute('aria-label', isZh() ? 'UI 改进' : 'UI improvements');
2246
+
2247
+ const mask = document.createElement('div');
2248
+ mask.className = 'dcc-modal-mask';
2249
+
2250
+ const card = document.createElement('div');
2251
+ card.className = 'dcc-modal-card';
2252
+
2253
+ const content = document.createElement('div');
2254
+ content.className = 'dcc-modal-content';
2255
+
2256
+ const title = document.createElement('div');
2257
+ title.className = 'dcc-modal-title';
2258
+ title.textContent = isZh() ? 'UI 改进' : 'UI improvements';
2259
+
2260
+ const body = document.createElement('div');
2261
+ body.className = 'dcc-modal-body';
2262
+ body.textContent = isZh()
2263
+ ? '安装/更新完成。需要重新载入一次前端界面,确保功能正常生效。\n此操作不会影响运行中的任务。'
2264
+ : 'Installed/updated. Reload the frontend once so every feature takes effect.\nRunning tasks are not affected.';
2265
+
2266
+ content.append(title, body);
2267
+
2268
+ const actions = document.createElement('div');
2269
+ actions.className = 'dcc-modal-actions';
2270
+
2271
+ const later = document.createElement('button');
2272
+ later.type = 'button';
2273
+ later.className = 'dcc-modal-btn';
2274
+ later.textContent = isZh() ? '稍后自行重启' : 'Restart later';
2275
+ later.addEventListener('click', close);
2276
+
2277
+ const reload = document.createElement('button');
2278
+ reload.type = 'button';
2279
+ reload.className = 'dcc-modal-btn dcc-modal-cta';
2280
+ reload.textContent = isZh() ? '立即重载' : 'Reload now';
2281
+ reload.addEventListener('click', () => {
2282
+ window.location.reload();
2283
+ });
2284
+
2285
+ actions.append(later, reload);
2286
+ card.append(content, actions);
2287
+ modal.append(mask, card);
2288
+ document.body.appendChild(modal);
2289
+ /* Esc 关闭:用捕获阶段,先于宿主自己的 Esc 处理 */
2290
+ document.addEventListener('keydown', onKey, true);
2291
+ reload.focus();
2292
+ }
2293
+
2294
+ return () => {
2295
+ if (timer !== 0) window.clearTimeout(timer);
2296
+ close();
2297
+ };
2298
+ }
2299
+
2130
2300
  /**
2131
2301
  * 宿主加载页(开机时的 "Loading plugins…" 那一屏)的外观适配。
2132
2302
  *
@@ -3170,6 +3340,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
3170
3340
  const removeReloadItem = installReloadMenuItem();
3171
3341
  const removeHistoryHint = installHistoryHint();
3172
3342
  const removeBootHint = installBootHint();
3343
+ const removeFirstRun = installFirstRunNotice();
3173
3344
  const removeDialogExit = installDialogExit();
3174
3345
  return () => {
3175
3346
  removeCss();
@@ -3184,6 +3355,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
3184
3355
  removeReloadItem();
3185
3356
  removeHistoryHint();
3186
3357
  removeBootHint();
3358
+ removeFirstRun();
3187
3359
  removeDialogExit();
3188
3360
  const root = document.documentElement;
3189
3361
  delete root.dataset.dccRadius;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-ui-alt",
3
- "version": "0.2.437",
3
+ "version": "0.2.446",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。",