@doitian/dsh-music 0.1.8 → 0.1.10
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 +11 -4
- package/lib/dj.js +135 -3
- package/lib/index.js +19 -3
- package/lib/netease.js +98 -0
- package/lib/panel.html +538 -109
- package/lib/router.js +67 -5
- package/lib/session.js +27 -0
- package/lib/state.js +25 -0
- package/package.json +1 -1
package/lib/panel.html
CHANGED
|
@@ -13,10 +13,16 @@
|
|
|
13
13
|
<meta name="dsh-music-panel-contract" content="2" />
|
|
14
14
|
<title>Music · music.163.com</title>
|
|
15
15
|
<style>
|
|
16
|
+
/* DSH's light palette (base background, primary label, scrollbar). The
|
|
17
|
+
page follows the shell's theme while it sits inside DSH, and the
|
|
18
|
+
system's otherwise; see syncShellTheme. Every other colour is mixed
|
|
19
|
+
from these. */
|
|
16
20
|
:root {
|
|
17
|
-
color-scheme: light
|
|
18
|
-
--bg:
|
|
19
|
-
--fg:
|
|
21
|
+
color-scheme: light;
|
|
22
|
+
--bg: #ffffff;
|
|
23
|
+
--fg: #0f1115;
|
|
24
|
+
--scrollbar-thumb: #e5e5e5;
|
|
25
|
+
--scrollbar-thumb-hover: #d4d4d4;
|
|
20
26
|
--muted: color-mix(in srgb, var(--fg) 56%, transparent);
|
|
21
27
|
--faint: color-mix(in srgb, var(--fg) 38%, transparent);
|
|
22
28
|
--line: color-mix(in srgb, var(--fg) 12%, transparent);
|
|
@@ -27,6 +33,23 @@
|
|
|
27
33
|
--radius: 12px;
|
|
28
34
|
--gap: 16px;
|
|
29
35
|
}
|
|
36
|
+
/* DSH's dark palette: the system's choice standalone, the shell's inside DSH. */
|
|
37
|
+
@media (prefers-color-scheme: dark) {
|
|
38
|
+
:root:not([data-theme="light"]) {
|
|
39
|
+
color-scheme: dark;
|
|
40
|
+
--bg: #151517;
|
|
41
|
+
--fg: #f9fafb;
|
|
42
|
+
--scrollbar-thumb: #3c3c3d;
|
|
43
|
+
--scrollbar-thumb-hover: #545557;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
:root[data-theme="dark"] {
|
|
47
|
+
color-scheme: dark;
|
|
48
|
+
--bg: #151517;
|
|
49
|
+
--fg: #f9fafb;
|
|
50
|
+
--scrollbar-thumb: #3c3c3d;
|
|
51
|
+
--scrollbar-thumb-hover: #545557;
|
|
52
|
+
}
|
|
30
53
|
* { box-sizing: border-box; }
|
|
31
54
|
html, body { margin: 0; height: 100%; }
|
|
32
55
|
body {
|
|
@@ -48,7 +71,25 @@
|
|
|
48
71
|
background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
|
|
49
72
|
}
|
|
50
73
|
input:focus, select:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
|
|
51
|
-
|
|
74
|
+
/* One icon set, one stroke: every icon on the page is drawn the same way,
|
|
75
|
+
and a state fills the outline rather than swapping in another glyph. */
|
|
76
|
+
svg.i { display: block; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
|
|
77
|
+
svg.i.filled { fill: currentColor; }
|
|
78
|
+
svg.i.small { width: 14px; height: 14px; }
|
|
79
|
+
|
|
80
|
+
/* Scrollbars as DSH draws them in its conversation and everywhere else
|
|
81
|
+
(dsh-client-ui-theme's scrollbar.css): a 5px rounded thumb on no
|
|
82
|
+
track, darker under the pointer. */
|
|
83
|
+
@supports not selector(::-webkit-scrollbar) {
|
|
84
|
+
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; }
|
|
85
|
+
}
|
|
86
|
+
::-webkit-scrollbar { width: 5px; height: 5px; }
|
|
87
|
+
::-webkit-scrollbar-track { background: none; }
|
|
88
|
+
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); background-clip: content-box; border-radius: 999px; }
|
|
89
|
+
::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-thumb-hover); }
|
|
90
|
+
::-webkit-scrollbar-corner { background: none; }
|
|
91
|
+
/* Inside a card, the thumb keeps clear of the rounded corners, as DSH's own cards do. */
|
|
92
|
+
.card ::-webkit-scrollbar-track { margin-block: 6px; }
|
|
52
93
|
|
|
53
94
|
/* ------------------------------------------------------------ layout
|
|
54
95
|
Wide: the stage (what is playing) on the left, what comes next — the
|
|
@@ -78,9 +119,11 @@
|
|
|
78
119
|
.side { overflow: hidden; border-left: 1px solid var(--line); }
|
|
79
120
|
.side .queue-card { flex: 1; min-height: 0; }
|
|
80
121
|
.side #queue { overflow: auto; }
|
|
81
|
-
/* With a column of its own, the lyrics fill what the stage
|
|
82
|
-
|
|
83
|
-
|
|
122
|
+
/* With a column of its own, the details or lyrics fill what the stage
|
|
123
|
+
leaves. The floor is the header and two lines: any higher and a short
|
|
124
|
+
window scrolls the whole column as well as the card. */
|
|
125
|
+
.stage .info-card { flex: 1; min-height: 72px; }
|
|
126
|
+
.stage .lyrics, .stage .details { flex: 1; max-height: none; }
|
|
84
127
|
}
|
|
85
128
|
|
|
86
129
|
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
|
|
@@ -104,7 +147,8 @@
|
|
|
104
147
|
display: grid; place-items: center; color: var(--faint); font-size: 40px;
|
|
105
148
|
box-shadow: 0 6px 24px color-mix(in srgb, #000 14%, transparent);
|
|
106
149
|
}
|
|
107
|
-
|
|
150
|
+
#cover-icon { display: grid; place-items: center; width: 38%; height: 38%; }
|
|
151
|
+
#cover-icon svg.i { width: 100%; height: 100%; stroke-width: 1.5; }
|
|
108
152
|
#cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
|
109
153
|
.np-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
|
110
154
|
.now-title { font-size: 22px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
|
|
@@ -116,7 +160,7 @@
|
|
|
116
160
|
.taste { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
|
|
117
161
|
.taste button {
|
|
118
162
|
width: 34px; height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center;
|
|
119
|
-
background: none;
|
|
163
|
+
background: none; color: var(--muted);
|
|
120
164
|
}
|
|
121
165
|
.taste button:hover:not(:disabled) { color: var(--fg); background: var(--hover); }
|
|
122
166
|
.taste button.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
|
|
@@ -132,7 +176,8 @@
|
|
|
132
176
|
.transport button:hover:not(:disabled) { background: var(--hover); }
|
|
133
177
|
.transport #play { width: 52px; height: 52px; background: var(--accent); color: #fff; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 35%, transparent); }
|
|
134
178
|
.transport #play:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
|
|
135
|
-
.transport
|
|
179
|
+
.transport svg.i { width: 20px; height: 20px; }
|
|
180
|
+
.transport #play svg.i { width: 22px; height: 22px; }
|
|
136
181
|
|
|
137
182
|
.secondary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
|
|
138
183
|
.secondary select, .secondary > button { padding: 4px 8px; font-size: 12px; }
|
|
@@ -141,7 +186,15 @@
|
|
|
141
186
|
#mute:hover:not(:disabled) { color: var(--fg); }
|
|
142
187
|
#volume { flex: 0 0 96px; }
|
|
143
188
|
|
|
144
|
-
.
|
|
189
|
+
.info-card { display: flex; flex-direction: column; min-height: 0; }
|
|
190
|
+
.tabs { display: flex; gap: 14px; }
|
|
191
|
+
.tab {
|
|
192
|
+
background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 0 0 2px;
|
|
193
|
+
color: var(--muted); font: inherit; text-transform: inherit; letter-spacing: inherit;
|
|
194
|
+
}
|
|
195
|
+
.tab:hover:not(:disabled) { background: none; color: var(--fg); }
|
|
196
|
+
.tab.on { color: var(--fg); border-bottom-color: var(--accent); }
|
|
197
|
+
.lyrics[hidden], .details[hidden] { display: none; }
|
|
145
198
|
/* The pane is a glance at the current line, not a page: a few lines of
|
|
146
199
|
synced text, scrolled for the rest. `--lyrics-lines` is the single knob. */
|
|
147
200
|
.lyrics {
|
|
@@ -150,10 +203,44 @@
|
|
|
150
203
|
overflow: auto; padding: 2px 12px 14px; font-size: 14px; line-height: 1.6; scrollbar-width: none;
|
|
151
204
|
}
|
|
152
205
|
.lyrics::-webkit-scrollbar { display: none; }
|
|
153
|
-
.lyrics.collapsed { display: none; }
|
|
154
206
|
.lyrics p { margin: 0; padding: 2px 0; color: var(--faint); transition: color 0.15s; }
|
|
155
207
|
.lyrics p.on { color: var(--fg); font-weight: 600; }
|
|
156
208
|
|
|
209
|
+
/* The song's facts first, then prose about the song, its artists and its
|
|
210
|
+
album, each clamped to a few lines until clicked. */
|
|
211
|
+
.details {
|
|
212
|
+
max-height: 320px; overflow: auto; padding: 2px 12px 14px;
|
|
213
|
+
display: flex; flex-direction: column; gap: 12px;
|
|
214
|
+
}
|
|
215
|
+
.details .alias { color: var(--muted); margin: 0; }
|
|
216
|
+
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 5px 14px; margin: 0; }
|
|
217
|
+
.facts dt { color: var(--muted); }
|
|
218
|
+
.facts dd { margin: 0; overflow-wrap: anywhere; }
|
|
219
|
+
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
220
|
+
.chip { padding: 0 8px; border-radius: 999px; background: var(--hover); font-size: 12px; }
|
|
221
|
+
.chip.genre { background: var(--accent-soft); }
|
|
222
|
+
.about h4 {
|
|
223
|
+
margin: 0 0 3px; color: var(--muted); font-size: 11px; font-weight: 600;
|
|
224
|
+
text-transform: uppercase; letter-spacing: 0.6px;
|
|
225
|
+
}
|
|
226
|
+
.about .prose {
|
|
227
|
+
cursor: pointer;
|
|
228
|
+
display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden;
|
|
229
|
+
}
|
|
230
|
+
.about .prose.open { display: block; }
|
|
231
|
+
.about .prose p { margin: 0; }
|
|
232
|
+
.about .prose p + p { margin-top: 8px; }
|
|
233
|
+
.about .by { color: var(--muted); font-size: 12px; margin-top: 2px; }
|
|
234
|
+
.about .badge {
|
|
235
|
+
margin-left: 6px; padding: 0 5px; border-radius: 4px; background: var(--accent-soft); color: var(--accent);
|
|
236
|
+
font-size: 10px; letter-spacing: 0.4px;
|
|
237
|
+
}
|
|
238
|
+
.about .written { cursor: pointer; }
|
|
239
|
+
.about .written p { margin: 0; }
|
|
240
|
+
.about .written p + p { margin-top: 8px; }
|
|
241
|
+
.about .writing { color: var(--muted); margin: 0; }
|
|
242
|
+
.details .source { align-self: flex-start; font-size: 12px; }
|
|
243
|
+
|
|
157
244
|
.need-gesture {
|
|
158
245
|
background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
|
|
159
246
|
border-radius: var(--radius); padding: 8px 12px; font-size: 12px;
|
|
@@ -165,18 +252,21 @@
|
|
|
165
252
|
.dj-card .card-head .title { color: var(--fg); font-size: 13px; font-weight: 650; text-transform: none; letter-spacing: 0; }
|
|
166
253
|
.dj-body { display: flex; flex-direction: column; gap: 8px; padding: 0 12px; font-size: 12px; }
|
|
167
254
|
#dj-prompt { width: 100%; }
|
|
168
|
-
/*
|
|
169
|
-
|
|
255
|
+
/* A switch reads on or off at a glance: the DJ, the listening history. */
|
|
256
|
+
.switch {
|
|
170
257
|
position: relative; width: 38px; height: 22px; padding: 0; border-radius: 11px;
|
|
171
258
|
background: color-mix(in srgb, var(--fg) 20%, transparent); border: 0; color: transparent; overflow: hidden;
|
|
172
259
|
}
|
|
173
|
-
|
|
260
|
+
.switch::after {
|
|
174
261
|
content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
|
|
175
262
|
background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px color-mix(in srgb, #000 30%, transparent);
|
|
176
263
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
264
|
+
.switch.on { background: var(--accent); }
|
|
265
|
+
.switch.on::after { transform: translateX(16px); }
|
|
266
|
+
.switch:hover:not(:disabled) { filter: brightness(0.96); }
|
|
267
|
+
/* The listening-history switch only means something signed in. */
|
|
268
|
+
.history { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
|
|
269
|
+
.history[hidden] { display: none; }
|
|
180
270
|
.plan b { color: var(--accent); }
|
|
181
271
|
.plan .muted, .muted { color: var(--muted); }
|
|
182
272
|
.plan > div + div { margin-top: 2px; }
|
|
@@ -187,7 +277,7 @@
|
|
|
187
277
|
display: inline-flex; gap: 2px; align-items: center; color: var(--fg);
|
|
188
278
|
background: var(--accent-soft); border-radius: 999px; padding: 1px 2px 1px 9px;
|
|
189
279
|
}
|
|
190
|
-
#boosts .boost button { border: 0; background: none; padding:
|
|
280
|
+
#boosts .boost button { border: 0; background: none; padding: 2px 5px; color: var(--muted); }
|
|
191
281
|
#boosts .boost button:hover:not(:disabled) { color: var(--fg); }
|
|
192
282
|
|
|
193
283
|
/* The DJ model picker is a set-once setting, so it keeps only its header
|
|
@@ -214,7 +304,7 @@
|
|
|
214
304
|
.row.playing { background: var(--accent-soft); }
|
|
215
305
|
.row.playing .name { color: var(--accent); font-weight: 600; }
|
|
216
306
|
.row .idx { width: 20px; text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; }
|
|
217
|
-
.row.playing .idx { color: var(--accent); }
|
|
307
|
+
.row.playing .idx { color: var(--accent); display: grid; justify-items: end; }
|
|
218
308
|
.row img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; background: var(--panel); }
|
|
219
309
|
.row .meta { min-width: 0; flex: 1; }
|
|
220
310
|
.row .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
@@ -222,14 +312,15 @@
|
|
|
222
312
|
.row .tag { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); flex: none; }
|
|
223
313
|
.row .dur { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; min-width: 32px; text-align: right; }
|
|
224
314
|
.row .acts { display: none; gap: 4px; flex: none; }
|
|
225
|
-
.row .acts button { padding:
|
|
315
|
+
.row .acts button { padding: 3px 5px; background: none; color: var(--muted); }
|
|
316
|
+
.row .acts button:hover:not(:disabled) { color: var(--fg); }
|
|
226
317
|
.row:hover .acts { display: flex; }
|
|
227
318
|
/* The list's own like control. A liked track keeps its filled heart
|
|
228
319
|
visible; the hollow one only appears on hover, so an unrated list is
|
|
229
320
|
not a wall of outlines. */
|
|
230
321
|
.row .heart {
|
|
231
|
-
background: none; border: 0; padding: 0;
|
|
232
|
-
|
|
322
|
+
background: none; border: 0; padding: 0; flex: none;
|
|
323
|
+
color: var(--muted); opacity: 0; transition: opacity 0.12s;
|
|
233
324
|
}
|
|
234
325
|
.row:hover .heart { opacity: 1; }
|
|
235
326
|
.row .heart.on { opacity: 1; color: var(--accent); }
|
|
@@ -237,7 +328,7 @@
|
|
|
237
328
|
|
|
238
329
|
.toast {
|
|
239
330
|
position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
|
|
240
|
-
background:
|
|
331
|
+
background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 9px; font-size: 12px;
|
|
241
332
|
opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 40; max-width: 80%;
|
|
242
333
|
}
|
|
243
334
|
.toast.on { opacity: 0.94; }
|
|
@@ -248,7 +339,7 @@
|
|
|
248
339
|
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
|
|
249
340
|
#qr { display: block; margin: 12px auto; width: 220px; height: 220px; image-rendering: pixelated; border-radius: 8px; background: #fff; padding: 8px; }
|
|
250
341
|
.hint { color: var(--muted); font-size: 12px; text-align: center; }
|
|
251
|
-
.lyrics .hint { text-align: left; }
|
|
342
|
+
.lyrics .hint, .details .hint { text-align: left; margin: 0; }
|
|
252
343
|
.row-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; }
|
|
253
344
|
</style>
|
|
254
345
|
</head>
|
|
@@ -257,6 +348,10 @@
|
|
|
257
348
|
<header>
|
|
258
349
|
<div class="brand"><span data-i18n="brand">Music</span><small>music.163.com</small></div>
|
|
259
350
|
<div class="spacer"></div>
|
|
351
|
+
<div class="history" id="history" hidden>
|
|
352
|
+
<span id="history-label" data-i18n="scrobbleLabel">Listening history</span>
|
|
353
|
+
<button id="scrobble-toggle" class="switch" role="switch" aria-labelledby="history-label"></button>
|
|
354
|
+
</div>
|
|
260
355
|
<div id="account"></div>
|
|
261
356
|
</header>
|
|
262
357
|
|
|
@@ -264,7 +359,7 @@
|
|
|
264
359
|
<section class="stage">
|
|
265
360
|
<div id="notices"></div>
|
|
266
361
|
<div class="np">
|
|
267
|
-
<div class="cover"><img id="cover" alt="" /></div>
|
|
362
|
+
<div class="cover"><span id="cover-icon"></span><img id="cover" alt="" /></div>
|
|
268
363
|
<div class="np-text">
|
|
269
364
|
<div class="now-title" id="np-title" data-i18n="nothingPlaying">Nothing playing</div>
|
|
270
365
|
<div class="now-artists" id="np-artists"></div>
|
|
@@ -272,10 +367,10 @@
|
|
|
272
367
|
<!-- Labels are state-dependent (a filled heart un-likes), so the
|
|
273
368
|
script owns text and title rather than data-i18n. -->
|
|
274
369
|
<div class="taste">
|
|
275
|
-
<button id="like" title="Like"
|
|
276
|
-
<button id="dislike" title="Dislike"
|
|
277
|
-
<button id="boost-more" title="More like this for an hour"
|
|
278
|
-
<button id="boost-less" title="Fewer like this for an hour"
|
|
370
|
+
<button id="like" title="Like"></button>
|
|
371
|
+
<button id="dislike" title="Dislike"></button>
|
|
372
|
+
<button id="boost-more" title="More like this for an hour"></button>
|
|
373
|
+
<button id="boost-less" title="Fewer like this for an hour"></button>
|
|
279
374
|
</div>
|
|
280
375
|
</div>
|
|
281
376
|
</div>
|
|
@@ -286,9 +381,9 @@
|
|
|
286
381
|
<span id="t-dur">0:00</span>
|
|
287
382
|
</div>
|
|
288
383
|
<div class="transport">
|
|
289
|
-
<button id="prev" data-i18n-title="prev" title="Previous"
|
|
290
|
-
<button id="play" data-i18n-title="playPause" title="Play/pause"
|
|
291
|
-
<button id="next" data-i18n-title="next" title="Next"
|
|
384
|
+
<button id="prev" data-i18n-title="prev" title="Previous"></button>
|
|
385
|
+
<button id="play" data-i18n-title="playPause" title="Play/pause"></button>
|
|
386
|
+
<button id="next" data-i18n-title="next" title="Next"></button>
|
|
292
387
|
</div>
|
|
293
388
|
<div class="secondary">
|
|
294
389
|
<button id="mode" data-i18n-title="modeTitle" data-i18n="modeList" title="Playback mode">List</button>
|
|
@@ -299,15 +394,15 @@
|
|
|
299
394
|
<input type="range" id="volume" min="0" max="1" step="0.01" value="0.8" />
|
|
300
395
|
</div>
|
|
301
396
|
|
|
302
|
-
<div class="card
|
|
397
|
+
<div class="card info-card">
|
|
303
398
|
<div class="card-head">
|
|
304
|
-
<
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
<button id="lyrics-toggle" class="link" type="button" aria-expanded="true">Hide</button>
|
|
399
|
+
<div class="tabs" role="tablist">
|
|
400
|
+
<button id="tab-details" class="tab" type="button" role="tab" data-i18n="details">Details</button>
|
|
401
|
+
<button id="tab-lyrics" class="tab" type="button" role="tab" data-i18n="lyrics">Lyrics</button>
|
|
402
|
+
</div>
|
|
309
403
|
</div>
|
|
310
|
-
<div class="
|
|
404
|
+
<div class="details" id="details" role="tabpanel"><p class="hint">—</p></div>
|
|
405
|
+
<div class="lyrics" id="lyrics" role="tabpanel" hidden><p class="hint">—</p></div>
|
|
311
406
|
</div>
|
|
312
407
|
</section>
|
|
313
408
|
|
|
@@ -316,7 +411,7 @@
|
|
|
316
411
|
<div class="card-head">
|
|
317
412
|
<span class="title">AI DJ</span>
|
|
318
413
|
<span class="grow"></span>
|
|
319
|
-
<button id="dj-toggle" role="switch" data-i18n-title="djToggleTitle" title="Continuous AI DJ: keep the queue stocked">AI DJ</button>
|
|
414
|
+
<button id="dj-toggle" class="switch" role="switch" data-i18n-title="djToggleTitle" title="Continuous AI DJ: keep the queue stocked">AI DJ</button>
|
|
320
415
|
</div>
|
|
321
416
|
<div class="dj-body">
|
|
322
417
|
<input id="dj-prompt" data-i18n-ph="djPromptPh" placeholder="AI DJ mood, e.g. rainy afternoon jazz" />
|
|
@@ -351,7 +446,11 @@
|
|
|
351
446
|
</div>
|
|
352
447
|
|
|
353
448
|
<div class="card queue-card">
|
|
354
|
-
<div class="card-head"
|
|
449
|
+
<div class="card-head">
|
|
450
|
+
<span data-i18n="queue">Queue</span> <span id="counts"></span>
|
|
451
|
+
<span class="grow"></span>
|
|
452
|
+
<button id="queue-clear" class="link" type="button" data-i18n="clearQueue" data-i18n-title="clearQueueTitle">Clear</button>
|
|
453
|
+
</div>
|
|
355
454
|
<div id="queue"></div>
|
|
356
455
|
</div>
|
|
357
456
|
</aside>
|
|
@@ -409,10 +508,24 @@
|
|
|
409
508
|
likeNeedsSignIn: '登录后才能在网易云标记喜欢',
|
|
410
509
|
mute: '静音',
|
|
411
510
|
lyrics: '歌词',
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
511
|
+
details: '详情',
|
|
512
|
+
noDetails: '暂无这首歌的信息',
|
|
513
|
+
album: '专辑',
|
|
514
|
+
albumTracks: '{n} 首',
|
|
515
|
+
genre: '曲风',
|
|
516
|
+
tags: '标签',
|
|
517
|
+
language: '语种',
|
|
518
|
+
featuredIn: '影视节目',
|
|
519
|
+
awards: '获奖',
|
|
520
|
+
aboutSong: '关于这首歌',
|
|
521
|
+
aboutAlbum: '关于专辑',
|
|
522
|
+
reviewBy: '乐评来自 {name}',
|
|
523
|
+
intro: '简介',
|
|
524
|
+
introWriting: '正在撰写简介…',
|
|
525
|
+
introFromNetease: '查看网易云音乐的介绍',
|
|
526
|
+
introFromAi: '查看 AI 简介',
|
|
527
|
+
introToNetease: '点击查看网易云音乐的介绍',
|
|
528
|
+
expand: '点击展开或收起',
|
|
416
529
|
queue: '播放队列',
|
|
417
530
|
djModel: 'AI DJ 模型',
|
|
418
531
|
djModelToggleShow: '展开模型设置',
|
|
@@ -444,6 +557,8 @@
|
|
|
444
557
|
queueEmpty: '队列为空,用 AI DJ 或让助手补歌',
|
|
445
558
|
remove: '移除',
|
|
446
559
|
removed: '已移除',
|
|
560
|
+
clearQueue: '清空',
|
|
561
|
+
clearQueueTitle: '清空队列,保留正在播放的歌曲;不会给歌曲打分',
|
|
447
562
|
loading: '加载中…',
|
|
448
563
|
instrumental: '纯音乐,无歌词',
|
|
449
564
|
other: '其他…',
|
|
@@ -473,6 +588,11 @@
|
|
|
473
588
|
boostCleared: '已取消临时偏好',
|
|
474
589
|
boostsTitle: '临时偏好',
|
|
475
590
|
boostMinutes: '{n} 分钟',
|
|
591
|
+
scrobbleLabel: '听歌记录',
|
|
592
|
+
scrobbleOnTitle: '播放计入网易云听歌记录(最近播放、听歌排行)——点击停止',
|
|
593
|
+
scrobbleOffTitle: '播放只留在本地——点击计入网易云听歌记录',
|
|
594
|
+
scrobbleOn: '播放将计入网易云听歌记录',
|
|
595
|
+
scrobbleOff: '播放不再计入听歌记录',
|
|
476
596
|
djOn: 'AI DJ 已开启',
|
|
477
597
|
djOff: 'AI DJ 已关闭',
|
|
478
598
|
connectFailed: '连接失败:',
|
|
@@ -506,10 +626,24 @@
|
|
|
506
626
|
likeNeedsSignIn: 'Sign in to NetEase to like tracks',
|
|
507
627
|
mute: 'Mute',
|
|
508
628
|
lyrics: 'Lyrics',
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
629
|
+
details: 'Details',
|
|
630
|
+
noDetails: 'No details for this song',
|
|
631
|
+
album: 'Album',
|
|
632
|
+
albumTracks: '{n} tracks',
|
|
633
|
+
genre: 'Genre',
|
|
634
|
+
tags: 'Tags',
|
|
635
|
+
language: 'Language',
|
|
636
|
+
featuredIn: 'Featured in',
|
|
637
|
+
awards: 'Awards',
|
|
638
|
+
aboutSong: 'About the song',
|
|
639
|
+
aboutAlbum: 'About the album',
|
|
640
|
+
reviewBy: 'Review by {name}',
|
|
641
|
+
intro: 'Introduction',
|
|
642
|
+
introWriting: 'Writing an introduction…',
|
|
643
|
+
introFromNetease: 'Show what NetEase says',
|
|
644
|
+
introFromAi: 'Show the AI introduction',
|
|
645
|
+
introToNetease: 'Click to show what NetEase says',
|
|
646
|
+
expand: 'Click to expand or collapse',
|
|
513
647
|
queue: 'Queue',
|
|
514
648
|
djModel: 'DJ model',
|
|
515
649
|
djModelToggleShow: 'Show the model settings',
|
|
@@ -541,6 +675,8 @@
|
|
|
541
675
|
queueEmpty: 'Queue empty — use the AI DJ or ask the assistant to add songs',
|
|
542
676
|
remove: 'Remove',
|
|
543
677
|
removed: 'Removed',
|
|
678
|
+
clearQueue: 'Clear',
|
|
679
|
+
clearQueueTitle: 'Clear the queue, keeping the song playing; no song is rated',
|
|
544
680
|
loading: 'Loading…',
|
|
545
681
|
instrumental: 'Instrumental',
|
|
546
682
|
other: 'Other…',
|
|
@@ -570,6 +706,11 @@
|
|
|
570
706
|
boostCleared: 'Boost cleared',
|
|
571
707
|
boostsTitle: 'Boosts',
|
|
572
708
|
boostMinutes: '{n} min',
|
|
709
|
+
scrobbleLabel: 'Listening history',
|
|
710
|
+
scrobbleOnTitle: 'Plays are added to your NetEase listening history (最近播放, 听歌排行) — click to stop',
|
|
711
|
+
scrobbleOffTitle: 'Plays stay local — click to add them to your NetEase listening history',
|
|
712
|
+
scrobbleOn: 'Plays will be added to your NetEase listening history',
|
|
713
|
+
scrobbleOff: 'Plays will stay local',
|
|
573
714
|
djOn: 'AI DJ on',
|
|
574
715
|
djOff: 'AI DJ off',
|
|
575
716
|
connectFailed: 'Cannot reach the host: ',
|
|
@@ -597,19 +738,62 @@
|
|
|
597
738
|
}
|
|
598
739
|
|
|
599
740
|
/** Translate a key, interpolating `{name}` placeholders from `vars`. */
|
|
600
|
-
/**
|
|
741
|
+
/**
|
|
742
|
+
* The page's one icon set: Lucide (https://lucide.dev, ISC licence), drawn
|
|
743
|
+
* as 24px outlines. DSH shares no icon set with plugins — the shell's
|
|
744
|
+
* module table holds React, Cordis and its UI primitives, none an icon
|
|
745
|
+
* library — and this page is its own document, so it carries its own.
|
|
746
|
+
* A state fills an outline (a liked heart) rather than swapping glyphs.
|
|
747
|
+
*/
|
|
601
748
|
const ICONS = {
|
|
602
|
-
play: '<
|
|
603
|
-
pause: '<
|
|
604
|
-
|
|
605
|
-
|
|
749
|
+
play: '<polygon points="6 3 20 12 6 21 6 3"/>',
|
|
750
|
+
pause: '<rect x="14" y="4" width="4" height="16" rx="1"/><rect x="6" y="4" width="4" height="16" rx="1"/>',
|
|
751
|
+
skipBack: '<polygon points="19 20 9 12 19 4 19 20"/><line x1="5" x2="5" y1="19" y2="5"/>',
|
|
752
|
+
skipForward: '<polygon points="5 4 15 12 5 20 5 4"/><line x1="19" x2="19" y1="5" y2="19"/>',
|
|
753
|
+
volume: '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><path d="M15.54 8.46a5 5 0 0 1 0 7.07"/><path d="M19.07 4.93a10 10 0 0 1 0 14.14"/>',
|
|
754
|
+
muted: '<polygon points="11 5 6 9 2 9 2 15 6 15 11 19 11 5"/><line x1="22" x2="16" y1="9" y2="15"/><line x1="16" x2="22" y1="9" y2="15"/>',
|
|
755
|
+
heart: '<path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/>',
|
|
756
|
+
x: '<path d="M18 6 6 18"/><path d="m6 6 12 12"/>',
|
|
757
|
+
more: '<path d="m17 11-5-5-5 5"/><path d="m17 18-5-5-5 5"/>',
|
|
758
|
+
less: '<path d="m7 6 5 5 5-5"/><path d="m7 13 5 5 5-5"/>',
|
|
759
|
+
music: '<path d="M9 18V5l12-2v13"/><circle cx="6" cy="18" r="3"/><circle cx="18" cy="16" r="3"/>',
|
|
606
760
|
};
|
|
607
761
|
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
762
|
+
function paintStaticIcons() {
|
|
763
|
+
setIcon($('prev'), 'skipBack');
|
|
764
|
+
setIcon($('next'), 'skipForward');
|
|
765
|
+
setIcon($('dislike'), 'x');
|
|
766
|
+
setIcon($('boost-more'), 'more');
|
|
767
|
+
setIcon($('boost-less'), 'less');
|
|
768
|
+
setIcon($('cover-icon'), 'music');
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* The listening-history switch: shown only signed in — there is no history
|
|
773
|
+
* to write to otherwise — and on when plays are being reported.
|
|
774
|
+
*/
|
|
775
|
+
function paintHistory() {
|
|
776
|
+
const scrobble = state?.scrobble;
|
|
777
|
+
const signedIn = Boolean(state?.authenticated);
|
|
778
|
+
$('history').hidden = !signedIn || !scrobble;
|
|
779
|
+
const on = Boolean(scrobble?.enabled);
|
|
780
|
+
$('scrobble-toggle').classList.toggle('on', on);
|
|
781
|
+
$('scrobble-toggle').setAttribute?.('aria-checked', String(on));
|
|
782
|
+
$('scrobble-toggle').title = t(on ? 'scrobbleOnTitle' : 'scrobbleOffTitle');
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
/** One icon as markup; `filled` fills the outline, `small` is the compact size. */
|
|
786
|
+
function icon(name, { filled = false, small = false } = {}) {
|
|
787
|
+
const classes = ['i', filled ? 'filled' : '', small ? 'small' : ''].filter(Boolean).join(' ');
|
|
788
|
+
return `<svg class="${classes}" viewBox="0 0 24 24" aria-hidden="true">${ICONS[name]}</svg>`;
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** Paint an icon into `el`, touching the DOM only when it changes. */
|
|
792
|
+
function setIcon(el, name, options = {}) {
|
|
793
|
+
const key = `${name}${options.filled ? ':filled' : ''}`;
|
|
794
|
+
if (!el || el.dataset.icon === key) return;
|
|
795
|
+
el.dataset.icon = key;
|
|
796
|
+
el.innerHTML = icon(name, options);
|
|
613
797
|
}
|
|
614
798
|
|
|
615
799
|
function t(key, vars) {
|
|
@@ -636,10 +820,11 @@
|
|
|
636
820
|
document.documentElement.lang = LANG === 'zh' ? 'zh-CN' : 'en';
|
|
637
821
|
} catch { /* headless */ }
|
|
638
822
|
applyStaticStrings();
|
|
639
|
-
// The
|
|
640
|
-
//
|
|
641
|
-
paintLyricsToggle();
|
|
823
|
+
// The model toggle's label depends on its fold, not on a fixed key, so
|
|
824
|
+
// it is painted rather than carried as data-i18n.
|
|
642
825
|
paintDjModelToggle();
|
|
826
|
+
// The details carry translated labels around NetEase's own text.
|
|
827
|
+
if (infoView === 'details') repaintDetails();
|
|
643
828
|
// The gesture hint carries markup; drop it so render() rebuilds it in
|
|
644
829
|
// the new language.
|
|
645
830
|
$('gesture')?.remove();
|
|
@@ -655,6 +840,42 @@
|
|
|
655
840
|
}
|
|
656
841
|
|
|
657
842
|
/** Follow the shell's language while this page lives inside it. */
|
|
843
|
+
/** The shell's colours this page takes on, by the shell's variable name. */
|
|
844
|
+
const SHELL_COLORS = [
|
|
845
|
+
['--dsw-alias-bg-base', '--bg'],
|
|
846
|
+
['--dsw-alias-label-primary', '--fg'],
|
|
847
|
+
['--dsh-scrollbar-thumb', '--scrollbar-thumb'],
|
|
848
|
+
['--dsh-scrollbar-thumb-hover', '--scrollbar-thumb-hover'],
|
|
849
|
+
];
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* Follow the shell's theme. DSH marks dark with `data-ds-dark-theme` on
|
|
853
|
+
* its body and paints from token variables there; this page takes the
|
|
854
|
+
* mark, then the live colours, so a custom DSH theme carries over too.
|
|
855
|
+
* A theme switch rewrites those attributes and styles, so watching them
|
|
856
|
+
* catches every switch. Standalone, the system's preference decides.
|
|
857
|
+
*/
|
|
858
|
+
function syncShellTheme() {
|
|
859
|
+
try {
|
|
860
|
+
const shell = window.parent?.document;
|
|
861
|
+
if (!shell?.body || shell === document) return;
|
|
862
|
+
const copy = () => {
|
|
863
|
+
const root = document.documentElement;
|
|
864
|
+
root.dataset.theme = shell.body.hasAttribute('data-ds-dark-theme') ? 'dark' : 'light';
|
|
865
|
+
const computed = getComputedStyle(shell.body);
|
|
866
|
+
for (const [from, to] of SHELL_COLORS) {
|
|
867
|
+
const value = computed.getPropertyValue(from).trim();
|
|
868
|
+
if (value) root.style.setProperty(to, value);
|
|
869
|
+
else root.style.removeProperty(to);
|
|
870
|
+
}
|
|
871
|
+
};
|
|
872
|
+
copy();
|
|
873
|
+
if (typeof MutationObserver !== 'function') return;
|
|
874
|
+
const observer = new MutationObserver(copy);
|
|
875
|
+
for (const node of [shell.documentElement, shell.body]) observer.observe(node, { attributes: true, attributeFilter: ['style', 'class', 'data-ds-dark-theme'] });
|
|
876
|
+
} catch { /* standalone, or the shell is out of reach */ }
|
|
877
|
+
}
|
|
878
|
+
|
|
658
879
|
function watchShellLocale() {
|
|
659
880
|
try {
|
|
660
881
|
const root = window.parent?.document?.documentElement;
|
|
@@ -671,9 +892,23 @@
|
|
|
671
892
|
let lyricTrackId = null;
|
|
672
893
|
/** Bumped per request so a slow reply for a skipped track is discarded. */
|
|
673
894
|
let lyricRequest = 0;
|
|
674
|
-
/** Local-storage key for
|
|
675
|
-
const
|
|
676
|
-
let
|
|
895
|
+
/** Local-storage key for which pane the info card shows: `details` or `lyrics`. */
|
|
896
|
+
const INFO_VIEW_PREF = 'dsh-music.info.view';
|
|
897
|
+
let infoView = readInfoViewPref();
|
|
898
|
+
/** Track whose details belong in the pane, as `lyricTrackId` is for lyrics. */
|
|
899
|
+
let detailsTrackId = null;
|
|
900
|
+
let detailsRequest = 0;
|
|
901
|
+
/** Details already fetched, by track id, so switching back is instant. */
|
|
902
|
+
const detailsCache = new Map();
|
|
903
|
+
/**
|
|
904
|
+
* Model-written introductions by `<track id>:<language>`: `'pending'`
|
|
905
|
+
* while one is being written, then `{text}`, empty when none could be.
|
|
906
|
+
*/
|
|
907
|
+
const intros = new Map();
|
|
908
|
+
/** Whether the last introduction came back empty, so the next track shows NetEase's prose while it waits. */
|
|
909
|
+
let introsUnavailable = false;
|
|
910
|
+
/** Which introduction the details show: `ai`, or NetEase's own (`netease`). Back to `ai` per track. */
|
|
911
|
+
let introSource = 'ai';
|
|
677
912
|
/** Local-storage key for whether the DJ model form is unfolded. */
|
|
678
913
|
const DJ_MODEL_PREF = 'dsh-music.djmodel.expanded';
|
|
679
914
|
let djModelExpanded = readDjModelPref();
|
|
@@ -984,25 +1219,19 @@
|
|
|
984
1219
|
$('np-title').textContent = track ? track.name : t('nothingPlaying');
|
|
985
1220
|
$('np-artists').textContent = track ? (track.artists || []).join(' / ') : '';
|
|
986
1221
|
$('np-album').textContent = track ? track.album || '' : '';
|
|
987
|
-
//
|
|
988
|
-
// every poll — not from the local transport's `applySource`,
|
|
989
|
-
// only ever runs when this page owns the audio element. In the
|
|
990
|
-
// case the shell engine plays, so that path is dead and the
|
|
991
|
-
// stayed empty forever.
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
if (trackId) loadLyrics(trackId);
|
|
996
|
-
else {
|
|
997
|
-
lyric = null;
|
|
998
|
-
lyricLine = -1;
|
|
999
|
-
$('lyrics').innerHTML = '<p class="hint">—</p>';
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
setIcon($('play'), state.playing ? 'pause' : 'play');
|
|
1222
|
+
// Details and lyrics belong to the track, and this page fetches them
|
|
1223
|
+
// itself on every poll — not from the local transport's `applySource`,
|
|
1224
|
+
// which only ever runs when this page owns the audio element. In the
|
|
1225
|
+
// normal case the shell engine plays, so that path is dead and the
|
|
1226
|
+
// pane stayed empty forever.
|
|
1227
|
+
syncInfo(track?.id ?? null);
|
|
1228
|
+
loadIntro();
|
|
1229
|
+
setIcon($('play'), state.playing ? 'pause' : 'play', { filled: true });
|
|
1003
1230
|
$('mode').textContent = { list: t('modeList'), single: t('modeSingle'), shuffle: t('modeShuffle') }[state.mode] || t('modeList');
|
|
1004
1231
|
$('counts').textContent = state.counts ? `(${state.counts.queued})` : '';
|
|
1232
|
+
$('queue-clear').disabled = (state.queue?.length ?? 0) <= (state.current ? 1 : 0);
|
|
1005
1233
|
$('dj-toggle').classList.toggle('on', Boolean(state.dj?.enabled));
|
|
1234
|
+
paintHistory();
|
|
1006
1235
|
// The mood brief is persisted player setting, not part of the DJ status
|
|
1007
1236
|
// block, so it comes from `settings`.
|
|
1008
1237
|
if (document.activeElement !== $('dj-prompt')) $('dj-prompt').value = state.settings?.djPrompt ?? '';
|
|
@@ -1090,13 +1319,13 @@
|
|
|
1090
1319
|
const index = start + offset;
|
|
1091
1320
|
const playing = index === state.index;
|
|
1092
1321
|
return `<div class="row ${playing ? 'playing' : ''}" data-jump="${index}">
|
|
1093
|
-
<span class="idx">${playing ? '
|
|
1322
|
+
<span class="idx">${playing ? icon('play', { filled: true, small: true }) : index + 1}</span>
|
|
1094
1323
|
<img src="${esc(track.picUrl || '')}" alt="" loading="lazy">
|
|
1095
1324
|
<span class="meta"><span class="name">${esc(track.name)}</span><span class="sub">${esc((track.artists || []).join(' / '))}</span></span>
|
|
1096
1325
|
${track.vip ? '<span class="tag">VIP</span>' : ''}
|
|
1097
|
-
<button class="heart ${track.liked ? 'on' : ''}" data-like="${index}" title="${esc(t(track.liked ? 'unlike' : 'like'))}">${track.liked
|
|
1326
|
+
<button class="heart ${track.liked ? 'on' : ''}" data-like="${index}" title="${esc(t(track.liked ? 'unlike' : 'like'))}">${icon('heart', { filled: track.liked, small: true })}</button>
|
|
1098
1327
|
<span class="dur">${fmt(track.duration)}</span>
|
|
1099
|
-
<span class="acts"><button data-remove="${index}" title="${esc(t('remove'))}"
|
|
1328
|
+
<span class="acts"><button data-remove="${index}" title="${esc(t('remove'))}">${icon('x', { small: true })}</button></span>
|
|
1100
1329
|
</div>`;
|
|
1101
1330
|
})
|
|
1102
1331
|
.join('');
|
|
@@ -1114,7 +1343,7 @@
|
|
|
1114
1343
|
const track = state?.current;
|
|
1115
1344
|
const liked = Boolean(track?.liked);
|
|
1116
1345
|
const disliked = Boolean(track?.disliked);
|
|
1117
|
-
$('like')
|
|
1346
|
+
setIcon($('like'), 'heart', { filled: liked });
|
|
1118
1347
|
$('like').classList.toggle('on', liked);
|
|
1119
1348
|
$('like').title = t(liked ? 'unlike' : 'like');
|
|
1120
1349
|
$('dislike').classList.toggle('on', disliked);
|
|
@@ -1140,7 +1369,7 @@
|
|
|
1140
1369
|
boosts
|
|
1141
1370
|
.map((boost) => {
|
|
1142
1371
|
const minutes = Math.max(Math.round((boost.until - now) / 60_000), 1);
|
|
1143
|
-
return `<span class="boost">${boost.direction === 'more' ? '
|
|
1372
|
+
return `<span class="boost">${icon(boost.direction === 'more' ? 'more' : 'less', { small: true })} ${esc(boost.name)} · ${esc(t('boostMinutes', { n: minutes }))}<button data-unboost="${boost.id}" title="${esc(t('boostClear'))}">${icon('x', { small: true })}</button></span>`;
|
|
1144
1373
|
})
|
|
1145
1374
|
.join('')
|
|
1146
1375
|
: '';
|
|
@@ -1233,38 +1462,212 @@
|
|
|
1233
1462
|
$('t-dur').textContent = fmt(duration);
|
|
1234
1463
|
}
|
|
1235
1464
|
|
|
1236
|
-
//
|
|
1237
|
-
/**
|
|
1238
|
-
function
|
|
1239
|
-
try { return localStorage.getItem(
|
|
1465
|
+
// ------------------------------------------------------ details + lyrics
|
|
1466
|
+
/** The pane shown, remembered across reloads when storage is open; details by default. */
|
|
1467
|
+
function readInfoViewPref() {
|
|
1468
|
+
try { return localStorage.getItem(INFO_VIEW_PREF) === 'lyrics' ? 'lyrics' : 'details'; } catch { return 'details'; }
|
|
1469
|
+
}
|
|
1470
|
+
|
|
1471
|
+
function saveInfoViewPref(view) {
|
|
1472
|
+
try { localStorage.setItem(INFO_VIEW_PREF, view); } catch { /* storage denied */ }
|
|
1240
1473
|
}
|
|
1241
1474
|
|
|
1242
|
-
|
|
1243
|
-
|
|
1475
|
+
/** Reflect `infoView` in the tabs and the panes. */
|
|
1476
|
+
function paintInfoTabs() {
|
|
1477
|
+
for (const view of ['details', 'lyrics']) {
|
|
1478
|
+
const on = infoView === view;
|
|
1479
|
+
$('tab-' + view).classList.toggle('on', on);
|
|
1480
|
+
$('tab-' + view).setAttribute('aria-selected', on ? 'true' : 'false');
|
|
1481
|
+
$(view).hidden = !on;
|
|
1482
|
+
}
|
|
1244
1483
|
}
|
|
1245
1484
|
|
|
1246
|
-
/**
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1485
|
+
/**
|
|
1486
|
+
* Bring the visible pane up to the track. Only the visible one: a hidden
|
|
1487
|
+
* pane is neither fetched nor painted, and catches up when it is shown.
|
|
1488
|
+
*/
|
|
1489
|
+
function syncInfo(trackId) {
|
|
1490
|
+
if (infoView === 'details') {
|
|
1491
|
+
if (trackId === detailsTrackId) return;
|
|
1492
|
+
detailsTrackId = trackId;
|
|
1493
|
+
if (trackId) loadDetails(trackId);
|
|
1494
|
+
else $('details').innerHTML = '<p class="hint">—</p>';
|
|
1495
|
+
return;
|
|
1496
|
+
}
|
|
1497
|
+
if (trackId === lyricTrackId) return;
|
|
1498
|
+
lyricTrackId = trackId;
|
|
1499
|
+
if (trackId) loadLyrics(trackId);
|
|
1500
|
+
else {
|
|
1501
|
+
lyric = null;
|
|
1502
|
+
lyricLine = -1;
|
|
1503
|
+
$('lyrics').innerHTML = '<p class="hint">—</p>';
|
|
1504
|
+
}
|
|
1253
1505
|
}
|
|
1254
1506
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
//
|
|
1262
|
-
|
|
1507
|
+
function showInfo(view) {
|
|
1508
|
+
if (view === infoView) return;
|
|
1509
|
+
infoView = view;
|
|
1510
|
+
saveInfoViewPref(view);
|
|
1511
|
+
paintInfoTabs();
|
|
1512
|
+
syncInfo(state?.current?.id ?? null);
|
|
1513
|
+
// A hidden pane kept no scroll position, so showing the lyrics puts the
|
|
1514
|
+
// current line back in view instead of waiting for the next line.
|
|
1515
|
+
if (view === 'lyrics') {
|
|
1263
1516
|
lyricLine = -1;
|
|
1264
1517
|
paintLyrics();
|
|
1265
1518
|
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
$('tab-details').onclick = () => showInfo('details');
|
|
1522
|
+
$('tab-lyrics').onclick = () => showInfo('lyrics');
|
|
1523
|
+
paintInfoTabs();
|
|
1524
|
+
|
|
1525
|
+
// The introduction's switch, or the written one itself, swaps it with
|
|
1526
|
+
// NetEase's prose; clamped prose opens in place.
|
|
1527
|
+
$('details').onclick = (event) => {
|
|
1528
|
+
const source = event.target.closest?.('[data-source]')?.dataset.source ?? (event.target.closest?.('.written') ? 'netease' : null);
|
|
1529
|
+
if (source) {
|
|
1530
|
+
introSource = source;
|
|
1531
|
+
repaintDetails({ keepScroll: true });
|
|
1532
|
+
return;
|
|
1533
|
+
}
|
|
1534
|
+
const prose = event.target.closest?.('.about .prose');
|
|
1535
|
+
if (prose) prose.classList.toggle('open');
|
|
1266
1536
|
};
|
|
1267
1537
|
|
|
1538
|
+
async function loadDetails(id) {
|
|
1539
|
+
const request = ++detailsRequest;
|
|
1540
|
+
introSource = 'ai';
|
|
1541
|
+
const cached = detailsCache.get(id);
|
|
1542
|
+
if (cached) {
|
|
1543
|
+
paintDetails(cached);
|
|
1544
|
+
return;
|
|
1545
|
+
}
|
|
1546
|
+
$('details').innerHTML = `<p class="hint">${esc(t('loading'))}</p>`;
|
|
1547
|
+
try {
|
|
1548
|
+
const info = await api('/info/' + id);
|
|
1549
|
+
detailsCache.set(id, info);
|
|
1550
|
+
if (detailsCache.size > 30) detailsCache.delete(detailsCache.keys().next().value);
|
|
1551
|
+
if (request !== detailsRequest) return;
|
|
1552
|
+
paintDetails(info);
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
if (request !== detailsRequest) return;
|
|
1555
|
+
$('details').innerHTML = `<p class="hint">${esc(error.message)}</p>`;
|
|
1556
|
+
}
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
/** Paint the shown track's details again: a language switch, an introduction, the switch. */
|
|
1560
|
+
function repaintDetails(options) {
|
|
1561
|
+
const info = detailsCache.get(detailsTrackId);
|
|
1562
|
+
if (info) paintDetails(info, options);
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
/**
|
|
1566
|
+
* Ask for the shown track's introduction, once its details are painted.
|
|
1567
|
+
*
|
|
1568
|
+
* Lazy on purpose: a model call takes seconds, so it waits for the poll
|
|
1569
|
+
* after the details land — playback and the NetEase facts never wait on
|
|
1570
|
+
* it — and it is asked only for the track the visible pane shows.
|
|
1571
|
+
*/
|
|
1572
|
+
async function loadIntro() {
|
|
1573
|
+
if (infoView !== 'details' || !detailsTrackId || !detailsCache.has(detailsTrackId)) return;
|
|
1574
|
+
const id = detailsTrackId;
|
|
1575
|
+
const key = `${id}:${LANG}`;
|
|
1576
|
+
if (intros.has(key)) return;
|
|
1577
|
+
intros.set(key, 'pending');
|
|
1578
|
+
if (intros.size > 60) intros.delete(intros.keys().next().value);
|
|
1579
|
+
let text = '';
|
|
1580
|
+
try {
|
|
1581
|
+
const answer = await api(`/intro/${id}?lang=${LANG}`);
|
|
1582
|
+
text = typeof answer?.text === 'string' ? answer.text : '';
|
|
1583
|
+
} catch { /* NetEase's prose stands in */ }
|
|
1584
|
+
intros.set(key, { text });
|
|
1585
|
+
introsUnavailable = !text;
|
|
1586
|
+
if (infoView === 'details' && detailsTrackId === id) repaintDetails({ keepScroll: true });
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
/** NetEase dates are midnight in China; read them there, as YYYY-MM-DD. */
|
|
1590
|
+
function chinaDate(ms) {
|
|
1591
|
+
try {
|
|
1592
|
+
return new Date(ms).toLocaleDateString('sv-SE', { timeZone: 'Asia/Shanghai' });
|
|
1593
|
+
} catch {
|
|
1594
|
+
return new Date(ms).toISOString().slice(0, 10);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
function paintDetails(info, { keepScroll = false } = {}) {
|
|
1599
|
+
const facts = [];
|
|
1600
|
+
const fact = (label, html) => facts.push(`<dt>${esc(t(label))}</dt><dd>${html}</dd>`);
|
|
1601
|
+
const chips = (list, kind = '') =>
|
|
1602
|
+
`<span class="chips">${list.map((item) => `<span class="chip ${kind}">${esc(item)}</span>`).join('')}</span>`;
|
|
1603
|
+
|
|
1604
|
+
const album = info.album ?? {};
|
|
1605
|
+
if (album.name) {
|
|
1606
|
+
const notes = [
|
|
1607
|
+
album.subType || album.type,
|
|
1608
|
+
album.publishTime ? chinaDate(album.publishTime) : '',
|
|
1609
|
+
album.company,
|
|
1610
|
+
album.size > 1 ? t('albumTracks', { n: album.size }) : '',
|
|
1611
|
+
].filter(Boolean);
|
|
1612
|
+
fact('album', esc(album.name) + (notes.length ? ` <span class="muted">· ${esc(notes.join(' · '))}</span>` : ''));
|
|
1613
|
+
}
|
|
1614
|
+
// A genre is a path such as 流行-华语流行; its leaf names it.
|
|
1615
|
+
if (info.genres?.length) fact('genre', chips(info.genres.map((genre) => genre.split('-').pop()), 'genre'));
|
|
1616
|
+
if (info.tags?.length) fact('tags', chips(info.tags));
|
|
1617
|
+
const spoken = [info.language, info.bpm ? `${info.bpm} BPM` : ''].filter(Boolean);
|
|
1618
|
+
if (spoken.length) fact('language', esc(spoken.join(' · ')));
|
|
1619
|
+
if (info.featuredIn?.length) fact('featuredIn', esc(info.featuredIn.join(';')));
|
|
1620
|
+
if (info.awards?.length) fact('awards', esc(info.awards.join(';')));
|
|
1621
|
+
|
|
1622
|
+
const netease = [];
|
|
1623
|
+
// NetEase separates paragraphs with a line break, often indented with
|
|
1624
|
+
// full-width spaces; each becomes its own paragraph, spaced apart.
|
|
1625
|
+
const paragraphs = (text) =>
|
|
1626
|
+
String(text)
|
|
1627
|
+
.split(/\n+/)
|
|
1628
|
+
.map((line) => line.trim())
|
|
1629
|
+
.filter(Boolean)
|
|
1630
|
+
.map((line) => `<p>${esc(line)}</p>`)
|
|
1631
|
+
.join('');
|
|
1632
|
+
const section = (title, text, by = '') =>
|
|
1633
|
+
netease.push(
|
|
1634
|
+
`<section class="about"><h4>${esc(title)}</h4><div class="prose" title="${esc(t('expand'))}">${paragraphs(text)}</div>` +
|
|
1635
|
+
(by ? `<div class="by">${esc(by)}</div>` : '') +
|
|
1636
|
+
'</section>',
|
|
1637
|
+
);
|
|
1638
|
+
if (info.review?.text) section(t('aboutSong'), info.review.text, info.review.by ? t('reviewBy', { name: info.review.by }) : '');
|
|
1639
|
+
for (const artist of info.artists ?? []) if (artist.intro) section(artist.name, artist.intro);
|
|
1640
|
+
if (album.intro) section(t('aboutAlbum'), album.intro);
|
|
1641
|
+
|
|
1642
|
+
// The model's introduction leads; NetEase's prose is a click away. While
|
|
1643
|
+
// it is written, NetEase's prose shows if the model was last unavailable.
|
|
1644
|
+
const intro = intros.get(`${info.id}:${LANG}`);
|
|
1645
|
+
const written = typeof intro === 'object' && intro.text ? intro.text : '';
|
|
1646
|
+
const waiting = intro === undefined || intro === 'pending';
|
|
1647
|
+
const head = `<h4>${esc(t('intro'))}<span class="badge">AI</span></h4>`;
|
|
1648
|
+
const swap = (to, label) => `<button class="link source" type="button" data-source="${to}">${esc(t(label))}</button>`;
|
|
1649
|
+
let about;
|
|
1650
|
+
if (introSource === 'ai' && written) {
|
|
1651
|
+
about =
|
|
1652
|
+
`<section class="about">${head}<div class="written" title="${esc(t('introToNetease'))}">${paragraphs(written)}</div></section>` +
|
|
1653
|
+
(netease.length ? swap('netease', 'introFromNetease') : '');
|
|
1654
|
+
} else if (introSource === 'ai' && waiting && !introsUnavailable) {
|
|
1655
|
+
about =
|
|
1656
|
+
`<section class="about">${head}<p class="writing">${esc(t('introWriting'))}</p></section>` +
|
|
1657
|
+
(netease.length ? swap('netease', 'introFromNetease') : '');
|
|
1658
|
+
} else {
|
|
1659
|
+
about = (written ? swap('ai', 'introFromAi') : '') + netease.join('');
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
const alias = info.alias?.length ? `<p class="alias">${esc(info.alias.join(' / '))}</p>` : '';
|
|
1663
|
+
const scrolled = $('details').scrollTop;
|
|
1664
|
+
$('details').innerHTML =
|
|
1665
|
+
facts.length || about || alias
|
|
1666
|
+
? alias + (facts.length ? `<dl class="facts">${facts.join('')}</dl>` : '') + about
|
|
1667
|
+
: `<p class="hint">${esc(t('noDetails'))}</p>`;
|
|
1668
|
+
$('details').scrollTop = keepScroll ? scrolled : 0;
|
|
1669
|
+
}
|
|
1670
|
+
|
|
1268
1671
|
async function loadLyrics(id) {
|
|
1269
1672
|
const request = ++lyricRequest;
|
|
1270
1673
|
lyric = null;
|
|
@@ -1299,7 +1702,7 @@
|
|
|
1299
1702
|
}
|
|
1300
1703
|
|
|
1301
1704
|
function paintLyrics() {
|
|
1302
|
-
if (!lyric) return;
|
|
1705
|
+
if (!lyric || infoView !== 'lyrics') return;
|
|
1303
1706
|
const at = positionMs();
|
|
1304
1707
|
let active = -1;
|
|
1305
1708
|
for (let index = 0; index < lyric.length; index++) {
|
|
@@ -1741,6 +2144,21 @@
|
|
|
1741
2144
|
if (target) return sendBoost(Number(target.dataset.unboost), 'none', target);
|
|
1742
2145
|
};
|
|
1743
2146
|
|
|
2147
|
+
$('scrobble-toggle').onclick = async (event) => {
|
|
2148
|
+
const next = !state?.scrobble?.enabled;
|
|
2149
|
+
const button = event?.currentTarget;
|
|
2150
|
+
if (button) button.disabled = true;
|
|
2151
|
+
try {
|
|
2152
|
+
state = await api('/scrobble', { method: 'POST', body: { enabled: next } });
|
|
2153
|
+
render();
|
|
2154
|
+
toast(t(next ? 'scrobbleOn' : 'scrobbleOff'));
|
|
2155
|
+
} catch (error) {
|
|
2156
|
+
toast(failureText(error));
|
|
2157
|
+
} finally {
|
|
2158
|
+
if (button) button.disabled = false;
|
|
2159
|
+
}
|
|
2160
|
+
};
|
|
2161
|
+
|
|
1744
2162
|
$('dj-toggle').onclick = async () => {
|
|
1745
2163
|
try {
|
|
1746
2164
|
const data = await api('/dj', { method: 'POST', body: { enabled: !state?.dj?.enabled, prompt: $('dj-prompt').value } });
|
|
@@ -1751,6 +2169,15 @@
|
|
|
1751
2169
|
};
|
|
1752
2170
|
$('dj-prompt').onchange = () => api('/dj', { method: 'POST', body: { prompt: $('dj-prompt').value, enabled: state?.dj?.enabled } }).then((data) => { state = data; render(); }).catch((error) => toast(error.message));
|
|
1753
2171
|
|
|
2172
|
+
// Not row-by-row removal, which reads each row as a dislike.
|
|
2173
|
+
$('queue-clear').onclick = async () => {
|
|
2174
|
+
try {
|
|
2175
|
+
state = await api('/queue', { method: 'POST', body: { action: 'clear', keepCurrent: true } });
|
|
2176
|
+
render();
|
|
2177
|
+
pokeEngine();
|
|
2178
|
+
} catch (error) { toast(failureText(error)); }
|
|
2179
|
+
};
|
|
2180
|
+
|
|
1754
2181
|
$('queue').onclick = async (event) => {
|
|
1755
2182
|
const like = event.target.closest('[data-like]');
|
|
1756
2183
|
const jump = event.target.closest('[data-jump]')?.dataset.jump;
|
|
@@ -1787,8 +2214,10 @@
|
|
|
1787
2214
|
}
|
|
1788
2215
|
}
|
|
1789
2216
|
|
|
2217
|
+
paintStaticIcons();
|
|
1790
2218
|
applyLocale();
|
|
1791
2219
|
watchShellLocale();
|
|
2220
|
+
syncShellTheme();
|
|
1792
2221
|
refresh();
|
|
1793
2222
|
setInterval(refresh, 1500);
|
|
1794
2223
|
void loadModelPicker();
|