@doitian/dsh-music 0.1.5 → 0.1.7
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 +59 -724
- package/cordis.patch.yml +12 -8
- package/lib/dj.js +239 -47
- package/lib/index.js +53 -5
- package/lib/panel.html +351 -167
- package/lib/router.js +49 -2
- package/lib/session.js +96 -9
- package/lib/state.js +60 -10
- package/package.json +1 -1
package/lib/panel.html
CHANGED
|
@@ -17,11 +17,15 @@
|
|
|
17
17
|
color-scheme: light dark;
|
|
18
18
|
--bg: var(--dsh-background, #ffffff);
|
|
19
19
|
--fg: var(--dsh-foreground, #1b1c1e);
|
|
20
|
-
--muted: color-mix(in srgb, var(--fg)
|
|
21
|
-
--
|
|
20
|
+
--muted: color-mix(in srgb, var(--fg) 56%, transparent);
|
|
21
|
+
--faint: color-mix(in srgb, var(--fg) 38%, transparent);
|
|
22
|
+
--line: color-mix(in srgb, var(--fg) 12%, transparent);
|
|
22
23
|
--panel: color-mix(in srgb, var(--fg) 4%, transparent);
|
|
24
|
+
--hover: color-mix(in srgb, var(--fg) 7%, transparent);
|
|
23
25
|
--accent: #e8503a;
|
|
24
|
-
--
|
|
26
|
+
--accent-soft: color-mix(in srgb, var(--accent) 13%, transparent);
|
|
27
|
+
--radius: 12px;
|
|
28
|
+
--gap: 16px;
|
|
25
29
|
}
|
|
26
30
|
* { box-sizing: border-box; }
|
|
27
31
|
html, body { margin: 0; height: 100%; }
|
|
@@ -35,126 +39,202 @@
|
|
|
35
39
|
background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
|
|
36
40
|
padding: 5px 10px; cursor: pointer; white-space: nowrap;
|
|
37
41
|
}
|
|
38
|
-
button:hover:not(:disabled) {
|
|
42
|
+
button:hover:not(:disabled) { background: var(--hover); }
|
|
43
|
+
/* The trip to NetEase is not instant on a cold cache; a click has to look
|
|
44
|
+
like it landed before the rows come back. */
|
|
39
45
|
button:disabled { opacity: 0.45; cursor: default; }
|
|
40
46
|
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
|
|
41
47
|
input, select {
|
|
42
|
-
background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px
|
|
48
|
+
background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px;
|
|
43
49
|
}
|
|
44
|
-
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); }
|
|
50
|
+
input:focus, select:focus, button:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }
|
|
51
|
+
svg { display: block; width: 18px; height: 18px; fill: currentColor; }
|
|
45
52
|
|
|
53
|
+
/* ------------------------------------------------------------ layout
|
|
54
|
+
Wide: the stage (what is playing) on the left, what comes next — the
|
|
55
|
+
DJ and the queue — on the right, each column scrolling on its own.
|
|
56
|
+
Narrow: one column, the whole page scrolling. */
|
|
46
57
|
#app { display: flex; flex-direction: column; height: 100%; }
|
|
47
|
-
|
|
48
58
|
header {
|
|
49
|
-
display: flex; align-items: center; gap:
|
|
50
|
-
border-bottom: 1px solid var(--line); flex
|
|
59
|
+
display: flex; align-items: center; gap: 10px; padding: 10px var(--gap);
|
|
60
|
+
border-bottom: 1px solid var(--line); flex: none;
|
|
51
61
|
}
|
|
52
62
|
.brand { font-weight: 650; letter-spacing: 0.2px; }
|
|
53
63
|
.brand small { font-weight: 400; color: var(--muted); margin-left: 6px; }
|
|
54
64
|
.spacer { flex: 1; }
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
#account {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
#account { display: flex; align-items: center; gap: 7px; color: var(--muted); min-width: 0; }
|
|
66
|
+
#account span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
67
|
+
#account img { width: 22px; height: 22px; border-radius: 50%; flex: none; }
|
|
68
|
+
|
|
69
|
+
main { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
|
|
70
|
+
.stage, .side { display: flex; flex-direction: column; gap: var(--gap); padding: var(--gap); min-width: 0; }
|
|
71
|
+
@media (max-width: 859px) {
|
|
72
|
+
/* Stacked, the two columns share one gap rather than two paddings. */
|
|
73
|
+
.side { padding-top: 0; }
|
|
74
|
+
}
|
|
75
|
+
@media (min-width: 860px) {
|
|
76
|
+
main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(340px, 30%); overflow: hidden; }
|
|
77
|
+
.stage { overflow: auto; }
|
|
78
|
+
.side { overflow: hidden; border-left: 1px solid var(--line); }
|
|
79
|
+
.side .queue-card { flex: 1; min-height: 0; }
|
|
80
|
+
.side #queue { overflow: auto; }
|
|
81
|
+
/* With a column of its own, the lyrics fill what the stage leaves. */
|
|
82
|
+
.stage .lyrics-card { flex: 1; min-height: 160px; }
|
|
83
|
+
.stage .lyrics { flex: 1; max-height: none; }
|
|
84
|
+
}
|
|
66
85
|
|
|
67
|
-
.
|
|
68
|
-
|
|
86
|
+
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
|
|
87
|
+
.card-head {
|
|
88
|
+
display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px;
|
|
89
|
+
color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
|
|
69
90
|
}
|
|
70
|
-
.
|
|
71
|
-
.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.row .meta { min-width: 0; flex: 1; }
|
|
75
|
-
.row .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
76
|
-
.row .sub { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
77
|
-
.row .tag { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; color: var(--muted); flex: none; }
|
|
78
|
-
.row .dur { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; }
|
|
79
|
-
.row .acts { display: none; gap: 4px; flex: none; }
|
|
80
|
-
.row:hover .acts { display: flex; }
|
|
81
|
-
/* The list's own like control. A liked track keeps its filled heart
|
|
82
|
-
visible; the hollow one only appears on hover, so an unrated list is
|
|
83
|
-
not a wall of outlines. */
|
|
84
|
-
.row .heart {
|
|
85
|
-
background: none; border: 0; padding: 0; width: 16px; flex: none;
|
|
86
|
-
font-size: 14px; line-height: 1; color: var(--muted); opacity: 0;
|
|
87
|
-
transition: opacity 0.12s;
|
|
91
|
+
.card-head .grow { flex: 1; }
|
|
92
|
+
.link {
|
|
93
|
+
background: none; border: 0; padding: 0; color: var(--muted); font: inherit;
|
|
94
|
+
text-transform: inherit; letter-spacing: inherit;
|
|
88
95
|
}
|
|
89
|
-
.
|
|
90
|
-
|
|
96
|
+
.link:hover:not(:disabled) { background: none; color: var(--fg); }
|
|
97
|
+
|
|
98
|
+
/* ------------------------------------------------------------- stage */
|
|
99
|
+
.np { display: flex; gap: 18px; align-items: flex-end; }
|
|
100
|
+
/* The frame holds the place, with a note in it, while there is no cover. */
|
|
101
|
+
.cover {
|
|
102
|
+
position: relative; width: clamp(96px, 22vw, 180px); aspect-ratio: 1; flex: none;
|
|
103
|
+
border-radius: var(--radius); overflow: hidden; background: var(--panel);
|
|
104
|
+
display: grid; place-items: center; color: var(--faint); font-size: 40px;
|
|
105
|
+
box-shadow: 0 6px 24px color-mix(in srgb, #000 14%, transparent);
|
|
106
|
+
}
|
|
107
|
+
.cover::before { content: "♪"; }
|
|
108
|
+
#cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
|
|
109
|
+
.np-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
|
|
110
|
+
.now-title { font-size: 22px; font-weight: 700; line-height: 1.25; overflow-wrap: anywhere; }
|
|
111
|
+
.now-artists { font-size: 14px; }
|
|
112
|
+
.now-album { color: var(--muted); }
|
|
113
|
+
/* What to do about this track: the taste switchers and the boosts. A
|
|
114
|
+
state is an accent icon on a tint, never a solid block — the only
|
|
115
|
+
filled control on the stage is play. */
|
|
116
|
+
.taste { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
|
|
117
|
+
.taste button {
|
|
118
|
+
width: 34px; height: 34px; padding: 0; border-radius: 50%; display: grid; place-items: center;
|
|
119
|
+
background: none; font-size: 15px; line-height: 1; color: var(--muted);
|
|
120
|
+
}
|
|
121
|
+
.taste button:hover:not(:disabled) { color: var(--fg); background: var(--hover); }
|
|
122
|
+
.taste button.on { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
|
|
91
123
|
|
|
92
|
-
.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
.now-title { font-size: 16px; font-weight: 650; line-height: 1.3; }
|
|
96
|
-
.now-artists { color: var(--muted); margin-top: 3px; }
|
|
97
|
-
.now-album { color: var(--muted); font-size: 12px; margin-top: 2px; }
|
|
98
|
-
.bar { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
99
|
-
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; padding: 0; height: 16px; flex: 1; min-width: 0; }
|
|
100
|
-
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--fg) 18%, transparent); }
|
|
124
|
+
.progress { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
|
|
125
|
+
input[type="range"] { -webkit-appearance: none; appearance: none; background: transparent; border: 0; padding: 0; height: 16px; flex: 1; min-width: 0; }
|
|
126
|
+
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--fg) 16%, transparent); }
|
|
101
127
|
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4px; border-radius: 50%; background: var(--accent); }
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
.
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
text-transform: inherit; letter-spacing: inherit; cursor: pointer;
|
|
122
|
-
}
|
|
123
|
-
.section-title.head button:hover { color: var(--fg); }
|
|
124
|
-
/* The pane is a glance at the current line, not a page: four lines of
|
|
125
|
-
synced text, scrolled for the rest, so the queue keeps the space.
|
|
126
|
-
`--lyrics-lines` is the single knob (the padding below is the `+ 12px`). */
|
|
128
|
+
input[type="range"]:focus { outline: none; }
|
|
129
|
+
|
|
130
|
+
.transport { display: flex; align-items: center; justify-content: center; gap: 14px; }
|
|
131
|
+
.transport button { width: 40px; height: 40px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: none; border-color: transparent; }
|
|
132
|
+
.transport button:hover:not(:disabled) { background: var(--hover); }
|
|
133
|
+
.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
|
+
.transport #play:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, #000); }
|
|
135
|
+
.transport #play svg { width: 22px; height: 22px; }
|
|
136
|
+
|
|
137
|
+
.secondary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
|
|
138
|
+
.secondary select, .secondary > button { padding: 4px 8px; font-size: 12px; }
|
|
139
|
+
#quality-info { color: var(--muted); }
|
|
140
|
+
#mute { background: none; border-color: transparent; padding: 4px; color: var(--muted); }
|
|
141
|
+
#mute:hover:not(:disabled) { color: var(--fg); }
|
|
142
|
+
#volume { flex: 0 0 96px; }
|
|
143
|
+
|
|
144
|
+
.lyrics-card { display: flex; flex-direction: column; min-height: 0; }
|
|
145
|
+
/* The pane is a glance at the current line, not a page: a few lines of
|
|
146
|
+
synced text, scrolled for the rest. `--lyrics-lines` is the single knob. */
|
|
127
147
|
.lyrics {
|
|
128
|
-
--lyrics-lines:
|
|
129
|
-
max-height: calc(var(--lyrics-lines) * 1.
|
|
130
|
-
|
|
148
|
+
--lyrics-lines: 6;
|
|
149
|
+
max-height: calc(var(--lyrics-lines) * 1.6em + var(--lyrics-lines) * 4px + 14px);
|
|
150
|
+
overflow: auto; padding: 2px 12px 14px; font-size: 14px; line-height: 1.6; scrollbar-width: none;
|
|
131
151
|
}
|
|
152
|
+
.lyrics::-webkit-scrollbar { display: none; }
|
|
132
153
|
.lyrics.collapsed { display: none; }
|
|
133
|
-
.lyrics p { margin: 0; padding: 2px 0; color: var(--
|
|
154
|
+
.lyrics p { margin: 0; padding: 2px 0; color: var(--faint); transition: color 0.15s; }
|
|
134
155
|
.lyrics p.on { color: var(--fg); font-weight: 600; }
|
|
135
|
-
|
|
136
|
-
.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
156
|
+
|
|
157
|
+
.need-gesture {
|
|
158
|
+
background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
|
|
159
|
+
border-radius: var(--radius); padding: 8px 12px; font-size: 12px;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* -------------------------------------------------------------- side */
|
|
163
|
+
.dj-card { padding-bottom: 12px; flex: none; }
|
|
164
|
+
.dj-card .card-head { padding-bottom: 8px; }
|
|
165
|
+
.dj-card .card-head .title { color: var(--fg); font-size: 13px; font-weight: 650; text-transform: none; letter-spacing: 0; }
|
|
166
|
+
.dj-body { display: flex; flex-direction: column; gap: 8px; padding: 0 12px; font-size: 12px; }
|
|
167
|
+
#dj-prompt { width: 100%; }
|
|
168
|
+
/* The DJ switch: a toggle that reads on or off at a glance. */
|
|
169
|
+
#dj-toggle {
|
|
170
|
+
position: relative; width: 38px; height: 22px; padding: 0; border-radius: 11px;
|
|
171
|
+
background: color-mix(in srgb, var(--fg) 20%, transparent); border: 0; color: transparent; overflow: hidden;
|
|
172
|
+
}
|
|
173
|
+
#dj-toggle::after {
|
|
174
|
+
content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
|
|
175
|
+
background: #fff; transition: transform 0.15s; box-shadow: 0 1px 3px color-mix(in srgb, #000 30%, transparent);
|
|
176
|
+
}
|
|
177
|
+
#dj-toggle.on { background: var(--accent); }
|
|
178
|
+
#dj-toggle.on::after { transform: translateX(16px); }
|
|
179
|
+
#dj-toggle:hover:not(:disabled) { filter: brightness(0.96); }
|
|
180
|
+
.plan b { color: var(--accent); }
|
|
181
|
+
.plan .muted, .muted { color: var(--muted); }
|
|
182
|
+
.plan > div + div { margin-top: 2px; }
|
|
183
|
+
|
|
184
|
+
#boosts:empty { display: none; }
|
|
185
|
+
#boosts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; color: var(--muted); }
|
|
186
|
+
#boosts .boost {
|
|
187
|
+
display: inline-flex; gap: 2px; align-items: center; color: var(--fg);
|
|
188
|
+
background: var(--accent-soft); border-radius: 999px; padding: 1px 2px 1px 9px;
|
|
189
|
+
}
|
|
190
|
+
#boosts .boost button { border: 0; background: none; padding: 0 6px; color: var(--muted); }
|
|
191
|
+
#boosts .boost button:hover:not(:disabled) { color: var(--fg); }
|
|
192
|
+
|
|
193
|
+
/* The DJ model picker is a set-once setting, so it keeps only its header
|
|
194
|
+
row until asked. The header is the click target; the chevron inside it
|
|
195
|
+
is the keyboard one. */
|
|
196
|
+
.model { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
|
|
142
197
|
.model-head { display: flex; align-items: baseline; gap: 8px; cursor: pointer; }
|
|
143
198
|
.model-head .model-now {
|
|
144
199
|
flex: 1; min-width: 0; text-align: right; color: var(--muted);
|
|
145
200
|
overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
|
|
146
201
|
}
|
|
147
|
-
.model-head .toggle {
|
|
148
|
-
|
|
149
|
-
color: var(--muted); cursor: pointer;
|
|
150
|
-
}
|
|
151
|
-
.model-head .toggle:hover { color: var(--fg); }
|
|
202
|
+
.model-head .toggle { background: none; border: 0; margin: 0; padding: 0 2px; font: inherit; color: var(--muted); }
|
|
203
|
+
.model-head .toggle:hover:not(:disabled) { background: none; color: var(--fg); }
|
|
152
204
|
.model-head .warn { color: var(--accent); }
|
|
153
205
|
.dj-model-body.collapsed { display: none; }
|
|
154
206
|
.row-inline { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
|
|
155
207
|
.row-inline select, .row-inline input { flex: 1 1 0; min-width: 0; font-size: 12px; padding: 4px 6px; }
|
|
156
208
|
.row-inline button { font-size: 12px; padding: 4px 8px; }
|
|
209
|
+
|
|
210
|
+
.queue-card { display: flex; flex-direction: column; overflow: hidden; }
|
|
211
|
+
#queue { padding: 0 6px 6px; }
|
|
212
|
+
.row { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 8px; cursor: pointer; }
|
|
213
|
+
.row:hover { background: var(--hover); }
|
|
214
|
+
.row.playing { background: var(--accent-soft); }
|
|
215
|
+
.row.playing .name { color: var(--accent); font-weight: 600; }
|
|
216
|
+
.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); }
|
|
218
|
+
.row img { width: 36px; height: 36px; border-radius: 6px; object-fit: cover; flex: none; background: var(--panel); }
|
|
219
|
+
.row .meta { min-width: 0; flex: 1; }
|
|
220
|
+
.row .name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
221
|
+
.row .sub { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
|
222
|
+
.row .tag { font-size: 10px; border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); flex: none; }
|
|
223
|
+
.row .dur { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; font-size: 12px; min-width: 32px; text-align: right; }
|
|
224
|
+
.row .acts { display: none; gap: 4px; flex: none; }
|
|
225
|
+
.row .acts button { padding: 1px 6px; font-size: 11px; background: none; color: var(--muted); }
|
|
226
|
+
.row:hover .acts { display: flex; }
|
|
227
|
+
/* The list's own like control. A liked track keeps its filled heart
|
|
228
|
+
visible; the hollow one only appears on hover, so an unrated list is
|
|
229
|
+
not a wall of outlines. */
|
|
230
|
+
.row .heart {
|
|
231
|
+
background: none; border: 0; padding: 0; width: 16px; flex: none;
|
|
232
|
+
font-size: 14px; line-height: 1; color: var(--muted); opacity: 0; transition: opacity 0.12s;
|
|
233
|
+
}
|
|
234
|
+
.row:hover .heart { opacity: 1; }
|
|
235
|
+
.row .heart.on { opacity: 1; color: var(--accent); }
|
|
157
236
|
.empty { padding: 24px 14px; color: var(--muted); text-align: center; }
|
|
237
|
+
|
|
158
238
|
.toast {
|
|
159
239
|
position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
|
|
160
240
|
background: #1b1c1e; color: #fff; padding: 8px 14px; border-radius: 9px; font-size: 12px;
|
|
@@ -168,8 +248,8 @@
|
|
|
168
248
|
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
|
|
169
249
|
#qr { display: block; margin: 12px auto; width: 220px; height: 220px; image-rendering: pixelated; border-radius: 8px; background: #fff; padding: 8px; }
|
|
170
250
|
.hint { color: var(--muted); font-size: 12px; text-align: center; }
|
|
251
|
+
.lyrics .hint { text-align: left; }
|
|
171
252
|
.row-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 14px; }
|
|
172
|
-
.need-gesture { background: color-mix(in srgb, var(--accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent); border-radius: var(--radius); padding: 8px 11px; margin: 0 14px 12px; font-size: 12px; }
|
|
173
253
|
</style>
|
|
174
254
|
</head>
|
|
175
255
|
<body>
|
|
@@ -177,82 +257,104 @@
|
|
|
177
257
|
<header>
|
|
178
258
|
<div class="brand"><span data-i18n="brand">Music</span><small>music.163.com</small></div>
|
|
179
259
|
<div class="spacer"></div>
|
|
180
|
-
<input id="dj-prompt" data-i18n-ph="djPromptPh" placeholder="AI DJ mood, e.g. rainy afternoon jazz" />
|
|
181
|
-
<button id="dj-toggle" data-i18n-title="djToggleTitle" title="Continuous AI DJ: keep the queue stocked">AI DJ</button>
|
|
182
260
|
<div id="account"></div>
|
|
183
261
|
</header>
|
|
184
262
|
|
|
185
263
|
<main>
|
|
186
|
-
<section class="
|
|
187
|
-
<div
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
</div>
|
|
195
|
-
</div>
|
|
196
|
-
<div class="bar">
|
|
197
|
-
<span id="t-cur">0:00</span>
|
|
198
|
-
<input type="range" id="seek" min="0" max="1000" value="0" step="1" />
|
|
199
|
-
<span id="t-dur">0:00</span>
|
|
200
|
-
</div>
|
|
201
|
-
<div class="controls">
|
|
202
|
-
<button id="prev" data-i18n-title="prev" title="Previous">⏮</button>
|
|
203
|
-
<button id="play" class="primary" data-i18n-title="playPause" title="Play/pause">▶</button>
|
|
204
|
-
<button id="next" data-i18n-title="next" title="Next">⏭</button>
|
|
205
|
-
<button id="mode" class="mode" data-i18n-title="modeTitle" data-i18n="modeList" title="Playback mode">List</button>
|
|
206
|
-
<select id="quality" class="mode" data-i18n-title="qualityTitle" title="Streaming quality"></select>
|
|
207
|
-
<span id="quality-info" class="mode" style="color: var(--muted)"></span>
|
|
208
|
-
<span class="grow"></span>
|
|
264
|
+
<section class="stage">
|
|
265
|
+
<div id="notices"></div>
|
|
266
|
+
<div class="np">
|
|
267
|
+
<div class="cover"><img id="cover" alt="" /></div>
|
|
268
|
+
<div class="np-text">
|
|
269
|
+
<div class="now-title" id="np-title" data-i18n="nothingPlaying">Nothing playing</div>
|
|
270
|
+
<div class="now-artists" id="np-artists"></div>
|
|
271
|
+
<div class="now-album" id="np-album"></div>
|
|
209
272
|
<!-- Labels are state-dependent (a filled heart un-likes), so the
|
|
210
273
|
script owns text and title rather than data-i18n. -->
|
|
211
|
-
<
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
274
|
+
<div class="taste">
|
|
275
|
+
<button id="like" title="Like">♡</button>
|
|
276
|
+
<button id="dislike" title="Dislike">✕</button>
|
|
277
|
+
<button id="boost-more" title="More like this for an hour">▲</button>
|
|
278
|
+
<button id="boost-less" title="Fewer like this for an hour">▼</button>
|
|
279
|
+
</div>
|
|
215
280
|
</div>
|
|
216
281
|
</div>
|
|
217
282
|
|
|
218
|
-
<div class="
|
|
219
|
-
<span
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
283
|
+
<div class="progress">
|
|
284
|
+
<span id="t-cur">0:00</span>
|
|
285
|
+
<input type="range" id="seek" min="0" max="1000" value="0" step="1" />
|
|
286
|
+
<span id="t-dur">0:00</span>
|
|
287
|
+
</div>
|
|
288
|
+
<div class="transport">
|
|
289
|
+
<button id="prev" data-i18n-title="prev" title="Previous"><svg viewBox="0 0 24 24"><path d="M6 5h2v14H6zM20 5v14L9.5 12z"/></svg></button>
|
|
290
|
+
<button id="play" data-i18n-title="playPause" title="Play/pause"><svg viewBox="0 0 24 24"><path d="M8 5v14l11-7z"/></svg></button>
|
|
291
|
+
<button id="next" data-i18n-title="next" title="Next"><svg viewBox="0 0 24 24"><path d="M16 5h2v14h-2zM4 5v14l10.5-7z"/></svg></button>
|
|
223
292
|
</div>
|
|
224
|
-
<div class="
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
<div class="
|
|
235
|
-
<span data-i18n="
|
|
236
|
-
<span class="
|
|
237
|
-
|
|
293
|
+
<div class="secondary">
|
|
294
|
+
<button id="mode" data-i18n-title="modeTitle" data-i18n="modeList" title="Playback mode">List</button>
|
|
295
|
+
<select id="quality" data-i18n-title="qualityTitle" title="Streaming quality"></select>
|
|
296
|
+
<span id="quality-info"></span>
|
|
297
|
+
<span class="spacer"></span>
|
|
298
|
+
<button id="mute" data-i18n-title="mute" title="Mute"></button>
|
|
299
|
+
<input type="range" id="volume" min="0" max="1" step="0.01" value="0.8" />
|
|
300
|
+
</div>
|
|
301
|
+
|
|
302
|
+
<div class="card lyrics-card">
|
|
303
|
+
<div class="card-head">
|
|
304
|
+
<span data-i18n="lyrics">Lyrics</span>
|
|
305
|
+
<span class="grow"></span>
|
|
306
|
+
<!-- Label and title are state-dependent, so the script owns them
|
|
307
|
+
(applyStaticStrings cannot know which way the pane is now). -->
|
|
308
|
+
<button id="lyrics-toggle" class="link" type="button" aria-expanded="true">Hide</button>
|
|
238
309
|
</div>
|
|
239
|
-
<div class="
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
</
|
|
247
|
-
<
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
310
|
+
<div class="lyrics" id="lyrics"><p class="hint">—</p></div>
|
|
311
|
+
</div>
|
|
312
|
+
</section>
|
|
313
|
+
|
|
314
|
+
<aside class="side">
|
|
315
|
+
<div class="card dj-card">
|
|
316
|
+
<div class="card-head">
|
|
317
|
+
<span class="title">AI DJ</span>
|
|
318
|
+
<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>
|
|
320
|
+
</div>
|
|
321
|
+
<div class="dj-body">
|
|
322
|
+
<input id="dj-prompt" data-i18n-ph="djPromptPh" placeholder="AI DJ mood, e.g. rainy afternoon jazz" />
|
|
323
|
+
<div id="dj-status"></div>
|
|
324
|
+
<div id="boosts"></div>
|
|
325
|
+
<div class="model" id="dj-model">
|
|
326
|
+
<!-- One always-visible line: the setting that matters at a glance is
|
|
327
|
+
the effective route, and the form below it is folded away until
|
|
328
|
+
asked for. -->
|
|
329
|
+
<div class="model-head" id="dj-model-head">
|
|
330
|
+
<span data-i18n="djModel">DJ model</span>
|
|
331
|
+
<span class="model-now"><span id="dj-model-route"></span><span id="dj-model-source"></span><span class="warn" id="dj-model-warn"></span></span>
|
|
332
|
+
<button id="dj-model-toggle" class="toggle" type="button" aria-controls="dj-model-body" aria-expanded="false"></button>
|
|
333
|
+
</div>
|
|
334
|
+
<div class="dj-model-body collapsed" id="dj-model-body">
|
|
335
|
+
<div class="row-inline">
|
|
336
|
+
<select id="dj-provider" title="provider route"></select>
|
|
337
|
+
<select id="dj-model-select" title="model"></select>
|
|
338
|
+
</div>
|
|
339
|
+
<div class="row-inline">
|
|
340
|
+
<input id="dj-model-custom" data-i18n-ph="customModelPh" placeholder="Custom model id" style="display: none" />
|
|
341
|
+
</div>
|
|
342
|
+
<div class="row-inline">
|
|
343
|
+
<button id="dj-model-save" class="primary" data-i18n="save">Save</button>
|
|
344
|
+
<button id="dj-model-test" data-i18n="test">Test</button>
|
|
345
|
+
<button id="dj-model-clear" data-i18n="revert" data-i18n-title="revertTitle" title="Revert to the profile patch">Revert</button>
|
|
346
|
+
</div>
|
|
347
|
+
<div id="dj-model-status" class="muted"></div>
|
|
348
|
+
</div>
|
|
251
349
|
</div>
|
|
252
|
-
<div id="dj-model-status" style="color: var(--muted)"></div>
|
|
253
350
|
</div>
|
|
254
351
|
</div>
|
|
255
|
-
|
|
352
|
+
|
|
353
|
+
<div class="card queue-card">
|
|
354
|
+
<div class="card-head"><span data-i18n="queue">Queue</span> <span id="counts"></span></div>
|
|
355
|
+
<div id="queue"></div>
|
|
356
|
+
</div>
|
|
357
|
+
</aside>
|
|
256
358
|
</main>
|
|
257
359
|
</div>
|
|
258
360
|
|
|
@@ -265,7 +367,6 @@
|
|
|
265
367
|
<button id="qr-close" class="primary" data-i18n="close">Close</button>
|
|
266
368
|
</div>
|
|
267
369
|
</dialog>
|
|
268
|
-
|
|
269
370
|
<div class="toast" id="toast"></div>
|
|
270
371
|
|
|
271
372
|
<script src="__BASE__/vendor/qrcode.js"></script>
|
|
@@ -364,6 +465,14 @@
|
|
|
364
465
|
liked: '已喜欢',
|
|
365
466
|
unliked: '已取消喜欢',
|
|
366
467
|
disliked: '不再推荐',
|
|
468
|
+
boostMore: '接下来一小时多放类似的',
|
|
469
|
+
boostLess: '接下来一小时少放类似的',
|
|
470
|
+
boostClear: '取消临时偏好',
|
|
471
|
+
boostedMore: '接下来一小时多放类似的',
|
|
472
|
+
boostedLess: '接下来一小时少放类似的',
|
|
473
|
+
boostCleared: '已取消临时偏好',
|
|
474
|
+
boostsTitle: '临时偏好',
|
|
475
|
+
boostMinutes: '{n} 分钟',
|
|
367
476
|
djOn: 'AI DJ 已开启',
|
|
368
477
|
djOff: 'AI DJ 已关闭',
|
|
369
478
|
connectFailed: '连接失败:',
|
|
@@ -453,6 +562,14 @@
|
|
|
453
562
|
liked: 'Liked',
|
|
454
563
|
unliked: 'Like removed',
|
|
455
564
|
disliked: 'Disliked',
|
|
565
|
+
boostMore: 'More like this for an hour',
|
|
566
|
+
boostLess: 'Fewer like this for an hour',
|
|
567
|
+
boostClear: 'Clear this boost',
|
|
568
|
+
boostedMore: 'More like this for the next hour',
|
|
569
|
+
boostedLess: 'Fewer like this for the next hour',
|
|
570
|
+
boostCleared: 'Boost cleared',
|
|
571
|
+
boostsTitle: 'Boosts',
|
|
572
|
+
boostMinutes: '{n} min',
|
|
456
573
|
djOn: 'AI DJ on',
|
|
457
574
|
djOff: 'AI DJ off',
|
|
458
575
|
connectFailed: 'Cannot reach the host: ',
|
|
@@ -480,6 +597,21 @@
|
|
|
480
597
|
}
|
|
481
598
|
|
|
482
599
|
/** Translate a key, interpolating `{name}` placeholders from `vars`. */
|
|
600
|
+
/** Monochrome icons for controls whose glyph changes with state. */
|
|
601
|
+
const ICONS = {
|
|
602
|
+
play: '<path d="M8 5v14l11-7z"/>',
|
|
603
|
+
pause: '<path d="M7 5h4v14H7zM13 5h4v14h-4z"/>',
|
|
604
|
+
volume: '<path d="M4 9v6h4l5 4V5L8 9zM16 8.5a4.5 4.5 0 0 1 0 7l-1-1.3a2.9 2.9 0 0 0 0-4.4zM17.8 5.6a8 8 0 0 1 0 12.8l-1-1.3a6.4 6.4 0 0 0 0-10.2z"/>',
|
|
605
|
+
muted: '<path d="M4 9v6h4l5 4V5L8 9zM16.3 9.4l1.1-1.1 2.1 2.1 2.1-2.1 1.1 1.1-2.1 2.1 2.1 2.1-1.1 1.1-2.1-2.1-2.1 2.1-1.1-1.1 2.1-2.1z"/>',
|
|
606
|
+
};
|
|
607
|
+
|
|
608
|
+
/** Paint `name` into `el`, touching the DOM only when it changes. */
|
|
609
|
+
function setIcon(el, name) {
|
|
610
|
+
if (!el || el.dataset.icon === name) return;
|
|
611
|
+
el.dataset.icon = name;
|
|
612
|
+
el.innerHTML = `<svg viewBox="0 0 24 24" aria-hidden="true">${ICONS[name]}</svg>`;
|
|
613
|
+
}
|
|
614
|
+
|
|
483
615
|
function t(key, vars) {
|
|
484
616
|
let text = DICT[LANG]?.[key] ?? DICT.en[key] ?? key;
|
|
485
617
|
if (vars) {
|
|
@@ -867,7 +999,7 @@
|
|
|
867
999
|
$('lyrics').innerHTML = '<p class="hint">—</p>';
|
|
868
1000
|
}
|
|
869
1001
|
}
|
|
870
|
-
$('play')
|
|
1002
|
+
setIcon($('play'), state.playing ? 'pause' : 'play');
|
|
871
1003
|
$('mode').textContent = { list: t('modeList'), single: t('modeSingle'), shuffle: t('modeShuffle') }[state.mode] || t('modeList');
|
|
872
1004
|
$('counts').textContent = state.counts ? `(${state.counts.queued})` : '';
|
|
873
1005
|
$('dj-toggle').classList.toggle('on', Boolean(state.dj?.enabled));
|
|
@@ -886,11 +1018,11 @@
|
|
|
886
1018
|
// DJ status
|
|
887
1019
|
const dj = state.dj || {};
|
|
888
1020
|
$('dj-status').innerHTML = dj.enabled || dj.lastPlan
|
|
889
|
-
? `<div class="
|
|
1021
|
+
? `<div class="plan">${dj.busy ? esc(t('djPlanning')) : dj.error ? `AI DJ: ${esc(dj.error)}` : ''}${
|
|
890
1022
|
dj.lastPlan
|
|
891
|
-
? `<div><b
|
|
1023
|
+
? `<div><b>+${dj.lastPlan.added}</b> ${esc(dj.lastPlan.vibe || '')}</div><div class="muted">${esc((dj.lastPlan.names || []).slice(-3).join(' · '))}</div>`
|
|
892
1024
|
: ''
|
|
893
|
-
}${dj.modelError && !dj.lastPlan?.route ? `<div
|
|
1025
|
+
}${dj.modelError && !dj.lastPlan?.route ? `<div class="muted">${esc(t('modelTierUnavailable'))}: ${esc(dj.modelError)}</div>` : ''}${dj.lastPlan?.source === 'heuristic' ? `<div class="muted">${esc(t('heuristics'))}</div>` : ''}</div>`
|
|
894
1026
|
: '';
|
|
895
1027
|
|
|
896
1028
|
if (autoplayBlocked()) {
|
|
@@ -899,7 +1031,7 @@
|
|
|
899
1031
|
el.id = 'gesture';
|
|
900
1032
|
el.className = 'need-gesture';
|
|
901
1033
|
el.innerHTML = `${esc(t('gestureText'))} — <button id="gesture-go" class="primary">${esc(t('gesturePlay'))}</button> <span style="color:var(--muted)">${esc(t('gestureNote'))}</span>`;
|
|
902
|
-
$('
|
|
1034
|
+
$('notices').append(el);
|
|
903
1035
|
el.querySelector('#gesture-go').onclick = resumeWithGesture;
|
|
904
1036
|
}
|
|
905
1037
|
} else {
|
|
@@ -909,7 +1041,7 @@
|
|
|
909
1041
|
// The engine owns the real volume; mirror it unless the user is
|
|
910
1042
|
// mid-drag, when overwriting the thumb would fight the pointer.
|
|
911
1043
|
if (document.activeElement !== $('volume')) $('volume').value = state.volume;
|
|
912
|
-
$('mute')
|
|
1044
|
+
setIcon($('mute'), state.muted || state.volume === 0 ? 'muted' : 'volume');
|
|
913
1045
|
|
|
914
1046
|
// Same for quality: the host is authoritative, the select mirrors it.
|
|
915
1047
|
const preferredLevel = state.audio?.preferred;
|
|
@@ -987,6 +1119,46 @@
|
|
|
987
1119
|
$('like').title = t(liked ? 'unlike' : 'like');
|
|
988
1120
|
$('dislike').classList.toggle('on', disliked);
|
|
989
1121
|
$('dislike').title = t(disliked ? 'undislike' : 'dislike');
|
|
1122
|
+
// A filled arrow is the boost in force; clicking it clears the boost.
|
|
1123
|
+
const boost = track?.boost ?? null;
|
|
1124
|
+
$('boost-more').classList.toggle('on', boost === 'more');
|
|
1125
|
+
$('boost-more').title = t(boost === 'more' ? 'boostClear' : 'boostMore');
|
|
1126
|
+
$('boost-less').classList.toggle('on', boost === 'less');
|
|
1127
|
+
$('boost-less').title = t(boost === 'less' ? 'boostClear' : 'boostLess');
|
|
1128
|
+
paintBoosts();
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
/**
|
|
1132
|
+
* The boosts in force, each with its time left and a ✕ to end it early —
|
|
1133
|
+
* so a temporary push is never invisible, and never outlives the mood.
|
|
1134
|
+
*/
|
|
1135
|
+
function paintBoosts() {
|
|
1136
|
+
const boosts = state?.boosts ?? [];
|
|
1137
|
+
const now = Date.now();
|
|
1138
|
+
$('boosts').innerHTML = boosts.length
|
|
1139
|
+
? `<span>${esc(t('boostsTitle'))}:</span>` +
|
|
1140
|
+
boosts
|
|
1141
|
+
.map((boost) => {
|
|
1142
|
+
const minutes = Math.max(Math.round((boost.until - now) / 60_000), 1);
|
|
1143
|
+
return `<span class="boost">${boost.direction === 'more' ? '▲' : '▼'} ${esc(boost.name)} · ${esc(t('boostMinutes', { n: minutes }))}<button data-unboost="${boost.id}" title="${esc(t('boostClear'))}">✕</button></span>`;
|
|
1144
|
+
})
|
|
1145
|
+
.join('')
|
|
1146
|
+
: '';
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
/** Boost a track, or clear its boost with `none`, and adopt the host's answer. */
|
|
1150
|
+
async function sendBoost(trackId, direction, button) {
|
|
1151
|
+
if (button) button.disabled = true;
|
|
1152
|
+
try {
|
|
1153
|
+
state = await api('/boost', { method: 'POST', body: { trackId, direction } });
|
|
1154
|
+
render();
|
|
1155
|
+
applyTransport();
|
|
1156
|
+
toast(t(direction === 'more' ? 'boostedMore' : direction === 'less' ? 'boostedLess' : 'boostCleared'));
|
|
1157
|
+
} catch (error) {
|
|
1158
|
+
toast(failureText(error));
|
|
1159
|
+
} finally {
|
|
1160
|
+
if (button) button.disabled = false;
|
|
1161
|
+
}
|
|
990
1162
|
}
|
|
991
1163
|
|
|
992
1164
|
/**
|
|
@@ -1525,7 +1697,7 @@
|
|
|
1525
1697
|
// The engine owns the real gain; mirror it locally and throttle the
|
|
1526
1698
|
// round-trip while the pointer is still down.
|
|
1527
1699
|
if (state) state.volume = value;
|
|
1528
|
-
$('mute')
|
|
1700
|
+
setIcon($('mute'), value === 0 ? 'muted' : 'volume');
|
|
1529
1701
|
if (Date.now() - volumePostAt > 150) {
|
|
1530
1702
|
volumePostAt = Date.now();
|
|
1531
1703
|
control({ action: 'volume', value });
|
|
@@ -1551,10 +1723,22 @@
|
|
|
1551
1723
|
await sendTaste(track, 'none', event?.currentTarget);
|
|
1552
1724
|
return;
|
|
1553
1725
|
}
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1726
|
+
// The host takes a disliked track out of the queue, and moves on when it
|
|
1727
|
+
// was playing; pressing next here as well would skip a second track.
|
|
1728
|
+
if (await sendTaste(track, 'disliked', event?.currentTarget)) toast(t('disliked'));
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
// Both boost buttons are switchers too: the filled one clears its boost.
|
|
1732
|
+
for (const direction of ['more', 'less']) {
|
|
1733
|
+
$(`boost-${direction}`).onclick = (event) => {
|
|
1734
|
+
const track = state?.current;
|
|
1735
|
+
if (!track) return;
|
|
1736
|
+
return sendBoost(track.id, track.boost === direction ? 'none' : direction, event?.currentTarget);
|
|
1737
|
+
};
|
|
1738
|
+
}
|
|
1739
|
+
$('boosts').onclick = (event) => {
|
|
1740
|
+
const target = event.target?.closest?.('[data-unboost]');
|
|
1741
|
+
if (target) return sendBoost(Number(target.dataset.unboost), 'none', target);
|
|
1558
1742
|
};
|
|
1559
1743
|
|
|
1560
1744
|
$('dj-toggle').onclick = async () => {
|