@vicyangorg/dsh-music 0.3.0 → 0.5.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 +356 -37
- 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/history.js +65 -22
- package/host/likes.js +203 -59
- package/host/main.js +2 -2
- package/host/metadata/artist.js +25 -5
- package/host/reco/discover.js +155 -72
- package/host/reco/index.js +53 -10
- package/host/reco/pools.js +28 -0
- package/host/reco/verify.js +26 -1
- package/icon.png +0 -0
- package/package.json +3 -3
- package/icon.svg +0 -16
package/client/index.js
CHANGED
|
@@ -96,6 +96,30 @@ 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: '关闭提示',
|
|
106
|
+
libTabsLabel: '曲库视图',
|
|
107
|
+
libTabLibrary: '曲库',
|
|
108
|
+
libTabLikes: '我喜欢',
|
|
109
|
+
playLikes: '播放我喜欢',
|
|
110
|
+
likesEmptyTitle: '还没有喜欢的歌',
|
|
111
|
+
likesEmptyBody: '在曲库里点 ♥,歌曲会自动入库并出现在这里。',
|
|
112
|
+
dislikeBtn: '不喜欢',
|
|
113
|
+
undislikeBtn: '取消不喜欢',
|
|
114
|
+
undislikedBtn: '已标记不喜欢,点击取消',
|
|
115
|
+
statDislikes: '不喜欢',
|
|
116
|
+
dislikesTitle: '不喜欢的歌',
|
|
117
|
+
dislikesEmpty: '还没有标记不喜欢的歌',
|
|
118
|
+
genre_pop: '流行',
|
|
119
|
+
genre_rock: '摇滚',
|
|
120
|
+
genre_hiphop: '说唱',
|
|
121
|
+
genre_punk: '朋克',
|
|
122
|
+
genre_country: '乡村',
|
|
99
123
|
welcomePathLabel: '音乐目录(可选)',
|
|
100
124
|
welcomePathPlaceholder: '~/Music/我的音乐',
|
|
101
125
|
welcomePathHint: '留空则使用已经扫描到的曲库;填了会自动挂载并重新扫描。',
|
|
@@ -244,7 +268,7 @@ window.__ModuleLoader__.load({
|
|
|
244
268
|
modeCycleHint: '点击切换播放模式',
|
|
245
269
|
modeHintShuffle: '随机播放:每轮打乱不重复',
|
|
246
270
|
artistPageBack: '返回推荐',
|
|
247
|
-
artistSongs: '
|
|
271
|
+
artistSongs: '歌曲',
|
|
248
272
|
artistLoading: '正在打开歌手页…',
|
|
249
273
|
artistError: '歌手页加载失败',
|
|
250
274
|
artistNoSongs: '这位歌手暂时没有已核实的歌曲。',
|
|
@@ -338,6 +362,30 @@ window.__ModuleLoader__.load({
|
|
|
338
362
|
lang_pt: 'Portuguese',
|
|
339
363
|
lang_it: 'Italian',
|
|
340
364
|
welcomeTasteNote: 'Preferences only bias the discovery batch - nothing is locked, and you can change them any time.',
|
|
365
|
+
favsTitle: 'Liked',
|
|
366
|
+
favsViewAll: 'View all',
|
|
367
|
+
favsBack: 'Back to library',
|
|
368
|
+
favsEmpty: 'No liked songs yet — hit the heart on any song and it lands here.',
|
|
369
|
+
artistReadyToast: 'Artist page ready',
|
|
370
|
+
pageReadyToast: 'Page ready',
|
|
371
|
+
closeNotice: 'Dismiss',
|
|
372
|
+
libTabsLabel: 'Library views',
|
|
373
|
+
libTabLibrary: 'Library',
|
|
374
|
+
libTabLikes: 'Liked',
|
|
375
|
+
playLikes: 'Play liked',
|
|
376
|
+
likesEmptyTitle: 'No liked songs yet',
|
|
377
|
+
likesEmptyBody: 'Hit the heart on any song to add it to your library and to this list.',
|
|
378
|
+
dislikeBtn: 'Dislike',
|
|
379
|
+
undislikeBtn: 'Undo dislike',
|
|
380
|
+
undislikedBtn: 'Marked as disliked — click to undo',
|
|
381
|
+
statDislikes: 'Disliked',
|
|
382
|
+
dislikesTitle: 'Disliked songs',
|
|
383
|
+
dislikesEmpty: 'Nothing disliked yet',
|
|
384
|
+
genre_pop: 'Pop',
|
|
385
|
+
genre_rock: 'Rock',
|
|
386
|
+
genre_hiphop: 'Hip-hop',
|
|
387
|
+
genre_punk: 'Punk',
|
|
388
|
+
genre_country: 'Country',
|
|
341
389
|
welcomePathLabel: 'Music folder (optional)',
|
|
342
390
|
welcomePathPlaceholder: '~/Music/My Music',
|
|
343
391
|
welcomePathHint: 'Leave empty to use the library already scanned; a folder is mounted and rescanned.',
|
|
@@ -486,7 +534,7 @@ window.__ModuleLoader__.load({
|
|
|
486
534
|
modeCycleHint: 'Click to switch play mode',
|
|
487
535
|
modeHintShuffle: 'Shuffle: random each pass, no repeats',
|
|
488
536
|
artistPageBack: 'Back to recommendations',
|
|
489
|
-
artistSongs: '
|
|
537
|
+
artistSongs: 'Songs',
|
|
490
538
|
artistLoading: 'Opening artist page…',
|
|
491
539
|
artistError: 'Artist page failed to load',
|
|
492
540
|
artistNoSongs: 'No verified songs for this artist yet.',
|
|
@@ -715,6 +763,12 @@ window.__ModuleLoader__.load({
|
|
|
715
763
|
['path', { d: 'M12 20s-7.4-4.6-9.3-9C1.4 7.6 3.4 4.5 6.6 4.5c2 0 3.4 1.1 4.2 2.4l1.2 2 1.2-2c.8-1.3 2.2-2.4 4.2-2.4 3.2 0 5.2 3.1 3.9 6.5-1.9 4.4-9.3 9-9.3 9z' }],
|
|
716
764
|
], { 'data-heart': 1 });
|
|
717
765
|
|
|
766
|
+
/* Thumbs-down: an outline hand, drawn for the dislike (taste) button. */
|
|
767
|
+
const IconThumbDown = makeIcon([
|
|
768
|
+
['path', { d: 'M10.5 14.5V4.2c0-.7.6-1.2 1.3-1.2h4.4c.6 0 1.1.4 1.3 1l2.4 6.6c.2.5.1 1.1-.2 1.5-.3.4-.8.7-1.3.7h-4.1l.8 3.9c.2.9-.3 1.8-1.1 2.2-.5.3-1.1.3-1.6 0-.3-.2-.6-.5-.8-.9l-1.1-2.9z' }],
|
|
769
|
+
['path', { d: 'M6.8 14.5H4.9c-.7 0-1.2-.5-1.2-1.2V4.2c0-.7.5-1.2 1.2-1.2h1.9c.7 0 1.2.5 1.2 1.2v9.1c0 .7-.5 1.2-1.2 1.2z' }],
|
|
770
|
+
], { 'data-thumbdown': 1 });
|
|
771
|
+
|
|
718
772
|
/* ================================================================
|
|
719
773
|
* 4. Styles — every color is a host theme token (--dsw-alias-*)
|
|
720
774
|
* ================================================================ */
|
|
@@ -786,6 +840,31 @@ window.__ModuleLoader__.load({
|
|
|
786
840
|
.dshm-tab-dot{width:6px;height:6px;border-radius:50%;background:var(--dsw-alias-brand-primary);animation:dshm-pulse 1.6s ease-in-out infinite;}
|
|
787
841
|
.dshm-body{flex:1;min-height:0;display:flex;flex-direction:column;container-type:inline-size;}
|
|
788
842
|
.dshm-toolbar{flex:none;display:flex;align-items:center;gap:8px;padding:10px 20px;border-bottom:1px solid var(--dsw-alias-border-l1);flex-wrap:wrap;width:100%;max-width:1120px;margin:0 auto;}
|
|
843
|
+
.dshm-libtabs{display:flex;align-items:center;gap:4px;padding:8px 20px 0;width:100%;max-width:1120px;margin:0 auto;flex:none;}
|
|
844
|
+
.dshm-libtabs-btn{appearance:none;border:1px solid transparent;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12.5px;padding:5px 12px;border-radius:8px;cursor:pointer;display:inline-flex;align-items:center;gap:6px;transition:background .12s,color .12s,border-color .12s;white-space:nowrap;}
|
|
845
|
+
.dshm-libtabs-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary);}
|
|
846
|
+
.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;}
|
|
847
|
+
.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;}
|
|
848
|
+
.dshm-favs{padding:10px 20px 2px;width:100%;max-width:1120px;margin:0 auto;flex:none;box-sizing:border-box;}
|
|
849
|
+
.dshm-favs-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;}
|
|
850
|
+
.dshm-favs-title{font-size:12.5px;font-weight:600;color:var(--dsw-alias-label-primary);}
|
|
851
|
+
.dshm-favs-all{margin-left:auto;}
|
|
852
|
+
.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;}
|
|
853
|
+
.dshm-favs-rail{display:flex;gap:10px;overflow-x:auto;padding:2px 0 10px;scrollbar-width:thin;}
|
|
854
|
+
.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;}
|
|
855
|
+
.dshm-favcard-cover{position:relative;display:block;width:104px;height:104px;border-radius:12px;overflow:hidden;background:var(--dsw-alias-bg-layer-2);}
|
|
856
|
+
.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);}
|
|
857
|
+
.dshm-favcard-title{font-size:12px;font-weight:600;color:var(--dsw-alias-label-primary);}
|
|
858
|
+
.dshm-favcard-sub{font-size:11px;color:var(--dsw-alias-label-tertiary);}
|
|
859
|
+
.dshm-favcard:hover .dshm-favcard-cover{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;}
|
|
860
|
+
.dshm-favcard-off{opacity:.5;cursor:not-allowed;}
|
|
861
|
+
.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);}
|
|
862
|
+
.dshm-favcard-more-label{font-size:11.5px;}
|
|
863
|
+
.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;}
|
|
864
|
+
.dshm-toast-icon{display:inline-flex;color:var(--dsw-alias-state-success-primary);}
|
|
865
|
+
.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;}
|
|
866
|
+
.dshm-toast-main:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
867
|
+
.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;}
|
|
789
868
|
.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;}
|
|
790
869
|
.dshm-search:focus-within{border-color:var(--dsw-alias-brand-primary);color:var(--dsw-alias-label-secondary);}
|
|
791
870
|
.dshm-search input{flex:1;min-width:0;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;outline:none;}
|
|
@@ -805,7 +884,7 @@ window.__ModuleLoader__.load({
|
|
|
805
884
|
.dshm-list::-webkit-scrollbar-thumb:hover{background:var(--dsw-alias-scrollbar-hover-l2);}
|
|
806
885
|
.dshm-group-head{position:sticky;top:0;z-index:1;display:flex;align-items:center;gap:6px;padding:10px 8px 6px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600;}
|
|
807
886
|
.dshm-group-head .dshm-group-count{color:var(--dsw-alias-label-tertiary);font-weight:400;}
|
|
808
|
-
.dshm-row{display:grid;grid-template-columns:40px minmax(0,1fr) auto auto auto 26px;align-items:center;gap:12px;padding:7px 8px;border-radius:10px;cursor:pointer;transition:background .12s;outline:none;}
|
|
887
|
+
.dshm-row{display:grid;grid-template-columns:40px minmax(0,1fr) auto auto auto auto 26px;align-items:center;gap:12px;padding:7px 8px;border-radius:10px;cursor:pointer;transition:background .12s;outline:none;}
|
|
809
888
|
.dshm-row-actions{display:flex;gap:2px;opacity:0;}
|
|
810
889
|
.dshm-row:hover .dshm-row-actions,.dshm-row:focus-within .dshm-row-actions{opacity:1;}
|
|
811
890
|
.dshm-row:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
@@ -972,7 +1051,7 @@ window.__ModuleLoader__.load({
|
|
|
972
1051
|
.dshm-col-count{font-size:11px;color:var(--dsw-alias-label-tertiary);}
|
|
973
1052
|
.dshm-col-play{margin-left:auto;}
|
|
974
1053
|
.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;}
|
|
975
|
-
.dshm-srow{display:grid;grid-template-columns:38px minmax(0,1fr) auto auto;align-items:center;gap:10px;padding:6px;border-radius:10px;transition:background .12s;}
|
|
1054
|
+
.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;}
|
|
976
1055
|
.dshm-srow:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
977
1056
|
.dshm-srow-main{min-width:0;display:flex;flex-direction:column;gap:1px;border:0;background:transparent;font:inherit;color:inherit;text-align:left;padding:0;cursor:pointer;}
|
|
978
1057
|
.dshm-srow-title{font-size:12.5px;font-weight:560;color:var(--dsw-alias-label-primary);}
|
|
@@ -985,6 +1064,13 @@ window.__ModuleLoader__.load({
|
|
|
985
1064
|
.dshm-like-btn:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);}
|
|
986
1065
|
.dshm-like-btn:active{transform:scale(1.18);}
|
|
987
1066
|
.dshm-like-btn-on{color:var(--dsw-alias-state-error-primary);}
|
|
1067
|
+
.dshm-row-off{opacity:.55;cursor:not-allowed;}
|
|
1068
|
+
.dshm-row-off:hover{background:transparent;}
|
|
1069
|
+
.dshm-dislike-btn-on{color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-interactive-bg-hover);}
|
|
1070
|
+
.dshm-dislikes{margin-top:14px;}
|
|
1071
|
+
.dshm-dislike-row{display:flex;align-items:center;gap:10px;padding:6px 8px;border-radius:9px;font-size:12.5px;color:var(--dsw-alias-label-secondary);}
|
|
1072
|
+
.dshm-dislike-row:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
1073
|
+
.dshm-dislike-undo{flex:none;}
|
|
988
1074
|
.dshm-playround{appearance:none;border:0;width:30px;height:30px;border-radius:50%;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;padding:0;flex:none;transition:background .13s,transform .1s;}
|
|
989
1075
|
.dshm-playround:hover{background:var(--dsw-alias-button-primary-hover);transform:scale(1.06);}
|
|
990
1076
|
.dshm-playround:disabled{opacity:.45;cursor:default;transform:none;}
|
|
@@ -1176,6 +1262,13 @@ window.__ModuleLoader__.load({
|
|
|
1176
1262
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body),
|
|
1177
1263
|
}),
|
|
1178
1264
|
likes: () => request('/dsh-music/api/library/likes'),
|
|
1265
|
+
dislike: (body) => request('/dsh-music/api/library/dislike', {
|
|
1266
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body),
|
|
1267
|
+
}),
|
|
1268
|
+
dislikes: () => request('/dsh-music/api/library/dislikes'),
|
|
1269
|
+
taste: (trackId, artist, title) => request('/dsh-music/api/library/taste' + (trackId
|
|
1270
|
+
? '?trackId=' + encodeURIComponent(trackId)
|
|
1271
|
+
: '?artist=' + encodeURIComponent(artist || '') + '&title=' + encodeURIComponent(title || ''))),
|
|
1179
1272
|
preview: (body) => request('/dsh-music/api/library/preview', {
|
|
1180
1273
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body),
|
|
1181
1274
|
}),
|
|
@@ -1286,6 +1379,44 @@ window.__ModuleLoader__.load({
|
|
|
1286
1379
|
return { source: store, load };
|
|
1287
1380
|
}
|
|
1288
1381
|
|
|
1382
|
+
/* Artist page loader (v9): loads run to completion even when the user
|
|
1383
|
+
* navigates away, results are cached for the whole session (reopening is
|
|
1384
|
+
* instant) and every finished load is announced through lastReady so the
|
|
1385
|
+
* panel can toast "artist page ready" with a one-click shortcut. */
|
|
1386
|
+
function createArtistPageService(api) {
|
|
1387
|
+
const store = createStore({ pages: {}, loading: {}, lastReady: null, error: null });
|
|
1388
|
+
const pending = new Map();
|
|
1389
|
+
const keyOf = (name) => normalizeZh(name || '').trim();
|
|
1390
|
+
function load(name) {
|
|
1391
|
+
if (!name) return Promise.resolve(null);
|
|
1392
|
+
const key = keyOf(name);
|
|
1393
|
+
const snap = store.getSnapshot();
|
|
1394
|
+
if (snap.pages[key]) return Promise.resolve(snap.pages[key]);
|
|
1395
|
+
if (pending.has(key)) return pending.get(key);
|
|
1396
|
+
store.set({ loading: { ...store.getSnapshot().loading, [key]: true } });
|
|
1397
|
+
const p = api.recoArtist(name)
|
|
1398
|
+
.then((data) => {
|
|
1399
|
+
const cur = store.getSnapshot();
|
|
1400
|
+
store.set({
|
|
1401
|
+
pages: { ...cur.pages, [key]: data },
|
|
1402
|
+
loading: { ...cur.loading, [key]: false },
|
|
1403
|
+
error: null,
|
|
1404
|
+
lastReady: { name, key, at: Date.now() },
|
|
1405
|
+
});
|
|
1406
|
+
return data;
|
|
1407
|
+
})
|
|
1408
|
+
.catch((err) => {
|
|
1409
|
+
const cur = store.getSnapshot();
|
|
1410
|
+
store.set({ loading: { ...cur.loading, [key]: false }, error: (err && err.message) || String(err) });
|
|
1411
|
+
throw err;
|
|
1412
|
+
})
|
|
1413
|
+
.finally(() => { pending.delete(key); });
|
|
1414
|
+
pending.set(key, p);
|
|
1415
|
+
return p;
|
|
1416
|
+
}
|
|
1417
|
+
return { source: store, load, keyOf };
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1289
1420
|
/* Artist portraits (batch 2, v6): one lightweight image lookup per name.
|
|
1290
1421
|
* Requests are coalesced in a 150ms window and limited to 3 in flight, so a
|
|
1291
1422
|
* page that renders 20 artist rows does not fire 20 parallel lookups.
|
|
@@ -1575,16 +1706,24 @@ window.__ModuleLoader__.load({
|
|
|
1575
1706
|
}
|
|
1576
1707
|
|
|
1577
1708
|
function createLikesService(api, onAutoDownload) {
|
|
1578
|
-
|
|
1709
|
+
/* keys/dislikes are mutually exclusive on the host: a dislike clears the
|
|
1710
|
+
* like and vice versa, so both maps are refreshed after every action. */
|
|
1711
|
+
const store = createStore({ keys: {}, dislikes: {}, items: [], dislikeItems: [], loaded: false, error: null });
|
|
1579
1712
|
async function load() {
|
|
1580
1713
|
try {
|
|
1581
1714
|
const data = await api.likes();
|
|
1582
1715
|
const keys = {};
|
|
1583
1716
|
for (const it of (data && data.items) || []) if (it.liked !== false) keys[likeKey(it)] = it;
|
|
1584
|
-
store.set({ keys, loaded: true, error: null });
|
|
1717
|
+
store.set({ keys, items: (data && data.items) || [], loaded: true, error: null });
|
|
1585
1718
|
} catch (err) {
|
|
1586
1719
|
store.set({ loaded: true, error: (err && err.message) || String(err) });
|
|
1587
1720
|
}
|
|
1721
|
+
try {
|
|
1722
|
+
const d = await api.dislikes();
|
|
1723
|
+
const dislikes = {};
|
|
1724
|
+
for (const it of (d && d.items) || []) dislikes[likeKey(it)] = it;
|
|
1725
|
+
store.set({ dislikes, dislikeItems: (d && d.items) || [] });
|
|
1726
|
+
} catch { /* dislikes are optional: an older host just has no such route */ }
|
|
1588
1727
|
}
|
|
1589
1728
|
async function toggle(item, liked) {
|
|
1590
1729
|
const body = item.id
|
|
@@ -1594,17 +1733,42 @@ window.__ModuleLoader__.load({
|
|
|
1594
1733
|
try { res = await api.like(body); } catch (err) { return { error: (err && err.message) || String(err) }; }
|
|
1595
1734
|
const key = likeKey(res && res.key ? { artist: res.key.split('::')[0], title: res.key.split('::')[1] } : item);
|
|
1596
1735
|
const keys = { ...store.getSnapshot().keys };
|
|
1736
|
+
const dislikes = { ...store.getSnapshot().dislikes };
|
|
1597
1737
|
if (liked) keys[key] = { artist: item.artist, title: item.title, trackId: res && res.trackId, inLibrary: res && res.inLibrary };
|
|
1598
1738
|
else delete keys[key];
|
|
1599
|
-
|
|
1739
|
+
/* Host keeps taste binary: liking clears a dislike. */
|
|
1740
|
+
if (liked && res && res.disliked === false) delete dislikes[key];
|
|
1741
|
+
store.set({ keys, dislikes });
|
|
1600
1742
|
if (res && res.downloading && onAutoDownload) onAutoDownload();
|
|
1743
|
+
/* Refresh the cached lists so the library card rail reflects the new
|
|
1744
|
+
* heart immediately (host is the source of truth, call is local). */
|
|
1745
|
+
load();
|
|
1746
|
+
return res || {};
|
|
1747
|
+
}
|
|
1748
|
+
async function setDislike(item, disliked) {
|
|
1749
|
+
const body = item.id
|
|
1750
|
+
? { trackId: item.id, disliked }
|
|
1751
|
+
: { artist: item.artist, title: item.title, album: item.album, durationMs: item.durationMs, disliked };
|
|
1752
|
+
let res = null;
|
|
1753
|
+
try { res = await api.dislike(body); } catch (err) { return { error: (err && err.message) || String(err) }; }
|
|
1754
|
+
const key = res && res.key ? res.key : likeKey(item);
|
|
1755
|
+
const keys = { ...store.getSnapshot().keys };
|
|
1756
|
+
const dislikes = { ...store.getSnapshot().dislikes };
|
|
1757
|
+
if (res && res.clearedLike) delete keys[key];
|
|
1758
|
+
if (res && res.disliked) dislikes[key] = { artist: item.artist, title: item.title, trackId: res.trackId, inLibrary: res.inLibrary, dislikedAt: Date.now() };
|
|
1759
|
+
else delete dislikes[key];
|
|
1760
|
+
store.set({ keys, dislikes });
|
|
1761
|
+
load();
|
|
1601
1762
|
return res || {};
|
|
1602
1763
|
}
|
|
1603
1764
|
function isLiked(item) {
|
|
1604
1765
|
return !!store.getSnapshot().keys[likeKey(item)];
|
|
1605
1766
|
}
|
|
1767
|
+
function isDisliked(item) {
|
|
1768
|
+
return !!store.getSnapshot().dislikes[likeKey(item)];
|
|
1769
|
+
}
|
|
1606
1770
|
load();
|
|
1607
|
-
return { source: store, toggle, isLiked, load };
|
|
1771
|
+
return { source: store, toggle, setDislike, isLiked, isDisliked, load };
|
|
1608
1772
|
}
|
|
1609
1773
|
|
|
1610
1774
|
function createPreviewService(api) {
|
|
@@ -2079,7 +2243,8 @@ window.__ModuleLoader__.load({
|
|
|
2079
2243
|
const [busy, setBusy] = useState(false);
|
|
2080
2244
|
const [failed, setFailed] = useState(false);
|
|
2081
2245
|
|
|
2082
|
-
const genreOptions = ['jazz', 'classical', '
|
|
2246
|
+
const genreOptions = ['pop', 'rock', 'electronic', 'hip hop', 'jazz', 'classical', 'folk', 'blues', 'soul', 'funk', 'reggae', 'metal', 'punk', 'country', 'ambient'];
|
|
2247
|
+
const genreLabel = (g) => 'genre_' + g.replace(/[^a-z]/g, '');
|
|
2083
2248
|
const langOptions = [
|
|
2084
2249
|
{ value: '中文', key: 'lang_zh' }, { value: '英语', key: 'lang_en' }, { value: '粤语', key: 'lang_yue' },
|
|
2085
2250
|
{ value: '日语', key: 'lang_ja' }, { value: '韩语', key: 'lang_ko' }, { value: '法语', key: 'lang_fr' },
|
|
@@ -2153,7 +2318,7 @@ window.__ModuleLoader__.load({
|
|
|
2153
2318
|
h('p', { className: 'dshm-wstep-sub' }, t('welcomeTasteSub')),
|
|
2154
2319
|
h('div', { className: 'dshm-wgroup' },
|
|
2155
2320
|
h('div', { className: 'dshm-wlabel' }, t('welcomeGenres')),
|
|
2156
|
-
h('div', { className: 'dshm-wchips' }, genreOptions.map((g) => tasteChip(g, t(
|
|
2321
|
+
h('div', { className: 'dshm-wchips' }, genreOptions.map((g) => tasteChip(g, t(genreLabel(g)), genres, setGenres)))),
|
|
2157
2322
|
h('div', { className: 'dshm-wgroup' },
|
|
2158
2323
|
h('div', { className: 'dshm-wlabel' }, t('welcomeLanguages')),
|
|
2159
2324
|
h('div', { className: 'dshm-wchips' }, langOptions.map((o) => tasteChip(o.value, t(o.key), langs, setLangs)))),
|
|
@@ -2309,9 +2474,21 @@ window.__ModuleLoader__.load({
|
|
|
2309
2474
|
}, h(IconHeart, { size: 15, style: liked ? { fill: 'currentColor' } : undefined }));
|
|
2310
2475
|
}
|
|
2311
2476
|
|
|
2312
|
-
function
|
|
2477
|
+
function DislikeButton({ t, item, likes, useLikes }) {
|
|
2478
|
+
const disliked = useLikes((st) => !!((st.dislikes || {})[likeKey(item)]));
|
|
2479
|
+
return h('button', {
|
|
2480
|
+
type: 'button',
|
|
2481
|
+
className: cx('dshm-like-btn', 'dshm-dislike-btn', disliked && 'dshm-dislike-btn-on'),
|
|
2482
|
+
'aria-label': disliked ? t('undislikeBtn') : t('dislikeBtn'),
|
|
2483
|
+
'aria-pressed': !!disliked,
|
|
2484
|
+
title: disliked ? t('undislikedBtn') : t('dislikeBtn'),
|
|
2485
|
+
onClick: (e) => { e.stopPropagation(); likes.setDislike(item, !disliked); },
|
|
2486
|
+
}, h(IconThumbDown, { size: 15, style: disliked ? { fill: 'currentColor' } : undefined }));
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
function TrackRow({ track, index, isCurrent, playing, onPlay, onDelete, onReveal, onOpenArtist, likes, useLikes, t, muted }) {
|
|
2313
2490
|
return h('div', {
|
|
2314
|
-
className: cx('dshm-row', isCurrent && 'dshm-row-current'),
|
|
2491
|
+
className: cx('dshm-row', isCurrent && 'dshm-row-current', muted && 'dshm-row-off'),
|
|
2315
2492
|
role: 'button', tabIndex: 0,
|
|
2316
2493
|
'aria-label': t('playTrack') + ': ' + track.title,
|
|
2317
2494
|
onClick: () => onPlay(track, index),
|
|
@@ -2335,6 +2512,7 @@ window.__ModuleLoader__.load({
|
|
|
2335
2512
|
track.album ? ' · ' + track.album : '')),
|
|
2336
2513
|
h('span', { className: 'dshm-row-dur' }, formatTime(track.duration)),
|
|
2337
2514
|
likes ? h(LikeButton, { t, item: track, likes, useLikes }) : null,
|
|
2515
|
+
likes ? h(DislikeButton, { t, item: track, likes, useLikes }) : null,
|
|
2338
2516
|
onDelete ? h('span', { className: 'dshm-row-actions', onClick: (e) => e.stopPropagation() },
|
|
2339
2517
|
h(IconButton, { label: t('revealTrack'), onClick: (e) => { e.stopPropagation(); onReveal(track); } }, h(IconDisc, { size: 14 })),
|
|
2340
2518
|
h(IconButton, { label: t('deleteTrack'), onClick: (e) => { e.stopPropagation(); onDelete(track); } }, h(IconClose, { size: 14 }))) : null,
|
|
@@ -2353,6 +2531,7 @@ window.__ModuleLoader__.load({
|
|
|
2353
2531
|
const [query, setQuery] = useState('');
|
|
2354
2532
|
const [searchState, setSearchState] = useState({ status: 'idle', local: [], remote: [] });
|
|
2355
2533
|
const [groupBy, setGroupBy] = useState('none');
|
|
2534
|
+
const [libTab, setLibTab] = useState('library');
|
|
2356
2535
|
const [rowError, setRowError] = useState('');
|
|
2357
2536
|
const [playNotice, setPlayNotice] = useState('');
|
|
2358
2537
|
const searchRef = useRef(null);
|
|
@@ -2363,6 +2542,17 @@ window.__ModuleLoader__.load({
|
|
|
2363
2542
|
const syncHint = useSync ? useSync((st) => st.hint) : null;
|
|
2364
2543
|
const syncUsable = syncAvail !== false;
|
|
2365
2544
|
const syncState = useSync ? useSync((st) => st.phase) : 'idle';
|
|
2545
|
+
const likeItems = useLikes((st) => st.items || []);
|
|
2546
|
+
/* Liked rows reuse the library row layout; host resolves trackId/audioUrl
|
|
2547
|
+
* for everything inside the library, so those rows are directly playable. */
|
|
2548
|
+
const likedTracks = useMemo(() => likeItems.map((it) => ({
|
|
2549
|
+
id: it.trackId || ('liked::' + it.key),
|
|
2550
|
+
title: it.title, artist: it.artist, album: it.album,
|
|
2551
|
+
duration: it.durationMs ? Math.round(it.durationMs / 1000) : (it.duration || 0),
|
|
2552
|
+
audioUrl: it.audioUrl || null, coverUrl: it.coverUrl || null,
|
|
2553
|
+
muted: !it.audioUrl,
|
|
2554
|
+
})), [likeItems]);
|
|
2555
|
+
const likedPlayable = useMemo(() => likedTracks.filter((tr) => !!tr.audioUrl), [likedTracks]);
|
|
2366
2556
|
|
|
2367
2557
|
/* Backend search (local filter + MusicBrainz completion), debounced.
|
|
2368
2558
|
* Empty query keeps the pure client-side browse below. */
|
|
@@ -2399,6 +2589,14 @@ window.__ModuleLoader__.load({
|
|
|
2399
2589
|
}, [tracks, query]);
|
|
2400
2590
|
/* While the backend search is ready, its local list wins (it shares the
|
|
2401
2591
|
* same normalization); otherwise fall back to instant client filtering. */
|
|
2592
|
+
const likedFiltered = useMemo(() => {
|
|
2593
|
+
const q = normalizeZh(query.trim());
|
|
2594
|
+
if (!q) return likedTracks;
|
|
2595
|
+
return likedTracks.filter((tr) =>
|
|
2596
|
+
normalizeZh(tr.title).includes(q) ||
|
|
2597
|
+
normalizeZh(tr.artist).includes(q) ||
|
|
2598
|
+
normalizeZh(tr.album).includes(q));
|
|
2599
|
+
}, [likedTracks, query]);
|
|
2402
2600
|
const searching = !!query.trim();
|
|
2403
2601
|
const shownList = searching && searchState.status === 'ready' ? searchState.local : filtered;
|
|
2404
2602
|
|
|
@@ -2437,6 +2635,13 @@ window.__ModuleLoader__.load({
|
|
|
2437
2635
|
try { setRowError(''); await library.reveal(track.id); }
|
|
2438
2636
|
catch (err) { setRowError((err && err.message) || t('deleteFailed')); }
|
|
2439
2637
|
}
|
|
2638
|
+
function playLiked(track) {
|
|
2639
|
+
if (!track.audioUrl) { setPlayNotice(t('topUnplayable')); return; }
|
|
2640
|
+
setPlayNotice('');
|
|
2641
|
+
const idx = likedPlayable.indexOf(track);
|
|
2642
|
+
player.playTracks(likedPlayable, idx >= 0 ? idx : 0);
|
|
2643
|
+
}
|
|
2644
|
+
|
|
2440
2645
|
const renderRow = (tr, i) => h(TrackRow, {
|
|
2441
2646
|
key: tr.id || i, track: tr, index: i,
|
|
2442
2647
|
isCurrent: currentId === tr.id, playing,
|
|
@@ -2481,7 +2686,27 @@ window.__ModuleLoader__.load({
|
|
|
2481
2686
|
|
|
2482
2687
|
let content;
|
|
2483
2688
|
const remoteList = searching && searchState.status === 'ready' ? searchState.remote : [];
|
|
2484
|
-
if (
|
|
2689
|
+
if (libTab === 'likes') {
|
|
2690
|
+
content = likeItems.length === 0
|
|
2691
|
+
? h(EmptyState, {
|
|
2692
|
+
icon: h(IconHeart, { size: 28 }),
|
|
2693
|
+
title: t('likesEmptyTitle'), body: t('likesEmptyBody'),
|
|
2694
|
+
}, h('button', {
|
|
2695
|
+
type: 'button', className: 'dshm-chipbtn dshm-chipbtn-primary',
|
|
2696
|
+
onClick: () => setLibTab('library'),
|
|
2697
|
+
}, h(IconNote, { size: 14 }), t('goLibrary')))
|
|
2698
|
+
: likedFiltered.length === 0
|
|
2699
|
+
? h(EmptyState, {
|
|
2700
|
+
icon: h(IconSearch, { size: 28 }),
|
|
2701
|
+
title: '“' + query.trim() + '”', body: t('searchNoLocal'),
|
|
2702
|
+
})
|
|
2703
|
+
: h('div', { className: 'dshm-list' },
|
|
2704
|
+
likedFiltered.map((tr, i) => h(TrackRow, {
|
|
2705
|
+
key: tr.id || ('liked' + i), track: tr, index: i,
|
|
2706
|
+
isCurrent: currentId === tr.id, playing, muted: tr.muted,
|
|
2707
|
+
onPlay: playLiked, onOpenArtist: openArtistPage, likes, useLikes, t,
|
|
2708
|
+
})));
|
|
2709
|
+
} else if (status === 'loading' && tracks.length === 0) {
|
|
2485
2710
|
content = h('div', { className: 'dshm-list' }, h(SkeletonRows));
|
|
2486
2711
|
} else if (status === 'error' && tracks.length === 0) {
|
|
2487
2712
|
content = h(EmptyState, {
|
|
@@ -2552,6 +2777,46 @@ window.__ModuleLoader__.load({
|
|
|
2552
2777
|
return h(React.Fragment, null,
|
|
2553
2778
|
sync ? h(SyncPanel, { t, sync, useSync }) : null,
|
|
2554
2779
|
rowError ? h('div', { className: 'dshm-errorline', role: 'alert', style: { margin: '8px 24px 0' } }, rowError) : null,
|
|
2780
|
+
libTab === 'likes'
|
|
2781
|
+
? h('div', { className: 'dshm-libtabs' },
|
|
2782
|
+
h('button', {
|
|
2783
|
+
type: 'button', className: 'dshm-chipbtn',
|
|
2784
|
+
onClick: () => setLibTab('library'),
|
|
2785
|
+
}, '← ' + t('favsBack')),
|
|
2786
|
+
h('span', { className: 'dshm-favs-title', style: { marginLeft: '4px' } }, t('libTabLikes')),
|
|
2787
|
+
h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit')))
|
|
2788
|
+
: h('div', { className: 'dshm-favs' },
|
|
2789
|
+
h('div', { className: 'dshm-favs-head' },
|
|
2790
|
+
h(IconHeart, { size: 14, style: { color: 'var(--dsw-alias-state-error-primary)' } }),
|
|
2791
|
+
h('span', { className: 'dshm-favs-title' }, t('favsTitle')),
|
|
2792
|
+
likeItems.length ? h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit')) : null,
|
|
2793
|
+
likeItems.length
|
|
2794
|
+
? h('button', {
|
|
2795
|
+
type: 'button', className: 'dshm-chipbtn dshm-favs-all',
|
|
2796
|
+
onClick: () => setLibTab('likes'),
|
|
2797
|
+
}, t('favsViewAll'), ' ›')
|
|
2798
|
+
: null),
|
|
2799
|
+
likeItems.length === 0
|
|
2800
|
+
? h('div', { className: 'dshm-favs-empty' }, h(IconHeart, { size: 16 }), t('favsEmpty'))
|
|
2801
|
+
: h('div', { className: 'dshm-favs-rail' },
|
|
2802
|
+
likedTracks.slice(0, 12).map((tr, i) => h('button', {
|
|
2803
|
+
key: tr.id || ('fav' + i), type: 'button',
|
|
2804
|
+
className: cx('dshm-favcard', tr.muted && 'dshm-favcard-off'),
|
|
2805
|
+
title: tr.muted ? t('topUnplayable') : (tr.title || '') + (tr.artist ? ' · ' + tr.artist : ''),
|
|
2806
|
+
onClick: () => playLiked(tr),
|
|
2807
|
+
},
|
|
2808
|
+
h('span', { className: 'dshm-favcard-cover' },
|
|
2809
|
+
h(Thumb, { src: tr.coverUrl, size: 96 }),
|
|
2810
|
+
h('span', { className: 'dshm-favcard-heart' }, h(IconHeart, { size: 11, style: { fill: 'currentColor' } }))),
|
|
2811
|
+
h('span', { className: 'dshm-favcard-title dshm-ellipsis' }, tr.title || t('untitled')),
|
|
2812
|
+
h('span', { className: 'dshm-favcard-sub dshm-ellipsis' }, tr.artist || t('unknownArtist')))),
|
|
2813
|
+
h('button', {
|
|
2814
|
+
type: 'button', className: 'dshm-favcard dshm-favcard-more',
|
|
2815
|
+
onClick: () => setLibTab('likes'),
|
|
2816
|
+
},
|
|
2817
|
+
h(IconQueue, { size: 18 }),
|
|
2818
|
+
h('span', { className: 'dshm-favcard-more-label' }, t('favsViewAll')),
|
|
2819
|
+
h('span', { className: 'dshm-count' }, likeItems.length)))),
|
|
2555
2820
|
h('div', { className: 'dshm-toolbar' },
|
|
2556
2821
|
h('label', { className: 'dshm-search' },
|
|
2557
2822
|
h(IconSearch, { size: 15 }),
|
|
@@ -2564,14 +2829,15 @@ window.__ModuleLoader__.load({
|
|
|
2564
2829
|
className: 'dshm-select', value: groupBy, 'aria-label': t('groupLabel'),
|
|
2565
2830
|
onChange: (e) => setGroupBy(e.target.value),
|
|
2566
2831
|
},
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2832
|
+
libTab === 'library' ? h(React.Fragment, null,
|
|
2833
|
+
h('option', { value: 'none' }, t('groupNone')),
|
|
2834
|
+
h('option', { value: 'artist' }, t('groupArtist')),
|
|
2835
|
+
h('option', { value: 'album' }, t('groupAlbum'))) : null),
|
|
2570
2836
|
h('button', {
|
|
2571
2837
|
type: 'button', className: 'dshm-chipbtn dshm-chipbtn-primary',
|
|
2572
|
-
disabled: busy || shownList.length === 0,
|
|
2573
|
-
onClick: () => player.playAll(shownList),
|
|
2574
|
-
}, h(IconPlay, { size: 13 }), t('playAll')),
|
|
2838
|
+
disabled: busy || (libTab === 'likes' ? likedPlayable.length === 0 : shownList.length === 0),
|
|
2839
|
+
onClick: () => player.playAll(libTab === 'likes' ? likedPlayable : shownList),
|
|
2840
|
+
}, h(IconPlay, { size: 13 }), libTab === 'likes' ? t('playLikes') : t('playAll')),
|
|
2575
2841
|
h('button', {
|
|
2576
2842
|
type: 'button', className: cx('dshm-chipbtn', 'dshm-mode-cycle'),
|
|
2577
2843
|
'aria-label': mode.label, title: mode.hint + ' · ' + t('modeCycleHint'),
|
|
@@ -2585,7 +2851,8 @@ window.__ModuleLoader__.load({
|
|
|
2585
2851
|
}, h(IconRefresh, { size: 13, className: syncState === 'running' ? 'dshm-spin' : undefined }),
|
|
2586
2852
|
syncState === 'running' ? t('syncing') : t('syncBtn')) : null,
|
|
2587
2853
|
h('span', { className: 'dshm-count', style: { marginLeft: 'auto' } },
|
|
2588
|
-
busy && tracks.length === 0 ? t('rescanning')
|
|
2854
|
+
busy && tracks.length === 0 ? t('rescanning')
|
|
2855
|
+
: (libTab === 'likes' ? likedFiltered.length : shownList.length) + ' ' + t('tracksUnit'))),
|
|
2589
2856
|
playNotice
|
|
2590
2857
|
? h('div', { className: 'dshm-mode-hint', style: { margin: '0 20px 6px', textAlign: 'right' }, role: 'status' }, playNotice)
|
|
2591
2858
|
: null,
|
|
@@ -2792,6 +3059,7 @@ window.__ModuleLoader__.load({
|
|
|
2792
3059
|
title: liked ? t('likedBtn') : t('likeBtn'),
|
|
2793
3060
|
onClick: () => likes.toggle(item, !liked),
|
|
2794
3061
|
}, h(IconHeart, { size: 15, style: liked ? { fill: 'currentColor' } : undefined })),
|
|
3062
|
+
likes ? h(DislikeButton, { t, item, likes, useLikes }) : null,
|
|
2795
3063
|
h('button', {
|
|
2796
3064
|
type: 'button', className: 'dshm-playround',
|
|
2797
3065
|
'aria-label': isCurrent && playing ? t('pause') : t('play'),
|
|
@@ -3050,22 +3318,27 @@ window.__ModuleLoader__.load({
|
|
|
3050
3318
|
/* ================================================================
|
|
3051
3319
|
* 11a2. Artist page (V3): profile + songs, play/preview + like
|
|
3052
3320
|
* ================================================================ */
|
|
3053
|
-
function ArtistPageView({ t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, useUi, useLikes, useLibrary, usePlayer, useArtistImages }) {
|
|
3321
|
+
function ArtistPageView({ t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, artistPage, useUi, useLikes, useLibrary, usePlayer, useArtistImages, useArtistPage }) {
|
|
3054
3322
|
const name = useUi((s) => s.artistName);
|
|
3055
3323
|
const tracks = useLibrary((st) => st.tracks);
|
|
3056
3324
|
const currentId = usePlayer((st) => (st.track ? st.track.id : null));
|
|
3057
3325
|
const playing = usePlayer((st) => st.playing);
|
|
3058
|
-
|
|
3326
|
+
/* Loading lives in the shared session-cache service, not in this view:
|
|
3327
|
+
* navigating away does not abort it, reopening the same artist is instant,
|
|
3328
|
+
* and the panel toasts when a background load finishes. */
|
|
3329
|
+
const pageKey = name ? normalizeZh(name).trim() : '';
|
|
3330
|
+
const cachedPage = useArtistPage ? useArtistPage((snap) => snap.pages[pageKey] || null) : null;
|
|
3331
|
+
const pageBusy = useArtistPage ? useArtistPage((snap) => !!snap.loading[pageKey]) : false;
|
|
3332
|
+
const [pageError, setPageError] = useState('');
|
|
3059
3333
|
const [notice, setNotice] = useState('');
|
|
3060
3334
|
useEffect(() => {
|
|
3061
|
-
if (!name) return undefined;
|
|
3335
|
+
if (!name || cachedPage || !artistPage) return undefined;
|
|
3062
3336
|
let dead = false;
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
.then((data) => { if (!dead) setSt({ status: 'ready', data, error: null }); })
|
|
3066
|
-
.catch((err) => { if (!dead) setSt({ status: 'error', data: null, error: (err && err.message) || String(err) }); });
|
|
3337
|
+
setPageError('');
|
|
3338
|
+
artistPage.load(name).catch((err) => { if (!dead) setPageError((err && err.message) || String(err)); });
|
|
3067
3339
|
return () => { dead = true; };
|
|
3068
|
-
}, [name]);
|
|
3340
|
+
}, [name, cachedPage]);
|
|
3341
|
+
const st = { status: cachedPage ? 'ready' : (pageError ? 'error' : 'loading'), data: cachedPage, error: pageError };
|
|
3069
3342
|
function onPlaySong(item) {
|
|
3070
3343
|
playSong(item, player, tracks, preview, setNotice, t);
|
|
3071
3344
|
}
|
|
@@ -3186,7 +3459,7 @@ window.__ModuleLoader__.load({
|
|
|
3186
3459
|
return d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
|
|
3187
3460
|
}
|
|
3188
3461
|
|
|
3189
|
-
function HistoryView({ t, history, player, openArtistPage, artistImages, useHistory, useLibrary, useArtistImages }) {
|
|
3462
|
+
function HistoryView({ t, history, player, openArtistPage, artistImages, likes, useHistory, useLibrary, useArtistImages, useLikes }) {
|
|
3190
3463
|
const s = useHistory((st) => st);
|
|
3191
3464
|
const [notice, setNotice] = useState('');
|
|
3192
3465
|
const tracks = useLibrary ? useLibrary((st) => st.tracks) : [];
|
|
@@ -3221,7 +3494,8 @@ window.__ModuleLoader__.load({
|
|
|
3221
3494
|
statCard(t('statSongs'), String(stats.uniqueSongs || 0)),
|
|
3222
3495
|
statCard(t('statArtists'), String(stats.uniqueArtists || 0)),
|
|
3223
3496
|
statCard(t('statSkipped'), String(stats.skippedCount || 0)),
|
|
3224
|
-
statCard(t('statCompletion'), Math.round((stats.avgCompletion || 0) * 100) + '%')
|
|
3497
|
+
statCard(t('statCompletion'), Math.round((stats.avgCompletion || 0) * 100) + '%'),
|
|
3498
|
+
statCard(t('statDislikes'), String((stats.dislikes && stats.dislikes.count) || 0))),
|
|
3225
3499
|
h('div', { className: 'dshm-trend' },
|
|
3226
3500
|
h('div', { className: 'dshm-asec-title' }, h(IconQueue, { size: 13 }), t('trendTitle')),
|
|
3227
3501
|
h('div', { className: 'dshm-bars' }, daily.map((d, i) => h('div', { className: 'dshm-bar-col', key: i },
|
|
@@ -3263,7 +3537,20 @@ window.__ModuleLoader__.load({
|
|
|
3263
3537
|
h('span', { className: 'dshm-top-rank' }, String(i + 1)),
|
|
3264
3538
|
h('span', { className: 'dshm-ellipsis', style: { flex: 1 } }, it.name || ''),
|
|
3265
3539
|
h('span', { className: 'dshm-count' }, (it.plays || 0) + ' ' + t('playsUnit'))))
|
|
3266
|
-
: h('div', { className: 'dshm-lyrics-hint' }, t('noSection'))))
|
|
3540
|
+
: h('div', { className: 'dshm-lyrics-hint' }, t('noSection')))),
|
|
3541
|
+
h('div', { className: 'dshm-dislikes' },
|
|
3542
|
+
h('div', { className: 'dshm-asec-title' }, h(IconThumbDown, { size: 13 }), t('dislikesTitle')),
|
|
3543
|
+
((stats.dislikes && stats.dislikes.songs) || []).length
|
|
3544
|
+
? stats.dislikes.songs.map((it, i) => h('div', { className: 'dshm-dislike-row', key: i },
|
|
3545
|
+
h('span', { className: 'dshm-ellipsis', style: { flex: 1 } },
|
|
3546
|
+
(it.title || '') + (it.artist ? ' · ' + it.artist : '')),
|
|
3547
|
+
h('span', { className: 'dshm-count' }, it.dislikedAt ? new Date(it.dislikedAt).toISOString().slice(0, 10) : ''),
|
|
3548
|
+
likes ? h('button', {
|
|
3549
|
+
type: 'button', className: 'dshm-chipbtn dshm-dislike-undo',
|
|
3550
|
+
title: t('undislikeBtn'),
|
|
3551
|
+
onClick: () => likes.setDislike({ artist: it.artist, title: it.title }, false),
|
|
3552
|
+
}, t('undislikeBtn')) : null))
|
|
3553
|
+
: h('div', { className: 'dshm-lyrics-hint' }, t('dislikesEmpty')))))
|
|
3267
3554
|
: null;
|
|
3268
3555
|
|
|
3269
3556
|
let list;
|
|
@@ -3433,7 +3720,7 @@ window.__ModuleLoader__.load({
|
|
|
3433
3720
|
/* ================================================================
|
|
3434
3721
|
* 12. Music panel (main slot): header + tabs + per-view body
|
|
3435
3722
|
* ================================================================ */
|
|
3436
|
-
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 }) {
|
|
3723
|
+
function MusicPanel({ t, player, library, lyrics, reco, download, sync, history, likes, preview, openView, openArtistPage, setMiniHidden, ui, artistImages, artistPage, onboarding, useUi, useLibrary, usePlayer, useLyrics, useReco, useDownload, useSync, useHistory, useLikes, usePreview, useArtistImages, useArtistPage, useOnboarding }) {
|
|
3437
3724
|
const view = useUi((s) => s.view);
|
|
3438
3725
|
const welcomePreview = useUi((s) => s.welcomePreview);
|
|
3439
3726
|
const onboardingSnap = useOnboarding((st) => st);
|
|
@@ -3444,6 +3731,24 @@ window.__ModuleLoader__.load({
|
|
|
3444
3731
|
const playing = usePlayer((s) => s.playing);
|
|
3445
3732
|
const busy = status === 'loading';
|
|
3446
3733
|
|
|
3734
|
+
/* Background loads (v9): when an artist page finishes while the user is
|
|
3735
|
+
* looking at another view, surface a toast that jumps straight there. */
|
|
3736
|
+
const pageReady = useArtistPage ? useArtistPage((snap) => snap.lastReady) : null;
|
|
3737
|
+
const toast = useUi((s) => s.toast);
|
|
3738
|
+
const [seenReadyAt, setSeenReadyAt] = useState(0);
|
|
3739
|
+
useEffect(() => {
|
|
3740
|
+
if (!pageReady || pageReady.at === seenReadyAt) return;
|
|
3741
|
+
setSeenReadyAt(pageReady.at);
|
|
3742
|
+
const cur = ui.getSnapshot();
|
|
3743
|
+
if (cur.view === 'artist' && normalizeZh(cur.artistName || '').trim() === pageReady.key) return;
|
|
3744
|
+
ui.set({ toast: { kind: 'artist', name: pageReady.name, at: pageReady.at } });
|
|
3745
|
+
}, [pageReady]);
|
|
3746
|
+
useEffect(() => {
|
|
3747
|
+
if (!toast) return undefined;
|
|
3748
|
+
const timer = setTimeout(() => ui.set({ toast: null }), 9000);
|
|
3749
|
+
return () => clearTimeout(timer);
|
|
3750
|
+
}, [toast]);
|
|
3751
|
+
|
|
3447
3752
|
if (view === 'welcome') {
|
|
3448
3753
|
return h(WelcomeView, {
|
|
3449
3754
|
t, onboarding, useOnboarding,
|
|
@@ -3472,9 +3777,9 @@ window.__ModuleLoader__.load({
|
|
|
3472
3777
|
: view === 'reco'
|
|
3473
3778
|
? h(RecoView, { t, reco, download, player, library, likes, preview, history, openArtistPage, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory })
|
|
3474
3779
|
: view === 'artist'
|
|
3475
|
-
? h(ArtistPageView, { t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, useUi, useLikes, useLibrary, usePlayer, useArtistImages })
|
|
3780
|
+
? h(ArtistPageView, { t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, artistPage, useUi, useLikes, useLibrary, usePlayer, useArtistImages, useArtistPage })
|
|
3476
3781
|
: view === 'history'
|
|
3477
|
-
? h(HistoryView, { t, history, player, openArtistPage, artistImages, useHistory, useLibrary, useArtistImages })
|
|
3782
|
+
? h(HistoryView, { t, history, player, openArtistPage, artistImages, likes, useHistory, useLibrary, useArtistImages, useLikes })
|
|
3478
3783
|
: h(NowPlayingView, { t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages });
|
|
3479
3784
|
|
|
3480
3785
|
return h(React.Fragment, null,
|
|
@@ -3506,7 +3811,20 @@ window.__ModuleLoader__.load({
|
|
|
3506
3811
|
className: 'dshm-tab', 'aria-selected': view === tab.id,
|
|
3507
3812
|
onClick: () => openView(tab.id),
|
|
3508
3813
|
}, tab.label, tab.dot ? h('span', { className: 'dshm-tab-dot', 'aria-hidden': true }) : null)))),
|
|
3509
|
-
h('div', { className: 'dshm-body', role: 'tabpanel' }, body))
|
|
3814
|
+
h('div', { className: 'dshm-body', role: 'tabpanel' }, body)),
|
|
3815
|
+
toast
|
|
3816
|
+
? h('div', { className: 'dshm-toast', role: 'status' },
|
|
3817
|
+
h('span', { className: 'dshm-toast-icon' }, h(IconCheck, { size: 14 })),
|
|
3818
|
+
h('button', {
|
|
3819
|
+
type: 'button', className: 'dshm-toast-main',
|
|
3820
|
+
onClick: () => { ui.set({ toast: null }); openArtistPage(toast.name); },
|
|
3821
|
+
},
|
|
3822
|
+
toast.kind === 'artist' ? t('artistReadyToast') + ' · ' + toast.name : t('pageReadyToast')),
|
|
3823
|
+
h('button', {
|
|
3824
|
+
type: 'button', className: 'dshm-toast-x', 'aria-label': t('closeNotice'),
|
|
3825
|
+
onClick: () => ui.set({ toast: null }),
|
|
3826
|
+
}, h(IconClose, { size: 12 })))
|
|
3827
|
+
: null);
|
|
3510
3828
|
}
|
|
3511
3829
|
|
|
3512
3830
|
/* ================================================================
|
|
@@ -3759,6 +4077,7 @@ window.__ModuleLoader__.load({
|
|
|
3759
4077
|
const library = createLibrary(api);
|
|
3760
4078
|
const lyricsService = createLyricsService(api);
|
|
3761
4079
|
const artistService = createArtistService(api);
|
|
4080
|
+
const artistPageService = createArtistPageService(api);
|
|
3762
4081
|
const artistImageService = createArtistImageService(api);
|
|
3763
4082
|
const onboardingService = createOnboardingService(api);
|
|
3764
4083
|
const recoService = createRecoService(api);
|
|
@@ -3835,10 +4154,10 @@ window.__ModuleLoader__.load({
|
|
|
3835
4154
|
player, library, lyrics: lyricsService, artist: artistService, artistImages: artistImageService, onboarding: onboardingService,
|
|
3836
4155
|
reco: recoService, download: downloadService, sync: syncService, history: historyService,
|
|
3837
4156
|
likes: likesService, preview: previewService,
|
|
3838
|
-
openView, openArtistPage, setMiniHidden, ui,
|
|
4157
|
+
openView, openArtistPage, setMiniHidden, ui, artistPage: artistPageService,
|
|
3839
4158
|
hooks: {
|
|
3840
4159
|
player: player.source, library: library.source, ui,
|
|
3841
|
-
lyrics: lyricsService.source, artist: artistService.source, artistImages: artistImageService.source, onboarding: onboardingService.source,
|
|
4160
|
+
lyrics: lyricsService.source, artist: artistService.source, artistPage: artistPageService.source, artistImages: artistImageService.source, onboarding: onboardingService.source,
|
|
3842
4161
|
reco: recoService.source, download: downloadService.source,
|
|
3843
4162
|
sync: syncService.source, history: historyService.source,
|
|
3844
4163
|
likes: likesService.source, preview: previewService.source,
|