dsh-ui-alt 0.2.437 → 0.2.445

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 +175 -11
  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,7 +6,7 @@ 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';
9
+ const VERSION = '0.2.445';
10
10
  const UPDATED = '2026-11-19';
11
11
  const DEFAULTS = {
12
12
  radiusDensity: true,
@@ -225,6 +225,8 @@ body[data-ds-dark-theme] .dcc-boot-cover {
225
225
  font-size: 13px;
226
226
  line-height: 20px;
227
227
  color: var(--dsw-alias-label-secondary);
228
+ /* 文案里用 \n 分段,需要它才真的换行 */
229
+ white-space: pre-line;
228
230
  }
229
231
  .dcc-modal-actions {
230
232
  display: flex;
@@ -244,6 +246,16 @@ body[data-ds-dark-theme] .dcc-boot-cover {
244
246
  cursor: pointer;
245
247
  }
246
248
  .dcc-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
249
+ /* 主操作:实底强调色,和宿主的主按钮一致 */
250
+ .dcc-modal-cta {
251
+ border-color: transparent;
252
+ background: var(--dsw-alias-label-primary);
253
+ color: var(--dsw-alias-label-primary-foreground);
254
+ }
255
+ .dcc-modal-cta:hover {
256
+ background: var(--dsw-alias-label-primary);
257
+ opacity: .88;
258
+ }
247
259
  /* 破坏性操作:常态无底色、文字红;悬停补一层淡红 */
248
260
  .dcc-modal-primary {
249
261
  border-color: transparent;
@@ -640,11 +652,29 @@ html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
640
652
  display: none !important;
641
653
  }
642
654
 
643
- /* 快照里的遮罩不要重播淡入——它是退场快照的一部分,
644
- 应该跟着外层一起淡出,否则看起来遮罩一直不消失。 */
645
- /* 特异性必须压过下面那条入场规则,否则快照里的遮罩会重播淡入、闪出白底。
646
- 不要改它的定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
647
- html[data-dcc-transition="on"] [data-dcc-dialog-clone] [class*="_mask"] {
655
+ /* 快照里的遮罩:
656
+ ① 不要重播淡入——它是退场快照的一部分,应该跟着外层一起淡出。
657
+ 特异性必须压过下面那条入场规则,否则会重播淡入、闪出白底。
658
+ ② 去掉 backdrop-filter。宿主遮罩靠它做模糊,但带 backdrop-filter 的元素
659
+ 在父级播 opacity 动画时,合成层会重新分配,中间闪一帧——
660
+ 退场那 200ms 看起来就是「暗层闪了一下」。
661
+ 快照本来就在整体淡出,模糊没有意义,去掉最干净。
662
+ ③ 伪元素也要停。宿主的 Modal(退出登录、额度提示这些都用它)把压暗层
663
+ 画在遮罩的 ::after 上:
664
+ ._mask_xxx { backdrop-filter: ... }
665
+ ._mask_xxx::after { background: var(--dsw-alias-bg-mask-1);
666
+ animation: _modalEnter ... }
667
+ 只停遮罩本体的 animation,::after 仍会在克隆重新入树时从 0 重播淡入,
668
+ 叠加到外层的 dcc-fade-out 上,就是「渐隐到一半又变暗,然后再消失」。
669
+ 克隆只是 200ms 的退场快照,伪元素保持静止、跟着整层一起淡出即可。
670
+ 不要改定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
671
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"] {
672
+ animation: none !important;
673
+ -webkit-backdrop-filter: none !important;
674
+ backdrop-filter: none !important;
675
+ }
676
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::before,
677
+ html[data-dcc-transition="on"] [data-dcc-dialog-clone][data-dcc-dialog-clone] [class*="_mask"]::after {
648
678
  animation: none !important;
649
679
  }
650
680
 
@@ -1078,6 +1108,7 @@ html[data-dcc-enabled="on"] [data-dsh-boot] [data-dcc-hint-fish] {
1078
1108
  flex: none;
1079
1109
  }
1080
1110
 
1111
+
1081
1112
  /* 追加到宿主菜单末尾的「重载前端界面」:外观对齐宿主自己的菜单项,
1082
1113
  高度、内边距、字号都按它的规格来。 */
1083
1114
  .dcc-menu-extra {
@@ -1471,14 +1502,22 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
1471
1502
  if (wrapper !== null) wrapper.remove();
1472
1503
  if (clone !== null) clone.remove();
1473
1504
 
1474
- /* 外层:完整照抄宿主导航项外层的类。
1475
- 之前排除了 panelEntryActive(怕常亮)和 panelEntryWide(以为没用),
1476
- 结果是布局对不上——panelEntryWide 决定了行的宽度和右侧留白,
1477
- 少了它整行都错位。active 类只在别处加,克隆时本来就不会有。 */
1505
+ /* 外层:照抄宿主导航项外层的类。
1506
+ panelEntryWide 必须带上——它决定行的宽度和右侧留白,少了整行错位。
1507
+
1508
+ 但 panelEntryActive 要排除:那是「当前页面」的标记,
1509
+ 取决于克隆时停在哪个页面。如果当时停在插件页,
1510
+ 「插件」那一行带这个类,抄过来会让新会话行常亮
1511
+ (.panelEntryActive 的 background-color 是 interactive-bg-hover)。
1512
+ 这个 bug 只在「插件页是新会话行创建时的当前页」时出现,
1513
+ 所以看起来像随机发作。 */
1478
1514
  const entry = row.parentElement;
1479
1515
  wrapper = document.createElement('div');
1480
1516
  if (entry !== null) {
1481
- for (const name of entry.classList) wrapper.classList.add(name);
1517
+ for (const name of entry.classList) {
1518
+ if (name.includes('_panelEntryActive')) continue;
1519
+ wrapper.classList.add(name);
1520
+ }
1482
1521
  }
1483
1522
  wrapper.setAttribute('data-dcc-newrow-wrap', '');
1484
1523
 
@@ -2127,6 +2166,129 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
2127
2166
  };
2128
2167
  }
2129
2168
 
2169
+ /**
2170
+ * 安装/更新/降级后的重载提示。
2171
+ *
2172
+ * 插件是运行期动态注入的,有些宿主元素在注入那一刻还没渲染出来,
2173
+ * 少数依赖它们的模块(视图切换控件、新会话行克隆)可能来不及建立。
2174
+ * 重新载入一次就都正常了。
2175
+ *
2176
+ * 判定用 localStorage 里的版本标记:
2177
+ * 标记缺失 → 首次安装
2178
+ * 标记不等于当前 → 升级或降级
2179
+ * 两种情况都提示;标记相同则不打扰。
2180
+ *
2181
+ * 不自动刷新——那会在用户正用着的时候把页面抽走。
2182
+ * 弹一个对话框,把决定权交回给用户。
2183
+ */
2184
+ function installFirstRunNotice() {
2185
+ const KEY = 'dsh-ui-alt:installed';
2186
+ let last = null;
2187
+ try {
2188
+ last = localStorage.getItem(KEY);
2189
+ localStorage.setItem(KEY, VERSION);
2190
+ } catch {
2191
+ /* 存储不可用时不提示,也不影响其它功能 */
2192
+ return () => {};
2193
+ }
2194
+ if (last === VERSION) return () => {};
2195
+
2196
+ let modal = null;
2197
+ let timer = 0;
2198
+
2199
+ /* 界面是否真的画出来了。启动遮罩和这个弹窗都靠它判断——
2200
+ 遮罩还没收走(宿主的加载页还在)时弹窗会浮在一片空黑上,
2201
+ 看不到被压暗的界面,观感像「背景是纯黑」。 */
2202
+ const ready = () => {
2203
+ const sidebar = document.querySelector('[class*="_root"]:has(nav[class*="_panelList"])');
2204
+ if (sidebar === null) return false;
2205
+ const rect = sidebar.getBoundingClientRect();
2206
+ return rect.width > 100 && rect.height > 100;
2207
+ };
2208
+
2209
+ /* 轮询等待界面就绪,最多等 20 秒;超时也弹,总比一直不提示好 */
2210
+ let waited = 0;
2211
+ const waitReady = () => {
2212
+ timer = 0;
2213
+ if (modal !== null) return;
2214
+ if (ready() || waited >= 20000) { show(); return; }
2215
+ waited += 200;
2216
+ timer = window.setTimeout(waitReady, 200);
2217
+ };
2218
+ timer = window.setTimeout(waitReady, 1000);
2219
+
2220
+ const close = () => {
2221
+ if (modal !== null) { modal.remove(); modal = null; }
2222
+ document.removeEventListener('keydown', onKey, true);
2223
+ };
2224
+
2225
+ const onKey = (event) => {
2226
+ if (event.key === 'Escape') close();
2227
+ };
2228
+
2229
+ function show() {
2230
+ timer = 0;
2231
+ if (modal !== null) return;
2232
+
2233
+ modal = document.createElement('div');
2234
+ modal.className = 'dcc-modal';
2235
+ modal.setAttribute('role', 'dialog');
2236
+ modal.setAttribute('aria-modal', 'true');
2237
+ modal.setAttribute('aria-label', isZh() ? 'UI 改进' : 'UI improvements');
2238
+
2239
+ const mask = document.createElement('div');
2240
+ mask.className = 'dcc-modal-mask';
2241
+
2242
+ const card = document.createElement('div');
2243
+ card.className = 'dcc-modal-card';
2244
+
2245
+ const content = document.createElement('div');
2246
+ content.className = 'dcc-modal-content';
2247
+
2248
+ const title = document.createElement('div');
2249
+ title.className = 'dcc-modal-title';
2250
+ title.textContent = isZh() ? 'UI 改进' : 'UI improvements';
2251
+
2252
+ const body = document.createElement('div');
2253
+ body.className = 'dcc-modal-body';
2254
+ body.textContent = isZh()
2255
+ ? '安装/更新完成。需要重新载入一次前端界面,确保功能正常生效。\n此操作不会影响运行中的任务。'
2256
+ : 'Installed/updated. Reload the frontend once so every feature takes effect.\nRunning tasks are not affected.';
2257
+
2258
+ content.append(title, body);
2259
+
2260
+ const actions = document.createElement('div');
2261
+ actions.className = 'dcc-modal-actions';
2262
+
2263
+ const later = document.createElement('button');
2264
+ later.type = 'button';
2265
+ later.className = 'dcc-modal-btn';
2266
+ later.textContent = isZh() ? '稍后自行重启' : 'Restart later';
2267
+ later.addEventListener('click', close);
2268
+
2269
+ const reload = document.createElement('button');
2270
+ reload.type = 'button';
2271
+ reload.className = 'dcc-modal-btn dcc-modal-cta';
2272
+ reload.textContent = isZh() ? '立即重载' : 'Reload now';
2273
+ reload.addEventListener('click', () => {
2274
+ window.location.reload();
2275
+ });
2276
+
2277
+ actions.append(later, reload);
2278
+ card.append(content, actions);
2279
+ modal.append(mask, card);
2280
+ document.body.appendChild(modal);
2281
+ /* Esc 关闭:用捕获阶段,先于宿主自己的 Esc 处理 */
2282
+ document.addEventListener('keydown', onKey, true);
2283
+ reload.focus();
2284
+ }
2285
+
2286
+ return () => {
2287
+ if (timer !== 0) window.clearTimeout(timer);
2288
+ close();
2289
+ };
2290
+ }
2291
+
2130
2292
  /**
2131
2293
  * 宿主加载页(开机时的 "Loading plugins…" 那一屏)的外观适配。
2132
2294
  *
@@ -3170,6 +3332,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
3170
3332
  const removeReloadItem = installReloadMenuItem();
3171
3333
  const removeHistoryHint = installHistoryHint();
3172
3334
  const removeBootHint = installBootHint();
3335
+ const removeFirstRun = installFirstRunNotice();
3173
3336
  const removeDialogExit = installDialogExit();
3174
3337
  return () => {
3175
3338
  removeCss();
@@ -3184,6 +3347,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
3184
3347
  removeReloadItem();
3185
3348
  removeHistoryHint();
3186
3349
  removeBootHint();
3350
+ removeFirstRun();
3187
3351
  removeDialogExit();
3188
3352
  const root = document.documentElement;
3189
3353
  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.445",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。",