@vicyangorg/dsh-music 0.4.0 → 0.6.0
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/client/index.js +412 -51
- package/docs/assets/library-shelf.webp +0 -0
- package/docs/assets/liked-full.webp +0 -0
- package/docs/assets/shelf-synced.webp +0 -0
- package/host/metadata/artist.js +25 -5
- package/host/reco/index.js +241 -92
- package/host/reco/verify.js +26 -1
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -96,6 +96,13 @@ window.__ModuleLoader__.load({
|
|
|
96
96
|
lang_pt: '葡萄牙语',
|
|
97
97
|
lang_it: '意大利语',
|
|
98
98
|
welcomeTasteNote: '偏好只用于微调探索批次,不会锁死你的推荐;之后随时能改。',
|
|
99
|
+
favsTitle: '我喜欢',
|
|
100
|
+
favsViewAll: '查看全部',
|
|
101
|
+
favsBack: '返回曲库',
|
|
102
|
+
favsEmpty: '还没有喜欢的歌——点任意歌曲的 ♥,它就会进入这里。',
|
|
103
|
+
artistReadyToast: '歌手页已就绪',
|
|
104
|
+
pageReadyToast: '页面已加载完成',
|
|
105
|
+
closeNotice: '关闭提示',
|
|
99
106
|
libTabsLabel: '曲库视图',
|
|
100
107
|
libTabLibrary: '曲库',
|
|
101
108
|
libTabLikes: '我喜欢',
|
|
@@ -261,7 +268,7 @@ window.__ModuleLoader__.load({
|
|
|
261
268
|
modeCycleHint: '点击切换播放模式',
|
|
262
269
|
modeHintShuffle: '随机播放:每轮打乱不重复',
|
|
263
270
|
artistPageBack: '返回推荐',
|
|
264
|
-
artistSongs: '
|
|
271
|
+
artistSongs: '歌曲',
|
|
265
272
|
artistLoading: '正在打开歌手页…',
|
|
266
273
|
artistError: '歌手页加载失败',
|
|
267
274
|
artistNoSongs: '这位歌手暂时没有已核实的歌曲。',
|
|
@@ -274,6 +281,10 @@ window.__ModuleLoader__.load({
|
|
|
274
281
|
recoGenerate: '生成推荐',
|
|
275
282
|
recoRegenerate: '换一批',
|
|
276
283
|
recoGenerating: '正在生成推荐(每首候选先联网核实,约需半分钟)…',
|
|
284
|
+
recoRefresh: '重新推荐本栏',
|
|
285
|
+
recoRefreshHint: '只重算这一栏,其余两栏保持当天已固化的内容',
|
|
286
|
+
recoRefreshing: '正在重新推荐这一栏…',
|
|
287
|
+
recoRefreshBusy: '这一栏正在生成中,请稍后再试',
|
|
277
288
|
recoEmptyTitle: '还没有推荐',
|
|
278
289
|
recoEmptyBody: '基于你的收听历史生成一批 10 首:7 首口味相近 + 3 首强制探索(流派/语言/年代轮换),每首都先联网核实真实存在,杜绝幻觉歌曲。多听几首歌,推荐会更懂你。',
|
|
279
290
|
recoError: '推荐生成失败',
|
|
@@ -355,6 +366,13 @@ window.__ModuleLoader__.load({
|
|
|
355
366
|
lang_pt: 'Portuguese',
|
|
356
367
|
lang_it: 'Italian',
|
|
357
368
|
welcomeTasteNote: 'Preferences only bias the discovery batch - nothing is locked, and you can change them any time.',
|
|
369
|
+
favsTitle: 'Liked',
|
|
370
|
+
favsViewAll: 'View all',
|
|
371
|
+
favsBack: 'Back to library',
|
|
372
|
+
favsEmpty: 'No liked songs yet — hit the heart on any song and it lands here.',
|
|
373
|
+
artistReadyToast: 'Artist page ready',
|
|
374
|
+
pageReadyToast: 'Page ready',
|
|
375
|
+
closeNotice: 'Dismiss',
|
|
358
376
|
libTabsLabel: 'Library views',
|
|
359
377
|
libTabLibrary: 'Library',
|
|
360
378
|
libTabLikes: 'Liked',
|
|
@@ -520,7 +538,7 @@ window.__ModuleLoader__.load({
|
|
|
520
538
|
modeCycleHint: 'Click to switch play mode',
|
|
521
539
|
modeHintShuffle: 'Shuffle: random each pass, no repeats',
|
|
522
540
|
artistPageBack: 'Back to recommendations',
|
|
523
|
-
artistSongs: '
|
|
541
|
+
artistSongs: 'Songs',
|
|
524
542
|
artistLoading: 'Opening artist page…',
|
|
525
543
|
artistError: 'Artist page failed to load',
|
|
526
544
|
artistNoSongs: 'No verified songs for this artist yet.',
|
|
@@ -533,6 +551,10 @@ window.__ModuleLoader__.load({
|
|
|
533
551
|
recoGenerate: 'Generate',
|
|
534
552
|
recoRegenerate: 'Another batch',
|
|
535
553
|
recoGenerating: 'Generating recommendations (every candidate is verified online first, ~30s)…',
|
|
554
|
+
recoRefresh: 'Refresh this column',
|
|
555
|
+
recoRefreshHint: 'Recomputes only this column; the other two keep today\'s fixed snapshot',
|
|
556
|
+
recoRefreshing: 'Refreshing this column…',
|
|
557
|
+
recoRefreshBusy: 'This column is being generated — try again in a moment',
|
|
536
558
|
recoEmptyTitle: 'No recommendations yet',
|
|
537
559
|
recoEmptyBody: 'We build a batch of 10 from your listening history: 7 close to your taste + 3 forced explorations (genre / language / era rotation), each verified online before it shows up. Play a few more songs and it gets smarter.',
|
|
538
560
|
recoError: 'Recommendations failed',
|
|
@@ -831,6 +853,26 @@ window.__ModuleLoader__.load({
|
|
|
831
853
|
.dshm-libtabs-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);}
|
|
832
854
|
.dshm-libtabs-on{background:var(--dsw-alias-interactive-bg-active);color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-border-l2);font-weight:600;}
|
|
833
855
|
.dshm-libtabs-count{font-size:10.5px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-1);border-radius:999px;padding:0 6px;line-height:16px;}
|
|
856
|
+
.dshm-favs{padding:10px 20px 2px;width:100%;max-width:1120px;margin:0 auto;flex:none;box-sizing:border-box;}
|
|
857
|
+
.dshm-favs-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;}
|
|
858
|
+
.dshm-favs-title{font-size:12.5px;font-weight:600;color:var(--dsw-alias-label-primary);}
|
|
859
|
+
.dshm-favs-all{margin-left:auto;}
|
|
860
|
+
.dshm-favs-empty{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--dsw-alias-label-tertiary);padding:10px 12px;border:1px dashed var(--dsw-alias-border-l1);border-radius:10px;}
|
|
861
|
+
.dshm-favs-rail{display:flex;gap:10px;overflow-x:auto;padding:2px 0 10px;scrollbar-width:thin;}
|
|
862
|
+
.dshm-favcard{appearance:none;border:0;background:transparent;padding:0;width:104px;flex:none;display:flex;flex-direction:column;gap:6px;cursor:pointer;text-align:left;color:inherit;font:inherit;}
|
|
863
|
+
.dshm-favcard-cover{position:relative;display:block;width:104px;height:104px;border-radius:12px;overflow:hidden;background:var(--dsw-alias-bg-layer-2);}
|
|
864
|
+
.dshm-favcard-heart{position:absolute;top:6px;right:6px;display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-state-error-primary);}
|
|
865
|
+
.dshm-favcard-title{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);}
|
|
866
|
+
.dshm-favcard-sub{font-size:11px;color:var(--dsw-alias-label-tertiary);}
|
|
867
|
+
.dshm-favcard:hover .dshm-favcard-cover{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;}
|
|
868
|
+
.dshm-favcard-off{opacity:.5;cursor:not-allowed;}
|
|
869
|
+
.dshm-favcard-more{height:104px;justify-content:center;align-items:center;gap:6px;border-radius:12px;border:1px dashed var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);}
|
|
870
|
+
.dshm-favcard-more-label{font-size:11.5px;}
|
|
871
|
+
.dshm-toast{position:fixed;right:20px;bottom:96px;z-index:1000;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);box-shadow:0 6px 20px var(--dsw-alias-border-l2);font-size:12.5px;color:var(--dsw-alias-label-primary);animation:dshm-fade-in .18s ease-out;}
|
|
872
|
+
.dshm-toast-icon{display:inline-flex;color:var(--dsw-alias-state-success-primary);}
|
|
873
|
+
.dshm-toast-main{appearance:none;border:0;background:transparent;color:var(--dsw-alias-brand-text);font:inherit;cursor:pointer;padding:2px 4px;border-radius:6px;}
|
|
874
|
+
.dshm-toast-main:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
875
|
+
.dshm-toast-x{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer;padding:4px;border-radius:6px;display:inline-flex;}
|
|
834
876
|
.dshm-search{display:flex;align-items:center;gap:8px;flex:1;min-width:180px;max-width:340px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:9px;padding:6px 10px;color:var(--dsw-alias-label-tertiary);transition:border-color .15s;}
|
|
835
877
|
.dshm-search:focus-within{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-secondary);}
|
|
836
878
|
.dshm-search input{flex:1;min-width:0;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;outline:none;}
|
|
@@ -1015,7 +1057,14 @@ window.__ModuleLoader__.load({
|
|
|
1015
1057
|
.dshm-col-head{flex:none;display:flex;align-items:center;gap:8px;padding:12px 14px 8px;}
|
|
1016
1058
|
.dshm-col-title{font-size:13.5px;font-weight:680;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:6px;}
|
|
1017
1059
|
.dshm-col-count{font-size:11px;color:var(--dsw-alias-label-tertiary);}
|
|
1018
|
-
.dshm-col-play{margin-left:
|
|
1060
|
+
.dshm-col-play{margin-left:0;}
|
|
1061
|
+
.dshm-col-actions{display:flex;align-items:center;gap:6px;margin-left:auto;}
|
|
1062
|
+
.dshm-col-refresh{width:26px;height:26px;padding:0;justify-content:center;color:var(--dsw-alias-label-secondary);}
|
|
1063
|
+
.dshm-col-refresh:hover{color:var(--dsw-alias-label-primary);}
|
|
1064
|
+
.dshm-col-loading{display:flex;align-items:center;gap:6px;padding:0 14px 6px;font-size:12px;color:var(--dsw-alias-label-secondary);}
|
|
1065
|
+
.dshm-refresh-note{color:var(--dsw-alias-label-secondary);}
|
|
1066
|
+
.dshm-playround-busy{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);opacity:.7;}
|
|
1067
|
+
.dshm-playround .dshm-spin,.dshm-col-refresh .dshm-spin,.dshm-col-loading .dshm-spin,.dshm-row-play .dshm-spin{display:inline-block;width:12px;height:12px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;box-sizing:border-box;}
|
|
1019
1068
|
.dshm-col-list{flex:1;min-height:0;overflow-y:auto;padding:2px 8px 16px;scrollbar-width:thin;scrollbar-color:var(--dsw-alias-scrollbar-bg-l2) transparent;}
|
|
1020
1069
|
.dshm-srow{display:grid;grid-template-columns:38px minmax(0,1fr) auto auto auto;align-items:center;gap:10px;padding:6px;border-radius:10px;transition:background .12s;}
|
|
1021
1070
|
.dshm-srow:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
@@ -1169,6 +1218,16 @@ window.__ModuleLoader__.load({
|
|
|
1169
1218
|
if (languages.length) parts.push('languages=' + encodeURIComponent(languages.join(',')));
|
|
1170
1219
|
return parts.length ? '?' + parts.join('&') : '';
|
|
1171
1220
|
}
|
|
1221
|
+
/* Same taste payload for POST bodies (per-column refresh). */
|
|
1222
|
+
function tasteBody(taste) {
|
|
1223
|
+
if (!taste || typeof taste !== 'object') return {};
|
|
1224
|
+
const genres = (taste.genres || []).filter(Boolean);
|
|
1225
|
+
const languages = (taste.languages || []).filter(Boolean);
|
|
1226
|
+
const body = {};
|
|
1227
|
+
if (genres.length) body.genres = genres;
|
|
1228
|
+
if (languages.length) body.languages = languages;
|
|
1229
|
+
return body;
|
|
1230
|
+
}
|
|
1172
1231
|
|
|
1173
1232
|
async function request(path, options) {
|
|
1174
1233
|
let res;
|
|
@@ -1194,6 +1253,10 @@ window.__ModuleLoader__.load({
|
|
|
1194
1253
|
artist: (name) => request('/dsh-music/api/artist?name=' + encodeURIComponent(name)),
|
|
1195
1254
|
artistImage: (name) => request('/dsh-music/api/reco/artist-image?name=' + encodeURIComponent(name)),
|
|
1196
1255
|
recoSections: (taste) => request('/dsh-music/api/reco/sections' + tasteQuery(taste)),
|
|
1256
|
+
recoSectionsRefresh: (axis, taste) => request('/dsh-music/api/reco/sections/refresh', {
|
|
1257
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1258
|
+
body: JSON.stringify(Object.assign({ axis }, tasteBody(taste))),
|
|
1259
|
+
}),
|
|
1197
1260
|
deleteTrack: (trackId, confirm) => request('/dsh-music/api/library/delete', {
|
|
1198
1261
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1199
1262
|
body: JSON.stringify({ trackId, confirm: !!confirm }),
|
|
@@ -1345,6 +1408,44 @@ window.__ModuleLoader__.load({
|
|
|
1345
1408
|
return { source: store, load };
|
|
1346
1409
|
}
|
|
1347
1410
|
|
|
1411
|
+
/* Artist page loader (v9): loads run to completion even when the user
|
|
1412
|
+
* navigates away, results are cached for the whole session (reopening is
|
|
1413
|
+
* instant) and every finished load is announced through lastReady so the
|
|
1414
|
+
* panel can toast "artist page ready" with a one-click shortcut. */
|
|
1415
|
+
function createArtistPageService(api) {
|
|
1416
|
+
const store = createStore({ pages: {}, loading: {}, lastReady: null, error: null });
|
|
1417
|
+
const pending = new Map();
|
|
1418
|
+
const keyOf = (name) => normalizeZh(name || '').trim();
|
|
1419
|
+
function load(name) {
|
|
1420
|
+
if (!name) return Promise.resolve(null);
|
|
1421
|
+
const key = keyOf(name);
|
|
1422
|
+
const snap = store.getSnapshot();
|
|
1423
|
+
if (snap.pages[key]) return Promise.resolve(snap.pages[key]);
|
|
1424
|
+
if (pending.has(key)) return pending.get(key);
|
|
1425
|
+
store.set({ loading: { ...store.getSnapshot().loading, [key]: true } });
|
|
1426
|
+
const p = api.recoArtist(name)
|
|
1427
|
+
.then((data) => {
|
|
1428
|
+
const cur = store.getSnapshot();
|
|
1429
|
+
store.set({
|
|
1430
|
+
pages: { ...cur.pages, [key]: data },
|
|
1431
|
+
loading: { ...cur.loading, [key]: false },
|
|
1432
|
+
error: null,
|
|
1433
|
+
lastReady: { name, key, at: Date.now() },
|
|
1434
|
+
});
|
|
1435
|
+
return data;
|
|
1436
|
+
})
|
|
1437
|
+
.catch((err) => {
|
|
1438
|
+
const cur = store.getSnapshot();
|
|
1439
|
+
store.set({ loading: { ...cur.loading, [key]: false }, error: (err && err.message) || String(err) });
|
|
1440
|
+
throw err;
|
|
1441
|
+
})
|
|
1442
|
+
.finally(() => { pending.delete(key); });
|
|
1443
|
+
pending.set(key, p);
|
|
1444
|
+
return p;
|
|
1445
|
+
}
|
|
1446
|
+
return { source: store, load, keyOf };
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1348
1449
|
/* Artist portraits (batch 2, v6): one lightweight image lookup per name.
|
|
1349
1450
|
* Requests are coalesced in a 150ms window and limited to 3 in flight, so a
|
|
1350
1451
|
* page that renders 20 artist rows does not fire 20 parallel lookups.
|
|
@@ -1440,7 +1541,12 @@ window.__ModuleLoader__.load({
|
|
|
1440
1541
|
* 6c. S3 services: recommendations / downloads / sync / history
|
|
1441
1542
|
* ================================================================ */
|
|
1442
1543
|
function createRecoService(api) {
|
|
1443
|
-
const store = createStore({
|
|
1544
|
+
const store = createStore({
|
|
1545
|
+
status: 'idle', items: [], sections: null, generatedAt: 0, stats: null, error: null, bootstrapNote: null,
|
|
1546
|
+
fromCache: { today: false, artist: false, new: false },
|
|
1547
|
+
refreshing: { today: false, artist: false, new: false },
|
|
1548
|
+
refreshError: null, refreshBusy: false,
|
|
1549
|
+
});
|
|
1444
1550
|
let inflight = false;
|
|
1445
1551
|
async function pollUntilIdle() {
|
|
1446
1552
|
for (;;) {
|
|
@@ -1493,6 +1599,8 @@ window.__ModuleLoader__.load({
|
|
|
1493
1599
|
store.set({
|
|
1494
1600
|
status: 'ready', sections, items: sections.today, generatedAt: data.generatedAt || Date.now(),
|
|
1495
1601
|
error: null, bootstrapNote: data.exploreOnly ? (data.note || null) : null,
|
|
1602
|
+
fromCache: (data && data.fromCache) || { today: false, artist: false, new: false },
|
|
1603
|
+
refreshError: null, refreshBusy: false,
|
|
1496
1604
|
});
|
|
1497
1605
|
return true;
|
|
1498
1606
|
} catch { return false; }
|
|
@@ -1508,7 +1616,41 @@ window.__ModuleLoader__.load({
|
|
|
1508
1616
|
}
|
|
1509
1617
|
} catch { /* keep empty CTA; user can still generate */ }
|
|
1510
1618
|
}
|
|
1511
|
-
|
|
1619
|
+
/* Per-column "recompute this column only" (十期). The Host keeps the
|
|
1620
|
+
* three-column daily snapshot and only regenerates the requested axis,
|
|
1621
|
+
* reusing the rest, so the other two columns never flicker. */
|
|
1622
|
+
const AXES = ['today', 'artist', 'new'];
|
|
1623
|
+
async function refresh(axis) {
|
|
1624
|
+
if (AXES.indexOf(axis) < 0 || !api.recoSectionsRefresh) return;
|
|
1625
|
+
const cur = store.getSnapshot();
|
|
1626
|
+
if (cur.refreshing[axis]) return;
|
|
1627
|
+
store.set({ refreshing: Object.assign({}, cur.refreshing, { [axis]: true }), refreshError: null, refreshBusy: false });
|
|
1628
|
+
try {
|
|
1629
|
+
const data = await api.recoSectionsRefresh(axis, readPrefs().taste || null);
|
|
1630
|
+
const prev = store.getSnapshot();
|
|
1631
|
+
const base = prev.sections || { today: [], artist: [], new: [] };
|
|
1632
|
+
const sections = {
|
|
1633
|
+
today: (data && data.today) || base.today || [],
|
|
1634
|
+
artist: (data && data.artist) || base.artist || [],
|
|
1635
|
+
new: (data && (data['new'] || data.newColumn)) || base['new'] || [],
|
|
1636
|
+
};
|
|
1637
|
+
store.set({
|
|
1638
|
+
status: 'ready', sections, items: sections.today, error: null,
|
|
1639
|
+
generatedAt: (data && data.generatedAt) || prev.generatedAt,
|
|
1640
|
+
fromCache: (data && data.fromCache) || prev.fromCache,
|
|
1641
|
+
refreshing: { today: false, artist: false, new: false },
|
|
1642
|
+
refreshError: null, refreshBusy: false,
|
|
1643
|
+
});
|
|
1644
|
+
} catch (err) {
|
|
1645
|
+
const msg = (err && err.message) || String(err);
|
|
1646
|
+
const busy = /409|正在|生成中/.test(msg);
|
|
1647
|
+
store.set({
|
|
1648
|
+
refreshing: { today: false, artist: false, new: false },
|
|
1649
|
+
refreshError: busy ? 'busy' : msg, refreshBusy: busy,
|
|
1650
|
+
});
|
|
1651
|
+
}
|
|
1652
|
+
}
|
|
1653
|
+
return { source: store, generate, load, refresh, searchStyle: (q) => api.recoStyle(q), artistPage: (name) => api.recoArtist(name) };
|
|
1512
1654
|
}
|
|
1513
1655
|
|
|
1514
1656
|
function createDownloadService(api) {
|
|
@@ -1668,6 +1810,9 @@ window.__ModuleLoader__.load({
|
|
|
1668
1810
|
if (liked && res && res.disliked === false) delete dislikes[key];
|
|
1669
1811
|
store.set({ keys, dislikes });
|
|
1670
1812
|
if (res && res.downloading && onAutoDownload) onAutoDownload();
|
|
1813
|
+
/* Refresh the cached lists so the library card rail reflects the new
|
|
1814
|
+
* heart immediately (host is the source of truth, call is local). */
|
|
1815
|
+
load();
|
|
1671
1816
|
return res || {};
|
|
1672
1817
|
}
|
|
1673
1818
|
async function setDislike(item, disliked) {
|
|
@@ -1736,6 +1881,95 @@ window.__ModuleLoader__.load({
|
|
|
1736
1881
|
return { source: store, start, dispose };
|
|
1737
1882
|
}
|
|
1738
1883
|
|
|
1884
|
+
/* ================================================================
|
|
1885
|
+
* 6b. Warm service —「缓存转圈」反馈(十期②)
|
|
1886
|
+
* pending 里为正在缓存的行;试听缓存同一时刻只能跑一首(Host 单 job +
|
|
1887
|
+
* 共享管线锁),所以这里串行预热:整栏播放时整栏行同时转圈,每首就绪
|
|
1888
|
+
* 立即解除该行转圈并追加到队列(首首就绪即开播)。同一时间只跑一轮,
|
|
1889
|
+
* 转圈期间再点任何一首都被忽略,避免连点重复下载。
|
|
1890
|
+
* ================================================================ */
|
|
1891
|
+
function createWarmService(preview, player) {
|
|
1892
|
+
const store = createStore({ pending: {}, running: false });
|
|
1893
|
+
function isPending(item) {
|
|
1894
|
+
return !!store.getSnapshot().pending[likeKey(item)];
|
|
1895
|
+
}
|
|
1896
|
+
function mark(items, on) {
|
|
1897
|
+
const next = Object.assign({}, store.getSnapshot().pending);
|
|
1898
|
+
for (const it of items || []) {
|
|
1899
|
+
const key = likeKey(it);
|
|
1900
|
+
if (on) next[key] = true;
|
|
1901
|
+
else delete next[key];
|
|
1902
|
+
}
|
|
1903
|
+
store.set({ pending: next });
|
|
1904
|
+
}
|
|
1905
|
+
function trackOf(item, audioUrl) {
|
|
1906
|
+
return {
|
|
1907
|
+
id: 'preview:' + likeKey(item),
|
|
1908
|
+
title: item.title, artist: item.artist, album: item.album,
|
|
1909
|
+
coverUrl: item.coverUrl || null, audioUrl, duration: null,
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
function warmOne(item) {
|
|
1913
|
+
return new Promise((resolve) => { preview.start(item, (res) => resolve(res || {})); });
|
|
1914
|
+
}
|
|
1915
|
+
function handle(item, res) {
|
|
1916
|
+
if (!res || !res.audioUrl) return;
|
|
1917
|
+
const tr = trackOf(item, res.audioUrl);
|
|
1918
|
+
if (!player.source.getSnapshot().track) player.playTracks([tr], 0);
|
|
1919
|
+
else player.appendTrack(tr);
|
|
1920
|
+
}
|
|
1921
|
+
/* Whole column: local hits start instantly, the rest warm serially. */
|
|
1922
|
+
async function playList(items, findLocal) {
|
|
1923
|
+
if (store.getSnapshot().running) return;
|
|
1924
|
+
const list = items || [];
|
|
1925
|
+
const localTracks = [];
|
|
1926
|
+
const remote = [];
|
|
1927
|
+
for (const it of list) {
|
|
1928
|
+
if (!it) continue;
|
|
1929
|
+
const lc = findLocal ? findLocal(it) : null;
|
|
1930
|
+
if (lc) {
|
|
1931
|
+
if (!localTracks.some((tr) => tr.id === lc.id)) localTracks.push(lc);
|
|
1932
|
+
} else if (it.verification) {
|
|
1933
|
+
remote.push(it);
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
if (localTracks.length) player.playTracks(localTracks, 0);
|
|
1937
|
+
if (!remote.length) return;
|
|
1938
|
+
mark(remote, true);
|
|
1939
|
+
store.set({ running: true });
|
|
1940
|
+
let firstError = null;
|
|
1941
|
+
try {
|
|
1942
|
+
for (const it of remote) {
|
|
1943
|
+
const res = await warmOne(it);
|
|
1944
|
+
mark([it], false);
|
|
1945
|
+
if (!res.audioUrl && res.error && !firstError) firstError = res.error;
|
|
1946
|
+
handle(it, res);
|
|
1947
|
+
}
|
|
1948
|
+
} finally {
|
|
1949
|
+
mark(remote, false);
|
|
1950
|
+
store.set({ running: false });
|
|
1951
|
+
}
|
|
1952
|
+
return { error: firstError };
|
|
1953
|
+
}
|
|
1954
|
+
/* Single row: only that row spins. */
|
|
1955
|
+
async function playOne(item) {
|
|
1956
|
+
if (store.getSnapshot().running) return null;
|
|
1957
|
+
mark([item], true);
|
|
1958
|
+
store.set({ running: true });
|
|
1959
|
+
let err = null;
|
|
1960
|
+
try {
|
|
1961
|
+
const res = await warmOne(item);
|
|
1962
|
+
if (res && res.error) err = res.error;
|
|
1963
|
+
handle(item, res);
|
|
1964
|
+
} finally {
|
|
1965
|
+
mark([item], false);
|
|
1966
|
+
store.set({ running: false });
|
|
1967
|
+
}
|
|
1968
|
+
return err ? { error: err } : null;
|
|
1969
|
+
}
|
|
1970
|
+
return { source: store, isPending, playList, playOne };
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1739
1973
|
/* ================================================================
|
|
1740
1974
|
* 7. Player engine — singleton audio, survives panel navigation
|
|
1741
1975
|
* ================================================================ */
|
|
@@ -1868,8 +2102,18 @@ window.__ModuleLoader__.load({
|
|
|
1868
2102
|
syncHost({ trackId: queue[index].id, queue: queue.map((tr) => tr.id).filter(Boolean) });
|
|
1869
2103
|
}
|
|
1870
2104
|
|
|
1871
|
-
|
|
1872
|
-
|
|
2105
|
+
/* Append one ready track without interrupting what plays now (十期②:
|
|
2106
|
+
* 整栏逐首缓存,就绪一首追加一首,队列自然续播). */
|
|
2107
|
+
function appendTrack(tr) {
|
|
2108
|
+
if (!tr || !tr.audioUrl) return;
|
|
2109
|
+
const snapNow = snap();
|
|
2110
|
+
if (!snapNow.track) { playTracks([tr], 0); return; }
|
|
2111
|
+
const queue = [...snapNow.queue, tr];
|
|
2112
|
+
set({ queue });
|
|
2113
|
+
syncHost({ queue: queue.map((x) => (x && x.id) || null).filter(Boolean) });
|
|
2114
|
+
}
|
|
2115
|
+
|
|
2116
|
+
function jumpTo(index) { const { queue } = snap();
|
|
1873
2117
|
if (index < 0 || index >= queue.length) return;
|
|
1874
2118
|
report(snap().track, true);
|
|
1875
2119
|
set({ queueIndex: index });
|
|
@@ -2048,6 +2292,7 @@ window.__ModuleLoader__.load({
|
|
|
2048
2292
|
return {
|
|
2049
2293
|
source: store,
|
|
2050
2294
|
playTracks,
|
|
2295
|
+
appendTrack,
|
|
2051
2296
|
playAll: (tracks, opts) => playTracks(tracks, 0, opts),
|
|
2052
2297
|
jumpTo,
|
|
2053
2298
|
toggle,
|
|
@@ -2411,7 +2656,7 @@ window.__ModuleLoader__.load({
|
|
|
2411
2656
|
}, h(IconThumbDown, { size: 15, style: disliked ? { fill: 'currentColor' } : undefined }));
|
|
2412
2657
|
}
|
|
2413
2658
|
|
|
2414
|
-
function TrackRow({ track, index, isCurrent, playing, onPlay, onDelete, onReveal, onOpenArtist, likes, useLikes, t, muted }) {
|
|
2659
|
+
function TrackRow({ track, index, isCurrent, playing, onPlay, onDelete, onReveal, onOpenArtist, likes, useLikes, t, muted, pending }) {
|
|
2415
2660
|
return h('div', {
|
|
2416
2661
|
className: cx('dshm-row', isCurrent && 'dshm-row-current', muted && 'dshm-row-off'),
|
|
2417
2662
|
role: 'button', tabIndex: 0,
|
|
@@ -2441,7 +2686,8 @@ window.__ModuleLoader__.load({
|
|
|
2441
2686
|
onDelete ? h('span', { className: 'dshm-row-actions', onClick: (e) => e.stopPropagation() },
|
|
2442
2687
|
h(IconButton, { label: t('revealTrack'), onClick: (e) => { e.stopPropagation(); onReveal(track); } }, h(IconDisc, { size: 14 })),
|
|
2443
2688
|
h(IconButton, { label: t('deleteTrack'), onClick: (e) => { e.stopPropagation(); onDelete(track); } }, h(IconClose, { size: 14 }))) : null,
|
|
2444
|
-
h('span', { className: 'dshm-row-play', 'aria-hidden': true },
|
|
2689
|
+
h('span', { className: cx('dshm-row-play', pending && 'dshm-playround-busy'), 'aria-hidden': true },
|
|
2690
|
+
pending ? h('span', { className: 'dshm-spin' }) : h(IconPlay, { size: 15 })));
|
|
2445
2691
|
}
|
|
2446
2692
|
|
|
2447
2693
|
/* ================================================================
|
|
@@ -2702,18 +2948,46 @@ window.__ModuleLoader__.load({
|
|
|
2702
2948
|
return h(React.Fragment, null,
|
|
2703
2949
|
sync ? h(SyncPanel, { t, sync, useSync }) : null,
|
|
2704
2950
|
rowError ? h('div', { className: 'dshm-errorline', role: 'alert', style: { margin: '8px 24px 0' } }, rowError) : null,
|
|
2705
|
-
|
|
2706
|
-
h('
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2951
|
+
libTab === 'likes'
|
|
2952
|
+
? h('div', { className: 'dshm-libtabs' },
|
|
2953
|
+
h('button', {
|
|
2954
|
+
type: 'button', className: 'dshm-chipbtn',
|
|
2955
|
+
onClick: () => setLibTab('library'),
|
|
2956
|
+
}, '← ' + t('favsBack')),
|
|
2957
|
+
h('span', { className: 'dshm-favs-title', style: { marginLeft: '4px' } }, t('libTabLikes')),
|
|
2958
|
+
h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit')))
|
|
2959
|
+
: h('div', { className: 'dshm-favs' },
|
|
2960
|
+
h('div', { className: 'dshm-favs-head' },
|
|
2961
|
+
h(IconHeart, { size: 14, style: { color: 'var(--dsw-alias-state-error-primary)' } }),
|
|
2962
|
+
h('span', { className: 'dshm-favs-title' }, t('favsTitle')),
|
|
2963
|
+
likeItems.length ? h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit')) : null,
|
|
2964
|
+
likeItems.length
|
|
2965
|
+
? h('button', {
|
|
2966
|
+
type: 'button', className: 'dshm-chipbtn dshm-favs-all',
|
|
2967
|
+
onClick: () => setLibTab('likes'),
|
|
2968
|
+
}, t('favsViewAll'), ' ›')
|
|
2969
|
+
: null),
|
|
2970
|
+
likeItems.length === 0
|
|
2971
|
+
? h('div', { className: 'dshm-favs-empty' }, h(IconHeart, { size: 16 }), t('favsEmpty'))
|
|
2972
|
+
: h('div', { className: 'dshm-favs-rail' },
|
|
2973
|
+
likedTracks.slice(0, 12).map((tr, i) => h('button', {
|
|
2974
|
+
key: tr.id || ('fav' + i), type: 'button',
|
|
2975
|
+
className: cx('dshm-favcard', tr.muted && 'dshm-favcard-off'),
|
|
2976
|
+
title: tr.muted ? t('topUnplayable') : (tr.title || '') + (tr.artist ? ' · ' + tr.artist : ''),
|
|
2977
|
+
onClick: () => playLiked(tr),
|
|
2978
|
+
},
|
|
2979
|
+
h('span', { className: 'dshm-favcard-cover' },
|
|
2980
|
+
h(Thumb, { src: tr.coverUrl, size: 96 }),
|
|
2981
|
+
h('span', { className: 'dshm-favcard-heart' }, h(IconHeart, { size: 11, style: { fill: 'currentColor' } }))),
|
|
2982
|
+
h('span', { className: 'dshm-favcard-title dshm-ellipsis' }, tr.title || t('untitled')),
|
|
2983
|
+
h('span', { className: 'dshm-favcard-sub dshm-ellipsis' }, tr.artist || t('unknownArtist')))),
|
|
2984
|
+
h('button', {
|
|
2985
|
+
type: 'button', className: 'dshm-favcard dshm-favcard-more',
|
|
2986
|
+
onClick: () => setLibTab('likes'),
|
|
2987
|
+
},
|
|
2988
|
+
h(IconQueue, { size: 18 }),
|
|
2989
|
+
h('span', { className: 'dshm-favcard-more-label' }, t('favsViewAll')),
|
|
2990
|
+
h('span', { className: 'dshm-count' }, likeItems.length)))),
|
|
2717
2991
|
h('div', { className: 'dshm-toolbar' },
|
|
2718
2992
|
h('label', { className: 'dshm-search' },
|
|
2719
2993
|
h(IconSearch, { size: 15 }),
|
|
@@ -2869,7 +3143,7 @@ window.__ModuleLoader__.load({
|
|
|
2869
3143
|
|
|
2870
3144
|
/* V3 helpers: shared play-or-preview flow (preview never enters the
|
|
2871
3145
|
* library; only ♥-like downloads it — the Host handles that on like). */
|
|
2872
|
-
function playSong(item, player, tracks, preview, setNotice, t) {
|
|
3146
|
+
function playSong(item, player, tracks, preview, setNotice, t, warm) {
|
|
2873
3147
|
const local = (item.trackId && tracks.find((tr) => tr.id === item.trackId))
|
|
2874
3148
|
|| tracks.find((tr) =>
|
|
2875
3149
|
normalizeZh(tr.artist) === normalizeZh(item.artist) &&
|
|
@@ -2880,6 +3154,14 @@ window.__ModuleLoader__.load({
|
|
|
2880
3154
|
return;
|
|
2881
3155
|
}
|
|
2882
3156
|
if (!item.verification) { setNotice(t('previewNoVerify')); return; }
|
|
3157
|
+
setNotice('');
|
|
3158
|
+
if (warm) {
|
|
3159
|
+
/* 十期②:该行 ▶ 变转圈直到缓存就绪;运行中再点被 warm 内部忽略。 */
|
|
3160
|
+
warm.playOne(item).then((res) => {
|
|
3161
|
+
if (res && res.error) setNotice(t('previewFail') + ':' + res.error);
|
|
3162
|
+
});
|
|
3163
|
+
return;
|
|
3164
|
+
}
|
|
2883
3165
|
setNotice(t('previewLoading'));
|
|
2884
3166
|
preview.start(item, (res) => {
|
|
2885
3167
|
if (res.error) { setNotice(t('previewFail') + ':' + res.error); return; }
|
|
@@ -2927,8 +3209,10 @@ window.__ModuleLoader__.load({
|
|
|
2927
3209
|
return h(Thumb, { src: url || null, size: size || 20, round: true, glyph: IconNote });
|
|
2928
3210
|
}
|
|
2929
3211
|
|
|
2930
|
-
function SongRow({ t, item, likes, useLikes, onPlay, onOpenArtist, isCurrent, playing, showReason }) {
|
|
3212
|
+
function SongRow({ t, item, likes, useLikes, onPlay, onOpenArtist, isCurrent, playing, showReason, warm, useWarm }) {
|
|
2931
3213
|
const liked = useLikes((st) => !!st.keys[likeKey(item)]);
|
|
3214
|
+
/* 十期②:该行的缓存转圈态由 warm store 驱动(整栏播放时整栏一起转)。 */
|
|
3215
|
+
const pending = warm && useWarm ? !!useWarm((st) => !!(st.pending && st.pending[likeKey(item)])) : false;
|
|
2932
3216
|
return h('div', { className: cx('dshm-srow', isCurrent && 'dshm-row-current') },
|
|
2933
3217
|
h(Thumb, { src: item.coverUrl, size: 38 }),
|
|
2934
3218
|
h('div', {
|
|
@@ -2958,11 +3242,15 @@ window.__ModuleLoader__.load({
|
|
|
2958
3242
|
}, h(IconHeart, { size: 15, style: liked ? { fill: 'currentColor' } : undefined })),
|
|
2959
3243
|
likes ? h(DislikeButton, { t, item, likes, useLikes }) : null,
|
|
2960
3244
|
h('button', {
|
|
2961
|
-
type: 'button', className: 'dshm-playround',
|
|
2962
|
-
'aria-label': isCurrent && playing ? t('pause') : t('play'),
|
|
2963
|
-
|
|
3245
|
+
type: 'button', className: cx('dshm-playround', pending && 'dshm-playround-busy'),
|
|
3246
|
+
'aria-label': pending ? t('previewLoading') : (isCurrent && playing ? t('pause') : t('play')),
|
|
3247
|
+
'aria-busy': pending ? 'true' : undefined,
|
|
3248
|
+
disabled: !!pending,
|
|
3249
|
+
title: pending ? t('previewLoading') : (isCurrent && playing ? t('pause') : t('previewLabel')),
|
|
2964
3250
|
onClick: () => onPlay(item),
|
|
2965
|
-
},
|
|
3251
|
+
}, pending
|
|
3252
|
+
? h('span', { className: 'dshm-spin', 'aria-hidden': true })
|
|
3253
|
+
: h(isCurrent && playing ? IconPause : IconPlay, { size: 13 })));
|
|
2966
3254
|
}
|
|
2967
3255
|
|
|
2968
3256
|
/* Artist column row: real artist/band image + name + genre hint + chevron. */
|
|
@@ -2979,7 +3267,7 @@ window.__ModuleLoader__.load({
|
|
|
2979
3267
|
h('span', { className: 'dshm-arow-arrow', 'aria-hidden': true }, '›'));
|
|
2980
3268
|
}
|
|
2981
3269
|
|
|
2982
|
-
function RecoView({ t, reco, download, player, library, likes, preview, history, openArtistPage, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory }) {
|
|
3270
|
+
function RecoView({ t, reco, download, player, library, likes, preview, history, openArtistPage, warm, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory, useWarm }) {
|
|
2983
3271
|
const s = useReco((st) => st);
|
|
2984
3272
|
const histStats = useHistory ? useHistory((st) => st.stats) : null;
|
|
2985
3273
|
const coldStart = !(histStats && histStats.totalPlays > 0);
|
|
@@ -3017,7 +3305,7 @@ window.__ModuleLoader__.load({
|
|
|
3017
3305
|
normalizeZh(tr.title) === normalizeZh(item.title));
|
|
3018
3306
|
}
|
|
3019
3307
|
function onPlay(item) {
|
|
3020
|
-
playSong(item, player, tracks, preview, setNotice, t);
|
|
3308
|
+
playSong(item, player, tracks, preview, setNotice, t, warm);
|
|
3021
3309
|
}
|
|
3022
3310
|
/* Clicking a row queues the whole visible list (deduped local matches)
|
|
3023
3311
|
* and jumps straight to the clicked song; preview-only items fall back
|
|
@@ -3034,7 +3322,14 @@ window.__ModuleLoader__.load({
|
|
|
3034
3322
|
if (localTracks.length) player.playTracks(localTracks, at);
|
|
3035
3323
|
else if (list.length) onPlay(item || list[0]);
|
|
3036
3324
|
}
|
|
3037
|
-
|
|
3325
|
+
/* 「播放本栏」:本地命中的立即入队,未入库的整栏一起转圈、串行预热,
|
|
3326
|
+
* 就绪一首追加一首(首首就绪即开播)。 */
|
|
3327
|
+
function playColumn(list) {
|
|
3328
|
+
if (!warm) { playListFrom(list, null); return; }
|
|
3329
|
+
warm.playList(list, findLocal).then((res) => {
|
|
3330
|
+
if (res && res.error) setNotice(t('previewFail') + ':' + res.error);
|
|
3331
|
+
});
|
|
3332
|
+
}
|
|
3038
3333
|
|
|
3039
3334
|
const sections = s.sections || { today: s.items, artist: [], new: [] };
|
|
3040
3335
|
const styleActive = styleState.status !== 'idle';
|
|
@@ -3047,15 +3342,35 @@ window.__ModuleLoader__.load({
|
|
|
3047
3342
|
if (!list.length) return h('div', { className: 'dshm-lyrics-hint' }, t('recoSectionEmpty'));
|
|
3048
3343
|
return list.map((item, i) => h(SongRow, {
|
|
3049
3344
|
key: i, t, item, likes, useLikes, onPlay: (it) => playListFrom(list, it), onOpenArtist: openArtistPage, showReason,
|
|
3050
|
-
isCurrent: isCur(item), playing,
|
|
3345
|
+
isCurrent: isCur(item), playing, warm, useWarm,
|
|
3051
3346
|
}));
|
|
3052
3347
|
}
|
|
3053
|
-
|
|
3348
|
+
/* 十期:每栏各自的「重新推荐」——只重算本栏,刷新中仅该栏转圈。 */
|
|
3349
|
+
function colRefresh(axis) {
|
|
3350
|
+
const refreshing = s.refreshing || {};
|
|
3351
|
+
const busy = !!refreshing[axis];
|
|
3352
|
+
return h('button', {
|
|
3353
|
+
type: 'button', className: cx('dshm-chipbtn dshm-col-refresh', busy && 'dshm-chipbtn-busy'),
|
|
3354
|
+
disabled: busy, title: t('recoRefreshHint'), 'aria-label': t('recoRefresh'),
|
|
3355
|
+
'aria-busy': busy ? 'true' : undefined,
|
|
3356
|
+
onClick: () => reco.refresh(axis),
|
|
3357
|
+
}, busy
|
|
3358
|
+
? h('span', { className: 'dshm-spin', 'aria-hidden': true })
|
|
3359
|
+
: h(IconRefresh, { size: 12 }));
|
|
3360
|
+
}
|
|
3361
|
+
function colRefreshBanner(axis) {
|
|
3362
|
+
const refreshing = s.refreshing || {};
|
|
3363
|
+
if (!refreshing[axis]) return null;
|
|
3364
|
+
return h('div', { className: 'dshm-col-loading', role: 'status' },
|
|
3365
|
+
h('span', { className: 'dshm-spin', 'aria-hidden': true }), t('recoRefreshing'));
|
|
3366
|
+
}
|
|
3367
|
+
function column(headKey, icon, list, extraHead, axis) {
|
|
3054
3368
|
return h('section', { className: 'dshm-column', key: headKey },
|
|
3055
3369
|
h('div', { className: 'dshm-col-head' },
|
|
3056
3370
|
h('div', { className: 'dshm-col-title' }, h(icon, { size: 14 }), t(headKey)),
|
|
3057
3371
|
h('span', { className: 'dshm-col-count' }, list.length + ' ' + t('tracksUnit')),
|
|
3058
|
-
extraHead),
|
|
3372
|
+
h('div', { className: 'dshm-col-actions' }, axis ? colRefresh(axis) : null, extraHead)),
|
|
3373
|
+
colRefreshBanner(axis),
|
|
3059
3374
|
h('div', { className: 'dshm-col-list' }, songRows(list, true)));
|
|
3060
3375
|
}
|
|
3061
3376
|
|
|
@@ -3138,17 +3453,24 @@ window.__ModuleLoader__.load({
|
|
|
3138
3453
|
h('span', { className: 'dshm-explore-chip' }, t('exploreChip')),
|
|
3139
3454
|
h('span', null, s.bootstrapNote))
|
|
3140
3455
|
: null,
|
|
3456
|
+
s.refreshError
|
|
3457
|
+
? h('div', { className: 'dshm-explore-note dshm-refresh-note', role: 'alert' },
|
|
3458
|
+
h(IconAlert, { size: 13 }),
|
|
3459
|
+
h('span', null, s.refreshBusy ? t('recoRefreshBusy') : s.refreshError))
|
|
3460
|
+
: null,
|
|
3141
3461
|
h('div', { className: 'dshm-columns' },
|
|
3142
3462
|
column('colToday', IconSparkles, sections.today || [],
|
|
3143
3463
|
h('button', {
|
|
3144
3464
|
type: 'button', className: 'dshm-chipbtn dshm-col-play',
|
|
3145
3465
|
disabled: !(sections.today || []).length,
|
|
3146
3466
|
onClick: () => playColumn(sections.today || []),
|
|
3147
|
-
}, h(IconPlay, { size: 12 }), t('playColumn'))),
|
|
3467
|
+
}, h(IconPlay, { size: 12 }), t('playColumn')), 'today'),
|
|
3148
3468
|
h('section', { className: 'dshm-column', key: 'colArtist' },
|
|
3149
3469
|
h('div', { className: 'dshm-col-head' },
|
|
3150
3470
|
h('div', { className: 'dshm-col-title' }, h(IconNote, { size: 14 }), t('colArtist')),
|
|
3151
|
-
h('span', { className: 'dshm-col-count' }, (sections.artist || []).length + ' ' + t('tracksUnit'))
|
|
3471
|
+
h('span', { className: 'dshm-col-count' }, (sections.artist || []).length + ' ' + t('tracksUnit')),
|
|
3472
|
+
h('div', { className: 'dshm-col-actions' }, colRefresh('artist'))),
|
|
3473
|
+
colRefreshBanner('artist'),
|
|
3152
3474
|
h('div', { className: 'dshm-col-list' },
|
|
3153
3475
|
(sections.artist || []).length === 0
|
|
3154
3476
|
? h('div', { className: 'dshm-lyrics-hint' }, t('recoSectionEmpty'))
|
|
@@ -3158,7 +3480,7 @@ window.__ModuleLoader__.load({
|
|
|
3158
3480
|
type: 'button', className: 'dshm-chipbtn dshm-col-play',
|
|
3159
3481
|
disabled: !(sections.new || []).length,
|
|
3160
3482
|
onClick: () => playColumn(sections.new || []),
|
|
3161
|
-
}, h(IconPlay, { size: 12 }), t('playColumn')))));
|
|
3483
|
+
}, h(IconPlay, { size: 12 }), t('playColumn')), 'new')));
|
|
3162
3484
|
}
|
|
3163
3485
|
|
|
3164
3486
|
/* Shared artist profile block (intro / news / trivia / similar), reused by
|
|
@@ -3215,22 +3537,27 @@ window.__ModuleLoader__.load({
|
|
|
3215
3537
|
/* ================================================================
|
|
3216
3538
|
* 11a2. Artist page (V3): profile + songs, play/preview + like
|
|
3217
3539
|
* ================================================================ */
|
|
3218
|
-
function ArtistPageView({ t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, useUi, useLikes, useLibrary, usePlayer, useArtistImages }) {
|
|
3540
|
+
function ArtistPageView({ t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, artistPage, useUi, useLikes, useLibrary, usePlayer, useArtistImages, useArtistPage }) {
|
|
3219
3541
|
const name = useUi((s) => s.artistName);
|
|
3220
3542
|
const tracks = useLibrary((st) => st.tracks);
|
|
3221
3543
|
const currentId = usePlayer((st) => (st.track ? st.track.id : null));
|
|
3222
3544
|
const playing = usePlayer((st) => st.playing);
|
|
3223
|
-
|
|
3545
|
+
/* Loading lives in the shared session-cache service, not in this view:
|
|
3546
|
+
* navigating away does not abort it, reopening the same artist is instant,
|
|
3547
|
+
* and the panel toasts when a background load finishes. */
|
|
3548
|
+
const pageKey = name ? normalizeZh(name).trim() : '';
|
|
3549
|
+
const cachedPage = useArtistPage ? useArtistPage((snap) => snap.pages[pageKey] || null) : null;
|
|
3550
|
+
const pageBusy = useArtistPage ? useArtistPage((snap) => !!snap.loading[pageKey]) : false;
|
|
3551
|
+
const [pageError, setPageError] = useState('');
|
|
3224
3552
|
const [notice, setNotice] = useState('');
|
|
3225
3553
|
useEffect(() => {
|
|
3226
|
-
if (!name) return undefined;
|
|
3554
|
+
if (!name || cachedPage || !artistPage) return undefined;
|
|
3227
3555
|
let dead = false;
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
.then((data) => { if (!dead) setSt({ status: 'ready', data, error: null }); })
|
|
3231
|
-
.catch((err) => { if (!dead) setSt({ status: 'error', data: null, error: (err && err.message) || String(err) }); });
|
|
3556
|
+
setPageError('');
|
|
3557
|
+
artistPage.load(name).catch((err) => { if (!dead) setPageError((err && err.message) || String(err)); });
|
|
3232
3558
|
return () => { dead = true; };
|
|
3233
|
-
}, [name]);
|
|
3559
|
+
}, [name, cachedPage]);
|
|
3560
|
+
const st = { status: cachedPage ? 'ready' : (pageError ? 'error' : 'loading'), data: cachedPage, error: pageError };
|
|
3234
3561
|
function onPlaySong(item) {
|
|
3235
3562
|
playSong(item, player, tracks, preview, setNotice, t);
|
|
3236
3563
|
}
|
|
@@ -3612,7 +3939,7 @@ window.__ModuleLoader__.load({
|
|
|
3612
3939
|
/* ================================================================
|
|
3613
3940
|
* 12. Music panel (main slot): header + tabs + per-view body
|
|
3614
3941
|
* ================================================================ */
|
|
3615
|
-
function MusicPanel({ t, player, library, lyrics, reco, download, sync, history, likes, preview, openView, openArtistPage, setMiniHidden, ui, artistImages, onboarding, useUi, useLibrary, usePlayer, useLyrics, useReco, useDownload, useSync, useHistory, useLikes, usePreview, useArtistImages, useOnboarding }) {
|
|
3942
|
+
function MusicPanel({ t, player, library, lyrics, reco, download, sync, history, likes, preview, warm, openView, openArtistPage, setMiniHidden, ui, artistImages, artistPage, onboarding, useUi, useLibrary, usePlayer, useLyrics, useReco, useDownload, useSync, useHistory, useLikes, usePreview, useWarm, useArtistImages, useArtistPage, useOnboarding }) {
|
|
3616
3943
|
const view = useUi((s) => s.view);
|
|
3617
3944
|
const welcomePreview = useUi((s) => s.welcomePreview);
|
|
3618
3945
|
const onboardingSnap = useOnboarding((st) => st);
|
|
@@ -3623,6 +3950,24 @@ window.__ModuleLoader__.load({
|
|
|
3623
3950
|
const playing = usePlayer((s) => s.playing);
|
|
3624
3951
|
const busy = status === 'loading';
|
|
3625
3952
|
|
|
3953
|
+
/* Background loads (v9): when an artist page finishes while the user is
|
|
3954
|
+
* looking at another view, surface a toast that jumps straight there. */
|
|
3955
|
+
const pageReady = useArtistPage ? useArtistPage((snap) => snap.lastReady) : null;
|
|
3956
|
+
const toast = useUi((s) => s.toast);
|
|
3957
|
+
const [seenReadyAt, setSeenReadyAt] = useState(0);
|
|
3958
|
+
useEffect(() => {
|
|
3959
|
+
if (!pageReady || pageReady.at === seenReadyAt) return;
|
|
3960
|
+
setSeenReadyAt(pageReady.at);
|
|
3961
|
+
const cur = ui.getSnapshot();
|
|
3962
|
+
if (cur.view === 'artist' && normalizeZh(cur.artistName || '').trim() === pageReady.key) return;
|
|
3963
|
+
ui.set({ toast: { kind: 'artist', name: pageReady.name, at: pageReady.at } });
|
|
3964
|
+
}, [pageReady]);
|
|
3965
|
+
useEffect(() => {
|
|
3966
|
+
if (!toast) return undefined;
|
|
3967
|
+
const timer = setTimeout(() => ui.set({ toast: null }), 9000);
|
|
3968
|
+
return () => clearTimeout(timer);
|
|
3969
|
+
}, [toast]);
|
|
3970
|
+
|
|
3626
3971
|
if (view === 'welcome') {
|
|
3627
3972
|
return h(WelcomeView, {
|
|
3628
3973
|
t, onboarding, useOnboarding,
|
|
@@ -3649,9 +3994,9 @@ window.__ModuleLoader__.load({
|
|
|
3649
3994
|
const body = view === 'library'
|
|
3650
3995
|
? h(LibraryView, { t, player, library, sync, download, preview, likes, openArtistPage, artistImages, useLikes, useSync, useDownload, useLibrary, usePlayer, useArtistImages })
|
|
3651
3996
|
: view === 'reco'
|
|
3652
|
-
? h(RecoView, { t, reco, download, player, library, likes, preview, history, openArtistPage, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory })
|
|
3997
|
+
? h(RecoView, { t, reco, download, player, library, likes, preview, history, openArtistPage, warm, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory, useWarm })
|
|
3653
3998
|
: view === 'artist'
|
|
3654
|
-
? h(ArtistPageView, { t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, useUi, useLikes, useLibrary, usePlayer, useArtistImages })
|
|
3999
|
+
? h(ArtistPageView, { t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, artistPage, useUi, useLikes, useLibrary, usePlayer, useArtistImages, useArtistPage })
|
|
3655
4000
|
: view === 'history'
|
|
3656
4001
|
? h(HistoryView, { t, history, player, openArtistPage, artistImages, likes, useHistory, useLibrary, useArtistImages, useLikes })
|
|
3657
4002
|
: h(NowPlayingView, { t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages });
|
|
@@ -3685,7 +4030,20 @@ window.__ModuleLoader__.load({
|
|
|
3685
4030
|
className: 'dshm-tab', 'aria-selected': view === tab.id,
|
|
3686
4031
|
onClick: () => openView(tab.id),
|
|
3687
4032
|
}, tab.label, tab.dot ? h('span', { className: 'dshm-tab-dot', 'aria-hidden': true }) : null)))),
|
|
3688
|
-
h('div', { className: 'dshm-body', role: 'tabpanel' }, body))
|
|
4033
|
+
h('div', { className: 'dshm-body', role: 'tabpanel' }, body)),
|
|
4034
|
+
toast
|
|
4035
|
+
? h('div', { className: 'dshm-toast', role: 'status' },
|
|
4036
|
+
h('span', { className: 'dshm-toast-icon' }, h(IconCheck, { size: 14 })),
|
|
4037
|
+
h('button', {
|
|
4038
|
+
type: 'button', className: 'dshm-toast-main',
|
|
4039
|
+
onClick: () => { ui.set({ toast: null }); openArtistPage(toast.name); },
|
|
4040
|
+
},
|
|
4041
|
+
toast.kind === 'artist' ? t('artistReadyToast') + ' · ' + toast.name : t('pageReadyToast')),
|
|
4042
|
+
h('button', {
|
|
4043
|
+
type: 'button', className: 'dshm-toast-x', 'aria-label': t('closeNotice'),
|
|
4044
|
+
onClick: () => ui.set({ toast: null }),
|
|
4045
|
+
}, h(IconClose, { size: 12 })))
|
|
4046
|
+
: null);
|
|
3689
4047
|
}
|
|
3690
4048
|
|
|
3691
4049
|
/* ================================================================
|
|
@@ -3938,6 +4296,7 @@ window.__ModuleLoader__.load({
|
|
|
3938
4296
|
const library = createLibrary(api);
|
|
3939
4297
|
const lyricsService = createLyricsService(api);
|
|
3940
4298
|
const artistService = createArtistService(api);
|
|
4299
|
+
const artistPageService = createArtistPageService(api);
|
|
3941
4300
|
const artistImageService = createArtistImageService(api);
|
|
3942
4301
|
const onboardingService = createOnboardingService(api);
|
|
3943
4302
|
const recoService = createRecoService(api);
|
|
@@ -3946,6 +4305,7 @@ window.__ModuleLoader__.load({
|
|
|
3946
4305
|
const historyService = createHistoryService(api);
|
|
3947
4306
|
const player = createPlayer(t, api);
|
|
3948
4307
|
const previewService = createPreviewService(api);
|
|
4308
|
+
const warmService = createWarmService(previewService, player);
|
|
3949
4309
|
const likesService = createLikesService(api, () => downloadService.warm());
|
|
3950
4310
|
ctx.effect(() => () => {
|
|
3951
4311
|
downloadService.dispose();
|
|
@@ -4013,14 +4373,15 @@ window.__ModuleLoader__.load({
|
|
|
4013
4373
|
inject: () => ({
|
|
4014
4374
|
player, library, lyrics: lyricsService, artist: artistService, artistImages: artistImageService, onboarding: onboardingService,
|
|
4015
4375
|
reco: recoService, download: downloadService, sync: syncService, history: historyService,
|
|
4016
|
-
likes: likesService, preview: previewService,
|
|
4017
|
-
openView, openArtistPage, setMiniHidden, ui,
|
|
4376
|
+
likes: likesService, preview: previewService, warm: warmService,
|
|
4377
|
+
openView, openArtistPage, setMiniHidden, ui, artistPage: artistPageService,
|
|
4018
4378
|
hooks: {
|
|
4019
4379
|
player: player.source, library: library.source, ui,
|
|
4020
|
-
lyrics: lyricsService.source, artist: artistService.source, artistImages: artistImageService.source, onboarding: onboardingService.source,
|
|
4380
|
+
lyrics: lyricsService.source, artist: artistService.source, artistPage: artistPageService.source, artistImages: artistImageService.source, onboarding: onboardingService.source,
|
|
4021
4381
|
reco: recoService.source, download: downloadService.source,
|
|
4022
4382
|
sync: syncService.source, history: historyService.source,
|
|
4023
4383
|
likes: likesService.source, preview: previewService.source,
|
|
4384
|
+
warm: warmService.source,
|
|
4024
4385
|
},
|
|
4025
4386
|
}),
|
|
4026
4387
|
}, MusicPanel)), 'dsh-music: main panel');
|