dsh-ui-alt 0.2.135 → 0.2.343
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 +52 -13
- package/client.js +1304 -145
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -6,20 +6,25 @@ 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.343';
|
|
10
|
+
const UPDATED = '2026-11-14';
|
|
11
11
|
const DEFAULTS = {
|
|
12
12
|
radiusDensity: true,
|
|
13
13
|
invertNewSession: true,
|
|
14
14
|
dimSessions: true,
|
|
15
|
+
enabled: true,
|
|
15
16
|
hideLogo: false,
|
|
16
17
|
winFont: false,
|
|
17
18
|
softenDarkText: true,
|
|
19
|
+
uiTransition: true,
|
|
20
|
+
disableMenuBlur: true,
|
|
18
21
|
sessionDot: false,
|
|
19
22
|
settingsFullscreen: true,
|
|
20
23
|
hideHoverCard: true,
|
|
21
24
|
hideRowButtons: true,
|
|
25
|
+
headerFade: true,
|
|
22
26
|
compactHeader: true,
|
|
27
|
+
compactAlwaysShow: false,
|
|
23
28
|
navCollapse: true,
|
|
24
29
|
optimizeStatsLayout: true,
|
|
25
30
|
showBalance: true,
|
|
@@ -45,6 +50,15 @@ window.__ModuleLoader__.load({
|
|
|
45
50
|
|
|
46
51
|
function applyPrefs(prefs) {
|
|
47
52
|
const root = document.documentElement;
|
|
53
|
+
/* 总开关关掉时,把本插件写上去的所有属性全部摘掉:
|
|
54
|
+
不受单独开关控制的那部分修复(标题栏去线、侧栏边距等)也一并失效。 */
|
|
55
|
+
if (!prefs.enabled) {
|
|
56
|
+
const keys = Object.keys(root.dataset).filter((key) => key.startsWith('dcc'));
|
|
57
|
+
for (const key of keys) delete root.dataset[key];
|
|
58
|
+
root.dataset.dccEnabled = 'off';
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
root.dataset.dccEnabled = 'on';
|
|
48
62
|
root.dataset.dccRadius = prefs.radiusDensity ? 'on' : 'off';
|
|
49
63
|
root.dataset.dccNew = prefs.invertNewSession ? 'on' : 'off';
|
|
50
64
|
root.dataset.dccDim = prefs.dimSessions ? 'on' : 'off';
|
|
@@ -52,10 +66,14 @@ window.__ModuleLoader__.load({
|
|
|
52
66
|
root.dataset.dccDot = prefs.sessionDot ? 'on' : 'off';
|
|
53
67
|
root.dataset.dccFont = prefs.winFont ? 'on' : 'off';
|
|
54
68
|
root.dataset.dccTextDim = prefs.softenDarkText ? 'on' : 'off';
|
|
69
|
+
root.dataset.dccTransition = prefs.uiTransition ? 'on' : 'off';
|
|
70
|
+
root.dataset.dccMenuBlur = prefs.disableMenuBlur ? 'on' : 'off';
|
|
55
71
|
root.dataset.dccFull = prefs.settingsFullscreen ? 'on' : 'off';
|
|
56
72
|
root.dataset.dccHover = prefs.hideHoverCard ? 'off' : 'on';
|
|
57
73
|
root.dataset.dccRowButtons = prefs.hideRowButtons ? 'on' : 'off';
|
|
74
|
+
root.dataset.dccHeaderFade = prefs.headerFade ? 'on' : 'off';
|
|
58
75
|
root.dataset.dccCompactHeader = prefs.compactHeader ? 'on' : 'off';
|
|
76
|
+
root.dataset.dccAlwaysShow = prefs.compactAlwaysShow ? 'on' : 'off';
|
|
59
77
|
root.dataset.dccCollapse = prefs.navCollapse ? 'on' : 'off';
|
|
60
78
|
root.dataset.dccStats = prefs.optimizeStatsLayout ? 'on' : 'off';
|
|
61
79
|
root.dataset.dccBalance = prefs.showBalance ? 'on' : 'off';
|
|
@@ -93,16 +111,170 @@ html[data-dcc-font="on"][data-windows-titlebar] body {
|
|
|
93
111
|
|
|
94
112
|
/* ---------- 设置页(始终可用) ---------- */
|
|
95
113
|
.dcc-page { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 760px; }
|
|
96
|
-
.dcc-title { margin: 0; padding: 0 2px; font-size:
|
|
114
|
+
.dcc-title { margin: 0; padding: 0 2px; font-size: 18px; line-height: 26px; font-weight: 600; color: var(--dsw-alias-label-primary); }
|
|
97
115
|
.dcc-intro { margin: 0; padding: 0 2px; font-size: 13px; line-height: 20px; color: var(--dsw-alias-label-secondary); }
|
|
98
116
|
.dcc-meta { margin: 0; padding: 2px 2px 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
|
|
99
117
|
.dcc-group { display: flex; flex-direction: column; padding: 6px 20px; border: 1px solid var(--dsw-alias-border-l2); border-radius: var(--dsw-radius-lg); background: var(--dsw-alias-bg-layer-1); }
|
|
100
|
-
|
|
118
|
+
/* 分组标题统一降为次要色:它是分区标签,不该和设置项标题抢注意力 */
|
|
119
|
+
.dcc-group-title { padding: 14px 2px 4px; font-size: 13px; line-height: 20px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
|
|
120
|
+
/* 依赖项未开启时置灰 */
|
|
121
|
+
.dcc-row-disabled {
|
|
122
|
+
opacity: .45;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
}
|
|
101
125
|
.dcc-row { display: flex; align-items: center; gap: 16px; padding: 14px 2px; border-top: 1px solid var(--dsw-alias-border-l1); }
|
|
102
126
|
.dcc-group-title + .dcc-row { border-top: none; }
|
|
127
|
+
/* 无组名的组(总开关那一块)没有标题,首行同样不该有分隔线 */
|
|
128
|
+
.dcc-group > .dcc-row:first-child { border-top: none; }
|
|
129
|
+
/* 启动遮罩:先盖住,等样式稳定后淡出。底色跟随深浅主题。
|
|
130
|
+
这两个值不能依赖 --dsw-alias-bg-base:它在深色主题下仍是白的,
|
|
131
|
+
所以这里直接按主题写死,和宿主两种模式的页面底色对齐。 */
|
|
132
|
+
.dcc-boot-cover {
|
|
133
|
+
position: fixed;
|
|
134
|
+
inset: 0;
|
|
135
|
+
z-index: 2147483000;
|
|
136
|
+
display: flex;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
background-color: #ffffff;
|
|
140
|
+
opacity: 1;
|
|
141
|
+
transition: opacity .3s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
|
|
142
|
+
pointer-events: none;
|
|
143
|
+
}
|
|
144
|
+
body[data-ds-dark-theme] .dcc-boot-cover {
|
|
145
|
+
background-color: #151517;
|
|
146
|
+
}
|
|
147
|
+
.dcc-boot-fish {
|
|
148
|
+
width: 64px;
|
|
149
|
+
height: auto;
|
|
150
|
+
opacity: .3;
|
|
151
|
+
}
|
|
152
|
+
.dcc-boot-cover-out { opacity: 0; }
|
|
153
|
+
/* 纯告知行:无右侧控件,用列表承载多条说明 */
|
|
154
|
+
.dcc-row-info {
|
|
155
|
+
align-items: flex-start;
|
|
156
|
+
}
|
|
157
|
+
.dcc-row-info .dcc-row-text {
|
|
158
|
+
flex: 1;
|
|
159
|
+
}
|
|
160
|
+
/* 底部信息行:左边版本信息(可换行),右边重置按钮 */
|
|
161
|
+
.dcc-meta-row {
|
|
162
|
+
display: flex;
|
|
163
|
+
align-items: flex-end;
|
|
164
|
+
justify-content: space-between;
|
|
165
|
+
gap: 16px;
|
|
166
|
+
padding: 2px 2px 0;
|
|
167
|
+
}
|
|
168
|
+
.dcc-meta-row .dcc-meta {
|
|
169
|
+
padding: 0;
|
|
170
|
+
white-space: pre-line;
|
|
171
|
+
}
|
|
172
|
+
.dcc-reset {
|
|
173
|
+
flex: none;
|
|
174
|
+
height: 26px;
|
|
175
|
+
padding: 0 10px;
|
|
176
|
+
border: 1px solid var(--dsw-alias-border-l3);
|
|
177
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
178
|
+
background: transparent;
|
|
179
|
+
color: var(--dsw-alias-label-secondary);
|
|
180
|
+
font: inherit;
|
|
181
|
+
font-size: 12px;
|
|
182
|
+
cursor: pointer;
|
|
183
|
+
}
|
|
184
|
+
.dcc-reset:hover {
|
|
185
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
186
|
+
color: var(--dsw-alias-label-primary);
|
|
187
|
+
}
|
|
188
|
+
/* 重置确认弹窗:结构与底色对齐宿主的 Dialog(root / mask / dialog / content / footer) */
|
|
189
|
+
.dcc-modal {
|
|
190
|
+
position: fixed;
|
|
191
|
+
inset: 0;
|
|
192
|
+
z-index: 2147483000;
|
|
193
|
+
display: flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
justify-content: center;
|
|
196
|
+
}
|
|
197
|
+
.dcc-modal-mask {
|
|
198
|
+
position: absolute;
|
|
199
|
+
inset: 0;
|
|
200
|
+
background: rgba(0, 0, 0, .5);
|
|
201
|
+
}
|
|
202
|
+
.dcc-modal-card {
|
|
203
|
+
position: relative;
|
|
204
|
+
width: 360px;
|
|
205
|
+
max-width: calc(100vw - 48px);
|
|
206
|
+
display: flex;
|
|
207
|
+
flex-direction: column;
|
|
208
|
+
border: 1px solid var(--dsw-alias-border-l2);
|
|
209
|
+
border-radius: var(--dsw-radius-lg, 12px);
|
|
210
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
211
|
+
box-shadow: 0 16px 48px rgba(0, 0, 0, .35);
|
|
212
|
+
animation: dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
213
|
+
}
|
|
214
|
+
.dcc-modal-content {
|
|
215
|
+
padding: 18px 20px 4px;
|
|
216
|
+
}
|
|
217
|
+
.dcc-modal-title {
|
|
218
|
+
font-size: 15px;
|
|
219
|
+
line-height: 22px;
|
|
220
|
+
font-weight: 600;
|
|
221
|
+
color: var(--dsw-alias-label-primary);
|
|
222
|
+
}
|
|
223
|
+
.dcc-modal-body {
|
|
224
|
+
margin-top: 6px;
|
|
225
|
+
font-size: 13px;
|
|
226
|
+
line-height: 20px;
|
|
227
|
+
color: var(--dsw-alias-label-secondary);
|
|
228
|
+
}
|
|
229
|
+
.dcc-modal-actions {
|
|
230
|
+
display: flex;
|
|
231
|
+
justify-content: flex-end;
|
|
232
|
+
gap: 8px;
|
|
233
|
+
padding: 14px 20px 18px;
|
|
234
|
+
}
|
|
235
|
+
.dcc-modal-btn {
|
|
236
|
+
height: 30px;
|
|
237
|
+
padding: 0 14px;
|
|
238
|
+
border: 1px solid var(--dsw-alias-border-l3);
|
|
239
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
240
|
+
background: transparent;
|
|
241
|
+
color: var(--dsw-alias-label-primary);
|
|
242
|
+
font: inherit;
|
|
243
|
+
font-size: 13px;
|
|
244
|
+
cursor: pointer;
|
|
245
|
+
}
|
|
246
|
+
.dcc-modal-btn:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
247
|
+
/* 破坏性操作:常态无底色、文字红;悬停补一层淡红 */
|
|
248
|
+
.dcc-modal-primary {
|
|
249
|
+
border-color: transparent;
|
|
250
|
+
background: transparent;
|
|
251
|
+
color: var(--dsw-alias-state-error-primary, #e5484d);
|
|
252
|
+
}
|
|
253
|
+
.dcc-modal-primary:hover {
|
|
254
|
+
background: color-mix(in oklab, var(--dsw-alias-state-error-primary, #e5484d) 14%, transparent);
|
|
255
|
+
}
|
|
256
|
+
.dcc-action {
|
|
257
|
+
flex: none;
|
|
258
|
+
height: 28px;
|
|
259
|
+
padding: 0 12px;
|
|
260
|
+
border: 1px solid var(--dsw-alias-border-l4);
|
|
261
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
262
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
263
|
+
color: var(--dsw-alias-label-primary);
|
|
264
|
+
font: inherit;
|
|
265
|
+
font-size: 13px;
|
|
266
|
+
cursor: pointer;
|
|
267
|
+
}
|
|
268
|
+
.dcc-action:hover { background: var(--dsw-alias-interactive-bg-hover); }
|
|
269
|
+
/* 总开关关闭时,下面所有分组置灰且不可操作(第一个组是总开关本身,跳过) */
|
|
270
|
+
html[data-dcc-enabled="off"] .dcc-page .dcc-group:not(.dcc-primary) {
|
|
271
|
+
opacity: .4;
|
|
272
|
+
pointer-events: none;
|
|
273
|
+
}
|
|
103
274
|
.dcc-row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
|
|
104
|
-
.dcc-row-title { font-size:
|
|
105
|
-
.dcc-row-desc {
|
|
275
|
+
.dcc-row-title { font-size: 15px; line-height: 22px; color: var(--dsw-alias-label-primary); }
|
|
276
|
+
.dcc-row-desc {
|
|
277
|
+
white-space: pre-line; font-size: 12px; line-height: 17px; color: var(--dsw-alias-label-secondary); }
|
|
106
278
|
.dcc-switch { position: relative; display: inline-flex; width: 36px; height: 20px; flex: none; cursor: pointer; }
|
|
107
279
|
.dcc-input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
|
|
108
280
|
/* 宿主全站默认 corner-shape: superellipse(1.5),999px 会被渲染成圆角矩形而不是胶囊。
|
|
@@ -140,13 +312,13 @@ html[data-dcc-radius="on"][data-windows-titlebar] [class*="_frame"] {
|
|
|
140
312
|
--dsh-windows-content-radius: 6px !important;
|
|
141
313
|
}
|
|
142
314
|
/* 选择题:选中项的序号用高亮反色(和勾选框一致) */
|
|
143
|
-
html [class*="_optionRow"][class*="_optionSelected"] [class*="_number"] {
|
|
315
|
+
html[data-dcc-enabled="on"] [class*="_optionRow"][class*="_optionSelected"] [class*="_number"] {
|
|
144
316
|
background-color: var(--dsw-alias-label-primary) !important;
|
|
145
317
|
color: var(--dsw-alias-label-primary-foreground) !important;
|
|
146
318
|
font-weight: 600 !important;
|
|
147
319
|
}
|
|
148
320
|
/* 悬停选项时序号数字更明显,但序号底色不变(选中项由上面的反色规则接管) */
|
|
149
|
-
html [class*="_optionRow"]:not([class*="_optionSelected"]):hover [class*="_number"] {
|
|
321
|
+
html[data-dcc-enabled="on"] [class*="_optionRow"]:not([class*="_optionSelected"]):hover [class*="_number"] {
|
|
150
322
|
color: var(--dsw-alias-label-primary) !important;
|
|
151
323
|
}
|
|
152
324
|
|
|
@@ -197,6 +369,18 @@ html[data-dcc-radius="on"] [class*="_media_"] {
|
|
|
197
369
|
html[data-dcc-new="on"] button[data-dcc-original] {
|
|
198
370
|
display: none !important;
|
|
199
371
|
}
|
|
372
|
+
/* 原版按钮被隐藏后,它外面那层容器仍然占着高度,形成一块空白。
|
|
373
|
+
用克隆行时把整层一并收掉;侧栏收窄到只剩图标时再放出来。 */
|
|
374
|
+
html[data-dcc-new="on"] div[class*="_newSessionRow"] {
|
|
375
|
+
display: none !important;
|
|
376
|
+
}
|
|
377
|
+
html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) div[class*="_newSessionRow"] {
|
|
378
|
+
display: block !important;
|
|
379
|
+
}
|
|
380
|
+
/* 用克隆行时,宿主给滚动区留的 4px 上边距也没有意义了 */
|
|
381
|
+
html[data-dcc-new="on"] [class*="_scrollRegion"] {
|
|
382
|
+
margin-top: 0 !important;
|
|
383
|
+
}
|
|
200
384
|
html[data-dcc-new="on"]:has([data-sidebar-collapsed="true"]) button[data-dcc-original] {
|
|
201
385
|
display: flex !important;
|
|
202
386
|
}
|
|
@@ -208,8 +392,8 @@ html[data-dcc-new="off"] button[data-dcc-newrow] {
|
|
|
208
392
|
}
|
|
209
393
|
/* 克隆行直接使用 panelRow 的类,宽度/内边距/行高/焦点环全部来自宿主;
|
|
210
394
|
默认和其它导航行一样是透明底,悬停时统一由下面的导航行规则上色 */
|
|
395
|
+
/* 悬停底色交给克隆时一同复制过来的 panelEntry 类,和别的导航行完全一致 */
|
|
211
396
|
html[data-dcc-new="on"] button[data-dcc-newrow] {
|
|
212
|
-
background-color: transparent !important;
|
|
213
397
|
color: var(--dsw-alias-label-primary) !important;
|
|
214
398
|
}
|
|
215
399
|
.dcc-newrow-content {
|
|
@@ -234,18 +418,28 @@ html[data-dcc-new="on"] button[data-dcc-newrow] {
|
|
|
234
418
|
font: inherit;
|
|
235
419
|
color: inherit;
|
|
236
420
|
}
|
|
237
|
-
/*
|
|
238
|
-
|
|
421
|
+
/* 左右内边距加到 12px 后,Logo 行整体右移了 4px,这里抵消回原位 */
|
|
422
|
+
/* 显示 logo 时,给导航区留出与上方接近的下边距(同样只在折叠开启时) */
|
|
423
|
+
html[data-dcc-collapse="on"][data-dcc-logo="shown"] nav[class*="_panelList"] {
|
|
239
424
|
margin-top: 4px;
|
|
240
425
|
}
|
|
241
|
-
/* Logo
|
|
242
|
-
html[data-dcc-
|
|
426
|
+
/* 新会话按钮换成小尺寸后,Logo 上方会显得空,向下挪 2px 找回平衡 */
|
|
427
|
+
html[data-dcc-collapse="on"][data-dcc-new="on"] [class*="_logoRow"] {
|
|
428
|
+
margin-top: 2px !important;
|
|
429
|
+
}
|
|
430
|
+
/* Logo 上下留白:高度略放大,底下留一点空隙,别贴着导航。
|
|
431
|
+
只在「导航折叠」开启时生效——关掉后侧栏回到整块滚动,
|
|
432
|
+
这圈额外留白就成了多余的空白,交给宿主原本的排布。 */
|
|
433
|
+
html[data-dcc-collapse="on"][data-dcc-logo="shown"] [class*="_logoRow"] {
|
|
434
|
+
/* 左右内边距加到 12px 后 Logo 会右移 4px,这里抵消回原位 */
|
|
435
|
+
margin-left: -4px !important;
|
|
243
436
|
height: 32px !important;
|
|
244
437
|
margin-bottom: 6px !important;
|
|
245
438
|
padding-top: 2px !important;
|
|
246
439
|
padding-bottom: 2px !important;
|
|
247
440
|
}
|
|
248
441
|
|
|
442
|
+
|
|
249
443
|
/* 克隆出来的新会话行在 nav 里,滚动时要固定;
|
|
250
444
|
原按钮不在这里处理——它在 nav 外面本来就固定,加 sticky 和背景
|
|
251
445
|
反而会让关闭开关后的外观和宿主原版不一样。 */
|
|
@@ -259,26 +453,31 @@ html[data-dcc-logo="shown"] [class*="_logoRow"] {
|
|
|
259
453
|
/* 侧栏滚动下放:整块滚动容器不再滚动,改成纵向布局;
|
|
260
454
|
Logo / 面板列表 / 工作区标题全部固定,只有工作区列表自己滚。
|
|
261
455
|
宽屏才有 data-sidebar-scrollport,收成细轨时这些规则不生效。 */
|
|
262
|
-
|
|
456
|
+
/* 这套固定布局只在「导航折叠」开启时生效;关掉后侧栏回到宿主原本的整块滚动。 */
|
|
457
|
+
html[data-dcc-collapse="on"] [data-sidebar-scrollport] {
|
|
263
458
|
overflow: hidden !important;
|
|
264
459
|
display: flex !important;
|
|
265
460
|
flex-direction: column !important;
|
|
266
461
|
}
|
|
267
|
-
[data-sidebar-scrollport] > nav[class*="_panelList"] {
|
|
462
|
+
html[data-dcc-collapse="on"] [data-sidebar-scrollport] > nav[class*="_panelList"] {
|
|
268
463
|
flex: none;
|
|
269
464
|
}
|
|
270
|
-
[data-sidebar-scrollport] > [class*="_regionArea"] {
|
|
465
|
+
html[data-dcc-collapse="on"] [data-sidebar-scrollport] > [class*="_regionArea"] {
|
|
271
466
|
flex: 1 1 auto;
|
|
272
467
|
min-height: 0;
|
|
273
468
|
overflow: hidden;
|
|
274
469
|
display: flex;
|
|
275
470
|
flex-direction: column;
|
|
471
|
+
/* 宿主 scrollArea 的右侧列比左侧少 2px,再补 4px 免得文字贴边 */
|
|
472
|
+
padding-right: 4px;
|
|
276
473
|
}
|
|
277
474
|
/* 工作区标题保持不动,列表区成为唯一的滚动容器。
|
|
278
475
|
宿主给 listArea 写的是 overflow-y:hidden,这里放开。 */
|
|
279
|
-
[data-sidebar-scrollport] [class*="_listArea"] {
|
|
476
|
+
html[data-dcc-collapse="on"] [data-sidebar-scrollport] [class*="_listArea"] {
|
|
280
477
|
overflow-y: auto !important;
|
|
281
478
|
overflow-x: hidden !important;
|
|
479
|
+
/* 底部留出与 footArea 等高的空白,滚到底时最后一项不会被底栏压住 */
|
|
480
|
+
padding-bottom: 105px !important;
|
|
282
481
|
}
|
|
283
482
|
|
|
284
483
|
/* 导航折叠:收起时用 max-height 裁到前两项(新会话 + 插件),
|
|
@@ -286,9 +485,7 @@ html[data-dcc-logo="shown"] [class*="_logoRow"] {
|
|
|
286
485
|
html[data-dcc-nav] nav[class*="_panelList"] {
|
|
287
486
|
overflow: hidden;
|
|
288
487
|
transition: max-height .15s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
|
|
289
|
-
|
|
290
|
-
/* 导航项之间放松一点,行与行不再挨得那么紧 */
|
|
291
|
-
html[data-dcc-nav] nav[class*="_panelList"] {
|
|
488
|
+
/* 导航项之间放松一点,行与行不再挨得那么紧 */
|
|
292
489
|
gap: 4px !important;
|
|
293
490
|
margin-bottom: 4px !important;
|
|
294
491
|
}
|
|
@@ -301,14 +498,11 @@ html[data-dcc-nav="expanded"] nav[class*="_panelList"] {
|
|
|
301
498
|
/* 整个侧栏的左右内边距:宿主根上用 --dsh-sidebar-inline-padding(默认 8px),
|
|
302
499
|
调大它,导航、工作区、会话列表会一起内缩,不用逐类去改 padding。
|
|
303
500
|
用 :has(nav) 限定成「包含面板列表的那个根」,避免误伤其他 _root。 */
|
|
304
|
-
html[data-dcc-
|
|
501
|
+
html[data-dcc-collapse="on"] [class*="_root"]:has(nav[class*="_panelList"]) {
|
|
305
502
|
--dsh-sidebar-inline-padding: 12px !important;
|
|
306
503
|
}
|
|
307
504
|
/* 右边缘再多留一点:宿主的 scrollArea 第三列是 inline-padding - 2px,
|
|
308
505
|
扣掉滚动条后文字几乎贴边,这里给工作区区域补 4px。 */
|
|
309
|
-
html[data-dcc-nav] [data-sidebar-scrollport] > [class*="_regionArea"] {
|
|
310
|
-
padding-right: 4px;
|
|
311
|
-
}
|
|
312
506
|
|
|
313
507
|
/* 折叠箭头:整行可点,高亮只画在中间那一小块 */
|
|
314
508
|
.dcc-nav-toggle {
|
|
@@ -366,12 +560,171 @@ html[data-dcc-radius="on"] [class*="_groupSection"] {
|
|
|
366
560
|
margin-top: 2px !important;
|
|
367
561
|
}
|
|
368
562
|
|
|
369
|
-
/*
|
|
370
|
-
|
|
563
|
+
/* 深色模式下正文不再用纯白:主文本压到 80%,次级文本同步压得更低,
|
|
564
|
+
否则主文本一降,和次级文本反而贴在一起,层次就没了。 */
|
|
371
565
|
html[data-dcc-text-dim="on"] body[data-ds-dark-theme] {
|
|
372
566
|
--dsw-alias-label-primary: rgba(255, 255, 255, .8) !important;
|
|
567
|
+
--dsw-alias-label-secondary: rgba(255, 255, 255, .52) !important;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/* 关掉动画开关时,只掐掉「消失」这一段:宿主在 dismiss 阶段会做淡出,
|
|
571
|
+
这里让它瞬间结束。菜单项的 hover 等其余过渡保持原样。 */
|
|
572
|
+
html[data-dcc-transition="off"] [data-menu-phase="dismiss"],
|
|
573
|
+
html[data-dcc-transition="off"] [data-menu-phase="dismiss"] * {
|
|
574
|
+
transition: none !important;
|
|
575
|
+
animation: none !important;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/* 禁用菜单的毛玻璃:宿主那层模糊聊胜于无,关掉之后弹层改用不透明底色,
|
|
579
|
+
既省掉合成开销,也让动画期间不再需要额外的兜底背景。 */
|
|
580
|
+
html[data-dcc-menu-blur="on"] [data-menu-material],
|
|
581
|
+
html[data-dcc-menu-blur="on"] [data-menu-material] *,
|
|
582
|
+
html[data-dcc-menu-blur="on"] [role="dialog"],
|
|
583
|
+
html[data-dcc-menu-blur="on"] [role="listbox"],
|
|
584
|
+
html[data-dcc-menu-blur="on"] [role="menu"] {
|
|
585
|
+
backdrop-filter: none !important;
|
|
586
|
+
-webkit-backdrop-filter: none !important;
|
|
587
|
+
}
|
|
588
|
+
/* 模糊没了就得有实底,否则会透出后面的内容。
|
|
589
|
+
上下文用量这类弹层不是 data-menu-material,用 role 兜住。 */
|
|
590
|
+
html[data-dcc-menu-blur="on"] [data-menu-material],
|
|
591
|
+
html[data-dcc-menu-blur="on"] [role="dialog"],
|
|
592
|
+
html[data-dcc-menu-blur="on"] [role="listbox"],
|
|
593
|
+
html[data-dcc-menu-blur="on"] [role="menu"] {
|
|
594
|
+
background-color: var(--dsw-alias-bg-layer-1) !important;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/* 禁用模糊后弹层本身已是不透明底,动画就不该再去动 background-color——
|
|
598
|
+
否则 keyframes 的 transparent 会盖掉实底,动画结束才回落,看起来就是闪一下。
|
|
599
|
+
所以这套场景单独用一组不带背景色的关键帧。 */
|
|
600
|
+
@keyframes dcc-fade-out {
|
|
601
|
+
from { opacity: 1; }
|
|
602
|
+
to { opacity: 0; }
|
|
603
|
+
}
|
|
604
|
+
@keyframes dcc-fade-in {
|
|
605
|
+
from { opacity: 0; }
|
|
606
|
+
to { opacity: 1; }
|
|
607
|
+
}
|
|
608
|
+
@keyframes dcc-plain-in {
|
|
609
|
+
from {
|
|
610
|
+
opacity: 0;
|
|
611
|
+
transform: scale(.94);
|
|
612
|
+
}
|
|
613
|
+
to {
|
|
614
|
+
opacity: 1;
|
|
615
|
+
transform: none;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
@keyframes dcc-plain-out {
|
|
619
|
+
from {
|
|
620
|
+
opacity: 1;
|
|
621
|
+
transform: none;
|
|
622
|
+
}
|
|
623
|
+
to {
|
|
624
|
+
opacity: 0;
|
|
625
|
+
transform: scale(.96);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/* 兜底色:动画期间顶替失效的毛玻璃。各弹层的实际背景不一样,
|
|
630
|
+
统一一个 token 会对不齐,所以按「浅色/深色 × 是否带毛玻璃」分档微调。 */
|
|
631
|
+
html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) {
|
|
632
|
+
--dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
|
|
633
|
+
}
|
|
634
|
+
html[data-dcc-enabled="on"] body[data-ds-dark-theme] [data-menu-material] {
|
|
635
|
+
--dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 88%, #000);
|
|
636
|
+
}
|
|
637
|
+
html[data-dcc-enabled="on"] body[data-ds-dark-theme] :where([role="dialog"], [role="listbox"], [role="menu"]):not([data-menu-material]) {
|
|
638
|
+
--dcc-menu-fallback: color-mix(in oklab, var(--dsw-alias-bg-layer-1) 82%, #fff);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/* 禁用悬停卡片时直接隐藏卡片本体。
|
|
642
|
+
新版的卡片是预渲染的常驻节点,悬停时只改 left/top 不改结构,
|
|
643
|
+
所以拦事件没有用;它带 --dsh-hover-preview-fade 这个专有变量,用它精确定位。 */
|
|
644
|
+
html[data-dcc-hover="off"] [class*="_card_"][style*="--dsh-hover-preview-fade"],
|
|
645
|
+
html[data-dcc-hover="off"] [class*="_card_"][data-closing] {
|
|
646
|
+
display: none !important;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/* 快照里的遮罩不要重播淡入——它是退场快照的一部分,
|
|
650
|
+
应该跟着外层一起淡出,否则看起来遮罩一直不消失。 */
|
|
651
|
+
/* 特异性必须压过下面那条入场规则,否则快照里的遮罩会重播淡入、闪出白底。
|
|
652
|
+
不要改它的定位——原遮罩只盖标题栏以下,铺满视口会盖住标题区。 */
|
|
653
|
+
html[data-dcc-transition="on"] [data-dcc-dialog-clone] [class*="_mask"] {
|
|
654
|
+
animation: none !important;
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/* 压暗遮罩的入场:从透明淡到实,时长与退场的 dcc-fade-out 对齐。
|
|
658
|
+
带 !important,避免被其他插件的通配符动效规则压平。 */
|
|
659
|
+
html[data-dcc-transition="on"] [class*="_mask"] {
|
|
660
|
+
animation: dcc-fade-in .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
/* 菜单出现/消失:整体从点击处缩放。
|
|
664
|
+
transform 会让同元素的 backdrop-filter 在动画期间失效,所以动画期间
|
|
665
|
+
用一层近似底色的背景兜住,避免那 130ms 出现「透明」的观感。 */
|
|
666
|
+
html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="enter"] {
|
|
667
|
+
transform-origin: var(--dcc-menu-origin, 50% 50%);
|
|
668
|
+
animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
669
|
+
}
|
|
670
|
+
html[data-dcc-transition="on"] [data-menu-material][data-menu-phase="dismiss"] {
|
|
671
|
+
transform-origin: var(--dcc-menu-origin, 50% 50%);
|
|
672
|
+
animation: dcc-menu-out .12s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards !important;
|
|
673
|
+
}
|
|
674
|
+
/* 子菜单、列表选择器这些没有 data-menu-phase 的弹出层,
|
|
675
|
+
用 role 单独命中,套同一组入场动画。对话框单独处理:
|
|
676
|
+
窗口从中心缩放,不跟随点击位置。 */
|
|
677
|
+
html[data-dcc-transition="on"] [role="menu"]:not([data-menu-phase]),
|
|
678
|
+
html[data-dcc-transition="on"] [role="listbox"]:not([data-menu-phase]) {
|
|
679
|
+
transform-origin: var(--dcc-menu-origin, left center);
|
|
680
|
+
animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
681
|
+
}
|
|
682
|
+
html[data-dcc-transition="on"] [role="dialog"]:not([data-menu-phase]) {
|
|
683
|
+
transform-origin: 50% 50%;
|
|
684
|
+
animation: dcc-menu-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) !important;
|
|
685
|
+
}
|
|
686
|
+
/* animation 简写会把 name 重置回 dcc-menu-in,所以这条必须写在它之后 */
|
|
687
|
+
html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="enter"],
|
|
688
|
+
html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"],
|
|
689
|
+
html[data-dcc-menu-blur="on"] [role="menu"]:not([data-menu-phase]),
|
|
690
|
+
html[data-dcc-menu-blur="on"] [role="listbox"]:not([data-menu-phase]),
|
|
691
|
+
html[data-dcc-menu-blur="on"] [role="dialog"]:not([data-menu-phase]) {
|
|
692
|
+
animation-name: dcc-plain-in !important;
|
|
693
|
+
}
|
|
694
|
+
html[data-dcc-menu-blur="on"] [data-menu-material][data-menu-phase="dismiss"] {
|
|
695
|
+
animation-name: dcc-plain-out !important;
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
@keyframes dcc-menu-in {
|
|
700
|
+
/* 缩放幅度保持 6%:再大宿主按 rect 算子菜单位置就会偏出去 */
|
|
701
|
+
from {
|
|
702
|
+
opacity: 0;
|
|
703
|
+
transform: scale(.94);
|
|
704
|
+
background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
|
|
705
|
+
}
|
|
706
|
+
to {
|
|
707
|
+
opacity: 1;
|
|
708
|
+
/* 必须是 none 而不是 scale(1):任何非 none 的 transform 都会创建包含块,
|
|
709
|
+
position: fixed 的后代(子菜单)会改为相对它定位,长菜单因此错位。 */
|
|
710
|
+
transform: none;
|
|
711
|
+
background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
@keyframes dcc-menu-out {
|
|
715
|
+
from {
|
|
716
|
+
opacity: 1;
|
|
717
|
+
transform: none;
|
|
718
|
+
background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
|
|
719
|
+
}
|
|
720
|
+
to {
|
|
721
|
+
opacity: 0;
|
|
722
|
+
transform: scale(.96);
|
|
723
|
+
background-color: var(--dcc-menu-fallback, var(--dsw-alias-bg-layer-1));
|
|
724
|
+
}
|
|
373
725
|
}
|
|
374
726
|
|
|
727
|
+
|
|
375
728
|
/* ---------- 工作区名称更明显,「展开其余」更淡 ---------- */
|
|
376
729
|
html[data-dcc-dim="on"] [class*="_projectRow"] [class*="_title"] {
|
|
377
730
|
color: var(--dsw-alias-label-primary) !important;
|
|
@@ -406,7 +759,7 @@ html[data-dcc-dot="on"] [class*="_sessionRow"]:has(.dsham_starSlot[data-favorite
|
|
|
406
759
|
}
|
|
407
760
|
/* 未收藏时的空心星(悬停才出现):压到与会话标题同色,不再用偏亮的 label-primary。
|
|
408
761
|
已收藏的实心金星保持 archive-manager 原色,不做处理。 */
|
|
409
|
-
html [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) .dsham_rowStar {
|
|
762
|
+
html[data-dcc-enabled="on"] [class*="_sessionRow"] .dsham_starSlot:not([data-favorited="true"]) .dsham_rowStar {
|
|
410
763
|
color: var(--dsw-alias-label-secondary) !important;
|
|
411
764
|
}
|
|
412
765
|
/* 「展开其余 N 个会话 / 收起」比工作区标题更淡 */
|
|
@@ -420,10 +773,10 @@ html[data-dcc-dim="on"] [class*="_sessionOverflowButton"]:hover {
|
|
|
420
773
|
|
|
421
774
|
/* ---------- 工作区行:悬停时不换成展开箭头,保持文件夹图标 ---------- */
|
|
422
775
|
/* 宿主默认:hover 时 .chevron 显示、.folder 隐藏(Rows.module.css)。这里反着压回去。 */
|
|
423
|
-
html [class*="_projectRow"]:hover [class*="_folder"] {
|
|
776
|
+
html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_folder"] {
|
|
424
777
|
display: inline-flex !important;
|
|
425
778
|
}
|
|
426
|
-
html [class*="_projectRow"]:hover [class*="_chevron"] {
|
|
779
|
+
html[data-dcc-enabled="on"] [class*="_projectRow"]:hover [class*="_chevron"] {
|
|
427
780
|
display: none !important;
|
|
428
781
|
}
|
|
429
782
|
|
|
@@ -481,6 +834,12 @@ html[data-dcc-hover="off"] [class*="_bridge_bgejw"] {
|
|
|
481
834
|
html[data-dcc-row-buttons="on"] [class*="_sessionRow"] [class*="_rowActions"] button[data-dcc-hidden] {
|
|
482
835
|
display: none !important;
|
|
483
836
|
}
|
|
837
|
+
/* 兜底:不等脚本标记,按按钮身份直接隐藏。
|
|
838
|
+
悬停行时「菜单」和「置顶」保留,其余立刻不可见——
|
|
839
|
+
脚本晚一拍也不会先闪出一排按钮。 */
|
|
840
|
+
html[data-dcc-row-buttons="on"] [class*="_sessionRow"]:hover [class*="_rowActions"] button:not([data-context-menu-trigger]):not([aria-label*="置顶"]):not([aria-label*="pin" i]):not([aria-label*="取消置顶"]):not([aria-label*="unpin" i]) {
|
|
841
|
+
display: none !important;
|
|
842
|
+
}
|
|
484
843
|
|
|
485
844
|
/* ---------- 会话标题栏紧凑化:标签行并入顶部工具区 ---------- */
|
|
486
845
|
/* 注意不能 display:none:宿主按标签行的 clientWidth 计算「能显示几个视图」,
|
|
@@ -509,64 +868,160 @@ html[data-dcc-compact-header="on"] [class*="_header"]:has([data-conversation-tab
|
|
|
509
868
|
这一条不受「会话标题栏紧凑化」开关控制——用户关掉「轨迹」后标题栏本来就矮,
|
|
510
869
|
没有标签行可压,但那根线依然不该出现。用 headerUtilities 而不是 tabs 定位,
|
|
511
870
|
保证两种形态(有/无标签行)都能命中。 */
|
|
512
|
-
|
|
871
|
+
/* 标题栏去掉硬分割线,改用内容顶部的柔边过渡 */
|
|
872
|
+
html[data-dcc-enabled="on"][data-dcc-header-fade="on"] [class*="_header"]:has([class*="_headerUtilities"]) {
|
|
513
873
|
border-bottom: none !important;
|
|
514
874
|
}
|
|
515
875
|
/* 顶部柔边只给「对话」用:轨迹视图整块都是界面,渐隐会吃掉它自己的表头。
|
|
516
876
|
轨道上没有 data-view 之类的标记,只能借标签页的选中态判断——
|
|
517
877
|
第一个 tab 就是「对话」,它 aria-selected 时才挂 mask。 */
|
|
518
|
-
html:has([data-conversation-tabs] [role="tab"]:first-child[aria-selected="true"]) [data-conversation-scroll] {
|
|
878
|
+
html[data-dcc-enabled="on"][data-dcc-header-fade="on"]:has([data-conversation-tabs] [role="tab"]:first-child[aria-selected="true"]) [data-conversation-scroll] {
|
|
519
879
|
-webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
|
|
520
880
|
mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
|
|
521
881
|
}
|
|
522
|
-
|
|
882
|
+
/* 宿主自带的「更多」按钮:只在紧凑化开启时隐藏——那时标签行被本插件的
|
|
883
|
+
下拉按钮取代,宿主这个按钮用不上。紧凑化关闭时标签行是原版的,
|
|
884
|
+
这个按钮必须留着,否则视图被裁掉后无法访问。 */
|
|
885
|
+
html[data-dcc-enabled="on"][data-dcc-compact-header="on"] [class*="_viewsMoreAnchor"] {
|
|
523
886
|
display: none !important;
|
|
524
887
|
}
|
|
525
888
|
/* 开关关掉时,自绘的分段控件不出现,标签行恢复原样 */
|
|
526
889
|
html[data-dcc-compact-header="off"] .dcc-segmented {
|
|
527
890
|
display: none !important;
|
|
528
891
|
}
|
|
529
|
-
/*
|
|
530
|
-
圆角用 sm(8px) 而不是 md(12px),描边用更浅的 l1。 */
|
|
892
|
+
/* 视图控件:一个普通的下拉按钮(当前视图名 + 箭头),点整块展开菜单。 */
|
|
531
893
|
.dcc-segmented {
|
|
532
894
|
box-sizing: border-box;
|
|
533
895
|
display: inline-flex;
|
|
534
896
|
align-items: stretch;
|
|
535
897
|
height: 24px;
|
|
536
|
-
|
|
537
|
-
视觉上边界内缩、显得比别的元素远一点,补 2px 回来 */
|
|
898
|
+
flex: none;
|
|
538
899
|
margin-right: 2px;
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
900
|
+
opacity: 0;
|
|
901
|
+
transition: opacity .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
|
|
902
|
+
}
|
|
903
|
+
/* 悬停整个标题栏区域时浮现;鼠标直接落在控件上也保持可见 */
|
|
904
|
+
[class*="_header"]:hover .dcc-segmented,
|
|
905
|
+
.dcc-segmented:hover,
|
|
906
|
+
.dcc-segmented:focus-within {
|
|
907
|
+
opacity: 1;
|
|
908
|
+
}
|
|
909
|
+
/* 不在「对话」视图时,控件常驻显示当前视图名 */
|
|
910
|
+
/* 开关打开时,对话视图下也不再自动隐藏 */
|
|
911
|
+
html[data-dcc-always-show="on"] .dcc-segmented {
|
|
912
|
+
opacity: 1;
|
|
913
|
+
}
|
|
914
|
+
.dcc-segmented[data-pinned="true"] {
|
|
915
|
+
opacity: 1;
|
|
544
916
|
}
|
|
545
|
-
.dcc-
|
|
917
|
+
.dcc-trigger {
|
|
546
918
|
display: inline-flex;
|
|
547
919
|
align-items: center;
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
920
|
+
gap: 6px;
|
|
921
|
+
height: 24px;
|
|
922
|
+
/* 左边多给 2px:右侧有箭头撑着,等宽内边距会让左边缘显得更挤 */
|
|
923
|
+
padding: 0 6px 0 8px;
|
|
924
|
+
border: 0.5px solid var(--dsw-alias-border-l4);
|
|
925
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
926
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
927
|
+
color: var(--dsw-alias-label-secondary);
|
|
551
928
|
font: inherit;
|
|
552
929
|
font-size: 12px;
|
|
553
930
|
line-height: 1;
|
|
554
|
-
|
|
931
|
+
white-space: nowrap;
|
|
555
932
|
cursor: pointer;
|
|
556
933
|
transition: background-color .12s, color .12s;
|
|
557
934
|
}
|
|
558
|
-
.dcc-
|
|
559
|
-
|
|
935
|
+
.dcc-trigger:hover {
|
|
936
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
937
|
+
color: var(--dsw-alias-label-primary);
|
|
560
938
|
}
|
|
561
|
-
.dcc-
|
|
939
|
+
.dcc-trigger[data-open="true"] {
|
|
562
940
|
background: var(--dsw-alias-interactive-bg-hover);
|
|
563
941
|
color: var(--dsw-alias-label-primary);
|
|
564
942
|
}
|
|
565
|
-
.dcc-
|
|
943
|
+
.dcc-trigger-label {
|
|
944
|
+
max-width: 120px;
|
|
945
|
+
overflow: hidden;
|
|
946
|
+
text-overflow: ellipsis;
|
|
947
|
+
}
|
|
948
|
+
.dcc-trigger-arrow {
|
|
949
|
+
display: block;
|
|
950
|
+
width: 12px;
|
|
951
|
+
height: 12px;
|
|
952
|
+
flex: none;
|
|
953
|
+
transition: transform .15s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1));
|
|
954
|
+
}
|
|
955
|
+
.dcc-trigger[data-open="true"] .dcc-trigger-arrow {
|
|
956
|
+
transform: rotate(180deg);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/* 溢出菜单:对齐宿主菜单的尺寸与层级(圆角 12、内距 6、项高 32、项圆角 8) */
|
|
960
|
+
.dcc-seg-menu {
|
|
961
|
+
position: fixed;
|
|
962
|
+
z-index: 2147483000;
|
|
963
|
+
min-width: 140px;
|
|
964
|
+
padding: 6px;
|
|
965
|
+
border-radius: var(--dsw-radius-md, 12px);
|
|
966
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
967
|
+
box-shadow:
|
|
968
|
+
0 0 0 1px var(--dsw-alias-border-l2),
|
|
969
|
+
0 10px 32px rgba(0, 0, 0, .24);
|
|
970
|
+
display: flex;
|
|
971
|
+
flex-direction: column;
|
|
972
|
+
gap: 2px;
|
|
973
|
+
}
|
|
974
|
+
.dcc-seg-menu-item {
|
|
975
|
+
display: flex;
|
|
976
|
+
align-items: center;
|
|
977
|
+
justify-content: space-between;
|
|
978
|
+
gap: 16px;
|
|
979
|
+
height: 32px;
|
|
980
|
+
padding: 0 12px;
|
|
981
|
+
border: 0;
|
|
982
|
+
border-radius: var(--dsw-radius-sm, 8px);
|
|
566
983
|
background: transparent;
|
|
984
|
+
color: var(--dsw-alias-label-primary);
|
|
985
|
+
font: inherit;
|
|
986
|
+
font-size: 13px;
|
|
987
|
+
line-height: 32px;
|
|
988
|
+
text-align: left;
|
|
989
|
+
white-space: nowrap;
|
|
990
|
+
cursor: pointer;
|
|
991
|
+
}
|
|
992
|
+
.dcc-seg-menu-label {
|
|
993
|
+
min-width: 0;
|
|
994
|
+
overflow: hidden;
|
|
995
|
+
text-overflow: ellipsis;
|
|
996
|
+
}
|
|
997
|
+
.dcc-seg-menu-check {
|
|
998
|
+
flex: none;
|
|
999
|
+
width: 14px;
|
|
1000
|
+
height: 14px;
|
|
1001
|
+
opacity: 0;
|
|
1002
|
+
color: var(--dsw-alias-state-business-primary);
|
|
1003
|
+
}
|
|
1004
|
+
.dcc-seg-menu-check::before {
|
|
1005
|
+
content: '';
|
|
1006
|
+
display: block;
|
|
1007
|
+
width: 100%;
|
|
1008
|
+
height: 100%;
|
|
1009
|
+
background-color: currentColor;
|
|
1010
|
+
-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.2 11.7 13 4.9' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
1011
|
+
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8.5 6.2 11.7 13 4.9' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
|
|
1012
|
+
-webkit-mask-size: contain;
|
|
1013
|
+
mask-size: contain;
|
|
1014
|
+
}
|
|
1015
|
+
.dcc-seg-menu-item[data-active="true"] .dcc-seg-menu-check {
|
|
1016
|
+
opacity: 1;
|
|
1017
|
+
}
|
|
1018
|
+
.dcc-seg-menu-item[data-active="true"] {
|
|
567
1019
|
color: var(--dsw-alias-state-business-primary);
|
|
568
1020
|
font-weight: 500;
|
|
569
1021
|
}
|
|
1022
|
+
.dcc-seg-menu-item:hover {
|
|
1023
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
1024
|
+
}
|
|
570
1025
|
|
|
571
1026
|
/* ---------- 输入框下方状态行:速率/缓存靠左,上下文环推到最右 ---------- */
|
|
572
1027
|
/* 宿主的 _dock 只有 280px 宽且居中,里面是两个子项:左边的胶囊组和包着环的
|
|
@@ -763,7 +1218,7 @@ html[data-dcc-select="on"] body [class*="_crumb"] * {
|
|
|
763
1218
|
}
|
|
764
1219
|
|
|
765
1220
|
/* ---------- 已归档会话:标题画删除线 ---------- */
|
|
766
|
-
html [class*="_sessionRow"][class*="_archived"] [class*="_title"] {
|
|
1221
|
+
html[data-dcc-enabled="on"] [class*="_sessionRow"][class*="_archived"] [class*="_title"] {
|
|
767
1222
|
text-decoration: line-through;
|
|
768
1223
|
text-decoration-thickness: 1px;
|
|
769
1224
|
}
|
|
@@ -778,24 +1233,25 @@ html[data-dcc-dot="on"] body[data-ds-dark-theme] [class*="_sessionRow"]::before
|
|
|
778
1233
|
opacity: .28;
|
|
779
1234
|
}
|
|
780
1235
|
/* 浅色主题下导航 hover 与新会话常规底色略微加强 */
|
|
781
|
-
body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
|
|
782
|
-
box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .035) !important;
|
|
783
|
-
}
|
|
784
1236
|
/* 浅色主题下选中会话的背景再强一点 */
|
|
785
|
-
body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
|
|
1237
|
+
html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) [class*="_sessionRow"][class*="_selected"] {
|
|
786
1238
|
box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .04) !important;
|
|
787
1239
|
}
|
|
788
1240
|
|
|
789
|
-
/*
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
box-shadow: inset 0 0 0 999px rgba(
|
|
1241
|
+
/* 导航行:悬停弱、选中强。
|
|
1242
|
+
宿主的激活标记不在行类名上,而是按钮的 aria-current="page",
|
|
1243
|
+
所以悬停作用在 :hover、选中作用在 [aria-current="page"],两者叠出来才有层次。 */
|
|
1244
|
+
html[data-dcc-enabled="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"]:hover {
|
|
1245
|
+
box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .05) !important;
|
|
794
1246
|
}
|
|
795
|
-
html[data-dcc-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
1247
|
+
html[data-dcc-enabled="on"] body[data-ds-dark-theme] nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
|
|
1248
|
+
box-shadow: inset 0 0 0 999px rgba(255, 255, 255, .16) !important;
|
|
1249
|
+
}
|
|
1250
|
+
html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"]:hover {
|
|
1251
|
+
box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .025) !important;
|
|
1252
|
+
}
|
|
1253
|
+
html[data-dcc-enabled="on"] body:not([data-ds-dark-theme]) nav[class*="_panelList"] [class*="_panelRow"][aria-current="page"] {
|
|
1254
|
+
box-shadow: inset 0 0 0 999px rgba(0, 0, 0, .07) !important;
|
|
799
1255
|
}
|
|
800
1256
|
|
|
801
1257
|
/* ---------- 设置面板:全屏(避开 Electron 标题栏)+ 标题左侧返回按钮 ---------- */
|
|
@@ -910,7 +1366,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
910
1366
|
const entryClasses = entry === null
|
|
911
1367
|
? []
|
|
912
1368
|
: [...entry.classList].filter((name) => name.includes('_panelEntry'));
|
|
913
|
-
clone.className = [...row.classList].
|
|
1369
|
+
clone.className = [...row.classList].join(' ')
|
|
914
1370
|
+ ' dcc-newrow'
|
|
915
1371
|
+ (entryClasses.length > 0 ? ' ' + entryClasses.join(' ') : '');
|
|
916
1372
|
const aria = orig.getAttribute('aria-label');
|
|
@@ -940,7 +1396,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
940
1396
|
if (nav === null || orig === null) return false;
|
|
941
1397
|
/* 开关关掉时彻底还原:移除克隆行、去掉原按钮上的标记,
|
|
942
1398
|
让它回到宿主本来的样子,而不是仅靠 CSS 隐藏 */
|
|
943
|
-
if (document.documentElement.dataset.dccNew !== 'on') {
|
|
1399
|
+
if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccNew !== 'on') {
|
|
944
1400
|
if (clone !== null) {
|
|
945
1401
|
clone.remove();
|
|
946
1402
|
clone = null;
|
|
@@ -1017,8 +1473,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1017
1473
|
};
|
|
1018
1474
|
|
|
1019
1475
|
/**
|
|
1020
|
-
*
|
|
1021
|
-
*
|
|
1476
|
+
* 按钮垂直位置按「标题文字的实际矩形」算——容器带 padding 时,
|
|
1477
|
+
* 盒子中心和文字中心并不重合。
|
|
1478
|
+
* 入场动画会给面板挂 transform,rect 是缩放后的,所以再除以缩放比
|
|
1479
|
+
* 还原成布局坐标,动画前后算出来的值才一致。
|
|
1022
1480
|
*/
|
|
1023
1481
|
const align = () => {
|
|
1024
1482
|
if (btn === null || !btn.isConnected || btn.offsetParent === null) return;
|
|
@@ -1029,8 +1487,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1029
1487
|
const rects = range.getClientRects();
|
|
1030
1488
|
if (rects.length === 0) return;
|
|
1031
1489
|
const textRect = rects[0];
|
|
1032
|
-
const
|
|
1033
|
-
const
|
|
1490
|
+
const panel = btn.offsetParent;
|
|
1491
|
+
const panelRect = panel.getBoundingClientRect();
|
|
1492
|
+
const scale = panel.offsetHeight > 0 ? panelRect.height / panel.offsetHeight : 1;
|
|
1493
|
+
const centerY = (textRect.top + textRect.height / 2 - panelRect.top) / (scale > 0 ? scale : 1);
|
|
1034
1494
|
btn.style.top = `${Math.round(centerY - btn.offsetHeight / 2)}px`;
|
|
1035
1495
|
};
|
|
1036
1496
|
|
|
@@ -1040,6 +1500,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1040
1500
|
};
|
|
1041
1501
|
|
|
1042
1502
|
const ensure = () => {
|
|
1503
|
+
/* 总开关关闭时自绘按钮也要撤掉,否则会留下一个没有样式的裸按钮 */
|
|
1504
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') {
|
|
1505
|
+
if (btn !== null) btn.remove();
|
|
1506
|
+
btn = null;
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1043
1509
|
const panel = findPanel();
|
|
1044
1510
|
if (panel === null) {
|
|
1045
1511
|
if (btn !== null) btn.remove();
|
|
@@ -1155,8 +1621,14 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1155
1621
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
1156
1622
|
document.addEventListener('click', onClick, true);
|
|
1157
1623
|
document.addEventListener('mousemove', onMove, true);
|
|
1624
|
+
/* 设置面板全屏 / 窗口模式切换后,返回按钮要重新对齐位置 */
|
|
1625
|
+
const onPrefs = (event) => {
|
|
1626
|
+
if (event.detail && event.detail.key === 'settingsFullscreen') ensure();
|
|
1627
|
+
};
|
|
1628
|
+
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
1158
1629
|
|
|
1159
1630
|
return () => {
|
|
1631
|
+
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
1160
1632
|
observer.disconnect();
|
|
1161
1633
|
if (timer !== null) clearTimeout(timer);
|
|
1162
1634
|
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
@@ -1199,6 +1671,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1199
1671
|
早先还挂了一个 MutationObserver 定期全量扫描,滚动时虚拟列表频繁改 DOM,
|
|
1200
1672
|
每 400ms 扫一遍所有会话行,反而成了新的卡顿源,已移除。 */
|
|
1201
1673
|
const onPointer = (event) => {
|
|
1674
|
+
/* 总开关关闭时,把之前打上的隐藏标记全部撤掉 */
|
|
1675
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') {
|
|
1676
|
+
const marked = document.querySelectorAll('[data-dcc-hidden]');
|
|
1677
|
+
for (const el of marked) el.removeAttribute('data-dcc-hidden');
|
|
1678
|
+
return;
|
|
1679
|
+
}
|
|
1202
1680
|
if (document.documentElement.dataset.dccRowButtons !== 'on') return;
|
|
1203
1681
|
const target = event.target;
|
|
1204
1682
|
if (!(target instanceof Element)) return;
|
|
@@ -1208,9 +1686,18 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1208
1686
|
filterRow(row);
|
|
1209
1687
|
};
|
|
1210
1688
|
|
|
1689
|
+
/* 开关切换后立刻撤掉/重建标记,不必等鼠标再划过去 */
|
|
1690
|
+
const onPrefs = (event) => {
|
|
1691
|
+
if (!event.detail || event.detail.key !== 'hideRowButtons') return;
|
|
1692
|
+
const marked = document.querySelectorAll('[data-dcc-hidden]');
|
|
1693
|
+
for (const el of marked) el.removeAttribute('data-dcc-hidden');
|
|
1694
|
+
lastRow = null;
|
|
1695
|
+
};
|
|
1696
|
+
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
1211
1697
|
document.addEventListener('pointerover', onPointer, true);
|
|
1212
1698
|
document.addEventListener('focusin', onPointer, true);
|
|
1213
1699
|
return () => {
|
|
1700
|
+
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
1214
1701
|
document.removeEventListener('pointerover', onPointer, true);
|
|
1215
1702
|
document.removeEventListener('focusin', onPointer, true);
|
|
1216
1703
|
const marked = document.querySelectorAll('[data-dcc-hidden]');
|
|
@@ -1227,8 +1714,11 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1227
1714
|
*/
|
|
1228
1715
|
function installHoverCardBlocker() {
|
|
1229
1716
|
const ROW = '[class*="_sessionRow"], [class*="_projectRow"], [class*="_searchResultRow"]';
|
|
1717
|
+
/* 最近一次「进入行」的时间戳,供下面的定时器过滤使用 */
|
|
1718
|
+
let lastRowHoverAt = 0;
|
|
1230
1719
|
|
|
1231
1720
|
const onOver = (event) => {
|
|
1721
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') return;
|
|
1232
1722
|
if (document.documentElement.dataset.dccHover !== 'off') return;
|
|
1233
1723
|
const target = event.target;
|
|
1234
1724
|
if (!(target instanceof Element)) return;
|
|
@@ -1237,13 +1727,59 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1237
1727
|
/* 已经在行内移动,不是「进入」,放行给宿主 */
|
|
1238
1728
|
const related = event.relatedTarget;
|
|
1239
1729
|
if (related instanceof Node && row.contains(related)) return;
|
|
1240
|
-
|
|
1730
|
+
lastRowHoverAt = Date.now();
|
|
1731
|
+
/* 用 stopImmediatePropagation 而不是 stopPropagation:
|
|
1732
|
+
宿主的悬停计时器只要收到「进入」就会挂上,同层的监听器也得一并掐断。 */
|
|
1733
|
+
event.stopImmediatePropagation();
|
|
1734
|
+
};
|
|
1735
|
+
|
|
1736
|
+
/* 宿主是在「进入行」之后用 setTimeout 排一个延迟,到点才真的取数并渲染。
|
|
1737
|
+
事件层抢不过它的注册顺序,所以改从这里掐:只丢弃悬停进入后极短时间内
|
|
1738
|
+
注册、且延迟落在该区间里的那一个,其余定时器全部放行。 */
|
|
1739
|
+
const originalSetTimeout = window.setTimeout;
|
|
1740
|
+
const patchedSetTimeout = function (fn, delay, ...rest) {
|
|
1741
|
+
if (document.documentElement.dataset.dccHover === 'off'
|
|
1742
|
+
&& typeof delay === 'number'
|
|
1743
|
+
&& delay >= 300 && delay <= 2000
|
|
1744
|
+
&& Date.now() - lastRowHoverAt < 400) {
|
|
1745
|
+
return 0;
|
|
1746
|
+
}
|
|
1747
|
+
return originalSetTimeout.call(this, fn, delay, ...rest);
|
|
1748
|
+
};
|
|
1749
|
+
window.setTimeout = patchedSetTimeout;
|
|
1750
|
+
const onMove = (event) => {
|
|
1751
|
+
if (document.documentElement.dataset.dccHover !== 'off') return;
|
|
1752
|
+
const target = event.target;
|
|
1753
|
+
if (!(target instanceof Element)) return;
|
|
1754
|
+
if (target.closest(ROW) === null) return;
|
|
1755
|
+
/* 行内移动也要刷新时间戳:宿主随时可能因为一次移动重新排上延迟调用,
|
|
1756
|
+
只在「进入」时记一次的话,停留久了时间戳过期,定时器就漏过去了。 */
|
|
1757
|
+
lastRowHoverAt = Date.now();
|
|
1758
|
+
event.stopImmediatePropagation();
|
|
1241
1759
|
};
|
|
1242
1760
|
|
|
1243
1761
|
/* 放在 window 捕获阶段:这是事件流最早的位置,先于 React 挂在 root 容器上的
|
|
1244
|
-
onPointerOverCapture,才能保证宿主那一层完全收不到「进入行」这件事。
|
|
1762
|
+
onPointerOverCapture,才能保证宿主那一层完全收不到「进入行」这件事。
|
|
1763
|
+
新版悬停卡片还会用 pointerenter / mouseenter 那条路径,一并截住。
|
|
1764
|
+
document 上再挂一层,覆盖宿主把监听挂在 document 的情况。 */
|
|
1245
1765
|
window.addEventListener('pointerover', onOver, true);
|
|
1246
|
-
|
|
1766
|
+
window.addEventListener('pointerenter', onOver, true);
|
|
1767
|
+
window.addEventListener('mouseenter', onOver, true);
|
|
1768
|
+
window.addEventListener('pointermove', onMove, true);
|
|
1769
|
+
window.addEventListener('mousemove', onMove, true);
|
|
1770
|
+
document.addEventListener('pointerover', onOver, true);
|
|
1771
|
+
document.addEventListener('pointermove', onMove, true);
|
|
1772
|
+
return () => {
|
|
1773
|
+
/* 还原 setTimeout,避免插件卸载后仍影响全局定时器 */
|
|
1774
|
+
if (window.setTimeout === patchedSetTimeout) window.setTimeout = originalSetTimeout;
|
|
1775
|
+
window.removeEventListener('pointerover', onOver, true);
|
|
1776
|
+
window.removeEventListener('pointerenter', onOver, true);
|
|
1777
|
+
window.removeEventListener('mouseenter', onOver, true);
|
|
1778
|
+
window.removeEventListener('pointermove', onMove, true);
|
|
1779
|
+
window.removeEventListener('mousemove', onMove, true);
|
|
1780
|
+
document.removeEventListener('pointerover', onOver, true);
|
|
1781
|
+
document.removeEventListener('pointermove', onMove, true);
|
|
1782
|
+
};
|
|
1247
1783
|
}
|
|
1248
1784
|
|
|
1249
1785
|
/**
|
|
@@ -1255,69 +1791,227 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1255
1791
|
let bar = null;
|
|
1256
1792
|
let observer = null;
|
|
1257
1793
|
let timer = null;
|
|
1794
|
+
/* 正在淡出的旧控件被临时挂到 body 上,卸载时要一起收走 */
|
|
1795
|
+
const ghosts = new Set();
|
|
1258
1796
|
|
|
1259
1797
|
const findTabs = () => document.querySelector('[data-conversation-tabs]');
|
|
1260
1798
|
const findHost = () => document.querySelector('[class*="_headerUtilities"]');
|
|
1799
|
+
/* 视图控件始终折叠:只显示「当前激活」+「⋯」,其余收进菜单。 */
|
|
1800
|
+
let segMenu = null;
|
|
1801
|
+
let segMenuGuard = null;
|
|
1802
|
+
let segMenuAnchor = null;
|
|
1803
|
+
const closeSegMenu = () => {
|
|
1804
|
+
if (segMenu !== null) {
|
|
1805
|
+
segMenu.remove();
|
|
1806
|
+
segMenu = null;
|
|
1807
|
+
}
|
|
1808
|
+
if (segMenuAnchor !== null) {
|
|
1809
|
+
segMenuAnchor.removeAttribute('data-open');
|
|
1810
|
+
/* 主动移除焦点:否则 :focus-within 会一直成立,鼠标移走后控件还留在那里 */
|
|
1811
|
+
if (typeof segMenuAnchor.blur === 'function') segMenuAnchor.blur();
|
|
1812
|
+
segMenuAnchor = null;
|
|
1813
|
+
}
|
|
1814
|
+
if (segMenuGuard !== null) {
|
|
1815
|
+
document.removeEventListener('pointerdown', segMenuGuard, true);
|
|
1816
|
+
segMenuGuard = null;
|
|
1817
|
+
}
|
|
1818
|
+
};
|
|
1261
1819
|
|
|
1262
1820
|
const syncActive = () => {
|
|
1263
1821
|
if (bar === null) return;
|
|
1264
1822
|
const tabs = findTabs();
|
|
1265
1823
|
if (tabs === null) return;
|
|
1266
1824
|
const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1825
|
+
const activeIndex = sources.findIndex((el) => el.getAttribute('aria-selected') === 'true');
|
|
1826
|
+
/* 按钮上显示当前视图名 */
|
|
1827
|
+
const label = bar.querySelector('.dcc-trigger-label');
|
|
1828
|
+
if (label !== null && sources[activeIndex] !== undefined) {
|
|
1829
|
+
const text = (sources[activeIndex].textContent || '').trim();
|
|
1830
|
+
if (label.textContent !== text) label.textContent = text;
|
|
1831
|
+
}
|
|
1832
|
+
/* 第一个视图(对话)之外的页面,控件要常驻显示当前视图名。
|
|
1833
|
+
宿主切视图的中间态可能一个选中项都没有(activeIndex 为 -1),
|
|
1834
|
+
这时保持上一次的状态,不要误判成「回到对话」而闪一下隐藏。 */
|
|
1835
|
+
if (activeIndex >= 0) {
|
|
1836
|
+
bar.dataset.pinned = activeIndex > 0 ? 'true' : 'false';
|
|
1272
1837
|
}
|
|
1273
1838
|
};
|
|
1274
1839
|
|
|
1275
1840
|
const build = (tabs, host) => {
|
|
1276
|
-
|
|
1841
|
+
/* 旧控件先淡出再移除,新控件从透明淡入——这样重建时是渐变而不是硬切 */
|
|
1842
|
+
if (bar !== null) {
|
|
1843
|
+
const old = bar;
|
|
1844
|
+
const rect = old.getBoundingClientRect();
|
|
1845
|
+
/* 控件已经被宿主摘掉时 rect 全是 0,照着定位会把它摆到窗口左上角。
|
|
1846
|
+
这种情况直接丢掉,不做淡出。 */
|
|
1847
|
+
/* 控件平时是隐藏的(opacity:0),只有标题栏被悬停时才可见。
|
|
1848
|
+
不可见时做淡出没有意义,反而会凭空闪一下,所以直接丢掉。 */
|
|
1849
|
+
const visible = old.isConnected && rect.width > 0
|
|
1850
|
+
&& window.getComputedStyle(old).opacity !== '0';
|
|
1851
|
+
if (!visible) {
|
|
1852
|
+
old.remove();
|
|
1853
|
+
} else {
|
|
1854
|
+
/* 把旧控件固定到原位置、脱离布局流再淡出——
|
|
1855
|
+
否则新旧两个都在标题栏里会互相挤动,看不出「淡出」这个动作。 */
|
|
1856
|
+
old.style.position = 'fixed';
|
|
1857
|
+
old.style.left = `${rect.left}px`;
|
|
1858
|
+
old.style.top = `${rect.top}px`;
|
|
1859
|
+
old.style.margin = '0';
|
|
1860
|
+
old.style.pointerEvents = 'none';
|
|
1861
|
+
old.style.zIndex = '1';
|
|
1862
|
+
document.body.appendChild(old);
|
|
1863
|
+
ghosts.add(old);
|
|
1864
|
+
window.requestAnimationFrame(() => {
|
|
1865
|
+
old.style.opacity = '0';
|
|
1866
|
+
});
|
|
1867
|
+
window.setTimeout(() => {
|
|
1868
|
+
old.remove();
|
|
1869
|
+
ghosts.delete(old);
|
|
1870
|
+
}, 300);
|
|
1871
|
+
}
|
|
1872
|
+
bar = null;
|
|
1873
|
+
}
|
|
1277
1874
|
bar = document.createElement('div');
|
|
1278
1875
|
bar.className = 'dcc-segmented';
|
|
1876
|
+
closeSegMenu();
|
|
1279
1877
|
const sources = Array.from(tabs.querySelectorAll('button[role="tab"]'));
|
|
1280
|
-
sources.
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1878
|
+
const activeIndex = sources.findIndex((el) => el.getAttribute('aria-selected') === 'true');
|
|
1879
|
+
|
|
1880
|
+
/* 把点击转发给宿主对应的标签按钮 */
|
|
1881
|
+
const forward = (index) => {
|
|
1882
|
+
const current = findTabs();
|
|
1883
|
+
if (current === null) return;
|
|
1884
|
+
const target = current.querySelectorAll('button[role="tab"]')[index];
|
|
1885
|
+
if (target !== undefined) target.click();
|
|
1886
|
+
};
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
/* 控件就是一个普通的下拉按钮:当前视图名 + 箭头,点整块展开菜单 */
|
|
1890
|
+
{
|
|
1891
|
+
const activeIdx = activeIndex >= 0 ? activeIndex : 0;
|
|
1892
|
+
const trigger = document.createElement('button');
|
|
1893
|
+
trigger.type = 'button';
|
|
1894
|
+
trigger.className = 'dcc-trigger';
|
|
1895
|
+
trigger.setAttribute('aria-haspopup', 'menu');
|
|
1896
|
+
const textNode = document.createElement('span');
|
|
1897
|
+
textNode.className = 'dcc-trigger-label';
|
|
1898
|
+
textNode.textContent = sources[activeIdx] === undefined
|
|
1899
|
+
? ''
|
|
1900
|
+
: (sources[activeIdx].textContent || '').trim();
|
|
1901
|
+
trigger.appendChild(textNode);
|
|
1902
|
+
|
|
1903
|
+
const arrow = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
1904
|
+
arrow.setAttribute('class', 'dcc-trigger-arrow');
|
|
1905
|
+
arrow.setAttribute('viewBox', '0 0 16 16');
|
|
1906
|
+
arrow.setAttribute('aria-hidden', 'true');
|
|
1907
|
+
const arrowPath = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
1908
|
+
arrowPath.setAttribute('d', 'M4 6.5 8 10.5 12 6.5');
|
|
1909
|
+
arrowPath.setAttribute('fill', 'none');
|
|
1910
|
+
arrowPath.setAttribute('stroke', 'currentColor');
|
|
1911
|
+
arrowPath.setAttribute('stroke-width', '1.6');
|
|
1912
|
+
arrowPath.setAttribute('stroke-linecap', 'round');
|
|
1913
|
+
arrowPath.setAttribute('stroke-linejoin', 'round');
|
|
1914
|
+
arrow.appendChild(arrowPath);
|
|
1915
|
+
trigger.appendChild(arrow);
|
|
1916
|
+
bar.appendChild(trigger);
|
|
1917
|
+
|
|
1918
|
+
const more = trigger;
|
|
1919
|
+
more.addEventListener('click', (event) => {
|
|
1920
|
+
event.stopPropagation();
|
|
1921
|
+
if (segMenu !== null) { closeSegMenu(); return; }
|
|
1922
|
+
const rect = bar.getBoundingClientRect();
|
|
1923
|
+
const menu = document.createElement('div');
|
|
1924
|
+
menu.className = 'dcc-seg-menu';
|
|
1925
|
+
/* 先插进 DOM 再量宽度,右边缘对齐到按钮右侧 —— 菜单宽度由内容决定,
|
|
1926
|
+
不能用固定值估算,否则会对不齐。 */
|
|
1927
|
+
/* 用 right 对齐按钮右边缘,不需要先量宽度——
|
|
1928
|
+
量宽度要读一次布局,会强制重排,表现为点击后慢半拍。 */
|
|
1929
|
+
menu.style.right = (window.innerWidth - rect.right) + 'px';
|
|
1930
|
+
menu.style.top = rect.bottom + 6 + 'px';
|
|
1931
|
+
const live = findTabs();
|
|
1932
|
+
const list = live === null ? [] : Array.from(live.querySelectorAll('button[role="tab"]'));
|
|
1933
|
+
const act = list.findIndex((el) => el.getAttribute('aria-selected') === 'true');
|
|
1934
|
+
/* 列出全部视图,当前选中的那项做标记——和标准下拉菜单一致 */
|
|
1935
|
+
list.forEach((source, index) => {
|
|
1936
|
+
const entry = document.createElement('button');
|
|
1937
|
+
entry.type = 'button';
|
|
1938
|
+
entry.className = 'dcc-seg-menu-item';
|
|
1939
|
+
const label = document.createElement('span');
|
|
1940
|
+
label.className = 'dcc-seg-menu-label';
|
|
1941
|
+
label.textContent = (source.textContent || '').trim();
|
|
1942
|
+
const check = document.createElement('span');
|
|
1943
|
+
check.className = 'dcc-seg-menu-check';
|
|
1944
|
+
check.setAttribute('aria-hidden', 'true');
|
|
1945
|
+
entry.append(label, check);
|
|
1946
|
+
if (index === act) {
|
|
1947
|
+
entry.dataset.active = 'true';
|
|
1948
|
+
entry.setAttribute('aria-current', 'true');
|
|
1949
|
+
}
|
|
1950
|
+
entry.addEventListener('click', () => {
|
|
1951
|
+
closeSegMenu();
|
|
1952
|
+
if (index === act) return;
|
|
1953
|
+
forward(index);
|
|
1954
|
+
});
|
|
1955
|
+
menu.appendChild(entry);
|
|
1956
|
+
});
|
|
1957
|
+
document.body.appendChild(menu);
|
|
1958
|
+
menu.style.transformOrigin = 'top right';
|
|
1959
|
+
menu.style.animation = 'dcc-plain-in .13s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1))';
|
|
1960
|
+
segMenu = menu;
|
|
1961
|
+
segMenuAnchor = more;
|
|
1962
|
+
more.setAttribute('data-open', 'true');
|
|
1963
|
+
window.setTimeout(() => {
|
|
1964
|
+
const onDown = (ev) => {
|
|
1965
|
+
if (segMenu !== menu) return;
|
|
1966
|
+
if (menu.contains(ev.target) || more.contains(ev.target)) return;
|
|
1967
|
+
closeSegMenu();
|
|
1968
|
+
};
|
|
1969
|
+
document.addEventListener('pointerdown', onDown, true);
|
|
1970
|
+
segMenuGuard = onDown;
|
|
1971
|
+
}, 0);
|
|
1296
1972
|
});
|
|
1297
|
-
|
|
1298
|
-
});
|
|
1973
|
+
}
|
|
1299
1974
|
host.insertBefore(bar, host.firstChild);
|
|
1300
1975
|
syncActive();
|
|
1976
|
+
/* 重建后如果这一页需要常驻显示(非对话视图),让它淡入而不是直接跳出来 */
|
|
1977
|
+
if (bar.dataset.pinned === 'true') {
|
|
1978
|
+
const fresh = bar;
|
|
1979
|
+
fresh.style.opacity = '0';
|
|
1980
|
+
window.requestAnimationFrame(() => {
|
|
1981
|
+
if (fresh.isConnected) fresh.style.opacity = '';
|
|
1982
|
+
});
|
|
1983
|
+
}
|
|
1301
1984
|
};
|
|
1302
1985
|
|
|
1303
1986
|
const ensure = () => {
|
|
1304
1987
|
/* 开关关掉时把自绘控件撤掉,标签行由 CSS 恢复原样 */
|
|
1305
|
-
if (document.documentElement.dataset.
|
|
1988
|
+
if (document.documentElement.dataset.dccEnabled !== 'on'
|
|
1989
|
+
|| document.documentElement.dataset.dccCompactHeader !== 'on') {
|
|
1306
1990
|
if (bar !== null) { bar.remove(); bar = null; }
|
|
1307
1991
|
return;
|
|
1308
1992
|
}
|
|
1309
1993
|
const tabs = findTabs();
|
|
1310
1994
|
const host = findHost();
|
|
1311
|
-
|
|
1995
|
+
/* 切换工作区时 tabs 会短暂消失再回来。这时别急着删控件——
|
|
1996
|
+
等它回来时不一定还有新的 DOM 变化来触发重建,控件就永久丢了。
|
|
1997
|
+
只有 host 真的没了才清掉。 */
|
|
1998
|
+
if (host === null) {
|
|
1312
1999
|
if (bar !== null) { bar.remove(); bar = null; }
|
|
1313
2000
|
return;
|
|
1314
2001
|
}
|
|
2002
|
+
if (tabs === null) return;
|
|
1315
2003
|
const count = tabs.querySelectorAll('button[role="tab"]').length;
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
2004
|
+
/* 切换工作区那一瞬标签还没渲染完,数量会短暂变成 0。
|
|
2005
|
+
这时如果按「数量不一致」去重建,就会闪一下。等它稳定下来再说。 */
|
|
2006
|
+
if (count === 0) return;
|
|
2007
|
+
/* 控件还在 DOM 里、只是容器换了 → 直接搬过去,不要重建(重建会闪一下) */
|
|
2008
|
+
if (bar !== null && bar.isConnected && bar.parentElement !== host) {
|
|
2009
|
+
host.insertBefore(bar, host.firstChild);
|
|
1319
2010
|
}
|
|
1320
|
-
|
|
2011
|
+
/* 控件固定只有两项(激活项 + ⋯),不能拿它和标签总数比,
|
|
2012
|
+
否则每次都会判定「数量不一致」→ 反复重建 → 看起来一直在闪。 */
|
|
2013
|
+
if (bar === null || !bar.isConnected) build(tabs, host);
|
|
2014
|
+
else syncActive();
|
|
1321
2015
|
};
|
|
1322
2016
|
|
|
1323
2017
|
const schedule = () => {
|
|
@@ -1329,7 +2023,20 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1329
2023
|
};
|
|
1330
2024
|
|
|
1331
2025
|
ensure();
|
|
1332
|
-
|
|
2026
|
+
/* 切视图时 aria-selected 一变就立刻同步,不走 350ms 防抖:
|
|
2027
|
+
否则非对话视图下要等半拍控件才常驻出来。 */
|
|
2028
|
+
const onSelect = () => {
|
|
2029
|
+
if (timer !== null) {
|
|
2030
|
+
clearTimeout(timer);
|
|
2031
|
+
timer = null;
|
|
2032
|
+
}
|
|
2033
|
+
ensure();
|
|
2034
|
+
};
|
|
2035
|
+
observer = new MutationObserver((records) => {
|
|
2036
|
+
const selected = records.some((record) => record.type === 'attributes');
|
|
2037
|
+
if (selected) onSelect();
|
|
2038
|
+
else schedule();
|
|
2039
|
+
});
|
|
1333
2040
|
observer.observe(document.body, {
|
|
1334
2041
|
childList: true,
|
|
1335
2042
|
subtree: true,
|
|
@@ -1337,10 +2044,25 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1337
2044
|
attributeFilter: ['aria-selected'],
|
|
1338
2045
|
});
|
|
1339
2046
|
|
|
2047
|
+
/* 紧凑化和完整模式这两个开关变化时重建控件。
|
|
2048
|
+
属性由 applyPrefs 在重渲染时写入,因此延后两帧再建,
|
|
2049
|
+
否则 ensure 读到的还是旧属性值。 */
|
|
2050
|
+
const onPrefs = (event) => {
|
|
2051
|
+
if (!event.detail) return;
|
|
2052
|
+
const key = event.detail.key;
|
|
2053
|
+
if (key !== 'compactHeader' && key !== 'compactHeaderFull') return;
|
|
2054
|
+
window.setTimeout(() => window.requestAnimationFrame(() => ensure()), 0);
|
|
2055
|
+
};
|
|
2056
|
+
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
2057
|
+
|
|
1340
2058
|
return () => {
|
|
2059
|
+
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
1341
2060
|
observer.disconnect();
|
|
1342
2061
|
if (timer !== null) clearTimeout(timer);
|
|
2062
|
+
closeSegMenu();
|
|
1343
2063
|
if (bar !== null) bar.remove();
|
|
2064
|
+
for (const ghost of ghosts) ghost.remove();
|
|
2065
|
+
ghosts.clear();
|
|
1344
2066
|
};
|
|
1345
2067
|
}
|
|
1346
2068
|
|
|
@@ -1368,6 +2090,12 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1368
2090
|
const sync = () => {
|
|
1369
2091
|
if (text === '') return;
|
|
1370
2092
|
const root = document.documentElement;
|
|
2093
|
+
/* 总开关关闭时不再写这两个值,否则会留下一个永远显示余额的伪元素 */
|
|
2094
|
+
if (root.dataset.dccEnabled !== 'on') {
|
|
2095
|
+
root.style.removeProperty('--dcc-balance-text');
|
|
2096
|
+
if (root.dataset.dccBalanceLow !== undefined) delete root.dataset.dccBalanceLow;
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
1371
2099
|
const next = JSON.stringify(`余额 ${text}`);
|
|
1372
2100
|
if (root.style.getPropertyValue('--dcc-balance-text') !== next) {
|
|
1373
2101
|
root.style.setProperty('--dcc-balance-text', next);
|
|
@@ -1415,12 +2143,21 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1415
2143
|
}
|
|
1416
2144
|
};
|
|
1417
2145
|
|
|
2146
|
+
|
|
1418
2147
|
window.addEventListener('dcc-balance-threshold', onThreshold);
|
|
2148
|
+
/* 开关切换后立刻按已拿到的数据重算,不必等下一次轮询 */
|
|
2149
|
+
const onPrefs = (event) => {
|
|
2150
|
+
if (!event.detail) return;
|
|
2151
|
+
/* 小数位数变化也要立刻重算,否则要关掉设置面板才看到效果 */
|
|
2152
|
+
if (event.detail.key === 'showBalance' || event.detail.key === 'balanceDecimals') recalc();
|
|
2153
|
+
};
|
|
2154
|
+
window.addEventListener('dcc-prefs-changed', onPrefs);
|
|
1419
2155
|
load();
|
|
1420
|
-
refresh = window.setInterval(load,
|
|
2156
|
+
refresh = window.setInterval(load, 40000);
|
|
1421
2157
|
|
|
1422
2158
|
return () => {
|
|
1423
2159
|
window.removeEventListener('dcc-balance-threshold', onThreshold);
|
|
2160
|
+
window.removeEventListener('dcc-prefs-changed', onPrefs);
|
|
1424
2161
|
if (refresh !== null) window.clearInterval(refresh);
|
|
1425
2162
|
document.documentElement.style.removeProperty('--dcc-balance-text');
|
|
1426
2163
|
delete document.documentElement.dataset.dccBalanceLow;
|
|
@@ -1443,7 +2180,7 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1443
2180
|
const sync = () => {
|
|
1444
2181
|
if (btn === null) return;
|
|
1445
2182
|
/* 开关关掉时撤掉箭头并强制展开,导航回到宿主原样 */
|
|
1446
|
-
if (document.documentElement.dataset.dccCollapse !== 'on') {
|
|
2183
|
+
if (document.documentElement.dataset.dccEnabled !== 'on' || document.documentElement.dataset.dccCollapse !== 'on') {
|
|
1447
2184
|
btn.remove();
|
|
1448
2185
|
btn = null;
|
|
1449
2186
|
document.documentElement.dataset.dccNav = 'expanded';
|
|
@@ -1529,8 +2266,25 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1529
2266
|
ensure();
|
|
1530
2267
|
observer = new MutationObserver(schedule);
|
|
1531
2268
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
2269
|
+
/* 新会话克隆行增删会改变「折叠时保留几项」,要立刻重算高度 */
|
|
2270
|
+
const onNewSessionPref = () => ensure();
|
|
2271
|
+
window.addEventListener('dcc-newsession-pref', onNewSessionPref);
|
|
2272
|
+
/* 导航折叠开关本身切换后也要立刻重算,否则箭头和布局要等 400ms 防抖 */
|
|
2273
|
+
const onNavPref = (event) => {
|
|
2274
|
+
if (event.detail && event.detail.key === 'navCollapse') {
|
|
2275
|
+
/* 重新打开导航折叠时,默认回到收起状态——
|
|
2276
|
+
否则会沿用上一次的展开状态,看起来像开关没生效。 */
|
|
2277
|
+
if (document.documentElement.dataset.dccCollapse === 'on') {
|
|
2278
|
+
document.documentElement.dataset.dccNav = 'collapsed';
|
|
2279
|
+
}
|
|
2280
|
+
window.setTimeout(() => ensure(), 0);
|
|
2281
|
+
}
|
|
2282
|
+
};
|
|
2283
|
+
window.addEventListener('dcc-prefs-changed', onNavPref);
|
|
1532
2284
|
|
|
1533
2285
|
return () => {
|
|
2286
|
+
window.removeEventListener('dcc-newsession-pref', onNewSessionPref);
|
|
2287
|
+
window.removeEventListener('dcc-prefs-changed', onNavPref);
|
|
1534
2288
|
observer.disconnect();
|
|
1535
2289
|
if (timer !== null) clearTimeout(timer);
|
|
1536
2290
|
if (btn !== null) btn.remove();
|
|
@@ -1538,6 +2292,265 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1538
2292
|
};
|
|
1539
2293
|
}
|
|
1540
2294
|
|
|
2295
|
+
/**
|
|
2296
|
+
* 菜单从点击处缩放展开。CSS 负责动画,这里只把「最后一次指针位置」
|
|
2297
|
+
* 换算成菜单内的相对坐标写进变量,让缩放的锚点落在点下去的地方。
|
|
2298
|
+
*/
|
|
2299
|
+
function installMenuOrigin() {
|
|
2300
|
+
let lastX = 0;
|
|
2301
|
+
let lastY = 0;
|
|
2302
|
+
let observer = null;
|
|
2303
|
+
/* 每出现一个新菜单就递增编号,用来判断「谁是最后出现的」。
|
|
2304
|
+
不能用 DOM 顺序:子菜单是 portal 节点,先出现的可能排在后面。 */
|
|
2305
|
+
let seq = 0;
|
|
2306
|
+
|
|
2307
|
+
const onDown = (event) => {
|
|
2308
|
+
lastX = event.clientX;
|
|
2309
|
+
lastY = event.clientY;
|
|
2310
|
+
};
|
|
2311
|
+
|
|
2312
|
+
const mark = () => {
|
|
2313
|
+
const menus = document.querySelectorAll('[role="menu"], [role="listbox"], [role="dialog"]');
|
|
2314
|
+
for (let i = 0; i < menus.length; i += 1) {
|
|
2315
|
+
const menu = menus[i];
|
|
2316
|
+
if (menu.hasAttribute('data-dcc-menu-seq')) continue;
|
|
2317
|
+
seq += 1;
|
|
2318
|
+
menu.setAttribute('data-dcc-menu-seq', String(seq));
|
|
2319
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') continue;
|
|
2320
|
+
if (document.documentElement.dataset.dccTransition !== 'on') continue;
|
|
2321
|
+
const rect = menu.getBoundingClientRect();
|
|
2322
|
+
if (rect.width <= 0 || rect.height <= 0) continue;
|
|
2323
|
+
const x = Math.min(1, Math.max(0, (lastX - rect.left) / rect.width));
|
|
2324
|
+
const y = Math.min(1, Math.max(0, (lastY - rect.top) / rect.height));
|
|
2325
|
+
menu.style.setProperty('--dcc-menu-origin', `${Math.round(x * 100)}% ${Math.round(y * 100)}%`);
|
|
2326
|
+
}
|
|
2327
|
+
/* 宿主切换可展开项时,旧子菜单要等关闭延迟才移除,期间会和新叠在一起。
|
|
2328
|
+
只留编号最大(最后出现)的那个可见,其余立即隐身;
|
|
2329
|
+
不碰宿主状态,它照常走自己的关闭流程。 */
|
|
2330
|
+
const subs = Array.from(document.querySelectorAll('[role="menu"]:not([data-menu-phase])'));
|
|
2331
|
+
if (subs.length < 2) {
|
|
2332
|
+
for (let i = 0; i < subs.length; i += 1) {
|
|
2333
|
+
subs[i].style.opacity = '';
|
|
2334
|
+
subs[i].style.pointerEvents = '';
|
|
2335
|
+
}
|
|
2336
|
+
return;
|
|
2337
|
+
}
|
|
2338
|
+
let newest = null;
|
|
2339
|
+
let newestSeq = -1;
|
|
2340
|
+
for (let i = 0; i < subs.length; i += 1) {
|
|
2341
|
+
const value = Number(subs[i].getAttribute('data-dcc-menu-seq') || 0);
|
|
2342
|
+
if (value > newestSeq) {
|
|
2343
|
+
newestSeq = value;
|
|
2344
|
+
newest = subs[i];
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
for (let i = 0; i < subs.length; i += 1) {
|
|
2348
|
+
const sub = subs[i];
|
|
2349
|
+
const keep = sub === newest;
|
|
2350
|
+
sub.style.opacity = keep ? '' : '0';
|
|
2351
|
+
sub.style.pointerEvents = keep ? '' : 'none';
|
|
2352
|
+
}
|
|
2353
|
+
};
|
|
2354
|
+
|
|
2355
|
+
window.addEventListener('pointerdown', onDown, true);
|
|
2356
|
+
observer = new MutationObserver(mark);
|
|
2357
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2358
|
+
mark();
|
|
2359
|
+
|
|
2360
|
+
return () => {
|
|
2361
|
+
observer.disconnect();
|
|
2362
|
+
window.removeEventListener('pointerdown', onDown, true);
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
|
|
2366
|
+
/**
|
|
2367
|
+
* 对话框没有关闭阶段(open 为 false 时整个 portal 直接卸载),
|
|
2368
|
+
* 所以退场动画只能靠「卸载瞬间克隆一份快照、覆盖在原位播完再删」。
|
|
2369
|
+
* 原节点照常卸载,不干扰 React 状态。
|
|
2370
|
+
*/
|
|
2371
|
+
function installDialogExit() {
|
|
2372
|
+
let observer = null;
|
|
2373
|
+
/* 节点被移除时再量尺寸已经晚了——脱离文档的元素 rect 全是 0。
|
|
2374
|
+
所以对话框一出现就把位置记下来,移除时直接取这份快照。 */
|
|
2375
|
+
const rects = new WeakMap();
|
|
2376
|
+
|
|
2377
|
+
const remember = (root) => {
|
|
2378
|
+
if (root.hasAttribute('data-dcc-dialog-clone')) return;
|
|
2379
|
+
const dialog = root.matches('[role="dialog"]') ? root : root.querySelector('[role="dialog"]');
|
|
2380
|
+
if (dialog === null || rects.has(dialog)) return;
|
|
2381
|
+
const rect = dialog.getBoundingClientRect();
|
|
2382
|
+
if (rect.width > 0 && rect.height > 0) rects.set(dialog, rect);
|
|
2383
|
+
};
|
|
2384
|
+
|
|
2385
|
+
const playExit = (dialog) => {
|
|
2386
|
+
if (document.documentElement.dataset.dccEnabled !== 'on') return;
|
|
2387
|
+
if (document.documentElement.dataset.dccTransition !== 'on') return;
|
|
2388
|
+
/* 快照自己也是 role="dialog",不排除的话它的移除会再触发一轮快照,无限循环 */
|
|
2389
|
+
/* 标记打在克隆的遮罩层上,卡片只是它的子孙,所以用 closest 向上找 */
|
|
2390
|
+
if (dialog.closest('[data-dcc-dialog-clone]') !== null) return;
|
|
2391
|
+
if (!rects.has(dialog)) return;
|
|
2392
|
+
/* 卡片本身是 position: relative,靠父级(fixed + flex)居中。
|
|
2393
|
+
所以克隆父级整层、保持它的定位不动,只把动画加在卡片上——
|
|
2394
|
+
卡片一旦被单独提出来改成 fixed,就会脱离这层居中上下文。 */
|
|
2395
|
+
const overlay = dialog.parentElement;
|
|
2396
|
+
const source = overlay !== null && overlay !== document.body ? overlay : dialog;
|
|
2397
|
+
const clone = source.cloneNode(true);
|
|
2398
|
+
clone.removeAttribute('data-dcc-menu-seq');
|
|
2399
|
+
clone.setAttribute('data-dcc-dialog-clone', '');
|
|
2400
|
+
clone.style.zIndex = '2147483000';
|
|
2401
|
+
clone.style.pointerEvents = 'none';
|
|
2402
|
+
/* 禁用模糊时弹层是不透明底,得用不带背景色的那组关键帧,
|
|
2403
|
+
否则快照会从实底渐变到兜底色,看起来就是退场时变色。 */
|
|
2404
|
+
const exitAnim = document.documentElement.dataset.dccMenuBlur === 'on'
|
|
2405
|
+
? 'dcc-plain-out'
|
|
2406
|
+
: 'dcc-menu-out';
|
|
2407
|
+
/* 整层统一淡出:这样压暗层和卡片一定同步,不依赖 mask 的类名是否命中 */
|
|
2408
|
+
/* 必须带 important:CSS 里的入场动画是 !important 的,
|
|
2409
|
+
内联样式不加同级就盖不过去,退场会反着放成入场。 */
|
|
2410
|
+
clone.style.setProperty('animation', 'dcc-fade-out .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards', 'important');
|
|
2411
|
+
/* 卡片在这之上再加缩放 */
|
|
2412
|
+
const inner = clone.querySelector('[role="dialog"]');
|
|
2413
|
+
if (inner !== null) {
|
|
2414
|
+
inner.style.setProperty('animation', `${exitAnim} .2s var(--ds-ease-in-out, cubic-bezier(.4, 0, .2, 1)) forwards`, 'important');
|
|
2415
|
+
}
|
|
2416
|
+
document.body.appendChild(clone);
|
|
2417
|
+
window.setTimeout(() => clone.remove(), 300);
|
|
2418
|
+
};
|
|
2419
|
+
|
|
2420
|
+
observer = new MutationObserver((records) => {
|
|
2421
|
+
for (let i = 0; i < records.length; i += 1) {
|
|
2422
|
+
const added = records[i].addedNodes;
|
|
2423
|
+
for (let j = 0; j < added.length; j += 1) {
|
|
2424
|
+
const node = added[j];
|
|
2425
|
+
if (node instanceof Element) remember(node);
|
|
2426
|
+
}
|
|
2427
|
+
const removed = records[i].removedNodes;
|
|
2428
|
+
for (let j = 0; j < removed.length; j += 1) {
|
|
2429
|
+
const node = removed[j];
|
|
2430
|
+
if (!(node instanceof Element)) continue;
|
|
2431
|
+
const dialog = node.matches('[role="dialog"]')
|
|
2432
|
+
? node
|
|
2433
|
+
: node.querySelector('[role="dialog"]');
|
|
2434
|
+
if (dialog !== null) playExit(dialog);
|
|
2435
|
+
}
|
|
2436
|
+
}
|
|
2437
|
+
});
|
|
2438
|
+
observer.observe(document.body, { childList: true, subtree: true });
|
|
2439
|
+
|
|
2440
|
+
return () => observer.disconnect();
|
|
2441
|
+
}
|
|
2442
|
+
|
|
2443
|
+
/**
|
|
2444
|
+
* 启动遮罩:宿主的加载页退场、应用界面渲染出来之后,本插件注入的样式
|
|
2445
|
+
* 还要再落一次,中间能看到一次布局跳变。这里等界面真正出现(侧栏根节点
|
|
2446
|
+
* 就位且有尺寸)再多等一帧,然后盖 500ms 再淡出。
|
|
2447
|
+
*/
|
|
2448
|
+
function installBootCover(prefs) {
|
|
2449
|
+
if (!prefs.enabled) return () => {};
|
|
2450
|
+
let cover = null;
|
|
2451
|
+
let themeObserver = null;
|
|
2452
|
+
let bootObserver = null;
|
|
2453
|
+
let rafId = 0;
|
|
2454
|
+
let fadeTimer = 0;
|
|
2455
|
+
let removeTimer = 0;
|
|
2456
|
+
let disposed = false;
|
|
2457
|
+
|
|
2458
|
+
const ready = () => {
|
|
2459
|
+
const sidebar = document.querySelector('[class*="_root"]:has(nav[class*="_panelList"])');
|
|
2460
|
+
if (sidebar === null) return false;
|
|
2461
|
+
const rect = sidebar.getBoundingClientRect();
|
|
2462
|
+
return rect.width > 100 && rect.height > 100;
|
|
2463
|
+
};
|
|
2464
|
+
|
|
2465
|
+
const wait = () => {
|
|
2466
|
+
if (disposed) return;
|
|
2467
|
+
if (!ready()) {
|
|
2468
|
+
rafId = window.requestAnimationFrame(wait);
|
|
2469
|
+
return;
|
|
2470
|
+
}
|
|
2471
|
+
makeCover();
|
|
2472
|
+
};
|
|
2473
|
+
|
|
2474
|
+
const makeCover = () => {
|
|
2475
|
+
if (disposed || cover !== null) return;
|
|
2476
|
+
cover = document.createElement('div');
|
|
2477
|
+
cover.className = 'dcc-boot-cover';
|
|
2478
|
+
const applyTheme = () => {
|
|
2479
|
+
if (cover === null) return;
|
|
2480
|
+
const dark = document.body.hasAttribute('data-ds-dark-theme')
|
|
2481
|
+
|| document.documentElement.hasAttribute('data-ds-dark-theme');
|
|
2482
|
+
cover.style.backgroundColor = dark ? '#151517' : '#ffffff';
|
|
2483
|
+
};
|
|
2484
|
+
applyTheme();
|
|
2485
|
+
themeObserver = new MutationObserver(applyTheme);
|
|
2486
|
+
themeObserver.observe(document.body, {
|
|
2487
|
+
attributes: true,
|
|
2488
|
+
attributeFilter: ['data-ds-dark-theme', 'class'],
|
|
2489
|
+
});
|
|
2490
|
+
themeObserver.observe(document.documentElement, {
|
|
2491
|
+
attributes: true,
|
|
2492
|
+
attributeFilter: ['data-ds-dark-theme', 'class'],
|
|
2493
|
+
});
|
|
2494
|
+
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
2495
|
+
svg.setAttribute('viewBox', '0 0 23.16 17.04');
|
|
2496
|
+
svg.setAttribute('class', 'dcc-boot-fish');
|
|
2497
|
+
svg.setAttribute('aria-hidden', 'true');
|
|
2498
|
+
const shape = document.createElementNS('http://www.w3.org/2000/svg', 'path');
|
|
2499
|
+
shape.setAttribute('d', FISH_LOGO_PATH);
|
|
2500
|
+
/* 直接按主题写死填充色,不依赖 CSS 选择器:
|
|
2501
|
+
之前靠 body:not([...]) 反色,浅色下没生效就会变成白鱼压在白底上。 */
|
|
2502
|
+
const darkNow = document.body.hasAttribute('data-ds-dark-theme')
|
|
2503
|
+
|| document.documentElement.hasAttribute('data-ds-dark-theme');
|
|
2504
|
+
shape.setAttribute('fill', darkNow ? '#ffffff' : '#000000');
|
|
2505
|
+
svg.appendChild(shape);
|
|
2506
|
+
cover.appendChild(svg);
|
|
2507
|
+
document.documentElement.appendChild(cover);
|
|
2508
|
+
fadeTimer = window.setTimeout(() => {
|
|
2509
|
+
if (cover === null) return;
|
|
2510
|
+
cover.classList.add('dcc-boot-cover-out');
|
|
2511
|
+
removeTimer = window.setTimeout(() => {
|
|
2512
|
+
if (themeObserver !== null) {
|
|
2513
|
+
themeObserver.disconnect();
|
|
2514
|
+
themeObserver = null;
|
|
2515
|
+
}
|
|
2516
|
+
if (cover !== null) cover.remove();
|
|
2517
|
+
cover = null;
|
|
2518
|
+
}, 320);
|
|
2519
|
+
}, 500);
|
|
2520
|
+
};
|
|
2521
|
+
|
|
2522
|
+
/* 宿主的加载页是 [data-dsh-boot]。它一被移除就立刻盖遮罩——
|
|
2523
|
+
MutationObserver 的回调在同一轮微任务里跑,赶在浏览器绘制之前,
|
|
2524
|
+
所以中间不会露出没有样式的那一帧。 */
|
|
2525
|
+
const hasBoot = () => document.querySelector('[data-dsh-boot]') !== null;
|
|
2526
|
+
if (hasBoot()) {
|
|
2527
|
+
bootObserver = new MutationObserver(() => {
|
|
2528
|
+
if (hasBoot()) return;
|
|
2529
|
+
bootObserver.disconnect();
|
|
2530
|
+
bootObserver = null;
|
|
2531
|
+
makeCover();
|
|
2532
|
+
});
|
|
2533
|
+
bootObserver.observe(document.body, { childList: true, subtree: true });
|
|
2534
|
+
} else {
|
|
2535
|
+
/* 插件加载得比加载页还晚,那就等界面就绪 */
|
|
2536
|
+
wait();
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
wait();
|
|
2540
|
+
return () => {
|
|
2541
|
+
disposed = true;
|
|
2542
|
+
if (bootObserver !== null) bootObserver.disconnect();
|
|
2543
|
+
if (themeObserver !== null) themeObserver.disconnect();
|
|
2544
|
+
if (rafId !== 0) window.cancelAnimationFrame(rafId);
|
|
2545
|
+
window.clearTimeout(fadeTimer);
|
|
2546
|
+
window.clearTimeout(removeTimer);
|
|
2547
|
+
if (cover !== null) cover.remove();
|
|
2548
|
+
};
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
/* 侧栏 Logo 那条鲸鱼(与宿主同一份 path),遮罩中心会用到 */
|
|
2552
|
+
const FISH_LOGO_PATH = 'M22.9168 1.43018C22.6713 1.31018 22.5658 1.53918 22.4223 1.65519C22.3733 1.69269 22.3318 1.74169 22.2903 1.78669C21.9317 2.1697 21.5127 2.42121 20.9657 2.39121C20.1657 2.34621 19.4827 2.59771 18.8787 3.20973C18.7502 2.45521 18.3236 2.0047 17.6746 1.71569C17.3351 1.56568 16.9916 1.41518 16.7536 1.08867C16.5876 0.856163 16.5421 0.597155 16.4591 0.341647C16.4061 0.187643 16.3536 0.0301382 16.1761 0.00363739C15.9836 -0.0263635 15.9081 0.135141 15.8326 0.270145C15.5306 0.822162 15.4136 1.43018 15.4251 2.0462C15.4516 3.43174 16.0366 4.53527 17.1991 5.3203C17.3311 5.4103 17.3651 5.5003 17.3236 5.63181C17.2441 5.90231 17.1501 6.16482 17.0671 6.43533C17.0141 6.60784 16.9351 6.64584 16.7501 6.57033C16.1121 6.30383 15.5611 5.90931 15.074 5.4328C14.2475 4.63328 13.5 3.75075 12.568 3.05973C12.349 2.89822 12.13 2.74822 11.9034 2.60522C10.9524 1.68169 12.028 0.923165 12.277 0.833162C12.5375 0.739159 12.3675 0.41615 11.5259 0.42015C10.6844 0.42365 9.91439 0.705658 8.93286 1.08117C8.78935 1.13767 8.63835 1.17867 8.48384 1.21267C7.59332 1.04367 6.66829 1.00617 5.70226 1.11517C3.88321 1.31768 2.43016 2.1777 1.36213 3.64575C0.0790928 5.4103 -0.222916 7.41536 0.146595 9.50642C0.535106 11.7105 1.66014 13.535 3.38869 14.9616C5.18125 16.4406 7.24581 17.1657 9.60138 17.0266C11.0319 16.9441 12.6245 16.7526 14.421 15.2321C14.874 15.4576 15.3496 15.5476 16.1381 15.6151C16.7456 15.6716 17.3306 15.5851 17.7836 15.4911C18.4931 15.3411 18.4441 14.6841 18.1876 14.5636C16.1081 13.595 16.5646 13.9891 16.1496 13.67C17.2061 12.42 18.8202 10.1979 19.3182 7.17235C19.3672 6.83834 19.4297 6.36783 19.4222 6.09732C19.4182 5.93231 19.4562 5.86831 19.6447 5.84931C20.1657 5.78931 20.6712 5.64681 21.1357 5.3913C22.4833 4.65528 23.0268 3.44624 23.1548 1.9972C23.1738 1.77569 23.1508 1.54668 22.9168 1.43018ZM11.1749 14.4736C9.15936 12.889 8.18184 12.3675 7.77832 12.39C7.40081 12.4125 7.46881 12.8445 7.55182 13.126C7.63882 13.404 7.75182 13.5955 7.91033 13.8396C8.01983 14.0011 8.09533 14.2411 7.80083 14.4216C7.15181 14.8231 6.02327 14.2866 5.97027 14.2601C4.65673 13.4865 3.5587 12.4655 2.78467 11.069C2.03715 9.72493 1.60314 8.28289 1.53164 6.74384C1.51264 6.37233 1.62214 6.24082 1.99215 6.17332C2.47916 6.08332 2.98118 6.06432 3.46769 6.13582C5.52476 6.43633 7.27581 7.35586 8.74385 8.8129C9.58188 9.64243 10.2159 10.634 10.8689 11.6025C11.5634 12.631 12.3105 13.611 13.262 14.4146C13.598 14.6961 13.866 14.9101 14.1225 15.0681C13.349 15.1546 12.058 15.1731 11.1749 14.4746L11.1749 14.4736ZM12.141 8.25988C12.141 8.09488 12.273 7.96338 12.439 7.96338C12.4765 7.96338 12.5105 7.97088 12.541 7.98188C12.5825 7.99688 12.6205 8.01938 12.6505 8.05338C12.7035 8.10588 12.7335 8.18088 12.7335 8.25988C12.7335 8.42489 12.6015 8.55639 12.4355 8.55639C12.2695 8.55639 12.141 8.42489 12.141 8.25988ZM15.1415 9.79893C14.949 9.87793 14.7565 9.94544 14.5715 9.95294C14.2845 9.96794 13.9715 9.85143 13.8015 9.70893C13.5375 9.48742 13.3485 9.36342 13.2695 8.97691C13.2355 8.8119 13.2545 8.55639 13.2845 8.40989C13.3525 8.09438 13.277 7.89187 13.0545 7.70787C12.8735 7.55786 12.643 7.51636 12.39 7.51636C12.2955 7.51636 12.209 7.47486 12.1445 7.44136C12.039 7.38886 11.9519 7.25735 12.035 7.09585C12.0615 7.04335 12.19 6.91584 12.22 6.89334C12.5635 6.69784 12.9595 6.76184 13.326 6.90834C13.6655 7.04735 13.9225 7.30236 14.292 7.66287C14.6695 8.09838 14.7375 8.21838 14.9525 8.54539C15.1225 8.8009 15.277 9.06341 15.3831 9.36392C15.4471 9.55142 15.3641 9.70493 15.1415 9.79893Z';
|
|
2553
|
+
|
|
1541
2554
|
function Switch(props) {
|
|
1542
2555
|
return h('label', { className: 'dcc-switch' },
|
|
1543
2556
|
h('input', {
|
|
@@ -1552,16 +2565,48 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1552
2565
|
}
|
|
1553
2566
|
|
|
1554
2567
|
function Row(props) {
|
|
2568
|
+
return h('div', { className: props.disabled ? 'dcc-row dcc-row-disabled' : 'dcc-row' },
|
|
2569
|
+
h('div', { className: 'dcc-row-text' },
|
|
2570
|
+
h('div', { className: 'dcc-row-title' }, props.title),
|
|
2571
|
+
props.desc ? h('div', { className: 'dcc-row-desc' }, props.desc) : null),
|
|
2572
|
+
h(Switch, {
|
|
2573
|
+
checked: props.checked,
|
|
2574
|
+
onChange: props.disabled ? () => {} : props.onChange,
|
|
2575
|
+
title: props.title,
|
|
2576
|
+
}));
|
|
2577
|
+
}
|
|
2578
|
+
|
|
2579
|
+
/* 纯告知行:右侧没有任何控件,内容按纯文本渲染(换行由 pre-line 处理) */
|
|
2580
|
+
function InfoRow(props) {
|
|
2581
|
+
return h('div', { className: 'dcc-row dcc-row-info' },
|
|
2582
|
+
h('div', { className: 'dcc-row-text' },
|
|
2583
|
+
h('div', { className: 'dcc-row-title' }, props.title),
|
|
2584
|
+
h('div', { className: 'dcc-row-desc' }, props.desc)));
|
|
2585
|
+
}
|
|
2586
|
+
|
|
2587
|
+
/* 右侧是按钮而不是开关的行:用于「重载前端界面」这类一次性操作 */
|
|
2588
|
+
function ActionRow(props) {
|
|
1555
2589
|
return h('div', { className: 'dcc-row' },
|
|
1556
2590
|
h('div', { className: 'dcc-row-text' },
|
|
1557
2591
|
h('div', { className: 'dcc-row-title' }, props.title),
|
|
1558
2592
|
props.desc ? h('div', { className: 'dcc-row-desc' }, props.desc) : null),
|
|
1559
|
-
h(
|
|
2593
|
+
h('button', {
|
|
2594
|
+
type: 'button',
|
|
2595
|
+
className: 'dcc-action',
|
|
2596
|
+
onClick: props.onClick,
|
|
2597
|
+
}, props.label));
|
|
1560
2598
|
}
|
|
1561
2599
|
|
|
1562
2600
|
function Section() {
|
|
1563
2601
|
const [prefs, setPrefs] = React.useState(readPrefs);
|
|
2602
|
+
const [confirmReset, setConfirmReset] = React.useState(false);
|
|
1564
2603
|
const zh = isZh();
|
|
2604
|
+
/* 重置全部设置:写回默认值后重载,避免残留的 DOM 与属性状态 */
|
|
2605
|
+
const resetPrefs = () => {
|
|
2606
|
+
const next = { ...DEFAULTS };
|
|
2607
|
+
savePrefs(next);
|
|
2608
|
+
if (typeof window !== 'undefined') window.location.reload();
|
|
2609
|
+
};
|
|
1565
2610
|
const update = (key) => (value) => {
|
|
1566
2611
|
setPrefs((current) => {
|
|
1567
2612
|
const next = { ...current, [key]: value };
|
|
@@ -1572,48 +2617,91 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1572
2617
|
if ((key === 'balanceThreshold' || key === 'balanceDecimals') && typeof window !== 'undefined') {
|
|
1573
2618
|
window.dispatchEvent(new Event('dcc-balance-threshold'));
|
|
1574
2619
|
}
|
|
1575
|
-
/*
|
|
2620
|
+
/* 「统一新会话按钮样式」切换后要立刻重建克隆行。
|
|
2621
|
+
延后一拍再发:属性由 applyPrefs 在下一次渲染里写入,
|
|
2622
|
+
事件如果先到,ensure 读到的还是旧值,看起来就像没反应。 */
|
|
1576
2623
|
if (key === 'invertNewSession' && typeof window !== 'undefined') {
|
|
1577
|
-
window.
|
|
2624
|
+
window.setTimeout(() => {
|
|
2625
|
+
window.dispatchEvent(new Event('dcc-newsession-pref'));
|
|
2626
|
+
}, 0);
|
|
2627
|
+
}
|
|
2628
|
+
/* 其余需要重建 DOM 的开关统一走这个事件,各模块只处理自己关心的 key。
|
|
2629
|
+
同样延后一拍,等 applyPrefs 把属性写进 html。 */
|
|
2630
|
+
if (typeof window !== 'undefined') {
|
|
2631
|
+
window.setTimeout(() => {
|
|
2632
|
+
window.dispatchEvent(new CustomEvent('dcc-prefs-changed', { detail: { key } }));
|
|
2633
|
+
}, 0);
|
|
2634
|
+
}
|
|
2635
|
+
/* 总开关切换会整体改变已注入的 DOM 与样式,重载一次前端最干净。
|
|
2636
|
+
偏好此时已经写进存储,重载后会按新状态重建。 */
|
|
2637
|
+
if (key === 'enabled' && typeof window !== 'undefined') {
|
|
2638
|
+
window.setTimeout(() => window.location.reload(), 60);
|
|
1578
2639
|
}
|
|
1579
2640
|
};
|
|
1580
2641
|
return h('div', { className: 'dcc-page' },
|
|
1581
2642
|
h('div', { className: 'dcc-title' }, zh ? 'UI 改进' : 'UI improvements'),
|
|
1582
2643
|
h('p', { className: 'dcc-intro' },
|
|
1583
2644
|
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.'),
|
|
1584
|
-
|
|
1585
|
-
|
|
2645
|
+
/* 无组名的操作区:总开关 + 重载前端界面 */
|
|
2646
|
+
h('div', { className: 'dcc-group dcc-primary' },
|
|
1586
2647
|
h(Row, {
|
|
1587
|
-
title: zh ? '
|
|
1588
|
-
desc: zh ? '
|
|
1589
|
-
checked: prefs.
|
|
1590
|
-
onChange: update('
|
|
2648
|
+
title: zh ? '总开关' : 'Master switch',
|
|
2649
|
+
desc: zh ? '关闭后将禁用全部修改,包括始终启用的部分界面修复功能。\n打开和关闭会重载前端界面,不影响正在运行的任务。' : 'Turning it off disables every change, including the always-on UI fixes.\nToggling it reloads the UI; running tasks are not affected.',
|
|
2650
|
+
checked: prefs.enabled,
|
|
2651
|
+
onChange: update('enabled'),
|
|
1591
2652
|
}),
|
|
2653
|
+
h(ActionRow, {
|
|
2654
|
+
title: zh ? '重载前端界面' : 'Reload the UI',
|
|
2655
|
+
desc: zh ? '调整本插件的设置后建议执行一次。使用了其他修改前端界面类的插件,也可以在此处重载。\n不会影响正在运行的任务。' : 'Recommended after changing this plugin settings. Also reloads other UI-modifying plugins.\nRunning tasks are not affected.',
|
|
2656
|
+
label: zh ? '重载' : 'Reload',
|
|
2657
|
+
onClick: () => { window.location.reload(); },
|
|
2658
|
+
})),
|
|
2659
|
+
h('div', { className: 'dcc-group' },
|
|
2660
|
+
h('div', { className: 'dcc-group-title' }, zh ? '外观' : 'Appearance'),
|
|
1592
2661
|
h(Row, {
|
|
1593
|
-
title: zh ? '
|
|
1594
|
-
desc: zh ? '
|
|
1595
|
-
checked: prefs.
|
|
1596
|
-
onChange: update('
|
|
2662
|
+
title: zh ? '减小圆角与间距' : 'Smaller radii and spacing',
|
|
2663
|
+
desc: zh ? '缩小全局圆角、缩小侧栏部分字号、收紧间距,使界面更高效。' : 'Smaller global radii, smaller sidebar type and tighter spacing, for a more efficient interface.',
|
|
2664
|
+
checked: prefs.radiusDensity,
|
|
2665
|
+
onChange: update('radiusDensity'),
|
|
1597
2666
|
}),
|
|
1598
2667
|
h(Row, {
|
|
1599
2668
|
title: zh ? '降低深色模式文字亮度' : 'Soften dark-mode text',
|
|
1600
2669
|
desc: zh ? '略微降低深色模式文字亮度,避免纯白文字过于刺眼。' : 'Slightly dims text in dark mode so pure white is less harsh.',
|
|
1601
2670
|
checked: prefs.softenDarkText,
|
|
1602
2671
|
onChange: update('softenDarkText'),
|
|
1603
|
-
})
|
|
1604
|
-
h('div', { className: 'dcc-group' },
|
|
1605
|
-
h('div', { className: 'dcc-group-title' }, zh ? '布局' : 'Layout'),
|
|
2672
|
+
}),
|
|
1606
2673
|
h(Row, {
|
|
1607
|
-
title: zh ? '
|
|
1608
|
-
desc: zh ? '
|
|
1609
|
-
checked: prefs.
|
|
1610
|
-
onChange: update('
|
|
2674
|
+
title: zh ? '为菜单和窗口添加动画' : 'Animate menus and dialogs',
|
|
2675
|
+
desc: zh ? '为菜单添加更流畅的出现和消失动画。部分菜单由于底层限制无法添加消失动画。' : 'Smoother open and close animations for menus. Some menus cannot animate their close due to platform limits.',
|
|
2676
|
+
checked: prefs.uiTransition,
|
|
2677
|
+
onChange: update('uiTransition'),
|
|
1611
2678
|
}),
|
|
1612
2679
|
h(Row, {
|
|
1613
|
-
title: zh ? '
|
|
1614
|
-
desc: zh ? '
|
|
1615
|
-
checked: prefs.
|
|
1616
|
-
onChange: update('
|
|
2680
|
+
title: zh ? '禁用菜单模糊效果' : 'Disable menu blur',
|
|
2681
|
+
desc: zh ? '禁用原版菜单聊胜于无的模糊效果,增加流畅度和整体感。' : 'Drops the stock menu blur for smoother rendering and a more unified look.',
|
|
2682
|
+
checked: prefs.disableMenuBlur,
|
|
2683
|
+
onChange: update('disableMenuBlur'),
|
|
2684
|
+
}),
|
|
2685
|
+
h(Row, {
|
|
2686
|
+
title: zh ? '设置面板全屏' : 'Full-screen settings panel',
|
|
2687
|
+
desc: zh ? '使用非窗口化的设置页面。' : 'Use a non-windowed settings page.',
|
|
2688
|
+
checked: prefs.settingsFullscreen,
|
|
2689
|
+
onChange: update('settingsFullscreen'),
|
|
2690
|
+
}),
|
|
2691
|
+
h(Row, {
|
|
2692
|
+
title: zh ? 'Windows 默认使用微软雅黑字体' : 'Use Microsoft YaHei by default on Windows',
|
|
2693
|
+
desc: zh ? '将 Windows 端默认字体改为微软雅黑。微软雅黑带有 hinting,使文字在显示设置低于 200% 缩放比例下,更加锐利清晰。\n若手动设置了字体,或使用 macOS 端,则不受影响。' : 'Use Microsoft YaHei as the default Windows font. It carries hinting, which keeps text sharp below 200% display scaling.\nHas no effect if you set a font manually, or on macOS.',
|
|
2694
|
+
checked: prefs.winFont,
|
|
2695
|
+
onChange: update('winFont'),
|
|
2696
|
+
}),
|
|
2697
|
+
),
|
|
2698
|
+
h('div', { className: 'dcc-group' },
|
|
2699
|
+
h('div', { className: 'dcc-group-title' }, zh ? '导航和工作区' : 'Navigation and workspace'),
|
|
2700
|
+
h(Row, {
|
|
2701
|
+
title: zh ? '隐藏左上角 Logo' : 'Hide the top-left logo',
|
|
2702
|
+
desc: zh ? '隐藏侧栏顶部的 Logo。' : 'Hide the logo at the top of the sidebar.',
|
|
2703
|
+
checked: prefs.hideLogo,
|
|
2704
|
+
onChange: update('hideLogo'),
|
|
1617
2705
|
}),
|
|
1618
2706
|
h(Row, {
|
|
1619
2707
|
title: zh ? '统一新会话按钮样式' : 'Unified new-session button',
|
|
@@ -1634,28 +2722,44 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1634
2722
|
onChange: update('dimSessions'),
|
|
1635
2723
|
}),
|
|
1636
2724
|
h(Row, {
|
|
1637
|
-
title: zh ? '
|
|
1638
|
-
desc: zh ? '会话前显示一个圆点。' : 'Show a dot before each session.',
|
|
1639
|
-
checked: prefs.sessionDot,
|
|
1640
|
-
onChange: update('sessionDot'),
|
|
1641
|
-
}),
|
|
1642
|
-
h(Row, {
|
|
1643
|
-
title: zh ? '移除工作区与会话悬停提示' : 'Remove workspace and session hover hints',
|
|
2725
|
+
title: zh ? '移除工作区与会话悬停详情卡片' : 'Remove workspace and session hover cards',
|
|
1644
2726
|
desc: zh ? '悬停在侧栏工作区、会话上时,不再显示详情卡片。使滚动更流畅。' : 'Hovering a workspace or session no longer shows a details card, which keeps scrolling smooth.',
|
|
1645
2727
|
checked: prefs.hideHoverCard,
|
|
1646
2728
|
onChange: update('hideHoverCard'),
|
|
1647
2729
|
}),
|
|
1648
2730
|
h(Row, {
|
|
1649
2731
|
title: zh ? '隐藏会话悬停多余按钮' : 'Hide extra session-row buttons',
|
|
1650
|
-
desc: zh ? '
|
|
2732
|
+
desc: zh ? '隐藏会话悬停时除了菜单和置顶之外的其他按钮,避免拥挤遮盖过多标题。\n正常情况下这些按钮都已经在右键菜单中包含。若其他插件添加的按钮未在右键菜单包含,可以关闭此功能。' : 'Hide every button on a hovered session row except the "…" menu and pin, so they stop crowding the title.\nThese actions are normally in the right-click menu too; turn this off if a plugin adds a button that is not.',
|
|
1651
2733
|
checked: prefs.hideRowButtons,
|
|
1652
2734
|
onChange: update('hideRowButtons'),
|
|
1653
2735
|
}),
|
|
1654
2736
|
h(Row, {
|
|
1655
|
-
title: zh ? '
|
|
1656
|
-
desc: zh ? '
|
|
1657
|
-
checked: prefs.
|
|
1658
|
-
onChange: update('
|
|
2737
|
+
title: zh ? '会话前圆点' : 'Session leading dot',
|
|
2738
|
+
desc: zh ? '在侧栏工作区会话前显示一个圆点标记。' : 'Show a dot marker before each session in the sidebar.',
|
|
2739
|
+
checked: prefs.sessionDot,
|
|
2740
|
+
onChange: update('sessionDot'),
|
|
2741
|
+
}),
|
|
2742
|
+
),
|
|
2743
|
+
h('div', { className: 'dcc-group' },
|
|
2744
|
+
h('div', { className: 'dcc-group-title' }, zh ? '会话标题栏' : 'Session header'),
|
|
2745
|
+
h(Row, {
|
|
2746
|
+
title: zh ? '柔化标题栏与会话区域过渡' : 'Soften the header-to-conversation transition',
|
|
2747
|
+
desc: zh ? '移除分割线,使用柔化边缘过渡标题栏和会话正文。' : 'Remove the divider and use a soft edge to ease the transition between the header and the conversation.',
|
|
2748
|
+
checked: prefs.headerFade,
|
|
2749
|
+
onChange: update('headerFade'),
|
|
2750
|
+
}),
|
|
2751
|
+
h(Row, {
|
|
2752
|
+
title: zh ? '会话标题栏紧凑化' : 'Compact session header',
|
|
2753
|
+
desc: zh ? '将视图切换按钮移到右上工具按钮处。使会话内容可视范围更大。\n此按钮在对话模式下默认隐藏,鼠标位于标题栏区域时才会显示。' : 'Move the view switcher button to the toolbar buttons in the top-right, giving the conversation more room.\nIn the conversation view it is hidden by default and only appears when the pointer is over the header.',
|
|
2754
|
+
checked: prefs.compactHeader,
|
|
2755
|
+
onChange: update('compactHeader'),
|
|
2756
|
+
}),
|
|
2757
|
+
h(Row, {
|
|
2758
|
+
title: zh ? '紧凑标题栏始终显示视图切换控件' : 'Always show view switcher',
|
|
2759
|
+
desc: zh ? '在对话视图下不自动隐藏视图切换控件。' : 'Keep the view switcher visible in the conversation view instead of hiding it until hover.',
|
|
2760
|
+
checked: prefs.compactAlwaysShow,
|
|
2761
|
+
disabled: !prefs.compactHeader,
|
|
2762
|
+
onChange: update('compactAlwaysShow'),
|
|
1659
2763
|
})),
|
|
1660
2764
|
h('div', { className: 'dcc-group' },
|
|
1661
2765
|
h('div', { className: 'dcc-group-title' }, zh ? '性能与用量信息' : 'Performance and usage'),
|
|
@@ -1712,9 +2816,55 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1712
2816
|
checked: prefs.textSelectLimit,
|
|
1713
2817
|
onChange: update('textSelectLimit'),
|
|
1714
2818
|
})),
|
|
1715
|
-
h('
|
|
1716
|
-
|
|
1717
|
-
|
|
2819
|
+
h('div', { className: 'dcc-group' },
|
|
2820
|
+
h('div', { className: 'dcc-group-title' }, zh ? '基础改进' : 'Base fixes'),
|
|
2821
|
+
h(InfoRow, {
|
|
2822
|
+
title: zh ? '基础细节改进和修复' : 'Base detail fixes and improvements',
|
|
2823
|
+
desc: zh
|
|
2824
|
+
? [
|
|
2825
|
+
'这些基础修复和改进影响很小,会始终启用,除非关闭总开关。',
|
|
2826
|
+
'- 左侧导航栏部分布局细节优化。',
|
|
2827
|
+
'- 工作区文件夹悬停时保留图标。',
|
|
2828
|
+
'- 已归档会话显示删除线。',
|
|
2829
|
+
'- 选择题弹窗细节优化。',
|
|
2830
|
+
'- 避免界面加载时跳变添加的过渡遮罩。',
|
|
2831
|
+
'- 修复二级右键菜单消失延迟。',
|
|
2832
|
+
].join('\n')
|
|
2833
|
+
: [
|
|
2834
|
+
'These small fixes and improvements are always on unless the master switch is off.',
|
|
2835
|
+
'- Layout details refined in the left navigation.',
|
|
2836
|
+
'- Workspace folder icons stay visible on hover.',
|
|
2837
|
+
'- Archived sessions show a strikethrough.',
|
|
2838
|
+
'- Multiple-choice dialog details refined.',
|
|
2839
|
+
'- A transition cover added to avoid layout jumps on startup.',
|
|
2840
|
+
'- Fixed the delay when closing a second-level context menu.',
|
|
2841
|
+
].join('\n'),
|
|
2842
|
+
})),
|
|
2843
|
+
h('div', { className: 'dcc-meta-row' },
|
|
2844
|
+
h('p', { className: 'dcc-meta' },
|
|
2845
|
+
/* 中文之间用一个全角空格(\u3000)分隔,比两个半角空格更稳 */
|
|
2846
|
+
zh
|
|
2847
|
+
? `版本:${VERSION}\u3000更新日期:${UPDATED}\n此版本基于 DSH v0.2.2-rc.3 测试`
|
|
2848
|
+
: `Version: ${VERSION} Updated: ${UPDATED}\nTested on DSH v0.2.2-rc.3`),
|
|
2849
|
+
h('button', {
|
|
2850
|
+
type: 'button',
|
|
2851
|
+
className: 'dcc-reset',
|
|
2852
|
+
onClick: () => setConfirmReset(true),
|
|
2853
|
+
}, zh ? '重置设置' : 'Reset')),
|
|
2854
|
+
confirmReset ? h('div', { className: 'dcc-modal', role: 'presentation' },
|
|
2855
|
+
h('div', {
|
|
2856
|
+
className: 'dcc-modal-mask',
|
|
2857
|
+
'aria-hidden': 'true',
|
|
2858
|
+
onClick: () => setConfirmReset(false),
|
|
2859
|
+
}),
|
|
2860
|
+
h('div', { className: 'dcc-modal-card', role: 'dialog', 'aria-modal': 'true', 'aria-label': zh ? '重置 UI 改进选项' : 'Reset UI improvements' },
|
|
2861
|
+
h('div', { className: 'dcc-modal-content' },
|
|
2862
|
+
h('div', { className: 'dcc-modal-title' }, zh ? '重置 UI 改进选项' : 'Reset UI improvements'),
|
|
2863
|
+
h('div', { className: 'dcc-modal-body' }, zh ? '将会重置本插件的所有设置项到默认状态。' : 'Every option in this plugin will be reset to its default.')),
|
|
2864
|
+
h('div', { className: 'dcc-modal-actions' },
|
|
2865
|
+
h('button', { type: 'button', className: 'dcc-modal-btn', onClick: () => setConfirmReset(false) }, zh ? '取消' : 'Cancel'),
|
|
2866
|
+
h('button', { type: 'button', className: 'dcc-modal-btn dcc-modal-primary', onClick: () => { resetPrefs(); } }, zh ? '重置' : 'Reset'))))
|
|
2867
|
+
: null);
|
|
1718
2868
|
}
|
|
1719
2869
|
|
|
1720
2870
|
function SectionIcon(props) {
|
|
@@ -1750,7 +2900,10 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1750
2900
|
const removeHoverCardBlocker = installHoverCardBlocker();
|
|
1751
2901
|
const removeViewSwitcher = installViewSwitcher();
|
|
1752
2902
|
const removeBalance = installBalancePill(ctx);
|
|
2903
|
+
const removeBootCover = installBootCover(readPrefs());
|
|
1753
2904
|
const removePluginPin = installNavToggle();
|
|
2905
|
+
const removeMenuOrigin = installMenuOrigin();
|
|
2906
|
+
const removeDialogExit = installDialogExit();
|
|
1754
2907
|
return () => {
|
|
1755
2908
|
removeCss();
|
|
1756
2909
|
removeNewSessionRow();
|
|
@@ -1759,15 +2912,21 @@ html[data-dcc-logo="hidden"] [class*="_logoRow"] {
|
|
|
1759
2912
|
removeHoverCardBlocker();
|
|
1760
2913
|
removeViewSwitcher();
|
|
1761
2914
|
removeBalance();
|
|
2915
|
+
removeBootCover();
|
|
1762
2916
|
removePluginPin();
|
|
2917
|
+
removeMenuOrigin();
|
|
2918
|
+
removeDialogExit();
|
|
1763
2919
|
const root = document.documentElement;
|
|
1764
2920
|
delete root.dataset.dccRadius;
|
|
1765
2921
|
delete root.dataset.dccNew;
|
|
1766
2922
|
delete root.dataset.dccDim;
|
|
2923
|
+
delete root.dataset.dccEnabled;
|
|
1767
2924
|
delete root.dataset.dccLogo;
|
|
1768
2925
|
delete root.dataset.dccDot;
|
|
1769
2926
|
delete root.dataset.dccFont;
|
|
1770
2927
|
delete root.dataset.dccTextDim;
|
|
2928
|
+
delete root.dataset.dccTransition;
|
|
2929
|
+
delete root.dataset.dccMenuBlur;
|
|
1771
2930
|
delete root.dataset.dccFull;
|
|
1772
2931
|
delete root.dataset.dccHover;
|
|
1773
2932
|
delete root.dataset.dccRowButtons;
|