dsh-ui-alt 0.2.17 → 0.2.87
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 +31 -3
- package/client.js +565 -8
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-ui-alt
|
|
2
2
|
|
|
3
|
-
在保持原版 UI
|
|
3
|
+
在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。
|
|
4
4
|
|
|
5
5
|
插件由 CSS 覆盖加少量 DOM 注入组成,所有改动都可以在 设置 →「UI 改进」里逐项开关;关掉开关即恢复原版外观。
|
|
6
6
|
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
|
|
18
18
|
| 开关 | 默认 | 效果 |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
-
|
|
|
20
|
+
| 减小圆角与间距 | 开 | 缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效 |
|
|
21
|
+
| 会话标题栏紧凑化 | 开 | 紧凑化会话标题栏,使会话内容可视范围更大 |
|
|
21
22
|
| 统一新会话按钮样式 | 开 | 新会话按钮样式改为与导航按钮一致 |
|
|
22
23
|
| 折叠侧栏导航功能 | 开 | 折叠侧栏导航,点击箭头展开收起 |
|
|
23
24
|
| 弱化工作区名称 | 开 | 工作区名称弱化,使工作区和会话更易区分 |
|
|
@@ -26,6 +27,22 @@
|
|
|
26
27
|
| 隐藏会话悬停多余按钮 | 开 | 悬停会话行时只保留菜单和置顶,其余按钮(含插件添加的)隐藏;若有插件按钮未在右键菜单中,可关闭 |
|
|
27
28
|
| 设置面板全屏 | 开 | 使用非窗口化的设置页面 |
|
|
28
29
|
|
|
30
|
+
**性能与用量信息**
|
|
31
|
+
|
|
32
|
+
| 开关 | 默认 | 效果 |
|
|
33
|
+
| --- | --- | --- |
|
|
34
|
+
| 优化布局 | 开 | 优化输入框下方性能与用量布局,将数据分布在左右两侧平衡视觉重心 |
|
|
35
|
+
| 显示余额 | 开 | 在输入框下方性能与用量中显示账户余额 |
|
|
36
|
+
| 余额警告阈值 | 3 | 余额低于此值将变为红色,最小为 0 |
|
|
37
|
+
| 余额小数位数 | 2 | 余额显示的小数位数 |
|
|
38
|
+
|
|
39
|
+
**规范化**
|
|
40
|
+
|
|
41
|
+
| 开关 | 默认 | 效果 |
|
|
42
|
+
| --- | --- | --- |
|
|
43
|
+
| 指针样式规范化 | 开 | 遵循桌面软件的指针样式规范,仅链接等跳转性元素会更改指针样式为「手形」 |
|
|
44
|
+
| 文本可选中限制 | 开 | 遵循桌面软件的规范,使 UI 界面元素的文本不可被选中;消息正文、会话标题与输入框仍可选中 |
|
|
45
|
+
|
|
29
46
|
另有一些不挂开关的固定样式:设置导航列宽 220px、归档会话标题画删除线、选择题选中项的序号反色高亮、浅色主题下选中会话背景加强、工作区行悬停时保持文件夹图标。
|
|
30
47
|
|
|
31
48
|
## 安装
|
|
@@ -55,6 +72,12 @@ plugin_manager install_bundle target=<本仓库绝对路径>
|
|
|
55
72
|
| `data-dcc-font` | `on` / `off` |
|
|
56
73
|
| `data-dcc-full` | `on` / `off` |
|
|
57
74
|
| `data-dcc-hover` | `on` / `off` |
|
|
75
|
+
| `data-dcc-row-buttons` | `on` / `off` |
|
|
76
|
+
| `data-dcc-compact-header` | `on` / `off` |
|
|
77
|
+
| `data-dcc-stats` | `on` / `off` |
|
|
78
|
+
| `data-dcc-balance` | `on` / `off` |
|
|
79
|
+
| `data-dcc-pointer` | `on` / `off` |
|
|
80
|
+
| `data-dcc-select` | `on` / `off` |
|
|
58
81
|
|
|
59
82
|
## 目录结构
|
|
60
83
|
|
|
@@ -110,7 +133,12 @@ plugin_manager install_bundle target=<本仓库绝对路径>
|
|
|
110
133
|
- 克隆出来的新会话行没有原按钮的 Tooltip 与快捷键提示(点击行为已转发,功能正常)。
|
|
111
134
|
- 设置返回按钮依赖宿主的 `_navTitle` / `_close` 类名。
|
|
112
135
|
- 「统一新会话按钮」关闭时,折叠导航的首位是隐藏的克隆行,计数偏移一项;显示效果正常。
|
|
113
|
-
-
|
|
136
|
+
- 侧栏悬停与滚动的开销主要来自宿主自身的样式重算(实测渲染占 60% 以上,脚本仅 4%),插件已在事件层拦掉了悬停卡片,但无法消除宿主这一层的成本。
|
|
137
|
+
- 余额取自宿主账户接口,未登录或接口不可用时该项不显示;余额每分钟刷新一次。
|
|
138
|
+
- 余额警告阈值只接受非负数值,负数或非法输入会被归零。
|
|
139
|
+
- 余额用伪元素渲染(这样余额刷新时不会闪),因此图标只能用 `background-image` 贴上去、颜色写死为中灰;低于阈值时也是整段变红,做不到只染数字。
|
|
140
|
+
- 「指针样式规范化」会把拖拽、缩放手柄的 `grab` / `resize` 光标一并压成箭头(拖拽功能本身不受影响)。
|
|
141
|
+
- 「文本可选中限制」依赖宿主的 `_action` / `_time` 等类名片段来排除操作栏;宿主若改名,可能需要补充排除项。
|
|
114
142
|
|
|
115
143
|
## License
|
|
116
144
|
|
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.
|
|
9
|
+
const VERSION = '0.2.87';
|
|
10
10
|
const UPDATED = '2026-11-11';
|
|
11
11
|
const DEFAULTS = {
|
|
12
12
|
radiusDensity: true,
|
|
@@ -19,6 +19,13 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
settingsFullscreen: true,
|
|
20
20
|
hideHoverCard: true,
|
|
21
21
|
hideRowButtons: true,
|
|
22
|
+
compactHeader: true,
|
|
23
|
+
optimizeStatsLayout: true,
|
|
24
|
+
showBalance: true,
|
|
25
|
+
balanceThreshold: 3,
|
|
26
|
+
balanceDecimals: 2,
|
|
27
|
+
pointerNormalize: true,
|
|
28
|
+
textSelectLimit: true,
|
|
22
29
|
};
|
|
23
30
|
|
|
24
31
|
const isZh = () => {
|
|
@@ -47,6 +54,11 @@ window.__ModuleLoader__.load({
|
|
|
47
54
|
root.dataset.dccFull = prefs.settingsFullscreen ? 'on' : 'off';
|
|
48
55
|
root.dataset.dccHover = prefs.hideHoverCard ? 'off' : 'on';
|
|
49
56
|
root.dataset.dccRowButtons = prefs.hideRowButtons ? 'on' : 'off';
|
|
57
|
+
root.dataset.dccCompactHeader = prefs.compactHeader ? 'on' : 'off';
|
|
58
|
+
root.dataset.dccStats = prefs.optimizeStatsLayout ? 'on' : 'off';
|
|
59
|
+
root.dataset.dccBalance = prefs.showBalance ? 'on' : 'off';
|
|
60
|
+
root.dataset.dccPointer = prefs.pointerNormalize ? 'on' : 'off';
|
|
61
|
+
root.dataset.dccSelect = prefs.textSelectLimit ? 'on' : 'off';
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
function savePrefs(prefs) {
|
|
@@ -147,9 +159,14 @@ html[data-dcc-radius="on"] [class*="_trailing"] > [class*="_primary"] svg {
|
|
|
147
159
|
width: 16px !important;
|
|
148
160
|
height: 16px !important;
|
|
149
161
|
}
|
|
150
|
-
/* 输入框左下角的「+」:宿主是 999px
|
|
162
|
+
/* 输入框左下角的「+」:宿主是 999px 圆形,同样收成小圆角方形;
|
|
163
|
+
底色也去掉,只在悬停时给出来(宿主的原始底色就是这一档)。 */
|
|
151
164
|
html[data-dcc-radius="on"] button[class*="_add"] {
|
|
152
165
|
border-radius: var(--dsw-radius-md) !important;
|
|
166
|
+
background: transparent !important;
|
|
167
|
+
}
|
|
168
|
+
html[data-dcc-radius="on"] button[class*="_add"]:hover {
|
|
169
|
+
background: var(--dsw-specific-selector) !important;
|
|
153
170
|
}
|
|
154
171
|
|
|
155
172
|
/* 主内容区左上角的大圆角(Windows 标题栏) */
|
|
@@ -414,6 +431,273 @@ html[data-dcc-row-buttons="on"] [class*="_sessionRow"] [class*="_rowActions"] bu
|
|
|
414
431
|
display: none !important;
|
|
415
432
|
}
|
|
416
433
|
|
|
434
|
+
/* ---------- 会话标题栏紧凑化:标签行并入顶部工具区 ---------- */
|
|
435
|
+
/* 注意不能 display:none:宿主按标签行的 clientWidth 计算「能显示几个视图」,
|
|
436
|
+
宽度变 0 会只剩一个「对话」。所以这里只把高度压到 0(不占布局),
|
|
437
|
+
宽度和可见性照旧,量出来的数量才是对的。 */
|
|
438
|
+
html[data-dcc-compact-header="on"] div:has(> [data-conversation-tabs]) {
|
|
439
|
+
height: 0 !important;
|
|
440
|
+
min-height: 0 !important;
|
|
441
|
+
max-height: 0 !important;
|
|
442
|
+
padding-top: 0 !important;
|
|
443
|
+
padding-bottom: 0 !important;
|
|
444
|
+
margin-top: 0 !important;
|
|
445
|
+
margin-bottom: 0 !important;
|
|
446
|
+
border: 0 !important;
|
|
447
|
+
overflow: hidden !important;
|
|
448
|
+
visibility: hidden;
|
|
449
|
+
pointer-events: none !important;
|
|
450
|
+
}
|
|
451
|
+
/* 标签行虽然高度归零,但它还在 DOM 里,宿主的 :has(._tabs) 依然成立,
|
|
452
|
+
标题栏会死守 min-height:76px。这里直接按「没有标签行」的形态压平。 */
|
|
453
|
+
html[data-dcc-compact-header="on"] [class*="_header"]:has([data-conversation-tabs]) {
|
|
454
|
+
min-height: 0 !important;
|
|
455
|
+
padding-bottom: 10px !important;
|
|
456
|
+
border-bottom: none !important;
|
|
457
|
+
}
|
|
458
|
+
/* 去掉硬分界线后,改用 mask 让内容顶部渐隐——滚动时文字淡入而不是被一条线切断。 */
|
|
459
|
+
html[data-dcc-compact-header="on"] [data-conversation-scroll] {
|
|
460
|
+
-webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
|
|
461
|
+
mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
|
|
462
|
+
}
|
|
463
|
+
html[data-dcc-compact-header="on"] [class*="_viewsMore"] {
|
|
464
|
+
display: none !important;
|
|
465
|
+
}
|
|
466
|
+
/* 开关关掉时,自绘的分段控件不出现,标签行恢复原样 */
|
|
467
|
+
html[data-dcc-compact-header="off"] .dcc-segmented {
|
|
468
|
+
display: none !important;
|
|
469
|
+
}
|
|
470
|
+
/* 分组按钮:与顶部官方按钮对齐——box-sizing 让 height 含边框,
|
|
471
|
+
圆角用 sm(8px) 而不是 md(12px),描边用更浅的 l1。 */
|
|
472
|
+
.dcc-segmented {
|
|
473
|
+
box-sizing: border-box;
|
|
474
|
+
display: inline-flex;
|
|
475
|
+
align-items: stretch;
|
|
476
|
+
height: 24px;
|
|
477
|
+
/* 宿主给 headerUtilities 的 gap 是 8px;我们这层带 0.5px 描边和圆角,
|
|
478
|
+
视觉上边界内缩、显得比别的元素远一点,补 2px 回来 */
|
|
479
|
+
margin-right: 2px;
|
|
480
|
+
padding: 0;
|
|
481
|
+
border: 0.5px solid var(--dsw-alias-border-l4);
|
|
482
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
483
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
484
|
+
overflow: hidden;
|
|
485
|
+
}
|
|
486
|
+
.dcc-seg {
|
|
487
|
+
display: inline-flex;
|
|
488
|
+
align-items: center;
|
|
489
|
+
border: 0;
|
|
490
|
+
background: transparent;
|
|
491
|
+
color: var(--dsw-alias-label-tertiary);
|
|
492
|
+
font: inherit;
|
|
493
|
+
font-size: 12px;
|
|
494
|
+
line-height: 1;
|
|
495
|
+
padding: 0 8px;
|
|
496
|
+
cursor: pointer;
|
|
497
|
+
transition: background-color .12s, color .12s;
|
|
498
|
+
}
|
|
499
|
+
.dcc-seg + .dcc-seg {
|
|
500
|
+
border-left: 0.5px solid var(--dsw-alias-border-l4);
|
|
501
|
+
}
|
|
502
|
+
.dcc-seg:hover:not([data-active="true"]) {
|
|
503
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
504
|
+
color: var(--dsw-alias-label-primary);
|
|
505
|
+
}
|
|
506
|
+
.dcc-seg[data-active="true"] {
|
|
507
|
+
background: transparent;
|
|
508
|
+
color: var(--dsw-alias-state-business-primary);
|
|
509
|
+
font-weight: 500;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/* ---------- 输入框下方状态行:速率/缓存靠左,上下文环推到最右 ---------- */
|
|
513
|
+
/* 宿主的 _dock 只有 280px 宽且居中,里面是两个子项:左边的胶囊组和包着环的
|
|
514
|
+
A6Bq1a_root。这里不撑满容器,而是套用聊天内容区的宽度变量并居中——
|
|
515
|
+
这样它会跟着「页面边距」一起走,不会顶到内容区外面。 */
|
|
516
|
+
html[data-dcc-stats="on"] [class*="_dock"]:has(button[aria-haspopup="dialog"]) {
|
|
517
|
+
box-sizing: border-box !important;
|
|
518
|
+
width: calc(var(--dsh-chat-content-width, 100%) + 24px) !important;
|
|
519
|
+
max-width: calc(var(--dsh-chat-content-width, 100%) + 24px) !important;
|
|
520
|
+
margin-inline: auto !important;
|
|
521
|
+
justify-content: flex-start !important;
|
|
522
|
+
}
|
|
523
|
+
/* 速率/缓存/余额成组留在左边,包着环的那个 root 吃掉剩余空间,被顶到最右 */
|
|
524
|
+
html[data-dcc-stats="on"] [class*="_dock"] > [class*="_root"]:has(button[aria-haspopup="dialog"]) {
|
|
525
|
+
margin-left: auto !important;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* 余额:用伪元素 + CSS 变量渲染,不往 React 的 DOM 里插任何节点。
|
|
529
|
+
旁边的速率/缓存是 React 自己渲染的,更新时只改文本;外挂节点会在
|
|
530
|
+
React 重排子节点时被摘掉,于是每次刷新都闪一下——伪元素没有这个问题。
|
|
531
|
+
注意统计项是「activity / usage 各占一个 anchor」,不是同组,
|
|
532
|
+
所以挂在「后面没有其他统计项」的那个上,也就是整排的最后一个。 */
|
|
533
|
+
html[data-dcc-balance="on"] [data-composer-stat]:not(:has(~ [data-composer-stat]))::after {
|
|
534
|
+
content: var(--dcc-balance-text, '');
|
|
535
|
+
display: inline-flex;
|
|
536
|
+
align-items: center;
|
|
537
|
+
align-self: center;
|
|
538
|
+
margin-left: 16px;
|
|
539
|
+
padding-left: 23px;
|
|
540
|
+
min-height: 16px;
|
|
541
|
+
font-size: 12px;
|
|
542
|
+
line-height: 16px;
|
|
543
|
+
color: var(--dsw-alias-label-tertiary);
|
|
544
|
+
white-space: nowrap;
|
|
545
|
+
/* 钱包图标用 background 贴上去:伪元素里塞不进 SVG 元素,
|
|
546
|
+
图标颜色只能写死(中灰),深浅主题下都能看 */
|
|
547
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238a8a8a' stroke-width='1'%3E%3Crect x='1.5' y='4' width='13' height='9' rx='2.5'/%3E%3Cpath d='M1.5 7.2h13'/%3E%3Ccircle cx='11.6' cy='9.8' r='0.9' fill='%238a8a8a' stroke='none'/%3E%3C/svg%3E");
|
|
548
|
+
background-repeat: no-repeat;
|
|
549
|
+
background-position: left center;
|
|
550
|
+
background-size: 16px 16px;
|
|
551
|
+
}
|
|
552
|
+
/* 低于阈值时整段变红 */
|
|
553
|
+
html[data-dcc-balance="on"][data-dcc-balance-low="on"] [data-composer-stat]:not(:has(~ [data-composer-stat]))::after {
|
|
554
|
+
color: var(--dsw-alias-state-error-primary);
|
|
555
|
+
}
|
|
556
|
+
/* 设置页的数值输入框 */
|
|
557
|
+
.dcc-number {
|
|
558
|
+
width: 72px;
|
|
559
|
+
flex: none;
|
|
560
|
+
padding: 4px 8px;
|
|
561
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
562
|
+
border-radius: var(--dsw-radius-sm, 4px);
|
|
563
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
564
|
+
color: var(--dsw-alias-label-primary);
|
|
565
|
+
font: inherit;
|
|
566
|
+
font-size: 13px;
|
|
567
|
+
text-align: right;
|
|
568
|
+
}
|
|
569
|
+
.dcc-number:focus {
|
|
570
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
571
|
+
outline-offset: 1px;
|
|
572
|
+
}
|
|
573
|
+
/* 设置页的下拉选择框 */
|
|
574
|
+
.dcc-select {
|
|
575
|
+
flex: none;
|
|
576
|
+
padding: 4px 6px;
|
|
577
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
578
|
+
border-radius: var(--dsw-radius-sm, 4px);
|
|
579
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
580
|
+
color: var(--dsw-alias-label-primary);
|
|
581
|
+
font: inherit;
|
|
582
|
+
font-size: 13px;
|
|
583
|
+
cursor: default;
|
|
584
|
+
}
|
|
585
|
+
.dcc-select:focus {
|
|
586
|
+
outline: 2px solid var(--dsw-alias-brand-primary);
|
|
587
|
+
outline-offset: 1px;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/* ---------- 指针样式规范化 ---------- */
|
|
591
|
+
/* 桌面软件的惯例:只有可跳转的东西才给手形。Web UI 常把「可点击」和「可跳转」
|
|
592
|
+
混为一谈,这里统一压回箭头,再单独放行链接和文本输入区。 */
|
|
593
|
+
/* 用 auto 而不是 default:auto 会按元素类型给浏览器默认光标,
|
|
594
|
+
文本区仍是 I 型、输入框仍是文本光标;default 会把这些也压成箭头。 */
|
|
595
|
+
html[data-dcc-pointer="on"] *,
|
|
596
|
+
html[data-dcc-pointer="on"] *::before,
|
|
597
|
+
html[data-dcc-pointer="on"] *::after {
|
|
598
|
+
cursor: auto !important;
|
|
599
|
+
}
|
|
600
|
+
/* 跳转性元素保留手形 */
|
|
601
|
+
html[data-dcc-pointer="on"] a[href],
|
|
602
|
+
html[data-dcc-pointer="on"] [role="link"],
|
|
603
|
+
html[data-dcc-pointer="on"] [data-href] {
|
|
604
|
+
cursor: pointer !important;
|
|
605
|
+
}
|
|
606
|
+
/* 「本轮改动」卡片:表头和文件行都是跳转性的(在侧边栏打开预览),
|
|
607
|
+
整张卡片放行手形——只写 button 会漏掉行内的 path / counts 等子元素 */
|
|
608
|
+
html[data-dcc-pointer="on"] [data-changed-files="true"],
|
|
609
|
+
html[data-dcc-pointer="on"] [data-changed-files="true"] * {
|
|
610
|
+
cursor: pointer !important;
|
|
611
|
+
}
|
|
612
|
+
/* 左上角的品牌 Logo 是可点击的(跳转官网),保留手形 */
|
|
613
|
+
html[data-dcc-pointer="on"] [class*="_brand"],
|
|
614
|
+
html[data-dcc-pointer="on"] [class*="_brand"] *,
|
|
615
|
+
html[data-dcc-pointer="on"] [class*="_logoRow"],
|
|
616
|
+
html[data-dcc-pointer="on"] [class*="_logoRow"] *,
|
|
617
|
+
html[data-dcc-pointer="on"] [class*="_railMark"],
|
|
618
|
+
html[data-dcc-pointer="on"] [class*="_railMark"] * {
|
|
619
|
+
cursor: pointer !important;
|
|
620
|
+
}
|
|
621
|
+
/* 输入区保留文本光标 */
|
|
622
|
+
html[data-dcc-pointer="on"] input,
|
|
623
|
+
html[data-dcc-pointer="on"] textarea,
|
|
624
|
+
html[data-dcc-pointer="on"] [contenteditable="true"] {
|
|
625
|
+
cursor: text !important;
|
|
626
|
+
}
|
|
627
|
+
/* 禁用态保留「禁止」提示,比默认箭头更清楚 */
|
|
628
|
+
html[data-dcc-pointer="on"] :disabled,
|
|
629
|
+
html[data-dcc-pointer="on"] [aria-disabled="true"] {
|
|
630
|
+
cursor: not-allowed !important;
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/* ---------- 文字可选范围 ---------- */
|
|
634
|
+
/* 界面文字一律不可选中(桌面软件的惯例:标题、按钮、标签、菜单不该拖出蓝底),
|
|
635
|
+
只有消息正文与输入区保留可选中。带 !important 是因为宿主自己给若干处写了
|
|
636
|
+
user-select: text,类选择器的优先级高于 html body,不强化压不住。 */
|
|
637
|
+
html[data-dcc-select="on"] body,
|
|
638
|
+
html[data-dcc-select="on"] body * {
|
|
639
|
+
user-select: none !important;
|
|
640
|
+
-webkit-user-select: none !important;
|
|
641
|
+
}
|
|
642
|
+
/* 消息正文(含其后代)可选 */
|
|
643
|
+
html[data-dcc-select="on"] body [data-conversation-scroll],
|
|
644
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] * {
|
|
645
|
+
user-select: text !important;
|
|
646
|
+
-webkit-user-select: text !important;
|
|
647
|
+
}
|
|
648
|
+
/* 但消息区里的界面元件不算正文:按钮、操作栏、时间、改动卡片一律压回不可选 */
|
|
649
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] button,
|
|
650
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] button *,
|
|
651
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [role="button"],
|
|
652
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [role="button"] *,
|
|
653
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_action"],
|
|
654
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_action"] *,
|
|
655
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_time"],
|
|
656
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] time,
|
|
657
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [data-changed-files="true"],
|
|
658
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [data-changed-files="true"] *,
|
|
659
|
+
/* 进行中的状态提示(「深度求索中,用时 1 秒…」)也是界面元件,不是正文 */
|
|
660
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [role="status"],
|
|
661
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [role="status"] *,
|
|
662
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [aria-live],
|
|
663
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [aria-live] *,
|
|
664
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_running"],
|
|
665
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_running"] *,
|
|
666
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_status"],
|
|
667
|
+
html[data-dcc-select="on"] body [data-conversation-scroll] [class*="_status"] * {
|
|
668
|
+
user-select: none !important;
|
|
669
|
+
-webkit-user-select: none !important;
|
|
670
|
+
}
|
|
671
|
+
/* 输入框那一片再压回不可选,否则整行(速率、余额、百分比)会被一起拖蓝 */
|
|
672
|
+
html[data-dcc-select="on"] body [data-conversation-region="composer"],
|
|
673
|
+
html[data-dcc-select="on"] body [data-conversation-region="composer"] * {
|
|
674
|
+
user-select: none !important;
|
|
675
|
+
-webkit-user-select: none !important;
|
|
676
|
+
}
|
|
677
|
+
/* 「本轮改动」卡片与消息时间属于界面元件,不是正文,一并压成不可选 */
|
|
678
|
+
html[data-dcc-select="on"] body [data-changed-files="true"],
|
|
679
|
+
html[data-dcc-select="on"] body [data-changed-files="true"] *,
|
|
680
|
+
html[data-dcc-select="on"] body time {
|
|
681
|
+
user-select: none !important;
|
|
682
|
+
-webkit-user-select: none !important;
|
|
683
|
+
}
|
|
684
|
+
/* 输入框本身放在最后,覆盖上面那条 */
|
|
685
|
+
html[data-dcc-select="on"] body input,
|
|
686
|
+
html[data-dcc-select="on"] body textarea,
|
|
687
|
+
html[data-dcc-select="on"] body [contenteditable="true"] {
|
|
688
|
+
user-select: text !important;
|
|
689
|
+
-webkit-user-select: text !important;
|
|
690
|
+
}
|
|
691
|
+
/* 会话标题(面包屑那一段)可选中,方便复制标题;
|
|
692
|
+
只放行标题区,右侧的按钮组仍是不可选 */
|
|
693
|
+
html[data-dcc-select="on"] body [class*="_titleRow"],
|
|
694
|
+
html[data-dcc-select="on"] body [class*="_titleCluster"],
|
|
695
|
+
html[data-dcc-select="on"] body [class*="_crumb"],
|
|
696
|
+
html[data-dcc-select="on"] body [class*="_crumb"] * {
|
|
697
|
+
user-select: text !important;
|
|
698
|
+
-webkit-user-select: text !important;
|
|
699
|
+
}
|
|
700
|
+
|
|
417
701
|
/* ---------- 已归档会话:标题画删除线 ---------- */
|
|
418
702
|
html [class*="_sessionRow"][class*="_archived"] [class*="_title"] {
|
|
419
703
|
text-decoration: line-through;
|
|
@@ -490,14 +774,14 @@ html [class*="_overlay"]:has([class*="_navTitle"]) [class*="_navCell"] {
|
|
|
490
774
|
}
|
|
491
775
|
.dcc-settings-back {
|
|
492
776
|
position: absolute;
|
|
493
|
-
top: 20px;
|
|
494
777
|
left: 14px;
|
|
778
|
+
top: 0;
|
|
495
779
|
z-index: 2;
|
|
496
780
|
display: inline-flex;
|
|
497
781
|
align-items: center;
|
|
498
782
|
justify-content: center;
|
|
499
783
|
width: 28px;
|
|
500
|
-
height:
|
|
784
|
+
height: 24px;
|
|
501
785
|
padding: 0;
|
|
502
786
|
border: 0;
|
|
503
787
|
border-radius: var(--dsw-radius-sm);
|
|
@@ -732,6 +1016,24 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
732
1016
|
return title === null ? null : title.parentElement;
|
|
733
1017
|
};
|
|
734
1018
|
|
|
1019
|
+
/**
|
|
1020
|
+
* 按钮垂直位置按「标题文字的实际矩形」算,而不是按容器盒算——
|
|
1021
|
+
* 容器带 padding / inline 布局时,盒子中心和文字中心并不重合。
|
|
1022
|
+
*/
|
|
1023
|
+
const align = () => {
|
|
1024
|
+
if (btn === null || !btn.isConnected || btn.offsetParent === null) return;
|
|
1025
|
+
const title = document.querySelector('[class*="_navTitle"]');
|
|
1026
|
+
if (title === null) return;
|
|
1027
|
+
const range = document.createRange();
|
|
1028
|
+
range.selectNodeContents(title);
|
|
1029
|
+
const rects = range.getClientRects();
|
|
1030
|
+
if (rects.length === 0) return;
|
|
1031
|
+
const textRect = rects[0];
|
|
1032
|
+
const panelRect = btn.offsetParent.getBoundingClientRect();
|
|
1033
|
+
const centerY = textRect.top + textRect.height / 2 - panelRect.top;
|
|
1034
|
+
btn.style.top = `${Math.round(centerY - btn.offsetHeight / 2)}px`;
|
|
1035
|
+
};
|
|
1036
|
+
|
|
735
1037
|
const closePanel = (panel) => {
|
|
736
1038
|
const close = panel.querySelector('[class*="_header"] [class*="_close"]');
|
|
737
1039
|
if (close !== null) close.click();
|
|
@@ -744,7 +1046,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
744
1046
|
btn = null;
|
|
745
1047
|
return;
|
|
746
1048
|
}
|
|
747
|
-
if (btn !== null && btn.isConnected && btn.parentElement === panel)
|
|
1049
|
+
if (btn !== null && btn.isConnected && btn.parentElement === panel) {
|
|
1050
|
+
align();
|
|
1051
|
+
return;
|
|
1052
|
+
}
|
|
748
1053
|
if (btn !== null) btn.remove();
|
|
749
1054
|
btn = document.createElement('button');
|
|
750
1055
|
btn.type = 'button';
|
|
@@ -756,6 +1061,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
756
1061
|
+ ' stroke-linecap="round" stroke-linejoin="round"/></svg>';
|
|
757
1062
|
btn.addEventListener('click', () => closePanel(panel));
|
|
758
1063
|
panel.appendChild(btn);
|
|
1064
|
+
align();
|
|
759
1065
|
};
|
|
760
1066
|
|
|
761
1067
|
const insertSoon = () => {
|
|
@@ -940,6 +1246,181 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
940
1246
|
return () => window.removeEventListener('pointerover', onOver, true);
|
|
941
1247
|
}
|
|
942
1248
|
|
|
1249
|
+
/**
|
|
1250
|
+
* 会话视图切换(对话 / 轨迹)从标签行搬到顶部工具区,做成一个分段控件。
|
|
1251
|
+
* 原标签行只是被 CSS 隐藏,按钮仍在 DOM 里——点击自绘按钮时转发给它,
|
|
1252
|
+
* 选中态则跟着原按钮的 aria-selected 走,所以和宿主的真实状态永远一致。
|
|
1253
|
+
*/
|
|
1254
|
+
function installViewSwitcher() {
|
|
1255
|
+
let bar = null;
|
|
1256
|
+
let observer = null;
|
|
1257
|
+
let timer = null;
|
|
1258
|
+
|
|
1259
|
+
const findTabs = () => document.querySelector('[data-conversation-tabs]');
|
|
1260
|
+
const findHost = () => document.querySelector('[class*="_headerUtilities"]');
|
|
1261
|
+
|
|
1262
|
+
const syncActive = () => {
|
|
1263
|
+
if (bar === null) return;
|
|
1264
|
+
const tabs = findTabs();
|
|
1265
|
+
if (tabs === null) return;
|
|
1266
|
+
const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
|
|
1267
|
+
const items = Array.from(bar.querySelectorAll('.dcc-seg'));
|
|
1268
|
+
for (let i = 0; i < items.length; i += 1) {
|
|
1269
|
+
const on = sources[i] !== undefined && sources[i].getAttribute('aria-selected') === 'true';
|
|
1270
|
+
if (on) items[i].setAttribute('data-active', 'true');
|
|
1271
|
+
else items[i].removeAttribute('data-active');
|
|
1272
|
+
}
|
|
1273
|
+
};
|
|
1274
|
+
|
|
1275
|
+
const build = (tabs, host) => {
|
|
1276
|
+
if (bar !== null) bar.remove();
|
|
1277
|
+
bar = document.createElement('div');
|
|
1278
|
+
bar.className = 'dcc-segmented';
|
|
1279
|
+
const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
|
|
1280
|
+
sources.forEach((source, index) => {
|
|
1281
|
+
const item = document.createElement('button');
|
|
1282
|
+
item.type = 'button';
|
|
1283
|
+
item.className = 'dcc-seg';
|
|
1284
|
+
item.textContent = (source.textContent || '').trim();
|
|
1285
|
+
item.addEventListener('click', () => {
|
|
1286
|
+
const current = findTabs();
|
|
1287
|
+
if (current === null) return;
|
|
1288
|
+
const target = current.querySelectorAll('button[role="tab"]')[index];
|
|
1289
|
+
if (target !== undefined) target.click();
|
|
1290
|
+
});
|
|
1291
|
+
bar.appendChild(item);
|
|
1292
|
+
});
|
|
1293
|
+
host.insertBefore(bar, host.firstChild);
|
|
1294
|
+
syncActive();
|
|
1295
|
+
};
|
|
1296
|
+
|
|
1297
|
+
const ensure = () => {
|
|
1298
|
+
/* 开关关掉时把自绘控件撤掉,标签行由 CSS 恢复原样 */
|
|
1299
|
+
if (document.documentElement.dataset.dccCompactHeader !== 'on') {
|
|
1300
|
+
if (bar !== null) { bar.remove(); bar = null; }
|
|
1301
|
+
return;
|
|
1302
|
+
}
|
|
1303
|
+
const tabs = findTabs();
|
|
1304
|
+
const host = findHost();
|
|
1305
|
+
if (tabs === null || host === null) {
|
|
1306
|
+
if (bar !== null) { bar.remove(); bar = null; }
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
const count = tabs.querySelectorAll('button[role="tab"]').length;
|
|
1310
|
+
if (bar === null || !bar.isConnected || bar.parentElement !== host || bar.children.length !== count) {
|
|
1311
|
+
build(tabs, host);
|
|
1312
|
+
return;
|
|
1313
|
+
}
|
|
1314
|
+
syncActive();
|
|
1315
|
+
};
|
|
1316
|
+
|
|
1317
|
+
const schedule = () => {
|
|
1318
|
+
if (timer !== null) return;
|
|
1319
|
+
timer = window.setTimeout(() => {
|
|
1320
|
+
timer = null;
|
|
1321
|
+
ensure();
|
|
1322
|
+
}, 350);
|
|
1323
|
+
};
|
|
1324
|
+
|
|
1325
|
+
ensure();
|
|
1326
|
+
observer = new MutationObserver(schedule);
|
|
1327
|
+
observer.observe(document.body, {
|
|
1328
|
+
childList: true,
|
|
1329
|
+
subtree: true,
|
|
1330
|
+
attributes: true,
|
|
1331
|
+
attributeFilter: ['aria-selected'],
|
|
1332
|
+
});
|
|
1333
|
+
|
|
1334
|
+
return () => {
|
|
1335
|
+
observer.disconnect();
|
|
1336
|
+
if (timer !== null) clearTimeout(timer);
|
|
1337
|
+
if (bar !== null) bar.remove();
|
|
1338
|
+
};
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
/**
|
|
1342
|
+
* 在输入框下方的状态行里显示账户余额,走宿主的账户接口
|
|
1343
|
+
* (ctx.remote.account.getBalance)。取不到就静默不显示,不影响其他功能。
|
|
1344
|
+
*/
|
|
1345
|
+
function installBalancePill(ctx) {
|
|
1346
|
+
let refresh = null;
|
|
1347
|
+
let text = '';
|
|
1348
|
+
let low = false;
|
|
1349
|
+
/* 原始金额与币种单独留着:改小数位或阈值时要能重新格式化,
|
|
1350
|
+
只存格式化后的字符串就回不去了。 */
|
|
1351
|
+
let rawAmount = null;
|
|
1352
|
+
let symbol = '¥';
|
|
1353
|
+
|
|
1354
|
+
const identity = () => ({
|
|
1355
|
+
version: VERSION,
|
|
1356
|
+
locale: navigator.language || 'zh-CN',
|
|
1357
|
+
timezoneOffsetSeconds: -new Date().getTimezoneOffset() * 60,
|
|
1358
|
+
});
|
|
1359
|
+
|
|
1360
|
+
/* 只写 CSS 变量和 html 上的标记位,不碰 React 的节点树。
|
|
1361
|
+
伪元素没有「被 React 摘掉再补回」这一步,所以刷新时不会闪。 */
|
|
1362
|
+
const sync = () => {
|
|
1363
|
+
if (text === '') return;
|
|
1364
|
+
const root = document.documentElement;
|
|
1365
|
+
const next = JSON.stringify(`余额 ${text}`);
|
|
1366
|
+
if (root.style.getPropertyValue('--dcc-balance-text') !== next) {
|
|
1367
|
+
root.style.setProperty('--dcc-balance-text', next);
|
|
1368
|
+
}
|
|
1369
|
+
const flag = low ? 'on' : 'off';
|
|
1370
|
+
if (root.dataset.dccBalanceLow !== flag) root.dataset.dccBalanceLow = flag;
|
|
1371
|
+
};
|
|
1372
|
+
|
|
1373
|
+
/* 只根据已拿到的余额重算显示与「是否低于阈值」。
|
|
1374
|
+
设置页改阈值或小数位时立即调用,否则要等下一分钟拉余额才生效。 */
|
|
1375
|
+
const recalc = () => {
|
|
1376
|
+
if (rawAmount === null) return;
|
|
1377
|
+
const prefs = readPrefs();
|
|
1378
|
+
const digits = Number(prefs.balanceDecimals);
|
|
1379
|
+
const decimals = Number.isFinite(digits) && digits >= 2 && digits <= 6 ? Math.round(digits) : 2;
|
|
1380
|
+
text = `${symbol}${rawAmount.toFixed(decimals)}`;
|
|
1381
|
+
const limit = Number(prefs.balanceThreshold);
|
|
1382
|
+
low = Number.isFinite(limit) && rawAmount < limit;
|
|
1383
|
+
sync();
|
|
1384
|
+
};
|
|
1385
|
+
|
|
1386
|
+
const onThreshold = () => recalc();
|
|
1387
|
+
|
|
1388
|
+
const load = async () => {
|
|
1389
|
+
try {
|
|
1390
|
+
/* 必须用 ctx.get('remote'):点号访问 ctx.remote.* 会被 trace,
|
|
1391
|
+
只有在 inject 了该服务的上下文里才可读,渲染回调里拿不到。 */
|
|
1392
|
+
const remote = typeof ctx.get === 'function' ? ctx.get('remote') : null;
|
|
1393
|
+
const account = remote !== null && typeof remote === 'object' ? remote.account : undefined;
|
|
1394
|
+
if (account === undefined || typeof account.getBalance !== 'function') return;
|
|
1395
|
+
const res = await account.getBalance(identity());
|
|
1396
|
+
if (!res || res.ok !== true) return;
|
|
1397
|
+
const value = res.value;
|
|
1398
|
+
if (!value || value.status !== 'ready') return;
|
|
1399
|
+
const wallets = Array.isArray(value.value) ? value.value : [];
|
|
1400
|
+
const wallet = wallets.find((w) => w.currency === 'CNY') || wallets[0];
|
|
1401
|
+
if (!wallet || typeof wallet.balance !== 'string') return;
|
|
1402
|
+
const amount = Number(wallet.balance);
|
|
1403
|
+
if (!Number.isFinite(amount)) return;
|
|
1404
|
+
rawAmount = amount;
|
|
1405
|
+
symbol = wallet.currency === 'CNY' ? '¥' : '$';
|
|
1406
|
+
recalc();
|
|
1407
|
+
} catch {
|
|
1408
|
+
/* 未登录或接口不可用:不显示余额 */
|
|
1409
|
+
}
|
|
1410
|
+
};
|
|
1411
|
+
|
|
1412
|
+
window.addEventListener('dcc-balance-threshold', onThreshold);
|
|
1413
|
+
load();
|
|
1414
|
+
refresh = window.setInterval(load, 60000);
|
|
1415
|
+
|
|
1416
|
+
return () => {
|
|
1417
|
+
window.removeEventListener('dcc-balance-threshold', onThreshold);
|
|
1418
|
+
if (refresh !== null) window.clearInterval(refresh);
|
|
1419
|
+
document.documentElement.style.removeProperty('--dcc-balance-text');
|
|
1420
|
+
delete document.documentElement.dataset.dccBalanceLow;
|
|
1421
|
+
};
|
|
1422
|
+
}
|
|
1423
|
+
|
|
943
1424
|
function Switch(props) {
|
|
944
1425
|
return h('label', { className: 'dcc-switch' },
|
|
945
1426
|
h('input', {
|
|
@@ -970,11 +1451,15 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
970
1451
|
savePrefs(next);
|
|
971
1452
|
return next;
|
|
972
1453
|
});
|
|
1454
|
+
/* 阈值或小数位变了要立刻重算显示,通知余额模块重算一次 */
|
|
1455
|
+
if ((key === 'balanceThreshold' || key === 'balanceDecimals') && typeof window !== 'undefined') {
|
|
1456
|
+
window.dispatchEvent(new Event('dcc-balance-threshold'));
|
|
1457
|
+
}
|
|
973
1458
|
};
|
|
974
1459
|
return h('div', { className: 'dcc-page' },
|
|
975
1460
|
h('div', { className: 'dcc-title' }, zh ? 'UI 改进' : 'UI improvements'),
|
|
976
1461
|
h('p', { className: 'dcc-intro' },
|
|
977
|
-
zh ? '在保持原版 UI
|
|
1462
|
+
zh ? '在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。' : 'Keeps the overall layout of the stock UI while tightening its radii, spacing and tidiness for a calmer, more professional and more efficient look. Also adds an account balance display. Most changes can be switched on or off individually in Settings.'),
|
|
978
1463
|
h('div', { className: 'dcc-group' },
|
|
979
1464
|
h('div', { className: 'dcc-group-title' }, zh ? '外观' : 'Appearance'),
|
|
980
1465
|
h(Row, {
|
|
@@ -992,11 +1477,17 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
992
1477
|
h('div', { className: 'dcc-group' },
|
|
993
1478
|
h('div', { className: 'dcc-group-title' }, zh ? '布局' : 'Layout'),
|
|
994
1479
|
h(Row, {
|
|
995
|
-
title: zh ? '
|
|
1480
|
+
title: zh ? '减小圆角与间距' : 'Smaller radii and spacing',
|
|
996
1481
|
desc: zh ? '缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效。' : 'Smaller global radii, smaller sidebar type and tighter spacing, for a more efficient interface.',
|
|
997
1482
|
checked: prefs.radiusDensity,
|
|
998
1483
|
onChange: update('radiusDensity'),
|
|
999
1484
|
}),
|
|
1485
|
+
h(Row, {
|
|
1486
|
+
title: zh ? '会话标题栏紧凑化' : 'Compact session header',
|
|
1487
|
+
desc: zh ? '紧凑化会话标题栏,使会话内容可视范围更大。' : 'Tighten the session header so more of the conversation is visible.',
|
|
1488
|
+
checked: prefs.compactHeader,
|
|
1489
|
+
onChange: update('compactHeader'),
|
|
1490
|
+
}),
|
|
1000
1491
|
h(Row, {
|
|
1001
1492
|
title: zh ? '统一新会话按钮样式' : 'Unified new-session button',
|
|
1002
1493
|
desc: zh ? '将新会话按钮样式改为与导航按钮一致的样式。' : 'Style the new-session button the same as the navigation buttons.',
|
|
@@ -1039,6 +1530,61 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1039
1530
|
checked: prefs.settingsFullscreen,
|
|
1040
1531
|
onChange: update('settingsFullscreen'),
|
|
1041
1532
|
})),
|
|
1533
|
+
h('div', { className: 'dcc-group' },
|
|
1534
|
+
h('div', { className: 'dcc-group-title' }, zh ? '性能与用量信息' : 'Performance and usage'),
|
|
1535
|
+
h(Row, {
|
|
1536
|
+
title: zh ? '优化布局' : 'Optimize layout',
|
|
1537
|
+
desc: zh ? '优化输入框下方性能与用量布局,将数据分布在左右两侧平衡视觉重心。' : 'Improve the layout of the performance and usage row, spreading the data across both sides to balance the visual weight.',
|
|
1538
|
+
checked: prefs.optimizeStatsLayout,
|
|
1539
|
+
onChange: update('optimizeStatsLayout'),
|
|
1540
|
+
}),
|
|
1541
|
+
h(Row, {
|
|
1542
|
+
title: zh ? '显示余额' : 'Show balance',
|
|
1543
|
+
desc: zh ? '在输入框下方性能与用量中显示余额。' : 'Show the account balance in the performance and usage row.',
|
|
1544
|
+
checked: prefs.showBalance,
|
|
1545
|
+
onChange: update('showBalance'),
|
|
1546
|
+
}),
|
|
1547
|
+
h('div', { className: 'dcc-row' },
|
|
1548
|
+
h('div', { className: 'dcc-row-text' },
|
|
1549
|
+
h('div', { className: 'dcc-row-title' }, zh ? '余额警告阈值' : 'Low balance threshold'),
|
|
1550
|
+
h('div', { className: 'dcc-row-desc' }, zh ? '余额低于此值将变为红色。最小为 0。' : 'The balance turns red below this value. Minimum 0.')),
|
|
1551
|
+
h('input', {
|
|
1552
|
+
type: 'number',
|
|
1553
|
+
min: '0',
|
|
1554
|
+
step: '1',
|
|
1555
|
+
className: 'dcc-number',
|
|
1556
|
+
value: prefs.balanceThreshold,
|
|
1557
|
+
'aria-label': zh ? '余额警告阈值' : 'Low balance threshold',
|
|
1558
|
+
onChange: (event) => {
|
|
1559
|
+
/* min 属性只是浏览器提示,拦不住手输负数或非法值,这里兜底归 0 */
|
|
1560
|
+
const next = Number(event.target.value);
|
|
1561
|
+
update('balanceThreshold')(Number.isFinite(next) && next >= 0 ? next : 0);
|
|
1562
|
+
},
|
|
1563
|
+
})),
|
|
1564
|
+
h('div', { className: 'dcc-row' },
|
|
1565
|
+
h('div', { className: 'dcc-row-text' },
|
|
1566
|
+
h('div', { className: 'dcc-row-title' }, zh ? '余额小数位数' : 'Balance decimal places'),
|
|
1567
|
+
h('div', { className: 'dcc-row-desc' }, zh ? '余额显示的小数位数。' : 'How many decimal places the balance shows.')),
|
|
1568
|
+
h('select', {
|
|
1569
|
+
className: 'dcc-select',
|
|
1570
|
+
value: String(prefs.balanceDecimals),
|
|
1571
|
+
'aria-label': zh ? '余额小数位数' : 'Balance decimal places',
|
|
1572
|
+
onChange: (event) => update('balanceDecimals')(Number(event.target.value)),
|
|
1573
|
+
}, [2, 3, 4, 5, 6].map((n) => h('option', { key: n, value: String(n) }, `${n} 位`))))),
|
|
1574
|
+
h('div', { className: 'dcc-group' },
|
|
1575
|
+
h('div', { className: 'dcc-group-title' }, zh ? '规范化' : 'Normalization'),
|
|
1576
|
+
h(Row, {
|
|
1577
|
+
title: zh ? '指针样式规范化' : 'Normalize pointer styles',
|
|
1578
|
+
desc: zh ? '遵循桌面软件的指针样式规范,仅链接等跳转性元素会更改指针样式为「手形」。' : 'Follows desktop conventions: only links and other navigational elements show a hand cursor.',
|
|
1579
|
+
checked: prefs.pointerNormalize,
|
|
1580
|
+
onChange: update('pointerNormalize'),
|
|
1581
|
+
}),
|
|
1582
|
+
h(Row, {
|
|
1583
|
+
title: zh ? '文本可选中限制' : 'Restrict text selection',
|
|
1584
|
+
desc: zh ? '遵循桌面软件的规范,使 UI 界面元素的文本不可被选中。' : 'Follows desktop conventions: text in interface elements cannot be selected.',
|
|
1585
|
+
checked: prefs.textSelectLimit,
|
|
1586
|
+
onChange: update('textSelectLimit'),
|
|
1587
|
+
})),
|
|
1042
1588
|
h('p', { className: 'dcc-meta' },
|
|
1043
1589
|
/* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
|
|
1044
1590
|
zh ? `版本:${VERSION}\u3000更新日期:${UPDATED}` : `Version: ${VERSION} Updated: ${UPDATED}`));
|
|
@@ -1055,7 +1601,9 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1055
1601
|
|
|
1056
1602
|
return {
|
|
1057
1603
|
name: 'dsh-ui-alt',
|
|
1058
|
-
|
|
1604
|
+
/* remote.account 是独立服务 key,和不声明就等于没有;
|
|
1605
|
+
只在 inject 里写上,ctx.get('remote').account 才可用。 */
|
|
1606
|
+
inject: ['slots', 'remote', 'remote.account'],
|
|
1059
1607
|
apply(ctx) {
|
|
1060
1608
|
ctx.effect(() => {
|
|
1061
1609
|
applyPrefs(readPrefs());
|
|
@@ -1074,6 +1622,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1074
1622
|
const removeSettingsBack = installSettingsBackButton();
|
|
1075
1623
|
const removeRowActionFilter = installRowActionFilter();
|
|
1076
1624
|
const removeHoverCardBlocker = installHoverCardBlocker();
|
|
1625
|
+
const removeViewSwitcher = installViewSwitcher();
|
|
1626
|
+
const removeBalance = installBalancePill(ctx);
|
|
1077
1627
|
return () => {
|
|
1078
1628
|
removeCss();
|
|
1079
1629
|
removeNewSessionRow();
|
|
@@ -1081,6 +1631,8 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1081
1631
|
removeSettingsBack();
|
|
1082
1632
|
removeRowActionFilter();
|
|
1083
1633
|
removeHoverCardBlocker();
|
|
1634
|
+
removeViewSwitcher();
|
|
1635
|
+
removeBalance();
|
|
1084
1636
|
const root = document.documentElement;
|
|
1085
1637
|
delete root.dataset.dccRadius;
|
|
1086
1638
|
delete root.dataset.dccNew;
|
|
@@ -1092,6 +1644,11 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1092
1644
|
delete root.dataset.dccFull;
|
|
1093
1645
|
delete root.dataset.dccHover;
|
|
1094
1646
|
delete root.dataset.dccRowButtons;
|
|
1647
|
+
delete root.dataset.dccCompactHeader;
|
|
1648
|
+
delete root.dataset.dccStats;
|
|
1649
|
+
delete root.dataset.dccBalance;
|
|
1650
|
+
delete root.dataset.dccPointer;
|
|
1651
|
+
delete root.dataset.dccSelect;
|
|
1095
1652
|
};
|
|
1096
1653
|
}, 'dsh-ui-alt: styles and preference attributes');
|
|
1097
1654
|
|
package/locale/en.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"meta": {
|
|
3
3
|
"title": "UI improvements",
|
|
4
|
-
"description": "
|
|
4
|
+
"description": "Keeps the overall layout of the stock UI while tightening its radii, spacing and tidiness for a calmer, more professional and more efficient look. Also adds an account balance display. Most changes can be switched on or off individually in Settings."
|
|
5
5
|
}
|
|
6
6
|
}
|
package/locale/zh.json
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-ui-alt",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.87",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"description": "在保持原版 UI
|
|
6
|
+
"description": "在保持原版 UI 大体布局不变的情况下,进行减小圆角、紧凑化、整洁化、高效化改进,使 UI 视觉更加冷静、专业、高效。同时添加余额显示。大部分改动可在设置中单独开关。",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"author": "AomiRaku",
|
|
9
9
|
"keywords": [
|