@vicyangorg/dsh-music 0.5.0 → 0.7.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/README.md +12 -8
- package/client/index.js +1960 -247
- package/docs/DETAIL.md +49 -9
- package/host/accounts.js +83 -0
- package/host/download.js +60 -18
- package/host/liked-sync.js +322 -0
- package/host/likes.js +124 -9
- package/host/main.js +27 -2
- package/host/onboarding.js +10 -4
- package/host/providers/common.js +66 -0
- package/host/providers/netease.js +266 -0
- package/host/providers/qqlogin.js +521 -0
- package/host/providers/qqmusic.js +213 -0
- package/host/reco/index.js +224 -88
- package/host/routes.js +33 -0
- package/host/source-scan.js +190 -0
- package/host/sync.js +18 -5
- package/host/t2s-extra.js +153 -0
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +1 -1
package/client/index.js
CHANGED
|
@@ -48,9 +48,18 @@ window.__ModuleLoader__.load({
|
|
|
48
48
|
panel: '音乐',
|
|
49
49
|
welcomeTitle: '欢迎使用 dsh-music',
|
|
50
50
|
welcomeSub: '本地优先的音乐库与推荐。花一分钟告诉我你想听什么,我把界面调到合你口味。',
|
|
51
|
-
|
|
51
|
+
settingsTitle: '设置',
|
|
52
|
+
settingsHint: '喜欢列表同步 · 推荐口味 · 音乐库',
|
|
53
|
+
settingsBack: '返回界面',
|
|
54
|
+
settingsSave: '保存设置',
|
|
55
|
+
settingsSaved: '已保存',
|
|
56
|
+
settingsFirstRunNote: '第一次来?先把下面三项过一遍,之后随时能回来改。',
|
|
57
|
+
setLikedTitle: '喜欢列表同步',
|
|
58
|
+
setTasteTitle: '推荐口味',
|
|
59
|
+
setLibTitle: '音乐库',
|
|
60
|
+
setLibSubReturning: '已经配置好了;要换目录或改用 starter 曲库就在这里改,保存后生效。',
|
|
61
|
+
settingsFinishHint: '完成后随时能从右上角「设置」回来修改',
|
|
52
62
|
welcomeSkip: '先随便看看',
|
|
53
|
-
welcomeBack: '返回界面',
|
|
54
63
|
welcomePoint1: '播放本地曲库,歌词与歌手资料齐全',
|
|
55
64
|
welcomePoint2: '按你的口味推荐,喜欢的歌才入库',
|
|
56
65
|
welcomePoint3: '所有数据只留在这台电脑上',
|
|
@@ -58,8 +67,6 @@ window.__ModuleLoader__.load({
|
|
|
58
67
|
welcomeTasteSub: '可以多选,也可以跳过;之后随时能在推荐里调整。',
|
|
59
68
|
welcomeGenres: '流派',
|
|
60
69
|
welcomeLanguages: '语言',
|
|
61
|
-
welcomePrev: '上一步',
|
|
62
|
-
welcomeNext: '下一步',
|
|
63
70
|
welcomeLibTitle: '从哪里开始?',
|
|
64
71
|
welcomeLibSub: '已经有本地音乐就选第一个;没有的话,我准备了一个免费的公共版权 starter 曲库。',
|
|
65
72
|
welcomeLocalTitle: '使用我已有的音乐库',
|
|
@@ -75,7 +82,6 @@ window.__ModuleLoader__.load({
|
|
|
75
82
|
welcomeCredits: '曲目与许可',
|
|
76
83
|
welcomeEnter: '进入推荐',
|
|
77
84
|
welcomeSaveFail: '保存失败,请重试',
|
|
78
|
-
welcomePreview: '预览欢迎页',
|
|
79
85
|
genre_jazz: '爵士',
|
|
80
86
|
genre_classical: '古典',
|
|
81
87
|
genre_electronic: '电子',
|
|
@@ -146,9 +152,6 @@ window.__ModuleLoader__.load({
|
|
|
146
152
|
emptyAddDirHint: '默认扫描目录(支持 mp3 / flac / m4a / wav 等):',
|
|
147
153
|
emptyRescanCta: '重新扫描曲库',
|
|
148
154
|
emptyDirNote: '也可以在插件配置里用 directories 自定义扫描目录。',
|
|
149
|
-
syncOptional: 'Spotify 同步(可选)',
|
|
150
|
-
syncOptionalHint: '可选功能:需要机器上已安装 spotify-sync CLI,没有也不影响听歌',
|
|
151
|
-
syncUnavailableHint: '未检测到 spotify-sync CLI,同步功能暂不可用(可跳过,不影响听歌)',
|
|
152
155
|
exploreChip: '探索批次',
|
|
153
156
|
recoColdTitle: '还没有收听历史',
|
|
154
157
|
recoColdBody: '先搜歌手或歌名试听,喜欢的歌会自动入库;听过几首后这里会按你的口味推荐。',
|
|
@@ -281,6 +284,10 @@ window.__ModuleLoader__.load({
|
|
|
281
284
|
recoGenerate: '生成推荐',
|
|
282
285
|
recoRegenerate: '换一批',
|
|
283
286
|
recoGenerating: '正在生成推荐(每首候选先联网核实,约需半分钟)…',
|
|
287
|
+
recoRefresh: '重新推荐本栏',
|
|
288
|
+
recoRefreshHint: '只重算这一栏,其余两栏保持当天已固化的内容',
|
|
289
|
+
recoRefreshing: '正在重新推荐这一栏…',
|
|
290
|
+
recoRefreshBusy: '这一栏正在生成中,请稍后再试',
|
|
284
291
|
recoEmptyTitle: '还没有推荐',
|
|
285
292
|
recoEmptyBody: '基于你的收听历史生成一批 10 首:7 首口味相近 + 3 首强制探索(流派/语言/年代轮换),每首都先联网核实真实存在,杜绝幻觉歌曲。多听几首歌,推荐会更懂你。',
|
|
286
293
|
recoError: '推荐生成失败',
|
|
@@ -290,6 +297,19 @@ window.__ModuleLoader__.load({
|
|
|
290
297
|
downloadDone: '已入库',
|
|
291
298
|
downloadFail: '失败',
|
|
292
299
|
downloadPlay: '已入库,曲库已刷新,可直接播放。',
|
|
300
|
+
downloadClose: '关闭下载面板',
|
|
301
|
+
downloadCollapse: '收起',
|
|
302
|
+
downloadExpand: '展开',
|
|
303
|
+
downloadQueued: '排队中',
|
|
304
|
+
downloadSkip: '已存在',
|
|
305
|
+
downloadFinished: '已结束',
|
|
306
|
+
downloadPillRunning: '入库中 {done}/{total}',
|
|
307
|
+
downloadPillDone: '已入库 {ok} 首',
|
|
308
|
+
downloadPillDoneFail: '已入库 {ok} 首,{fail} 首失败',
|
|
309
|
+
downloadSummary: '完成:{ok} 首入库,{fail} 首失败',
|
|
310
|
+
downloadSummaryAll: '全部 {ok} 首已入库',
|
|
311
|
+
downloadOpenLibrary: '打开曲库',
|
|
312
|
+
downloadPlayOne: '播放这首',
|
|
293
313
|
downloadError: '入库失败',
|
|
294
314
|
downloadIdle: '暂无入库任务',
|
|
295
315
|
syncBtn: '同步 Spotify',
|
|
@@ -301,6 +321,92 @@ window.__ModuleLoader__.load({
|
|
|
301
321
|
syncFail: '失败',
|
|
302
322
|
syncMissing: '本地缺失',
|
|
303
323
|
syncError: '同步失败',
|
|
324
|
+
/* 喜欢列表导入(网易云 / QQ 音乐,只读) */
|
|
325
|
+
importBtn: '导入喜欢列表',
|
|
326
|
+
importBtnHint: '从网易云音乐 / QQ 音乐的「我喜欢」只读导入到本地(不下载)',
|
|
327
|
+
importTabNetease: '网易云音乐',
|
|
328
|
+
importTabQq: 'QQ 音乐',
|
|
329
|
+
importQrLoading: '正在生成二维码…',
|
|
330
|
+
importQrWaiting: '等待扫码…',
|
|
331
|
+
importQrConfirmed: '已扫码,请在手机上确认登录',
|
|
332
|
+
importQrDone: '登录成功',
|
|
333
|
+
importQrExpired: '二维码已过期,请重新生成',
|
|
334
|
+
importQrRegenerate: '重新生成',
|
|
335
|
+
importQrHint: '打开网易云音乐 App → 左侧菜单「我的」→ 右上角「+」或设置里的「扫一扫」,对准二维码,登录后自动完成连接。',
|
|
336
|
+
importQqConnect: '连接',
|
|
337
|
+
importConnecting: '连接中…',
|
|
338
|
+
importSyncNow: '导入到「我喜欢」',
|
|
339
|
+
importSyncing: '导入中…',
|
|
340
|
+
importReQr: '重新扫码登录',
|
|
341
|
+
importDisconnect: '断开连接',
|
|
342
|
+
importResDisliked: '本地 👎 跳过',
|
|
343
|
+
importResUnavailable: '云端已下架',
|
|
344
|
+
importResRemoved: '云端已移除',
|
|
345
|
+
importResRemovedHint: '仅提示:不会取消本地 ♥,也不会删除文件',
|
|
346
|
+
importDoneLine: '已导入 {total} 首到「我喜欢」:新增 {added},之前已有 {existed}',
|
|
347
|
+
importViewLikes: '查看「我喜欢」',
|
|
348
|
+
importQrStep1: '用手机扫码登录',
|
|
349
|
+
importQrStep2: '登录后自动导入到「我喜欢」',
|
|
350
|
+
importAutoNote: '扫码并在手机上确认后会立刻导入一次。登录凭据只保存在本机、不上传;插件只读你的「我喜欢的音乐」,不改云端任何内容。',
|
|
351
|
+
importQqPrivacy: '登录凭据只保存在本机(~/.dsh/dsh-music/accounts.json,权限 0600),不上传;可随时断开连接。',
|
|
352
|
+
importQqQrStep1: '用手机 QQ 扫一扫登录',
|
|
353
|
+
importQqQrHint: '打开手机 QQ → 右上角「+」→「扫一扫」,对准二维码,在手机上确认登录。',
|
|
354
|
+
importQqBusyHint: '手机提示「登录频繁」?今天扫码次数太多,等 30 分钟~2 小时再试,期间别反复扫。',
|
|
355
|
+
importQqQrNote: '登录后自动导入到「我喜欢」。用微信登录 QQ 音乐的账号扫不了,请改用 Cookie。',
|
|
356
|
+
importQqUseCookie: '用 Cookie 连接(微信登录的账号)',
|
|
357
|
+
importQqUseQr: '改用手机 QQ 扫码',
|
|
358
|
+
importQrReportHint: '重新生成后再扫一次;还是不行的话,把括号里的内容发给我们。',
|
|
359
|
+
prvQqHowCookie: '扫码或粘贴 Cookie',
|
|
360
|
+
importQqStep1: '在浏览器登录 QQ 音乐网页版',
|
|
361
|
+
importQqOpen: '打开 y.qq.com',
|
|
362
|
+
importQqLoginHint: 'QQ 或微信登录都可以,登录后别关这个标签页。',
|
|
363
|
+
importQqStep2: '复制登录凭据到剪贴板',
|
|
364
|
+
importQqCopy: '复制命令',
|
|
365
|
+
importQqCopied: '已复制',
|
|
366
|
+
importQqStep2Hint: '在 y.qq.com 页面打开开发者工具({keys})→ Console,粘贴命令并回车',
|
|
367
|
+
importQqFallback: '命令不好用?在 y.qq.com 打开开发者工具({keys})→ Network → 刷新页面 → 点任意一个请求 → 复制 Request Headers 里的 Cookie 整行。',
|
|
368
|
+
importQqStep3: '粘贴到这里,自动连接并导入',
|
|
369
|
+
importQqPlaceholder: '粘贴 Cookie,例如 qm_keyst=…; uin=…',
|
|
370
|
+
importQqNeedKey: '没拿到登录凭据(qm_keyst)。请先在 y.qq.com 登录,再按上面的方法复制一次。',
|
|
371
|
+
importKnownLine: '已导入 {n} 首',
|
|
372
|
+
importLastSyncLine: '上次 {time}',
|
|
373
|
+
prvNeteaseHow: '扫码连接',
|
|
374
|
+
prvQqHow: '扫码连接',
|
|
375
|
+
spStep1: '安装 spotify-sync 命令行(可选)',
|
|
376
|
+
spStep1Ok: '已检测到 spotify-sync,这一步不用管。',
|
|
377
|
+
spStep1Hint: '还没检测到 spotify-sync 命令。这是可选功能,没有它也能听歌;装好后点「重新检测」,或在插件配置里指定 syncCommand / syncScriptPath。',
|
|
378
|
+
spRecheck: '重新检测',
|
|
379
|
+
spStep2: '完成 Spotify 授权',
|
|
380
|
+
spStep2Ok: '已找到授权凭据。',
|
|
381
|
+
spStep2Hint: '还没找到授权凭据。登录凭据由 spotify-sync 自己保管(~/.config/spotify-sync/refresh_token),本插件只检查文件在不在、从不读取。按 spotify-sync 的说明登录授权一次,再点「重新检测」。',
|
|
382
|
+
spStep3: '同步收藏到本地曲库',
|
|
383
|
+
spBody: '新增的收藏会下载到 ~/Music/spotify-liked 并并入曲库;已有的不重复下载。',
|
|
384
|
+
spStateNoCli: '未安装',
|
|
385
|
+
spStateNoAuth: '待授权',
|
|
386
|
+
spStateReady: '已就绪',
|
|
387
|
+
spStateChecking: '检测中…',
|
|
388
|
+
setLikedSub: '把你在音乐 App 里「喜欢」的歌带进来:只读、不改云端;导入的歌先进「我喜欢」,想听再入库。',
|
|
389
|
+
addMissing: '入库(联网核实后下载)',
|
|
390
|
+
addMissingQueued: '已加入入库队列,完成后自动出现在曲库',
|
|
391
|
+
addMissingQueuedFront: '「{title}」已置顶到入库队列,下载完成后自动出现在曲库',
|
|
392
|
+
nowLikesLabel: '喜欢 / 不喜欢',
|
|
393
|
+
addMissingSearching: '还没入库:正在找已核实的音源,找到就加入下载队列…',
|
|
394
|
+
addMissingSearchingBatch: '正在为没入库的歌逐首找已核实的音源…',
|
|
395
|
+
addMissingBatch: '入库 {n} 首',
|
|
396
|
+
addMissingBatchQueued: '已把 {n} 首加入入库队列(每批最多 20 首,串行下载),{m} 首暂时没找到可靠音源',
|
|
397
|
+
addMissingNoneBatch: '这些歌暂时都没找到可靠音源',
|
|
398
|
+
addMissingNone: '没找到可靠的音源,去曲库搜「{title}」试试',
|
|
399
|
+
likesMissingCount: '{n} 首还没入库',
|
|
400
|
+
addReady: '已找到可靠音源,点击入库',
|
|
401
|
+
addReadyShort: '可入库',
|
|
402
|
+
addNone: '暂未找到可靠音源,点击再找一次',
|
|
403
|
+
scanProgress: '查找音源 {done}/{total} · 已找到 {found}',
|
|
404
|
+
scanHint: '导入后会在后台逐首查找已核实的音源(MusicBrainz);找到的行会亮起「可入库」,点歌也会直接入库',
|
|
405
|
+
addMissingHint: '这些歌只标记了 ♥、还没下载。点歌后面的入库按钮会先联网核实再下载。',
|
|
406
|
+
importEnabledOff: '主机已关闭喜欢列表导入(配置项 likedSync = false)',
|
|
407
|
+
importCookieEmpty: '请先粘贴 Cookie',
|
|
408
|
+
srcNetease: '网易云',
|
|
409
|
+
srcQq: 'QQ 音乐',
|
|
304
410
|
tabHistory: '历史',
|
|
305
411
|
historyTitle: '收听历史',
|
|
306
412
|
historyEmpty: '还没有播放记录,去曲库放几首歌吧。',
|
|
@@ -314,9 +420,18 @@ window.__ModuleLoader__.load({
|
|
|
314
420
|
panel: 'Music',
|
|
315
421
|
welcomeTitle: 'Welcome to dsh-music',
|
|
316
422
|
welcomeSub: 'A local-first music library and recommender. Tell me what you like and I will tune the panel to you.',
|
|
317
|
-
|
|
423
|
+
settingsTitle: 'Settings',
|
|
424
|
+
settingsHint: 'Liked-list sync · taste · library',
|
|
425
|
+
settingsBack: 'Back to the app',
|
|
426
|
+
settingsSave: 'Save settings',
|
|
427
|
+
settingsSaved: 'Saved',
|
|
428
|
+
settingsFirstRunNote: 'First time here? Walk through the three sections below — you can change everything later.',
|
|
429
|
+
setLikedTitle: 'Liked-list sync',
|
|
430
|
+
setTasteTitle: 'Taste',
|
|
431
|
+
setLibTitle: 'Library',
|
|
432
|
+
setLibSubReturning: 'Already set up. Change the folder or switch to the starter library here; takes effect after saving.',
|
|
433
|
+
settingsFinishHint: 'You can come back any time via “Settings” in the top-right corner',
|
|
318
434
|
welcomeSkip: 'Just browse',
|
|
319
|
-
welcomeBack: 'Back to the app',
|
|
320
435
|
welcomePoint1: 'Play your local library with lyrics and artist profiles',
|
|
321
436
|
welcomePoint2: 'Recommendations tuned to your taste; only liked songs are saved',
|
|
322
437
|
welcomePoint3: 'Everything stays on this computer',
|
|
@@ -324,8 +439,6 @@ window.__ModuleLoader__.load({
|
|
|
324
439
|
welcomeTasteSub: 'Pick as many as you want, or skip; you can change this later in Recommendations.',
|
|
325
440
|
welcomeGenres: 'Genres',
|
|
326
441
|
welcomeLanguages: 'Languages',
|
|
327
|
-
welcomePrev: 'Back',
|
|
328
|
-
welcomeNext: 'Next',
|
|
329
442
|
welcomeLibTitle: 'Where should we start?',
|
|
330
443
|
welcomeLibSub: 'Already have local music? Pick the first one. Otherwise I prepared a free public-domain starter library.',
|
|
331
444
|
welcomeLocalTitle: 'Use my existing music',
|
|
@@ -341,7 +454,6 @@ window.__ModuleLoader__.load({
|
|
|
341
454
|
welcomeCredits: 'Tracks & licences',
|
|
342
455
|
welcomeEnter: 'Open Recommendations',
|
|
343
456
|
welcomeSaveFail: 'Could not save — please try again',
|
|
344
|
-
welcomePreview: 'Preview welcome',
|
|
345
457
|
genre_jazz: 'Jazz',
|
|
346
458
|
genre_classical: 'Classical',
|
|
347
459
|
genre_electronic: 'Electronic',
|
|
@@ -412,9 +524,6 @@ window.__ModuleLoader__.load({
|
|
|
412
524
|
emptyAddDirHint: 'Default scanned folders (mp3 / flac / m4a / wav…):',
|
|
413
525
|
emptyRescanCta: 'Rescan library',
|
|
414
526
|
emptyDirNote: 'You can also set custom folders with `directories` in the plugin config.',
|
|
415
|
-
syncOptional: 'Spotify sync (optional)',
|
|
416
|
-
syncOptionalHint: 'Optional: needs the spotify-sync CLI installed; music works without it',
|
|
417
|
-
syncUnavailableHint: 'spotify-sync CLI not found — sync is unavailable (safe to skip)',
|
|
418
527
|
exploreChip: 'Exploration batch',
|
|
419
528
|
recoColdTitle: 'No listening history yet',
|
|
420
529
|
recoColdBody: 'Search and preview some songs first — liked songs are added automatically, and recommendations will follow your taste.',
|
|
@@ -547,6 +656,10 @@ window.__ModuleLoader__.load({
|
|
|
547
656
|
recoGenerate: 'Generate',
|
|
548
657
|
recoRegenerate: 'Another batch',
|
|
549
658
|
recoGenerating: 'Generating recommendations (every candidate is verified online first, ~30s)…',
|
|
659
|
+
recoRefresh: 'Refresh this column',
|
|
660
|
+
recoRefreshHint: 'Recomputes only this column; the other two keep today\'s fixed snapshot',
|
|
661
|
+
recoRefreshing: 'Refreshing this column…',
|
|
662
|
+
recoRefreshBusy: 'This column is being generated — try again in a moment',
|
|
550
663
|
recoEmptyTitle: 'No recommendations yet',
|
|
551
664
|
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.',
|
|
552
665
|
recoError: 'Recommendations failed',
|
|
@@ -556,6 +669,19 @@ window.__ModuleLoader__.load({
|
|
|
556
669
|
downloadDone: 'In library',
|
|
557
670
|
downloadFail: 'Failed',
|
|
558
671
|
downloadPlay: 'Added — the library was refreshed; play it from Library.',
|
|
672
|
+
downloadClose: 'Close download panel',
|
|
673
|
+
downloadCollapse: 'Collapse',
|
|
674
|
+
downloadExpand: 'Expand',
|
|
675
|
+
downloadQueued: 'Queued',
|
|
676
|
+
downloadSkip: 'Already in library',
|
|
677
|
+
downloadFinished: 'Finished',
|
|
678
|
+
downloadPillRunning: 'Adding {done}/{total}',
|
|
679
|
+
downloadPillDone: '{ok} added',
|
|
680
|
+
downloadPillDoneFail: '{ok} added, {fail} failed',
|
|
681
|
+
downloadSummary: 'Done: {ok} added, {fail} failed',
|
|
682
|
+
downloadSummaryAll: 'All {ok} added',
|
|
683
|
+
downloadOpenLibrary: 'Open library',
|
|
684
|
+
downloadPlayOne: 'Play this track',
|
|
559
685
|
downloadError: 'Could not add to library',
|
|
560
686
|
downloadIdle: 'Nothing queued',
|
|
561
687
|
syncBtn: 'Sync Spotify',
|
|
@@ -567,6 +693,92 @@ window.__ModuleLoader__.load({
|
|
|
567
693
|
syncFail: 'Failed',
|
|
568
694
|
syncMissing: 'Missing locally',
|
|
569
695
|
syncError: 'Sync failed',
|
|
696
|
+
/* Liked-list import (NetEase / QQ Music, read-only) */
|
|
697
|
+
importBtn: 'Import liked',
|
|
698
|
+
importBtnHint: 'Read-only import of your NetEase Cloud Music / QQ Music liked list (no downloads)',
|
|
699
|
+
importTabNetease: 'NetEase Cloud Music',
|
|
700
|
+
importTabQq: 'QQ Music',
|
|
701
|
+
importQrLoading: 'Generating QR code…',
|
|
702
|
+
importQrWaiting: 'Waiting for scan…',
|
|
703
|
+
importQrConfirmed: 'Scanned — confirm the login on your phone',
|
|
704
|
+
importQrDone: 'Signed in',
|
|
705
|
+
importQrExpired: 'QR code expired — generate a new one',
|
|
706
|
+
importQrRegenerate: 'Regenerate',
|
|
707
|
+
importQrHint: 'Open the NetEase Cloud Music app → “Mine” → the “+” / scan entry, point it at the QR code; the connection completes right after login.',
|
|
708
|
+
importQqConnect: 'Connect',
|
|
709
|
+
importConnecting: 'Connecting…',
|
|
710
|
+
importSyncNow: 'Import into “Liked”',
|
|
711
|
+
importSyncing: 'Importing…',
|
|
712
|
+
importReQr: 'Sign in again (QR)',
|
|
713
|
+
importDisconnect: 'Disconnect',
|
|
714
|
+
importResDisliked: 'Skipped (local 👎)',
|
|
715
|
+
importResUnavailable: 'Unavailable in cloud',
|
|
716
|
+
importResRemoved: 'Removed in cloud',
|
|
717
|
+
importResRemovedHint: 'Informational only: local ♥ marks and files are kept',
|
|
718
|
+
importDoneLine: 'Imported {total} songs into “Liked”: {added} new, {existed} already there',
|
|
719
|
+
importViewLikes: 'View Liked',
|
|
720
|
+
importQrStep1: 'Scan the QR code with your phone',
|
|
721
|
+
importQrStep2: 'Imports into “Liked” right after sign-in',
|
|
722
|
+
importAutoNote: 'Once you confirm on your phone the first import starts right away. Your login stays on this machine and is never uploaded; the plugin only reads “My Favorite Music” and changes nothing in the cloud.',
|
|
723
|
+
importQqPrivacy: 'Your login stays on this machine (~/.dsh/dsh-music/accounts.json, mode 0600) and is never uploaded; disconnect any time.',
|
|
724
|
+
importQqQrStep1: 'Scan with the QQ app on your phone',
|
|
725
|
+
importQqQrHint: 'Open the QQ app → “+” at the top right → “Scan”, point it at the QR code and confirm on your phone.',
|
|
726
|
+
importQqBusyHint: 'Phone says “logging in too frequently”? Too many scans today — wait 30 minutes to 2 hours and don’t retry repeatedly.',
|
|
727
|
+
importQqQrNote: 'Once you confirm, the first import starts right away. Accounts that sign in to QQ Music with WeChat cannot scan here — use the cookie instead.',
|
|
728
|
+
importQqUseCookie: 'Connect with a cookie (WeChat accounts)',
|
|
729
|
+
importQqUseQr: 'Scan with the QQ app instead',
|
|
730
|
+
importQrReportHint: 'Regenerate and scan again; if it still fails, send us the text in brackets.',
|
|
731
|
+
prvQqHowCookie: 'Scan or paste cookie',
|
|
732
|
+
importQqStep1: 'Sign in to QQ Music on the web',
|
|
733
|
+
importQqOpen: 'Open y.qq.com',
|
|
734
|
+
importQqLoginHint: 'QQ or WeChat sign-in both work; leave that tab open afterwards.',
|
|
735
|
+
importQqStep2: 'Copy the sign-in cookie to the clipboard',
|
|
736
|
+
importQqCopy: 'Copy command',
|
|
737
|
+
importQqCopied: 'Copied',
|
|
738
|
+
importQqStep2Hint: 'On the y.qq.com tab open DevTools ({keys}) → Console, paste the command and press Enter',
|
|
739
|
+
importQqFallback: 'Command didn’t work? On y.qq.com open DevTools ({keys}) → Network → reload → pick any request → copy the whole Cookie line under Request Headers.',
|
|
740
|
+
importQqStep3: 'Paste it here — it connects and imports automatically',
|
|
741
|
+
importQqPlaceholder: 'Paste the cookie, e.g. qm_keyst=…; uin=…',
|
|
742
|
+
importQqNeedKey: 'No sign-in cookie (qm_keyst) yet. Sign in at y.qq.com first, then copy again.',
|
|
743
|
+
importKnownLine: '{n} songs imported',
|
|
744
|
+
importLastSyncLine: 'last {time}',
|
|
745
|
+
prvNeteaseHow: 'Scan to connect',
|
|
746
|
+
prvQqHow: 'Scan to connect',
|
|
747
|
+
spStep1: 'Install the spotify-sync CLI (optional)',
|
|
748
|
+
spStep1Ok: 'spotify-sync detected — nothing to do here.',
|
|
749
|
+
spStep1Hint: 'spotify-sync was not found. It’s optional: everything else works without it. After installing, click Re-check, or set syncCommand / syncScriptPath in the plugin config.',
|
|
750
|
+
spRecheck: 'Re-check',
|
|
751
|
+
spStep2: 'Authorize Spotify',
|
|
752
|
+
spStep2Ok: 'Credentials found.',
|
|
753
|
+
spStep2Hint: 'No credentials yet. spotify-sync keeps its own login (~/.config/spotify-sync/refresh_token); this plugin only checks that the file exists and never reads it. Authorize once as spotify-sync describes, then click Re-check.',
|
|
754
|
+
spStep3: 'Sync Liked Songs into your library',
|
|
755
|
+
spBody: 'New likes are downloaded to ~/Music/spotify-liked and added to the library; existing files are skipped.',
|
|
756
|
+
spStateNoCli: 'Not installed',
|
|
757
|
+
spStateNoAuth: 'Authorize',
|
|
758
|
+
spStateReady: 'Ready',
|
|
759
|
+
spStateChecking: 'Checking…',
|
|
760
|
+
setLikedSub: 'Bring in the songs you liked in other music apps: read-only, nothing changes in the cloud; imported songs land in Liked first, and you add them to the library when you want to listen.',
|
|
761
|
+
addMissing: 'Add to library (verified download)',
|
|
762
|
+
addMissingQueued: 'Queued — it appears in the library when done',
|
|
763
|
+
addMissingQueuedFront: '“{title}” moved to the top of the queue — it appears in the library when done',
|
|
764
|
+
nowLikesLabel: 'Like / dislike',
|
|
765
|
+
addMissingSearching: 'Not in your library yet — looking for a verified source, it gets queued automatically…',
|
|
766
|
+
addMissingSearchingBatch: 'Looking up verified sources for the songs that are not in your library yet…',
|
|
767
|
+
addMissingBatch: 'Download {n}',
|
|
768
|
+
addMissingBatchQueued: 'Queued {n} songs (up to 20 per batch, one at a time); no reliable source found for {m} yet',
|
|
769
|
+
addMissingNoneBatch: 'No reliable source found for these songs yet',
|
|
770
|
+
addMissingNone: 'No reliable source found — try searching “{title}” in the library',
|
|
771
|
+
likesMissingCount: '{n} not in library yet',
|
|
772
|
+
addReady: 'Verified source found — click to add',
|
|
773
|
+
addReadyShort: 'Ready',
|
|
774
|
+
addNone: 'No verified source yet — click to search again',
|
|
775
|
+
scanProgress: 'Finding sources {done}/{total} · {found} found',
|
|
776
|
+
scanHint: 'Imported tracks are matched against verified sources (MusicBrainz) in the background; rows light up “Ready” and clicking them adds them directly',
|
|
777
|
+
addMissingHint: 'These songs are only marked ♥ and not downloaded yet. The add-to-library button verifies online first, then downloads.',
|
|
778
|
+
importEnabledOff: 'Liked-list import is disabled on this host (config likedSync = false)',
|
|
779
|
+
importCookieEmpty: 'Paste the cookie first',
|
|
780
|
+
srcNetease: 'NetEase',
|
|
781
|
+
srcQq: 'QQ Music',
|
|
570
782
|
tabHistory: 'History',
|
|
571
783
|
historyTitle: 'Listening history',
|
|
572
784
|
historyEmpty: 'No plays yet — go play something from the library.',
|
|
@@ -660,6 +872,226 @@ window.__ModuleLoader__.load({
|
|
|
660
872
|
};
|
|
661
873
|
}
|
|
662
874
|
|
|
875
|
+
/* ================================================================
|
|
876
|
+
* 2b. Minimal QR encoder (Model 2, byte mode, v1–10, EC level M) — renders the
|
|
877
|
+
* NetEase login URL as SVG modules. Zero deps; verified with zxing-cpp + OpenCV.
|
|
878
|
+
* ================================================================ */
|
|
879
|
+
/* QR-BEGIN:极简 QR Code 编码器(Model 2,byte 模式,版本 1–10,纠错级 M,自动选版 + 8 掩码择优)。
|
|
880
|
+
只用于把网易云登录 URL 渲染成二维码;零依赖、纯函数,返回扁平模块矩阵供 SVG 渲染。 */;
|
|
881
|
+
const QR_EC_LEVEL = 'M';
|
|
882
|
+
const QR_EC_BITS = { L: 1, M: 0, Q: 3, H: 2 }
|
|
883
|
+
// [每块纠错码字, 组1块数, 组1数据码字, 组2块数, 组2数据码字](版本 1–10 × L/M/Q/H,ISO/IEC 18004 表 9)
|
|
884
|
+
const QR_EC_TABLE = [
|
|
885
|
+
[[7, 1, 19, 0, 0], [10, 1, 16, 0, 0], [13, 1, 13, 0, 0], [17, 1, 9, 0, 0]],
|
|
886
|
+
[[10, 1, 34, 0, 0], [16, 1, 28, 0, 0], [22, 1, 22, 0, 0], [28, 1, 16, 0, 0]],
|
|
887
|
+
[[15, 1, 55, 0, 0], [26, 1, 44, 0, 0], [18, 2, 17, 0, 0], [22, 2, 13, 0, 0]],
|
|
888
|
+
[[20, 1, 80, 0, 0], [18, 2, 32, 0, 0], [26, 2, 24, 0, 0], [16, 4, 9, 0, 0]],
|
|
889
|
+
[[26, 1, 108, 0, 0], [24, 2, 43, 0, 0], [18, 2, 15, 2, 16], [22, 2, 11, 2, 12]],
|
|
890
|
+
[[18, 2, 68, 0, 0], [16, 4, 27, 0, 0], [24, 4, 19, 0, 0], [28, 4, 15, 0, 0]],
|
|
891
|
+
[[20, 2, 78, 0, 0], [18, 4, 31, 0, 0], [18, 2, 14, 4, 15], [26, 4, 13, 1, 14]],
|
|
892
|
+
[[24, 2, 97, 0, 0], [22, 2, 38, 2, 39], [22, 4, 18, 2, 19], [26, 4, 14, 2, 15]],
|
|
893
|
+
[[30, 2, 116, 0, 0], [22, 3, 36, 2, 37], [20, 4, 16, 4, 17], [24, 4, 12, 4, 13]],
|
|
894
|
+
[[18, 2, 68, 2, 69], [26, 4, 43, 1, 44], [24, 6, 19, 2, 20], [28, 6, 15, 2, 16]],
|
|
895
|
+
];
|
|
896
|
+
// 校正图形中心坐标(版本 1–10)
|
|
897
|
+
// 总码字数(版本 1–10)
|
|
898
|
+
const QR_TOTAL = [26, 44, 70, 100, 134, 172, 196, 242, 292, 346];
|
|
899
|
+
const QR_ALIGN = [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50]];
|
|
900
|
+
const QR_GF_EXP = new Uint8Array(512);
|
|
901
|
+
const QR_GF_LOG = new Uint8Array(256);
|
|
902
|
+
for (let i = 0, x = 1; i < 255; i++) { QR_GF_EXP[i] = x; QR_GF_LOG[x] = i; x <<= 1; if (x & 0x100) x ^= 0x11d }
|
|
903
|
+
for (let i = 255; i < 512; i++) QR_GF_EXP[i] = QR_GF_EXP[i - 255];
|
|
904
|
+
const qrGfMul = (a, b) => (a && b ? QR_GF_EXP[QR_GF_LOG[a] + QR_GF_LOG[b]] : 0);
|
|
905
|
+
// RS 生成多项式 ∏(x - α^i),降幂系数,首项为 1
|
|
906
|
+
function qrRsGenerator(degree) {
|
|
907
|
+
let poly = [1];
|
|
908
|
+
for (let i = 0; i < degree; i++) {
|
|
909
|
+
const next = new Array(poly.length + 1).fill(0);
|
|
910
|
+
for (let j = 0; j < poly.length; j++) { next[j] ^= poly[j]; next[j + 1] ^= qrGfMul(poly[j], QR_GF_EXP[i]) }
|
|
911
|
+
poly = next;
|
|
912
|
+
}
|
|
913
|
+
return poly;
|
|
914
|
+
}
|
|
915
|
+
function qrRsRemainder(data, degree) {
|
|
916
|
+
const gen = qrRsGenerator(degree);
|
|
917
|
+
const rem = new Uint8Array(degree);
|
|
918
|
+
for (const d of data) {
|
|
919
|
+
const factor = d ^ rem[0];
|
|
920
|
+
rem.copyWithin(0, 1);
|
|
921
|
+
rem[degree - 1] = 0;
|
|
922
|
+
if (factor) for (let i = 0; i < degree; i++) rem[i] ^= qrGfMul(gen[i + 1], factor);
|
|
923
|
+
}
|
|
924
|
+
return rem;
|
|
925
|
+
}
|
|
926
|
+
/** 把字节编成数据码字:模式指示 0100 + 8/16 位长度 + 数据 + 终止符 + 0xEC/0x11 填充 */
|
|
927
|
+
function qrCodewords(bytes, version, dataCodewords) {
|
|
928
|
+
const capacityBits = dataCodewords * 8;
|
|
929
|
+
const bits = [];
|
|
930
|
+
const push = (value, n) => { for (let i = n - 1; i >= 0; i--) bits.push((value >>> i) & 1) }
|
|
931
|
+
push(4, 4);
|
|
932
|
+
push(bytes.length, version <= 9 ? 8 : 16);
|
|
933
|
+
for (const b of bytes) push(b, 8);
|
|
934
|
+
push(0, Math.min(4, capacityBits - bits.length));
|
|
935
|
+
if (bits.length % 8) push(0, 8 - (bits.length % 8));
|
|
936
|
+
for (let pad = 0xec; bits.length < capacityBits; pad ^= 0xec ^ 0x11) push(pad, 8);
|
|
937
|
+
const out = new Uint8Array(dataCodewords);
|
|
938
|
+
for (let i = 0; i < dataCodewords; i++) { let v = 0; for (let j = 0; j < 8; j++) v = (v << 1) | bits[i * 8 + j]; out[i] = v }
|
|
939
|
+
return out;
|
|
940
|
+
}
|
|
941
|
+
/** 分块 + RS 纠错 + 交织 */
|
|
942
|
+
function qrInterleave(data, spec) {
|
|
943
|
+
const [ecPerBlock, g1Count, g1Data, g2Count, g2Data] = spec;
|
|
944
|
+
const blocks = [];
|
|
945
|
+
let offset = 0;
|
|
946
|
+
for (let i = 0; i < g1Count; i++) { blocks.push(Array.from(data.slice(offset, offset + g1Data))); offset += g1Data }
|
|
947
|
+
for (let i = 0; i < g2Count; i++) { blocks.push(Array.from(data.slice(offset, offset + g2Data))); offset += g2Data }
|
|
948
|
+
const ecc = blocks.map((b) => Array.from(qrRsRemainder(Uint8Array.from(b), ecPerBlock)));
|
|
949
|
+
const maxData = Math.max(g1Data, g2Data);
|
|
950
|
+
const out = [];
|
|
951
|
+
for (let i = 0; i < maxData; i++) for (const b of blocks) if (i < b.length) out.push(b[i]);
|
|
952
|
+
for (let i = 0; i < ecPerBlock; i++) for (const e of ecc) out.push(e[i]);
|
|
953
|
+
return Uint8Array.from(out);
|
|
954
|
+
}
|
|
955
|
+
function qrBuildBase(version) {
|
|
956
|
+
const size = version * 4 + 17;
|
|
957
|
+
const modules = new Uint8Array(size * size);
|
|
958
|
+
const isFunction = new Uint8Array(size * size);
|
|
959
|
+
const set = (r, c, v) => { modules[r * size + c] = v; isFunction[r * size + c] = 1 }
|
|
960
|
+
const finder = (r0, c0) => {
|
|
961
|
+
for (let r = -1; r <= 7; r++) for (let c = -1; c <= 7; c++) {
|
|
962
|
+
const rr = r0 + r, cc = c0 + c;
|
|
963
|
+
if (rr < 0 || cc < 0 || rr >= size || cc >= size) continue;
|
|
964
|
+
const dark = r >= 0 && r <= 6 && c >= 0 && c <= 6 && (r === 0 || r === 6 || c === 0 || c === 6 || (r >= 2 && r <= 4 && c >= 2 && c <= 4));
|
|
965
|
+
set(rr, cc, dark ? 1 : 0);
|
|
966
|
+
}
|
|
967
|
+
}
|
|
968
|
+
finder(0, 0); finder(0, size - 7); finder(size - 7, 0);
|
|
969
|
+
for (let i = 8; i < size - 8; i++) { const v = i % 2 === 0 ? 1 : 0; set(6, i, v); set(i, 6, v) }
|
|
970
|
+
const centers = QR_ALIGN[version - 1];
|
|
971
|
+
const last = centers.length - 1;
|
|
972
|
+
for (const ci of centers.keys()) for (const cj of centers.keys()) {
|
|
973
|
+
if ((ci === 0 && cj === 0) || (ci === 0 && cj === last) || (ci === last && cj === 0)) continue;
|
|
974
|
+
const cr = centers[ci], cc = centers[cj];
|
|
975
|
+
for (let r = -2; r <= 2; r++) for (let c = -2; c <= 2; c++) set(cr + r, cc + c, Math.max(Math.abs(r), Math.abs(c)) !== 1 ? 1 : 0);
|
|
976
|
+
}
|
|
977
|
+
set(size - 8, 8, 1);
|
|
978
|
+
for (let i = 0; i <= 8; i++) if (i !== 6) { isFunction[8 * size + i] = 1; isFunction[i * size + 8] = 1 }
|
|
979
|
+
for (let i = 0; i < 8; i++) isFunction[8 * size + size - 1 - i] = 1;
|
|
980
|
+
for (let i = 0; i < 7; i++) isFunction[(size - 1 - i) * size + 8] = 1;
|
|
981
|
+
if (version >= 7) {
|
|
982
|
+
let rem = version << 12;
|
|
983
|
+
for (let i = 17; i >= 12; i--) if ((rem >>> i) & 1) rem ^= 0x1f25 << (i - 12);
|
|
984
|
+
const bits = (version << 12) | (rem & 0xfff);
|
|
985
|
+
for (let i = 0; i < 18; i++) {
|
|
986
|
+
const bit = (bits >>> i) & 1;
|
|
987
|
+
const a = size - 11 + (i % 3), b = Math.floor(i / 3);
|
|
988
|
+
set(b, a, bit);
|
|
989
|
+
set(a, b, bit);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
return { size, modules, isFunction }
|
|
993
|
+
}
|
|
994
|
+
const QR_MASKS = [
|
|
995
|
+
(x, y) => (x + y) % 2 === 0,
|
|
996
|
+
(x, y) => y % 2 === 0,
|
|
997
|
+
(x, y) => x % 3 === 0,
|
|
998
|
+
(x, y) => (x + y) % 3 === 0,
|
|
999
|
+
(x, y) => (Math.floor(x / 3) + Math.floor(y / 2)) % 2 === 0,
|
|
1000
|
+
(x, y) => ((x * y) % 2) + ((x * y) % 3) === 0,
|
|
1001
|
+
(x, y) => (((x * y) % 2) + ((x * y) % 3)) % 2 === 0,
|
|
1002
|
+
(x, y) => (((x + y) % 2) + ((x * y) % 3)) % 2 === 0,
|
|
1003
|
+
];
|
|
1004
|
+
function qrWriteFormat(base, mask) {
|
|
1005
|
+
const { size, modules } = base;
|
|
1006
|
+
const data = QR_EC_BITS[QR_EC_LEVEL] << 3 | mask;
|
|
1007
|
+
let rem = data << 10;
|
|
1008
|
+
for (let i = 14; i >= 10; i--) if ((rem >>> i) & 1) rem ^= 0x537 << (i - 10);
|
|
1009
|
+
const bits = ((data << 10) | (rem & 0x3ff)) ^ 0x5412;
|
|
1010
|
+
const put = (r, c, i) => { modules[r * size + c] = (bits >>> i) & 1 }
|
|
1011
|
+
for (let i = 0; i <= 5; i++) put(i, 8, i);
|
|
1012
|
+
put(7, 8, 6); put(8, 8, 7); put(8, 7, 8);
|
|
1013
|
+
for (let i = 9; i < 15; i++) put(8, 14 - i, i);
|
|
1014
|
+
for (let i = 0; i < 8; i++) put(8, size - 1 - i, i);
|
|
1015
|
+
for (let i = 8; i < 15; i++) put(size - 15 + i, 8, i);
|
|
1016
|
+
modules[(size - 8) * size + 8] = 1;
|
|
1017
|
+
}
|
|
1018
|
+
function qrPenalty(base) {
|
|
1019
|
+
const { size, modules } = base;
|
|
1020
|
+
let score = 0;
|
|
1021
|
+
const at = (r, c) => modules[r * size + c];
|
|
1022
|
+
// N1:行/列连续同色 ≥5
|
|
1023
|
+
for (let r = 0; r < size; r++) for (let c = 0; c < size; c++) {
|
|
1024
|
+
let runH = 1;
|
|
1025
|
+
while (c + runH < size && at(r, c + runH) === at(r, c)) runH++
|
|
1026
|
+
let runV = 1;
|
|
1027
|
+
while (r + runV < size && at(r + runV, c) === at(r, c)) runV++
|
|
1028
|
+
if (runH >= 5) score += 3 + runH - 5;
|
|
1029
|
+
if (runV >= 5) score += 3 + runV - 5;
|
|
1030
|
+
}
|
|
1031
|
+
// N2:2×2 同色块
|
|
1032
|
+
for (let r = 0; r < size - 1; r++) for (let c = 0; c < size - 1; c++) {
|
|
1033
|
+
const v = at(r, c);
|
|
1034
|
+
if (at(r, c + 1) === v && at(r + 1, c) === v && at(r + 1, c + 1) === v) score += 3;
|
|
1035
|
+
}
|
|
1036
|
+
// N3:1011101 且一侧有 0000(行与列)
|
|
1037
|
+
const P1 = 0b00001011101, P2 = 0b10111010000;
|
|
1038
|
+
const scan = (get) => {
|
|
1039
|
+
let acc = 0;
|
|
1040
|
+
for (let i = 0; i < size; i++) {
|
|
1041
|
+
acc = ((acc << 1) | get(i)) & 0x7ff;
|
|
1042
|
+
if (i >= 10 && (acc === P1 || acc === P2)) score += 40;
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
for (let r = 0; r < size; r++) { scan((c) => at(r, c)); scan((c) => at(c, r)) }
|
|
1046
|
+
// N4:暗模块比例偏离 50%
|
|
1047
|
+
let dark = 0;
|
|
1048
|
+
for (let i = 0; i < modules.length; i++) dark += modules[i];
|
|
1049
|
+
score += 10 * Math.floor(Math.abs((dark * 100) / modules.length - 50) / 5);
|
|
1050
|
+
return score;
|
|
1051
|
+
}
|
|
1052
|
+
/** 入口:文本 → { version, size, mask, modules: Uint8Array(size*size) };超出容量返回 null */
|
|
1053
|
+
function qrEncode(text, encoder = new TextEncoder()) {
|
|
1054
|
+
const bytes = encoder.encode(String(text ?? ''));
|
|
1055
|
+
let version = 0;
|
|
1056
|
+
let spec = null;
|
|
1057
|
+
let dataCodewords = 0;
|
|
1058
|
+
for (let v = 1; v <= 10; v++) {
|
|
1059
|
+
const s = QR_EC_TABLE[v - 1][['L', 'M', 'Q', 'H'].indexOf(QR_EC_LEVEL)];
|
|
1060
|
+
const dc = QR_TOTAL[v - 1] - s[0] * (s[1] + s[3]);
|
|
1061
|
+
const countBits = v <= 9 ? 8 : 16;
|
|
1062
|
+
if (4 + countBits + bytes.length * 8 <= dc * 8) { version = v; spec = s; dataCodewords = dc; break }
|
|
1063
|
+
}
|
|
1064
|
+
if (!version) return null;
|
|
1065
|
+
const base = qrBuildBase(version);
|
|
1066
|
+
const codewords = qrInterleave(qrCodewords(bytes, version, dataCodewords), spec);
|
|
1067
|
+
const { size, modules, isFunction } = base;
|
|
1068
|
+
let bit = 0;
|
|
1069
|
+
const totalBits = codewords.length * 8;
|
|
1070
|
+
for (let right = size - 1; right >= 1; right -= 2) {
|
|
1071
|
+
if (right === 6) right = 5;
|
|
1072
|
+
for (let vert = 0; vert < size; vert++) for (let j = 0; j < 2; j++) {
|
|
1073
|
+
const x = right - j;
|
|
1074
|
+
const upward = ((right + 1) & 2) === 0;
|
|
1075
|
+
const y = upward ? size - 1 - vert : vert;
|
|
1076
|
+
if (isFunction[y * size + x] || bit >= totalBits) continue;
|
|
1077
|
+
modules[y * size + x] = (codewords[bit >>> 3] >>> (7 - (bit & 7))) & 1;
|
|
1078
|
+
bit++
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1081
|
+
// 8 个掩码择优:在未掩码副本上逐个试
|
|
1082
|
+
const clean = Uint8Array.from(modules);
|
|
1083
|
+
let best = null;
|
|
1084
|
+
for (let m = 0; m < 8; m++) {
|
|
1085
|
+
modules.set(clean);
|
|
1086
|
+
for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) if (!isFunction[y * size + x] && QR_MASKS[m](x, y)) modules[y * size + x] ^= 1;
|
|
1087
|
+
qrWriteFormat(base, m);
|
|
1088
|
+
const score = qrPenalty(base);
|
|
1089
|
+
if (!best || score < best.score) best = { mask: m, score, modules: Uint8Array.from(modules) }
|
|
1090
|
+
}
|
|
1091
|
+
return { version, size, mask: best.mask, modules: best.modules }
|
|
1092
|
+
}
|
|
1093
|
+
/* QR-END */
|
|
1094
|
+
|
|
663
1095
|
/* ================================================================
|
|
664
1096
|
* 3. Original icon set (hand-drawn paths, currentColor, 24 viewBox)
|
|
665
1097
|
* ================================================================ */
|
|
@@ -759,6 +1191,19 @@ window.__ModuleLoader__.load({
|
|
|
759
1191
|
['path', { d: 'M8 10.5 12 14.5 16 10.5' }],
|
|
760
1192
|
['path', { d: 'M5 18.5h14' }],
|
|
761
1193
|
]);
|
|
1194
|
+
/* 喜欢列表导入:箭头进入一个盒(区别于下载的“落入托盘”)。 */
|
|
1195
|
+
const IconExternal = makeIcon([['path', { d: 'M14 4h6v6' }], ['path', { d: 'M20 4l-9 9' }], ['path', { d: 'M19 14v4.5a1.5 1.5 0 0 1-1.5 1.5h-12A1.5 1.5 0 0 1 4 18.5v-12A1.5 1.5 0 0 1 5.5 5H10' }]]);
|
|
1196
|
+
const IconSpotify = makeIcon([['path', { d: 'M6 9.5a12 12 0 0 1 12 0' }], ['path', { d: 'M7.5 12.8a9 9 0 0 1 9 0' }], ['path', { d: 'M9 16a5.5 5.5 0 0 1 6 0' }]]);
|
|
1197
|
+
const IconImport = makeIcon([
|
|
1198
|
+
['path', { d: 'M10 5H6.5A1.5 1.5 0 0 0 5 6.5v11A1.5 1.5 0 0 0 6.5 19h11a1.5 1.5 0 0 0 1.5-1.5V14' }],
|
|
1199
|
+
['path', { d: 'M14 4h6v6' }],
|
|
1200
|
+
['path', { d: 'M20 4l-9 9' }],
|
|
1201
|
+
]);
|
|
1202
|
+
/* 设置:齿轮(喜欢列表同步 / 推荐口味 / 音乐库 都收在这一个入口里)。 */
|
|
1203
|
+
const IconGear = makeIcon([
|
|
1204
|
+
['circle', { cx: 12, cy: 12, r: 3 }],
|
|
1205
|
+
['path', { d: 'M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09a1.65 1.65 0 0 0-1-1.51 1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09a1.65 1.65 0 0 0 1.51-1 1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06a1.65 1.65 0 0 0 1.82.33h.01a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51h.01a1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82v.01a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z' }],
|
|
1206
|
+
]);
|
|
762
1207
|
const IconHeart = makeIcon([
|
|
763
1208
|
['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' }],
|
|
764
1209
|
], { 'data-heart': 1 });
|
|
@@ -774,10 +1219,6 @@ window.__ModuleLoader__.load({
|
|
|
774
1219
|
* ================================================================ */
|
|
775
1220
|
const CSS = `
|
|
776
1221
|
.dshm-panel{position:relative;display:flex;flex-direction:column;height:100%;min-height:0;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;}
|
|
777
|
-
.dshm-welcome{position:relative;height:100%;display:flex;align-items:center;justify-content:center;overflow:auto;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;animation:dshm-fade-in .28s ease-out;}
|
|
778
|
-
.dshm-welcome-inner{position:relative;width:min(540px,calc(100% - 48px));padding:32px 0;text-align:center;}
|
|
779
|
-
.dshm-welcome-preview .dshm-wclose{position:absolute;right:0;top:6px;appearance:none;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-secondary);width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;cursor:pointer;}
|
|
780
|
-
.dshm-welcome-preview .dshm-wclose:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
781
1222
|
.dshm-welcome-hero{position:relative;}
|
|
782
1223
|
.dshm-welcome-glow{position:absolute;left:50%;top:0;width:330px;height:300px;transform:translateX(-50%);border-radius:50%;background:radial-gradient(circle,var(--dsw-alias-brand-primary),transparent 70%);opacity:.16;filter:blur(18px);pointer-events:none;}
|
|
783
1224
|
.dshm-welcome-fish{position:relative;display:flex;justify-content:center;animation:dshm-float 4.5s ease-in-out infinite;}
|
|
@@ -970,13 +1411,14 @@ window.__ModuleLoader__.load({
|
|
|
970
1411
|
.dshm-transport{justify-content:center;}
|
|
971
1412
|
.dshm-volumerow{margin:0 auto;}
|
|
972
1413
|
}
|
|
973
|
-
.dshm-mini{position:fixed;right:16px;bottom:16px;z-index:2147483000;width:min(
|
|
1414
|
+
.dshm-mini{position:fixed;right:16px;bottom:16px;z-index:2147483000;width:min(420px,calc(100% - 32px));background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:14px;box-shadow:0 10px 30px var(--dsw-alias-bg-mask-2);overflow:hidden;animation:dshm-mini-in .22s ease-out;}
|
|
974
1415
|
.dshm-mini-fab{position:fixed;right:16px;bottom:16px;z-index:2147483000;width:48px;height:48px;border-radius:50%;padding:0;overflow:hidden;display:flex;align-items:center;justify-content:center;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);box-shadow:0 10px 30px var(--dsw-alias-bg-mask-2);cursor:grab;touch-action:none;animation:dshm-mini-in .18s ease-out;}
|
|
975
1416
|
.dshm-mini-fab:hover{box-shadow:0 12px 34px var(--dsw-alias-bg-mask-2);}
|
|
976
1417
|
.dshm-mini-fab:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px;}
|
|
977
1418
|
.dshm-mini-fab-dragging{cursor:grabbing;animation:none;box-shadow:0 16px 40px var(--dsw-alias-bg-mask-2);}
|
|
978
1419
|
.dshm-mini-fab-badge{position:absolute;right:1px;bottom:1px;width:19px;height:19px;border-radius:50%;display:flex;align-items:center;justify-content:center;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);border:2px solid var(--dsw-alias-bg-layer-1);pointer-events:none;}
|
|
979
1420
|
.dshm-mini-dragging{box-shadow:0 16px 40px var(--dsw-alias-bg-mask-2);transition:none;animation:none;}
|
|
1421
|
+
.dshm-mini{touch-action:none;user-select:none;-webkit-user-select:none;cursor:default;}
|
|
980
1422
|
@keyframes dshm-mini-in{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:none;}}
|
|
981
1423
|
.dshm-mini-inner{display:flex;align-items:center;gap:6px;padding:8px 10px 8px 20px;}
|
|
982
1424
|
.dshm-mini-main{display:flex;align-items:center;gap:10px;flex:1;min-width:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;padding:2px;border-radius:9px;text-align:left;}
|
|
@@ -1000,6 +1442,16 @@ window.__ModuleLoader__.load({
|
|
|
1000
1442
|
.dshm-mode-cycle{min-width:32px;}
|
|
1001
1443
|
.dshm-chipbtn.dshm-mode-cycle{padding:0 9px;}
|
|
1002
1444
|
.dshm-mini-controls{display:flex;align-items:center;gap:2px;flex:none;}
|
|
1445
|
+
.dshm-mini-controls .dshm-iconbtn{width:28px;height:28px;}
|
|
1446
|
+
.dshm-mini-controls .dshm-mini-play{width:30px;height:30px;}
|
|
1447
|
+
.dshm-mini-like{width:24px;height:24px;margin:0 1px;}
|
|
1448
|
+
.dshm-mini-like:hover{background:transparent;}
|
|
1449
|
+
.dshm-mini-like-on{background:transparent;}
|
|
1450
|
+
.dshm-now-actions{display:inline-flex;align-self:flex-start;align-items:center;gap:2px;padding:3px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);box-shadow:0 1px 2px var(--dsw-alias-bg-mask-1);margin:-2px 0 2px;}
|
|
1451
|
+
.dshm-now-like{width:34px;height:34px;border-radius:50%;}
|
|
1452
|
+
.dshm-now-like:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
1453
|
+
.dshm-now-like.dshm-like-btn-on{background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);}
|
|
1454
|
+
.dshm-now-like.dshm-dislike-btn-on{background:var(--dsw-alias-interactive-bg-hover);}
|
|
1003
1455
|
.dshm-mini-play{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);border-radius:50%;width:34px;height:34px;}
|
|
1004
1456
|
.dshm-mini-play:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover);color:var(--dsw-alias-label-primary-inverted);}
|
|
1005
1457
|
.dshm-reco{max-width:560px;margin:0 auto;}
|
|
@@ -1025,10 +1477,116 @@ window.__ModuleLoader__.load({
|
|
|
1025
1477
|
.dshm-dl-status{font-size:11px;color:var(--dsw-alias-label-tertiary);flex:none;}
|
|
1026
1478
|
.dshm-dl-bar{height:3px;border-radius:2px;background:var(--dsw-alias-bg-layer-3);overflow:hidden;margin:2px 0 4px;}
|
|
1027
1479
|
.dshm-dl-bar>div{height:100%;background:var(--dsw-alias-brand-primary);transition:width .4s ease;}
|
|
1480
|
+
.dshm-dl-float{position:fixed;right:16px;bottom:16px;z-index:2147483000;width:min(340px,calc(100% - 32px));background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);border-radius:14px;box-shadow:0 10px 30px var(--dsw-alias-bg-mask-2);padding:10px 12px;display:flex;flex-direction:column;gap:8px;animation:dshm-mini-in .22s ease-out;}
|
|
1481
|
+
.dshm-dl-head{display:flex;align-items:center;gap:8px;min-width:0;}
|
|
1482
|
+
.dshm-dl-title{font-size:13px;font-weight:600;}
|
|
1483
|
+
.dshm-dl-list{display:flex;flex-direction:column;gap:4px;max-height:min(40vh,320px);overflow:auto;padding-right:2px;}
|
|
1484
|
+
.dshm-dl-wait{background:var(--dsw-alias-brand-primary);opacity:.45;}
|
|
1485
|
+
.dshm-dl-note{font-size:11px;color:var(--dsw-alias-label-tertiary);max-width:40%;flex:none;}
|
|
1486
|
+
.dshm-dl-foot{display:flex;align-items:center;gap:8px;border-top:1px solid var(--dsw-alias-border-l1);padding-top:8px;}
|
|
1487
|
+
.dshm-dl-sum{font-size:12px;flex:1;min-width:0;}
|
|
1488
|
+
.dshm-dl-sum-ok{color:var(--dsw-alias-state-success-primary);}
|
|
1489
|
+
.dshm-dl-sum-warn{color:var(--dsw-alias-state-warn-primary);}
|
|
1490
|
+
.dshm-dl-pill{position:fixed;right:16px;bottom:16px;z-index:2147483000;display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:999px;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l2);box-shadow:0 6px 20px var(--dsw-alias-bg-mask-2);font-size:12.5px;color:var(--dsw-alias-label-primary);cursor:pointer;max-width:calc(100% - 32px);}
|
|
1491
|
+
.dshm-dl-pill-bar{width:56px;height:3px;border-radius:2px;background:var(--dsw-alias-bg-layer-3);overflow:hidden;flex:none;}
|
|
1492
|
+
.dshm-dl-pill-bar>span{display:block;height:100%;background:var(--dsw-alias-brand-primary);transition:width .4s ease;}
|
|
1028
1493
|
.dshm-sync{margin:12px 24px 0;background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:12px;padding:12px 16px;display:flex;flex-direction:column;gap:10px;}
|
|
1029
1494
|
.dshm-sync-chips{display:flex;gap:8px;flex-wrap:wrap;}
|
|
1030
1495
|
.dshm-sync-chip{font-size:11.5px;border:1px solid var(--dsw-alias-border-l1);border-radius:99px;padding:4px 12px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2);}
|
|
1031
1496
|
.dshm-sync-detail{font-size:11.5px;color:var(--dsw-alias-label-tertiary);line-height:1.7;}
|
|
1497
|
+
.dshm-sync-chip-ok{color:var(--dsw-alias-state-success-primary);border-color:currentColor;}
|
|
1498
|
+
.dshm-sync-chip-warn{color:var(--dsw-alias-state-warn-primary);border-color:currentColor;}
|
|
1499
|
+
.dshm-imp-result{display:flex;flex-direction:column;gap:8px;}
|
|
1500
|
+
.dshm-state-actions{display:flex;gap:8px;justify-content:center;flex-wrap:wrap;}
|
|
1501
|
+
.dshm-chipbtn-plain{background:transparent;}
|
|
1502
|
+
.dshm-src-chips{display:inline-flex;gap:4px;margin-left:6px;vertical-align:middle;}
|
|
1503
|
+
.dshm-src-chip{font-size:10px;line-height:1;border:1px solid var(--dsw-alias-border-l1);border-radius:99px;padding:2px 6px;color:var(--dsw-alias-label-tertiary);background:var(--dsw-alias-bg-layer-2);}
|
|
1504
|
+
.dshm-src-netease{color:var(--dsw-alias-state-error-primary);}
|
|
1505
|
+
.dshm-src-qq{color:var(--dsw-alias-label-secondary);}
|
|
1506
|
+
.dshm-imp-account{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:13px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:10px;padding:8px 12px;}
|
|
1507
|
+
.dshm-imp-nick{font-weight:600;}
|
|
1508
|
+
.dshm-imp-time{font-size:11.5px;color:var(--dsw-alias-label-tertiary);}
|
|
1509
|
+
.dshm-imp-qr{display:flex;gap:16px;align-items:flex-start;}
|
|
1510
|
+
.dshm-imp-qr-box{flex:none;width:196px;height:196px;border-radius:10px;overflow:hidden;display:flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);}
|
|
1511
|
+
.dshm-imp-qr-fallback{display:flex;flex-direction:column;align-items:center;gap:8px;font-size:12px;color:var(--dsw-alias-label-tertiary);text-align:center;padding:12px;}
|
|
1512
|
+
.dshm-imp-qr-side{flex:1;display:flex;flex-direction:column;gap:10px;min-width:0;}
|
|
1513
|
+
.dshm-imp-step{font-size:13px;font-weight:600;color:var(--dsw-alias-label-primary);}
|
|
1514
|
+
.dshm-imp-hint{font-size:12px;line-height:1.7;color:var(--dsw-alias-label-tertiary);}
|
|
1515
|
+
.dshm-imp-cookie{font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:9px;padding:9px 11px;box-sizing:border-box;width:100%;outline:none;}
|
|
1516
|
+
.dshm-imp-actions{display:flex;gap:8px;flex-wrap:wrap;}
|
|
1517
|
+
.dshm-qr{display:block;}
|
|
1518
|
+
.dshm-sync-bare{margin:0;padding:10px 0 0;border-top:1px dashed var(--dsw-alias-border-l1);border-radius:0;background:transparent;border-left:0;border-right:0;border-bottom:0;}
|
|
1519
|
+
.dshm-prvs{display:flex;flex-direction:column;gap:8px;}
|
|
1520
|
+
.dshm-prv{background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:12px;overflow:hidden;transition:border-color .15s ease;}
|
|
1521
|
+
.dshm-prv:hover{border-color:var(--dsw-alias-border-l2);}
|
|
1522
|
+
.dshm-prv-open,.dshm-prv-open:hover{border-color:var(--dsw-alias-border-l3);}
|
|
1523
|
+
.dshm-prv-head{display:flex;align-items:center;gap:12px;width:100%;padding:11px 14px;background:transparent;border:0;color:var(--dsw-alias-label-primary);text-align:left;cursor:pointer;font:inherit;min-width:0;}
|
|
1524
|
+
.dshm-prv-head:hover{background:var(--dsw-alias-bg-layer-2);}
|
|
1525
|
+
.dshm-prv-head:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px;}
|
|
1526
|
+
.dshm-prv-icon{display:inline-flex;align-items:center;justify-content:center;width:34px;height:34px;border-radius:10px;flex:none;color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 12%,transparent);}
|
|
1527
|
+
.dshm-prv-netease .dshm-prv-icon{color:var(--dsw-alias-state-error-primary);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 12%,transparent);}
|
|
1528
|
+
.dshm-prv-spotify .dshm-prv-icon{color:var(--dsw-alias-state-success-primary);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 12%,transparent);}
|
|
1529
|
+
.dshm-prv-name{font-size:13.5px;font-weight:600;flex:none;}
|
|
1530
|
+
.dshm-prv-state{margin-left:auto;display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
|
|
1531
|
+
.dshm-prv-state::before{content:'';width:7px;height:7px;border-radius:50%;background:currentColor;flex:none;}
|
|
1532
|
+
.dshm-prv-state-ok{color:var(--dsw-alias-state-success-primary);}
|
|
1533
|
+
.dshm-prv-state-busy{color:var(--dsw-alias-brand-primary);}
|
|
1534
|
+
.dshm-prv-state-off::before{opacity:.45;}
|
|
1535
|
+
.dshm-prv-chev{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .18s ease;}
|
|
1536
|
+
.dshm-prv-open .dshm-prv-chev{transform:rotate(180deg);}
|
|
1537
|
+
.dshm-prv-body{padding:4px 16px 16px;border-top:1px solid var(--dsw-alias-border-l1);}
|
|
1538
|
+
.dshm-prv-body p{margin:0;}
|
|
1539
|
+
.dshm-steps{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;}
|
|
1540
|
+
.dshm-step{display:grid;grid-template-columns:24px 1fr;gap:10px;padding:10px 0;position:relative;}
|
|
1541
|
+
.dshm-step:not(:last-child)::before{content:'';position:absolute;left:11px;top:36px;bottom:-2px;width:2px;border-radius:1px;background:var(--dsw-alias-border-l1);}
|
|
1542
|
+
.dshm-step-n{position:relative;z-index:1;display:inline-flex;align-items:center;justify-content:center;width:24px;height:24px;border-radius:50%;font-size:12px;font-weight:600;color:var(--dsw-alias-label-secondary);border:1.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-2);}
|
|
1543
|
+
.dshm-step-done .dshm-step-n{color:var(--dsw-alias-state-success-primary);border-color:currentColor;background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 12%,transparent);}
|
|
1544
|
+
.dshm-step-active .dshm-step-n{color:var(--dsw-alias-brand-primary);border-color:currentColor;}
|
|
1545
|
+
.dshm-step-miss .dshm-step-n{color:var(--dsw-alias-state-error-primary);border-color:currentColor;}
|
|
1546
|
+
.dshm-step-todo{opacity:.55;}
|
|
1547
|
+
.dshm-step-done .dshm-step-title{color:var(--dsw-alias-label-secondary);}
|
|
1548
|
+
.dshm-step-body{display:flex;flex-direction:column;gap:8px;min-width:0;padding-top:2px;}
|
|
1549
|
+
.dshm-step-title{font-size:13px;font-weight:600;line-height:20px;color:var(--dsw-alias-label-primary);}
|
|
1550
|
+
.dshm-step-content{display:flex;flex-direction:column;gap:8px;min-width:0;}
|
|
1551
|
+
.dshm-step-content>.dshm-chipbtn,.dshm-step-content>.dshm-linkbtn{align-self:flex-start;}
|
|
1552
|
+
.dshm-step-content>.dshm-imp-cookie{align-self:stretch;}
|
|
1553
|
+
.dshm-step-content p{margin:0;}
|
|
1554
|
+
.dshm-imp-summary{display:flex;align-items:flex-start;gap:6px;font-size:13px;font-weight:600;line-height:1.5;color:var(--dsw-alias-state-success-primary);}
|
|
1555
|
+
.dshm-imp-summary svg{flex:none;margin-top:3px;}
|
|
1556
|
+
.dshm-ava{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:50%;flex:none;font-size:12.5px;font-weight:700;color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 14%,transparent);}
|
|
1557
|
+
.dshm-imp-nick{max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
|
|
1558
|
+
.dshm-linkbtn{display:inline-flex;align-items:center;gap:4px;padding:0;border:0;background:transparent;color:var(--dsw-alias-brand-primary);font:inherit;font-size:12.5px;cursor:pointer;align-self:flex-start;}
|
|
1559
|
+
.dshm-linkbtn:hover{text-decoration:underline;}
|
|
1560
|
+
.dshm-imp-hint-more{font-size:11.5px;padding-top:8px;border-top:1px dashed var(--dsw-alias-border-l1);}
|
|
1561
|
+
.dshm-imp-cookie:focus-visible{border-color:var(--dsw-alias-brand-primary);box-shadow:0 0 0 3px color-mix(in srgb,var(--dsw-alias-brand-primary) 18%,transparent);}
|
|
1562
|
+
.dshm-row-add-ready{width:auto;height:24px;padding:0 9px 0 7px;gap:3px;border-radius:999px;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);}
|
|
1563
|
+
.dshm-row-add-ready:hover{filter:brightness(1.08);background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);}
|
|
1564
|
+
.dshm-row-add-text{font-size:11px;font-weight:600;line-height:1;}
|
|
1565
|
+
.dshm-row-add-none{opacity:.6;border:1px dashed var(--dsw-alias-border-l3);}
|
|
1566
|
+
.dshm-missing-chip.dshm-scan-chip{display:inline-flex;align-items:center;gap:4px;color:var(--dsw-alias-brand-primary);border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 35%,transparent);}
|
|
1567
|
+
.dshm-missing-chip{font-size:11.5px;color:var(--dsw-alias-state-warn-primary);border:1px solid currentColor;border-radius:99px;padding:2px 9px;white-space:nowrap;}
|
|
1568
|
+
.dshm-settings{position:relative;height:100%;overflow:auto;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;animation:dshm-fade-in .28s ease-out;}
|
|
1569
|
+
.dshm-settings-inner{max-width:720px;margin:0 auto;padding:28px 24px 96px;width:100%;box-sizing:border-box;display:flex;flex-direction:column;gap:20px;}
|
|
1570
|
+
.dshm-settings-narrow{max-width:540px;}
|
|
1571
|
+
.dshm-set-hero{margin:8px 0 4px;text-align:center;}
|
|
1572
|
+
.dshm-logo{display:block;width:160px;height:160px;object-fit:contain;filter:drop-shadow(0 12px 24px var(--dsw-alias-bg-mask-2));user-select:none;}
|
|
1573
|
+
.dshm-set-first-note{margin:4px 0 0;font-size:12.5px;line-height:1.7;color:var(--dsw-alias-label-tertiary);text-align:center;}
|
|
1574
|
+
.dshm-set-top{display:flex;align-items:center;gap:12px;flex-wrap:wrap;padding-bottom:12px;border-bottom:1px solid var(--dsw-alias-border-l1);}
|
|
1575
|
+
.dshm-set-top-title{display:flex;align-items:center;gap:8px;color:var(--dsw-alias-label-primary);}
|
|
1576
|
+
.dshm-set-top-title h1{margin:0;font-size:18px;}
|
|
1577
|
+
.dshm-set-top .dshm-count{margin-left:auto;}
|
|
1578
|
+
.dshm-set-sections{display:flex;flex-direction:column;gap:28px;}
|
|
1579
|
+
.dshm-set-section{display:flex;flex-direction:column;gap:12px;scroll-margin-top:12px;}
|
|
1580
|
+
.dshm-set-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px;color:var(--dsw-alias-label-primary);}
|
|
1581
|
+
.dshm-set-head-icon{display:inline-flex;width:26px;height:26px;border-radius:8px;align-items:center;justify-content:center;background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-brand-primary);flex:none;}
|
|
1582
|
+
.dshm-set-head .dshm-wstep-title{margin:0;font-size:15px;}
|
|
1583
|
+
.dshm-set-head .dshm-wstep-sub{flex-basis:100%;margin:0;max-width:none;padding-left:34px;line-height:1.55;}
|
|
1584
|
+
.dshm-imp-logged{display:flex;flex-direction:column;gap:10px;min-width:0;}
|
|
1585
|
+
.dshm-imp-account{max-width:100%;}
|
|
1586
|
+
.dshm-set-foot{position:sticky;bottom:0;z-index:2;display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:4px -24px -96px;padding:12px 24px 20px;background:var(--dsw-alias-bg-base);border-top:1px solid var(--dsw-alias-border-l1);}
|
|
1587
|
+
.dshm-set-foot-hint{font-size:11.5px;color:var(--dsw-alias-label-tertiary);margin-left:auto;}
|
|
1588
|
+
.dshm-set-saved{display:inline-flex;align-items:center;gap:4px;font-size:12px;color:var(--dsw-alias-state-success-primary);}
|
|
1589
|
+
@media (max-width:520px){.dshm-imp-qr{flex-direction:column;align-items:center;}.dshm-settings-inner{padding:20px 16px 88px;}.dshm-set-foot{margin:4px -16px -88px;padding:10px 16px 18px;}}
|
|
1032
1590
|
.dshm-hrow{display:grid;grid-template-columns:40px minmax(0,1fr) auto auto auto;gap:10px;align-items:center;padding:6px 8px;border-radius:10px;}
|
|
1033
1591
|
.dshm-hrow-click{cursor:pointer;}
|
|
1034
1592
|
.dshm-hrow-click:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
@@ -1049,7 +1607,14 @@ window.__ModuleLoader__.load({
|
|
|
1049
1607
|
.dshm-col-head{flex:none;display:flex;align-items:center;gap:8px;padding:12px 14px 8px;}
|
|
1050
1608
|
.dshm-col-title{font-size:13.5px;font-weight:680;color:var(--dsw-alias-label-primary);display:flex;align-items:center;gap:6px;}
|
|
1051
1609
|
.dshm-col-count{font-size:11px;color:var(--dsw-alias-label-tertiary);}
|
|
1052
|
-
.dshm-col-play{margin-left:
|
|
1610
|
+
.dshm-col-play{margin-left:0;}
|
|
1611
|
+
.dshm-col-actions{display:flex;align-items:center;gap:6px;margin-left:auto;}
|
|
1612
|
+
.dshm-col-refresh{width:26px;height:26px;padding:0;justify-content:center;color:var(--dsw-alias-label-secondary);}
|
|
1613
|
+
.dshm-col-refresh:hover{color:var(--dsw-alias-label-primary);}
|
|
1614
|
+
.dshm-col-loading{display:flex;align-items:center;gap:6px;padding:0 14px 6px;font-size:12px;color:var(--dsw-alias-label-secondary);}
|
|
1615
|
+
.dshm-refresh-note{color:var(--dsw-alias-label-secondary);}
|
|
1616
|
+
.dshm-playround-busy{background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);opacity:.7;}
|
|
1617
|
+
.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;}
|
|
1053
1618
|
.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;}
|
|
1054
1619
|
.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;}
|
|
1055
1620
|
.dshm-srow:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
@@ -1183,9 +1748,9 @@ window.__ModuleLoader__.load({
|
|
|
1183
1748
|
.dshm-artist-btn{appearance:none;background:none;border:0;color:inherit;font:inherit;padding:0;cursor:pointer;text-align:left;display:inline-flex;align-items:center;gap:5px;max-width:100%;vertical-align:middle;}
|
|
1184
1749
|
.dshm-artist-btn:hover{text-decoration:underline;text-underline-offset:3px;}
|
|
1185
1750
|
@media (prefers-reduced-motion:reduce){
|
|
1186
|
-
.dshm-eq-on i,.dshm-tab-dot,.dshm-skel-box,.dshm-spin,.dshm-state-spin,.dshm-mini,.dshm-mini-fab,.dshm-drawer,.dshm-welcome,.dshm-
|
|
1751
|
+
.dshm-eq-on i,.dshm-tab-dot,.dshm-skel-box,.dshm-spin,.dshm-state-spin,.dshm-mini,.dshm-mini-fab,.dshm-drawer,.dshm-welcome-fish,.dshm-settings,.dshm-logo{animation:none;}
|
|
1187
1752
|
.dshm-mini{animation:none;}
|
|
1188
|
-
.dshm-row,.dshm-iconbtn,.dshm-chipbtn,.dshm-playbtn,.dshm-slider-thumb,.dshm-mini-progress>div,.dshm-reco-card,.dshm-dl-bar>div,.dshm-like-btn,.dshm-playround,.dshm-artcard,.dshm-mode-btn{transition:none;}
|
|
1753
|
+
.dshm-row,.dshm-iconbtn,.dshm-chipbtn,.dshm-playbtn,.dshm-slider-thumb,.dshm-mini-progress>div,.dshm-reco-card,.dshm-dl-bar>div,.dshm-like-btn,.dshm-playround,.dshm-artcard,.dshm-mode-btn,.dshm-prv,.dshm-prv-chev{transition}:none;}
|
|
1189
1754
|
}
|
|
1190
1755
|
`;
|
|
1191
1756
|
|
|
@@ -1203,6 +1768,16 @@ window.__ModuleLoader__.load({
|
|
|
1203
1768
|
if (languages.length) parts.push('languages=' + encodeURIComponent(languages.join(',')));
|
|
1204
1769
|
return parts.length ? '?' + parts.join('&') : '';
|
|
1205
1770
|
}
|
|
1771
|
+
/* Same taste payload for POST bodies (per-column refresh). */
|
|
1772
|
+
function tasteBody(taste) {
|
|
1773
|
+
if (!taste || typeof taste !== 'object') return {};
|
|
1774
|
+
const genres = (taste.genres || []).filter(Boolean);
|
|
1775
|
+
const languages = (taste.languages || []).filter(Boolean);
|
|
1776
|
+
const body = {};
|
|
1777
|
+
if (genres.length) body.genres = genres;
|
|
1778
|
+
if (languages.length) body.languages = languages;
|
|
1779
|
+
return body;
|
|
1780
|
+
}
|
|
1206
1781
|
|
|
1207
1782
|
async function request(path, options) {
|
|
1208
1783
|
let res;
|
|
@@ -1228,6 +1803,10 @@ window.__ModuleLoader__.load({
|
|
|
1228
1803
|
artist: (name) => request('/dsh-music/api/artist?name=' + encodeURIComponent(name)),
|
|
1229
1804
|
artistImage: (name) => request('/dsh-music/api/reco/artist-image?name=' + encodeURIComponent(name)),
|
|
1230
1805
|
recoSections: (taste) => request('/dsh-music/api/reco/sections' + tasteQuery(taste)),
|
|
1806
|
+
recoSectionsRefresh: (axis, taste) => request('/dsh-music/api/reco/sections/refresh', {
|
|
1807
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1808
|
+
body: JSON.stringify(Object.assign({ axis }, tasteBody(taste))),
|
|
1809
|
+
}),
|
|
1231
1810
|
deleteTrack: (trackId, confirm) => request('/dsh-music/api/library/delete', {
|
|
1232
1811
|
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1233
1812
|
body: JSON.stringify({ trackId, confirm: !!confirm }),
|
|
@@ -1238,13 +1817,15 @@ window.__ModuleLoader__.load({
|
|
|
1238
1817
|
}),
|
|
1239
1818
|
reco: (taste) => request('/dsh-music/api/reco' + tasteQuery(taste)),
|
|
1240
1819
|
recoStatus: () => request('/dsh-music/api/reco/status'),
|
|
1241
|
-
|
|
1242
|
-
|
|
1820
|
+
/* opts.front:运行中也接收,并置顶到待下载列表顶部(用户点了想先听的歌) */
|
|
1821
|
+
download: (items, opts) => request('/dsh-music/api/download', {
|
|
1822
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
1823
|
+
body: JSON.stringify(opts && opts.front ? { items, front: true } : { items }),
|
|
1243
1824
|
}),
|
|
1244
1825
|
downloadStatus: () => request('/dsh-music/api/download/status'),
|
|
1245
1826
|
sync: () => request('/dsh-music/api/sync', { method: 'POST' }),
|
|
1246
1827
|
syncStatus: () => request('/dsh-music/api/sync/status'),
|
|
1247
|
-
syncAvailability: () => request('/dsh-music/api/sync/availability'),
|
|
1828
|
+
syncAvailability: (refresh) => request('/dsh-music/api/sync/availability' + (refresh ? '?refresh=1' : '')),
|
|
1248
1829
|
history: (limit) => request('/dsh-music/api/history?limit=' + (limit || 50)),
|
|
1249
1830
|
historyStats: () => request('/dsh-music/api/history/stats'),
|
|
1250
1831
|
onboardingState: () => request('/dsh-music/api/onboarding/state'),
|
|
@@ -1273,6 +1854,16 @@ window.__ModuleLoader__.load({
|
|
|
1273
1854
|
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body),
|
|
1274
1855
|
}),
|
|
1275
1856
|
previewStatus: () => request('/dsh-music/api/library/preview/status'),
|
|
1857
|
+
/* 喜欢列表导入(网易云 / QQ 音乐,只读) */
|
|
1858
|
+
likedSyncStatus: () => request('/dsh-music/api/liked-sync/status'),
|
|
1859
|
+
likedSyncNeteaseQr: () => request('/dsh-music/api/liked-sync/netease/qr', { method: 'POST' }),
|
|
1860
|
+
likedSyncNeteaseQrPoll: (key) => request('/dsh-music/api/liked-sync/netease/qr/poll?key=' + encodeURIComponent(key || '')),
|
|
1861
|
+
likedSyncQqQr: () => request('/dsh-music/api/liked-sync/qq/qr', { method: 'POST' }),
|
|
1862
|
+
likedSyncQqQrPoll: (key) => request('/dsh-music/api/liked-sync/qq/qr/poll?key=' + encodeURIComponent(key || '')),
|
|
1863
|
+
likedSyncQqConnect: (cookie) => request('/dsh-music/api/liked-sync/qq/connect', {
|
|
1864
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ cookie }),
|
|
1865
|
+
}),
|
|
1866
|
+
likedSyncAction: (provider, action) => request('/dsh-music/api/liked-sync/' + encodeURIComponent(provider) + '/' + encodeURIComponent(action), { method: 'POST' }),
|
|
1276
1867
|
};
|
|
1277
1868
|
}
|
|
1278
1869
|
|
|
@@ -1477,7 +2068,7 @@ window.__ModuleLoader__.load({
|
|
|
1477
2068
|
mode: (data && data.mode) || null,
|
|
1478
2069
|
libraryConfigured: !!(data && data.libraryConfigured),
|
|
1479
2070
|
libraryPath: (data && data.libraryPath) || null,
|
|
1480
|
-
starter, taste: (data && data.taste) || null, error: null,
|
|
2071
|
+
starter, taste: (data && (data.taste || data.prefs)) || null, error: null,
|
|
1481
2072
|
});
|
|
1482
2073
|
return data;
|
|
1483
2074
|
} catch (err) {
|
|
@@ -1512,7 +2103,12 @@ window.__ModuleLoader__.load({
|
|
|
1512
2103
|
* 6c. S3 services: recommendations / downloads / sync / history
|
|
1513
2104
|
* ================================================================ */
|
|
1514
2105
|
function createRecoService(api) {
|
|
1515
|
-
const store = createStore({
|
|
2106
|
+
const store = createStore({
|
|
2107
|
+
status: 'idle', items: [], sections: null, generatedAt: 0, stats: null, error: null, bootstrapNote: null,
|
|
2108
|
+
fromCache: { today: false, artist: false, new: false },
|
|
2109
|
+
refreshing: { today: false, artist: false, new: false },
|
|
2110
|
+
refreshError: null, refreshBusy: false,
|
|
2111
|
+
});
|
|
1516
2112
|
let inflight = false;
|
|
1517
2113
|
async function pollUntilIdle() {
|
|
1518
2114
|
for (;;) {
|
|
@@ -1565,6 +2161,8 @@ window.__ModuleLoader__.load({
|
|
|
1565
2161
|
store.set({
|
|
1566
2162
|
status: 'ready', sections, items: sections.today, generatedAt: data.generatedAt || Date.now(),
|
|
1567
2163
|
error: null, bootstrapNote: data.exploreOnly ? (data.note || null) : null,
|
|
2164
|
+
fromCache: (data && data.fromCache) || { today: false, artist: false, new: false },
|
|
2165
|
+
refreshError: null, refreshBusy: false,
|
|
1568
2166
|
});
|
|
1569
2167
|
return true;
|
|
1570
2168
|
} catch { return false; }
|
|
@@ -1580,7 +2178,41 @@ window.__ModuleLoader__.load({
|
|
|
1580
2178
|
}
|
|
1581
2179
|
} catch { /* keep empty CTA; user can still generate */ }
|
|
1582
2180
|
}
|
|
1583
|
-
|
|
2181
|
+
/* Per-column "recompute this column only" (十期). The Host keeps the
|
|
2182
|
+
* three-column daily snapshot and only regenerates the requested axis,
|
|
2183
|
+
* reusing the rest, so the other two columns never flicker. */
|
|
2184
|
+
const AXES = ['today', 'artist', 'new'];
|
|
2185
|
+
async function refresh(axis) {
|
|
2186
|
+
if (AXES.indexOf(axis) < 0 || !api.recoSectionsRefresh) return;
|
|
2187
|
+
const cur = store.getSnapshot();
|
|
2188
|
+
if (cur.refreshing[axis]) return;
|
|
2189
|
+
store.set({ refreshing: Object.assign({}, cur.refreshing, { [axis]: true }), refreshError: null, refreshBusy: false });
|
|
2190
|
+
try {
|
|
2191
|
+
const data = await api.recoSectionsRefresh(axis, readPrefs().taste || null);
|
|
2192
|
+
const prev = store.getSnapshot();
|
|
2193
|
+
const base = prev.sections || { today: [], artist: [], new: [] };
|
|
2194
|
+
const sections = {
|
|
2195
|
+
today: (data && data.today) || base.today || [],
|
|
2196
|
+
artist: (data && data.artist) || base.artist || [],
|
|
2197
|
+
new: (data && (data['new'] || data.newColumn)) || base['new'] || [],
|
|
2198
|
+
};
|
|
2199
|
+
store.set({
|
|
2200
|
+
status: 'ready', sections, items: sections.today, error: null,
|
|
2201
|
+
generatedAt: (data && data.generatedAt) || prev.generatedAt,
|
|
2202
|
+
fromCache: (data && data.fromCache) || prev.fromCache,
|
|
2203
|
+
refreshing: { today: false, artist: false, new: false },
|
|
2204
|
+
refreshError: null, refreshBusy: false,
|
|
2205
|
+
});
|
|
2206
|
+
} catch (err) {
|
|
2207
|
+
const msg = (err && err.message) || String(err);
|
|
2208
|
+
const busy = /409|正在|生成中/.test(msg);
|
|
2209
|
+
store.set({
|
|
2210
|
+
refreshing: { today: false, artist: false, new: false },
|
|
2211
|
+
refreshError: busy ? 'busy' : msg, refreshBusy: busy,
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
}
|
|
2215
|
+
return { source: store, generate, load, refresh, searchStyle: (q) => api.recoStyle(q), artistPage: (name) => api.recoArtist(name) };
|
|
1584
2216
|
}
|
|
1585
2217
|
|
|
1586
2218
|
function createDownloadService(api) {
|
|
@@ -1606,9 +2238,9 @@ window.__ModuleLoader__.load({
|
|
|
1606
2238
|
};
|
|
1607
2239
|
tick();
|
|
1608
2240
|
}
|
|
1609
|
-
async function start(items) {
|
|
2241
|
+
async function start(items, opts) {
|
|
1610
2242
|
try {
|
|
1611
|
-
await api.download(items);
|
|
2243
|
+
await api.download(items, opts);
|
|
1612
2244
|
store.set({ error: null, finishedAt: 0 });
|
|
1613
2245
|
} catch (err) {
|
|
1614
2246
|
store.set({ error: (err && err.message) || String(err) });
|
|
@@ -1623,17 +2255,20 @@ window.__ModuleLoader__.load({
|
|
|
1623
2255
|
}
|
|
1624
2256
|
|
|
1625
2257
|
function createSyncService(api) {
|
|
1626
|
-
|
|
2258
|
+
/* authorized:null 未知 / true 已找到 spotify-sync 的授权凭据文件 / false 还没授权(主机只查文件存在) */
|
|
2259
|
+
const store = createStore({ phase: 'idle', result: null, error: null, available: null, hint: null, authorized: null });
|
|
1627
2260
|
let timer = null;
|
|
1628
2261
|
/* Host probe endpoint: sync is optional, so a failed probe means "unavailable". */
|
|
1629
|
-
async function probe() {
|
|
2262
|
+
async function probe(force) {
|
|
1630
2263
|
try {
|
|
1631
|
-
const a = await api.syncAvailability();
|
|
1632
|
-
store.set({ available: !!(a && a.available), hint: (a && a.hint) || null });
|
|
2264
|
+
const a = await api.syncAvailability(!!force);
|
|
2265
|
+
store.set({ available: !!(a && a.available), hint: (a && a.hint) || null, authorized: a && a.authorized != null ? !!a.authorized : null });
|
|
1633
2266
|
} catch {
|
|
1634
2267
|
store.set({ available: false, hint: null });
|
|
1635
2268
|
}
|
|
1636
2269
|
}
|
|
2270
|
+
/* 用户装好 CLI / 完成授权后点「重新检测」:让主机重探(不执行 CLI) */
|
|
2271
|
+
async function recheck() { await probe(true); return store.getSnapshot(); }
|
|
1637
2272
|
function noteAvailable(s) {
|
|
1638
2273
|
if (s && typeof s.available === 'boolean') store.set({ available: s.available, hint: s.hint || null });
|
|
1639
2274
|
}
|
|
@@ -1672,7 +2307,7 @@ window.__ModuleLoader__.load({
|
|
|
1672
2307
|
}
|
|
1673
2308
|
async function warm() { await probe(); const r = await refresh(); if (r) poll(); }
|
|
1674
2309
|
function dispose() { if (timer) { clearTimeout(timer); timer = null; } }
|
|
1675
|
-
return { source: store, start, warm, dispose, probe };
|
|
2310
|
+
return { source: store, start, warm, dispose, probe, recheck };
|
|
1676
2311
|
}
|
|
1677
2312
|
|
|
1678
2313
|
function createHistoryService(api) {
|
|
@@ -1708,13 +2343,13 @@ window.__ModuleLoader__.load({
|
|
|
1708
2343
|
function createLikesService(api, onAutoDownload) {
|
|
1709
2344
|
/* keys/dislikes are mutually exclusive on the host: a dislike clears the
|
|
1710
2345
|
* like and vice versa, so both maps are refreshed after every action. */
|
|
1711
|
-
const store = createStore({ keys: {}, dislikes: {}, items: [], dislikeItems: [], loaded: false, error: null });
|
|
2346
|
+
const store = createStore({ keys: {}, dislikes: {}, items: [], dislikeItems: [], loaded: false, error: null, scan: null });
|
|
1712
2347
|
async function load() {
|
|
1713
2348
|
try {
|
|
1714
2349
|
const data = await api.likes();
|
|
1715
2350
|
const keys = {};
|
|
1716
2351
|
for (const it of (data && data.items) || []) if (it.liked !== false) keys[likeKey(it)] = it;
|
|
1717
|
-
store.set({ keys, items: (data && data.items) || [], loaded: true, error: null });
|
|
2352
|
+
store.set({ keys, items: (data && data.items) || [], loaded: true, error: null, scan: (data && data.scan) || null });
|
|
1718
2353
|
} catch (err) {
|
|
1719
2354
|
store.set({ loaded: true, error: (err && err.message) || String(err) });
|
|
1720
2355
|
}
|
|
@@ -1771,6 +2406,213 @@ window.__ModuleLoader__.load({
|
|
|
1771
2406
|
return { source: store, toggle, setDislike, isLiked, isDisliked, load };
|
|
1772
2407
|
}
|
|
1773
2408
|
|
|
2409
|
+
/* ================================================================
|
|
2410
|
+
* 6d-2. 喜欢列表导入服务:网易云扫码 / QQ 音乐扫码或 Cookie → 本地「我喜欢」
|
|
2411
|
+
* 只读契约(host/liked-sync.js):不改云端、不下载,只标记 ♥。
|
|
2412
|
+
* store 字段:open/tab/enabled/providers/loaded/error/errorProvider(错误归属的平台,设置页分卡展示)·
|
|
2413
|
+
* qr{provider,key,url,matrix,png}/qrPhase(idle|loading|waiting|confirmed|done|expired|error)/qrMessage ·
|
|
2414
|
+
* qqMode(qr|cookie)/qqCookie/connecting · syncing/provider · result · notice
|
|
2415
|
+
* ================================================================ */
|
|
2416
|
+
function createLikedSyncService(api, onChange) {
|
|
2417
|
+
const store = createStore({
|
|
2418
|
+
open: false, tab: 'netease', enabled: true, providers: {}, loaded: false, error: null, errorProvider: null,
|
|
2419
|
+
qr: null, qrPhase: 'idle', qrMessage: '', qqMode: 'qr', qqCookie: '', connecting: false, syncing: null, result: null, notice: null, copied: false,
|
|
2420
|
+
});
|
|
2421
|
+
let pollTimer = null;
|
|
2422
|
+
let copiedTimer = null;
|
|
2423
|
+
/* 二维码到期能自动换一张:每次打开设置只自动续一次(风控 804 不自动续,要用户亲自点) */
|
|
2424
|
+
const qrAutoRetries = { netease: 0, qq: 0 };
|
|
2425
|
+
let pollSeq = 0;
|
|
2426
|
+
function stopPolling() {
|
|
2427
|
+
if (pollTimer) { clearTimeout(pollTimer); pollTimer = null; }
|
|
2428
|
+
pollSeq++;
|
|
2429
|
+
return pollSeq;
|
|
2430
|
+
}
|
|
2431
|
+
function isConnected(provider) {
|
|
2432
|
+
const p = store.getSnapshot().providers[provider];
|
|
2433
|
+
return !!(p && p.connected);
|
|
2434
|
+
}
|
|
2435
|
+
async function load() {
|
|
2436
|
+
try {
|
|
2437
|
+
const s = await api.likedSyncStatus();
|
|
2438
|
+
/* 不碰 error:同步/连接失败后紧跟的 load() 不能把主机文案冲掉 */
|
|
2439
|
+
store.set({ enabled: !s || s.enabled !== false, providers: (s && s.providers) || {}, loaded: true });
|
|
2440
|
+
} catch (err) {
|
|
2441
|
+
store.set({ loaded: true, error: (err && err.message) || String(err), errorProvider: null });
|
|
2442
|
+
}
|
|
2443
|
+
}
|
|
2444
|
+
function open(tab) {
|
|
2445
|
+
const next = tab || store.getSnapshot().tab || 'netease';
|
|
2446
|
+
stopPolling();
|
|
2447
|
+
qrAutoRetries.netease = 0;
|
|
2448
|
+
qrAutoRetries.qq = 0;
|
|
2449
|
+
store.set({ open: true, tab: next, qr: null, qrPhase: 'idle', qrMessage: '', result: null, notice: null, error: null, errorProvider: null, copied: false });
|
|
2450
|
+
load();
|
|
2451
|
+
autoStartQr(next);
|
|
2452
|
+
}
|
|
2453
|
+
function close() {
|
|
2454
|
+
stopPolling();
|
|
2455
|
+
store.set({ open: false });
|
|
2456
|
+
}
|
|
2457
|
+
function selectTab(tab) {
|
|
2458
|
+
stopPolling();
|
|
2459
|
+
const fresh = qrProviderFor(tab);
|
|
2460
|
+
if (fresh) qrAutoRetries[fresh] = 0; /* 用户亲自切到这家 = 新会话,重新给一次自动续码机会 */
|
|
2461
|
+
store.set({ tab, qr: null, qrPhase: 'idle', qrMessage: '', result: null, notice: null, error: null, errorProvider: null });
|
|
2462
|
+
autoStartQr(tab);
|
|
2463
|
+
}
|
|
2464
|
+
/* 当前展开的平台若处于扫码模式且未登录,就自动取一张二维码(同一时刻只有一个二维码会话) */
|
|
2465
|
+
function qrProviderFor(tab) {
|
|
2466
|
+
if (tab === 'netease') return 'netease';
|
|
2467
|
+
if (tab === 'qq' && (store.getSnapshot().qqMode || 'qr') === 'qr') return 'qq';
|
|
2468
|
+
return null;
|
|
2469
|
+
}
|
|
2470
|
+
function autoStartQr(tab) {
|
|
2471
|
+
const provider = qrProviderFor(tab);
|
|
2472
|
+
if (provider && !isConnected(provider)) startQr(provider);
|
|
2473
|
+
}
|
|
2474
|
+
async function startQr(provider = 'netease') {
|
|
2475
|
+
const seq = stopPolling();
|
|
2476
|
+
store.set({ qr: null, qrPhase: 'loading', qrMessage: '', error: null, errorProvider: null });
|
|
2477
|
+
try {
|
|
2478
|
+
let qr;
|
|
2479
|
+
if (provider === 'qq') {
|
|
2480
|
+
/* QQ 的二维码是 ptlogin 下发的图片:主机已解成模块矩阵(解不出就退回 PNG data URL) */
|
|
2481
|
+
const res = await api.likedSyncQqQr();
|
|
2482
|
+
const matrix = res && res.matrix && Array.isArray(res.matrix.modules) && res.matrix.size > 0
|
|
2483
|
+
? { size: res.matrix.size, modules: Uint8Array.from(res.matrix.modules) } : null;
|
|
2484
|
+
if (!res || !res.key || (!matrix && !res.png)) throw new Error('QR unavailable');
|
|
2485
|
+
qr = { provider, key: res.key, matrix, png: res.png || null };
|
|
2486
|
+
} else {
|
|
2487
|
+
const res = await api.likedSyncNeteaseQr();
|
|
2488
|
+
const matrix = qrEncode(res && res.url);
|
|
2489
|
+
if (!matrix) throw new Error('QR too long');
|
|
2490
|
+
qr = { provider, key: res.key, url: res.url, matrix };
|
|
2491
|
+
}
|
|
2492
|
+
if (seq !== pollSeq) return;
|
|
2493
|
+
store.set({ qr, qrPhase: 'waiting', qrMessage: '' });
|
|
2494
|
+
pollQr(provider, qr.key, seq);
|
|
2495
|
+
} catch (err) {
|
|
2496
|
+
if (seq !== pollSeq) return;
|
|
2497
|
+
store.set({ qrPhase: 'error', qrMessage: (err && err.message) || String(err) });
|
|
2498
|
+
}
|
|
2499
|
+
}
|
|
2500
|
+
async function pollQr(provider, key, seq) {
|
|
2501
|
+
try {
|
|
2502
|
+
const r = provider === 'qq' ? await api.likedSyncQqQrPoll(key) : await api.likedSyncNeteaseQrPoll(key);
|
|
2503
|
+
if (seq !== pollSeq) return;
|
|
2504
|
+
const code = r && r.code;
|
|
2505
|
+
if (code === 803) {
|
|
2506
|
+
store.set({ qrPhase: 'done', qrMessage: (r && r.message) || '', notice: r && r.account ? { provider, nickname: r.account.nickname || '' } : null });
|
|
2507
|
+
await load();
|
|
2508
|
+
/* 新用户路径:扫码成功 = 登录完成 → 不用再点一次,直接导入 */
|
|
2509
|
+
await sync(provider);
|
|
2510
|
+
return;
|
|
2511
|
+
}
|
|
2512
|
+
if (code === 800 && qrAutoRetries[provider] < 1 && isConnected(provider) === false) {
|
|
2513
|
+
/* 二维码 2 分钟到期是常态(新用户 often 来不及):不打扰用户,自动换一张;每家只自动续一次 */
|
|
2514
|
+
qrAutoRetries[provider]++;
|
|
2515
|
+
store.set({ qrPhase: 'loading', qrMessage: '', qr: null });
|
|
2516
|
+
startQr(provider);
|
|
2517
|
+
return;
|
|
2518
|
+
}
|
|
2519
|
+
if (code === 800 || code === 804) {
|
|
2520
|
+
/* 800 = 服务端说过期(文案通用即可);804 = 风控等,把服务端原话带给用户 */
|
|
2521
|
+
store.set({ qrPhase: 'expired', qrMessage: code === 804 ? ((r && r.message) || '') : '' });
|
|
2522
|
+
return;
|
|
2523
|
+
}
|
|
2524
|
+
store.set({ qrPhase: code === 802 ? 'confirmed' : 'waiting', qrMessage: (r && r.message) || '' });
|
|
2525
|
+
pollTimer = setTimeout(() => { pollTimer = null; pollQr(provider, key, seq); }, 2000);
|
|
2526
|
+
} catch (err) {
|
|
2527
|
+
if (seq !== pollSeq) return;
|
|
2528
|
+
/* 主机只对未知/过期 key 返回 404;其余按过期处理,让用户重新生成。 */
|
|
2529
|
+
store.set({ qrPhase: 'expired', qrMessage: (err && err.message) || String(err) });
|
|
2530
|
+
}
|
|
2531
|
+
}
|
|
2532
|
+
/* QQ 登录方式切换:手机 QQ 扫码(默认)/ 粘贴 Cookie(微信登录的账号) */
|
|
2533
|
+
function setQqMode(mode) {
|
|
2534
|
+
const next = mode === 'cookie' ? 'cookie' : 'qr';
|
|
2535
|
+
const s = store.getSnapshot();
|
|
2536
|
+
if (s.qqMode === next) return;
|
|
2537
|
+
stopPolling();
|
|
2538
|
+
qrAutoRetries.qq = 0;
|
|
2539
|
+
store.set({ qqMode: next, qr: null, qrPhase: 'idle', qrMessage: '', result: null, notice: null, error: null, errorProvider: null });
|
|
2540
|
+
if (s.open && s.tab === 'qq' && next === 'qr') startQr('qq');
|
|
2541
|
+
}
|
|
2542
|
+
function setQqCookie(value) {
|
|
2543
|
+
store.set({ qqCookie: String(value || ''), error: null, errorProvider: null });
|
|
2544
|
+
}
|
|
2545
|
+
async function connectQq() {
|
|
2546
|
+
const cookie = (store.getSnapshot().qqCookie || '').trim();
|
|
2547
|
+
if (!cookie) { store.set({ error: 'importCookieEmpty', errorProvider: 'qq' }); return; }
|
|
2548
|
+
/* connecting 一直保持到自动导入结束:粘贴即连接期间不能再触发一次 */
|
|
2549
|
+
store.set({ connecting: true, error: null, errorProvider: null, result: null });
|
|
2550
|
+
try {
|
|
2551
|
+
const res = await api.likedSyncQqConnect(cookie);
|
|
2552
|
+
store.set({ qqCookie: '', notice: { provider: 'qq', nickname: (res && res.account && res.account.nickname) || '' } });
|
|
2553
|
+
await load();
|
|
2554
|
+
await sync('qq');
|
|
2555
|
+
} catch (err) {
|
|
2556
|
+
store.set({ error: (err && err.message) || String(err), errorProvider: 'qq' });
|
|
2557
|
+
} finally {
|
|
2558
|
+
store.set({ connecting: false });
|
|
2559
|
+
}
|
|
2560
|
+
}
|
|
2561
|
+
async function sync(provider) {
|
|
2562
|
+
if (store.getSnapshot().syncing) return;
|
|
2563
|
+
store.set({ syncing: provider, error: null, errorProvider: null, result: null, notice: null });
|
|
2564
|
+
try {
|
|
2565
|
+
const res = await api.likedSyncAction(provider, 'sync');
|
|
2566
|
+
store.set({ syncing: null, result: Object.assign({ provider }, res || {}) });
|
|
2567
|
+
if (onChange) onChange(provider, res);
|
|
2568
|
+
} catch (err) {
|
|
2569
|
+
store.set({ syncing: null, error: (err && err.message) || String(err), errorProvider: provider });
|
|
2570
|
+
}
|
|
2571
|
+
await load();
|
|
2572
|
+
}
|
|
2573
|
+
async function disconnect(provider) {
|
|
2574
|
+
store.set({ error: null, errorProvider: null, result: null });
|
|
2575
|
+
try { await api.likedSyncAction(provider, 'disconnect'); } catch (err) { store.set({ error: (err && err.message) || String(err), errorProvider: provider }); }
|
|
2576
|
+
await load();
|
|
2577
|
+
if (store.getSnapshot().open && qrProviderFor(provider) === provider) startQr(provider);
|
|
2578
|
+
}
|
|
2579
|
+
/* QQ:「复制命令」把 copy(document.cookie) 写进剪贴板,用户到 y.qq.com 的 Console 里粘贴执行 */
|
|
2580
|
+
async function copyCookieCommand() {
|
|
2581
|
+
const cmd = 'copy(document.cookie)';
|
|
2582
|
+
try {
|
|
2583
|
+
if (typeof navigator !== 'undefined' && navigator.clipboard && navigator.clipboard.writeText) {
|
|
2584
|
+
await navigator.clipboard.writeText(cmd);
|
|
2585
|
+
} else {
|
|
2586
|
+
const ta = typeof document !== 'undefined' && document.createElement ? document.createElement('textarea') : null;
|
|
2587
|
+
if (!ta) return false;
|
|
2588
|
+
ta.value = cmd;
|
|
2589
|
+
ta.setAttribute('readonly', '');
|
|
2590
|
+
ta.style.position = 'fixed';
|
|
2591
|
+
ta.style.opacity = '0';
|
|
2592
|
+
document.body.appendChild(ta);
|
|
2593
|
+
ta.select();
|
|
2594
|
+
const ok = typeof document.execCommand === 'function' ? document.execCommand('copy') : false;
|
|
2595
|
+
document.body.removeChild(ta);
|
|
2596
|
+
if (!ok) return false;
|
|
2597
|
+
}
|
|
2598
|
+
} catch {
|
|
2599
|
+
return false;
|
|
2600
|
+
}
|
|
2601
|
+
store.set({ copied: true });
|
|
2602
|
+
if (copiedTimer) clearTimeout(copiedTimer);
|
|
2603
|
+
copiedTimer = setTimeout(() => store.set({ copied: false }), 2000);
|
|
2604
|
+
return true;
|
|
2605
|
+
}
|
|
2606
|
+
/* 在新标签页打开外部网址(QQ 音乐网页版登录) */
|
|
2607
|
+
function openUrl(url) {
|
|
2608
|
+
try {
|
|
2609
|
+
if (typeof window !== 'undefined' && typeof window.open === 'function') window.open(url, '_blank', 'noopener,noreferrer');
|
|
2610
|
+
} catch { /* 宿主禁止弹窗时静默:用户可手动打开 */ }
|
|
2611
|
+
}
|
|
2612
|
+
function dispose() { stopPolling(); if (copiedTimer) { clearTimeout(copiedTimer); copiedTimer = null; } }
|
|
2613
|
+
return { source: store, load, open, close, selectTab, startQr, setQqMode, setQqCookie, connectQq, sync, disconnect, copyCookieCommand, openUrl, dispose };
|
|
2614
|
+
}
|
|
2615
|
+
|
|
1774
2616
|
function createPreviewService(api) {
|
|
1775
2617
|
const store = createStore({ status: 'idle', item: null, error: null });
|
|
1776
2618
|
let timer = null;
|
|
@@ -1811,6 +2653,95 @@ window.__ModuleLoader__.load({
|
|
|
1811
2653
|
return { source: store, start, dispose };
|
|
1812
2654
|
}
|
|
1813
2655
|
|
|
2656
|
+
/* ================================================================
|
|
2657
|
+
* 6b. Warm service —「缓存转圈」反馈(十期②)
|
|
2658
|
+
* pending 里为正在缓存的行;试听缓存同一时刻只能跑一首(Host 单 job +
|
|
2659
|
+
* 共享管线锁),所以这里串行预热:整栏播放时整栏行同时转圈,每首就绪
|
|
2660
|
+
* 立即解除该行转圈并追加到队列(首首就绪即开播)。同一时间只跑一轮,
|
|
2661
|
+
* 转圈期间再点任何一首都被忽略,避免连点重复下载。
|
|
2662
|
+
* ================================================================ */
|
|
2663
|
+
function createWarmService(preview, player) {
|
|
2664
|
+
const store = createStore({ pending: {}, running: false });
|
|
2665
|
+
function isPending(item) {
|
|
2666
|
+
return !!store.getSnapshot().pending[likeKey(item)];
|
|
2667
|
+
}
|
|
2668
|
+
function mark(items, on) {
|
|
2669
|
+
const next = Object.assign({}, store.getSnapshot().pending);
|
|
2670
|
+
for (const it of items || []) {
|
|
2671
|
+
const key = likeKey(it);
|
|
2672
|
+
if (on) next[key] = true;
|
|
2673
|
+
else delete next[key];
|
|
2674
|
+
}
|
|
2675
|
+
store.set({ pending: next });
|
|
2676
|
+
}
|
|
2677
|
+
function trackOf(item, audioUrl) {
|
|
2678
|
+
return {
|
|
2679
|
+
id: 'preview:' + likeKey(item),
|
|
2680
|
+
title: item.title, artist: item.artist, album: item.album,
|
|
2681
|
+
coverUrl: item.coverUrl || null, audioUrl, duration: null,
|
|
2682
|
+
};
|
|
2683
|
+
}
|
|
2684
|
+
function warmOne(item) {
|
|
2685
|
+
return new Promise((resolve) => { preview.start(item, (res) => resolve(res || {})); });
|
|
2686
|
+
}
|
|
2687
|
+
function handle(item, res) {
|
|
2688
|
+
if (!res || !res.audioUrl) return;
|
|
2689
|
+
const tr = trackOf(item, res.audioUrl);
|
|
2690
|
+
if (!player.source.getSnapshot().track) player.playTracks([tr], 0);
|
|
2691
|
+
else player.appendTrack(tr);
|
|
2692
|
+
}
|
|
2693
|
+
/* Whole column: local hits start instantly, the rest warm serially. */
|
|
2694
|
+
async function playList(items, findLocal) {
|
|
2695
|
+
if (store.getSnapshot().running) return;
|
|
2696
|
+
const list = items || [];
|
|
2697
|
+
const localTracks = [];
|
|
2698
|
+
const remote = [];
|
|
2699
|
+
for (const it of list) {
|
|
2700
|
+
if (!it) continue;
|
|
2701
|
+
const lc = findLocal ? findLocal(it) : null;
|
|
2702
|
+
if (lc) {
|
|
2703
|
+
if (!localTracks.some((tr) => tr.id === lc.id)) localTracks.push(lc);
|
|
2704
|
+
} else if (it.verification) {
|
|
2705
|
+
remote.push(it);
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
if (localTracks.length) player.playTracks(localTracks, 0);
|
|
2709
|
+
if (!remote.length) return;
|
|
2710
|
+
mark(remote, true);
|
|
2711
|
+
store.set({ running: true });
|
|
2712
|
+
let firstError = null;
|
|
2713
|
+
try {
|
|
2714
|
+
for (const it of remote) {
|
|
2715
|
+
const res = await warmOne(it);
|
|
2716
|
+
mark([it], false);
|
|
2717
|
+
if (!res.audioUrl && res.error && !firstError) firstError = res.error;
|
|
2718
|
+
handle(it, res);
|
|
2719
|
+
}
|
|
2720
|
+
} finally {
|
|
2721
|
+
mark(remote, false);
|
|
2722
|
+
store.set({ running: false });
|
|
2723
|
+
}
|
|
2724
|
+
return { error: firstError };
|
|
2725
|
+
}
|
|
2726
|
+
/* Single row: only that row spins. */
|
|
2727
|
+
async function playOne(item) {
|
|
2728
|
+
if (store.getSnapshot().running) return null;
|
|
2729
|
+
mark([item], true);
|
|
2730
|
+
store.set({ running: true });
|
|
2731
|
+
let err = null;
|
|
2732
|
+
try {
|
|
2733
|
+
const res = await warmOne(item);
|
|
2734
|
+
if (res && res.error) err = res.error;
|
|
2735
|
+
handle(item, res);
|
|
2736
|
+
} finally {
|
|
2737
|
+
mark([item], false);
|
|
2738
|
+
store.set({ running: false });
|
|
2739
|
+
}
|
|
2740
|
+
return err ? { error: err } : null;
|
|
2741
|
+
}
|
|
2742
|
+
return { source: store, isPending, playList, playOne };
|
|
2743
|
+
}
|
|
2744
|
+
|
|
1814
2745
|
/* ================================================================
|
|
1815
2746
|
* 7. Player engine — singleton audio, survives panel navigation
|
|
1816
2747
|
* ================================================================ */
|
|
@@ -1923,19 +2854,34 @@ window.__ModuleLoader__.load({
|
|
|
1923
2854
|
if (!list.length) return;
|
|
1924
2855
|
if (snap().track) report(snap().track, true);
|
|
1925
2856
|
/* D1:播放全部必须跟随当前模式——随机态先打乱队列再随机起播,
|
|
1926
|
-
* 顺序/单曲态从首曲开始(单曲由 repeat=one 循环当前首)。
|
|
2857
|
+
* 顺序/单曲态从首曲开始(单曲由 repeat=one 循环当前首)。
|
|
2858
|
+
* 十三期修复:点某一首(行 / 队列 / 歌手页)必须从**这一首**开始——随机态只打乱
|
|
2859
|
+
* 它后面的队列(这首排第一),绝不随机起播;只有 playAll 显式要 shuffleStart 才随机起播。 */
|
|
1927
2860
|
const wantShuffle = opts && typeof opts.shuffle === 'boolean' ? opts.shuffle : snap().shuffle;
|
|
2861
|
+
const randomStart = !!(opts && opts.shuffleStart);
|
|
1928
2862
|
let queue = list;
|
|
1929
|
-
|
|
2863
|
+
/* 行点击的 startIndex 指向调用方给的列表(可能含无音频项),过滤后要用同一首重新定位 */
|
|
2864
|
+
const picked = tracks ? tracks[startIndex | 0] : null;
|
|
2865
|
+
let index = picked ? list.indexOf(picked) : -1;
|
|
2866
|
+
if (index < 0) index = Math.min(Math.max(0, startIndex | 0), list.length - 1);
|
|
1930
2867
|
if (wantShuffle && queue.length > 1) {
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
2868
|
+
const shuffled = (arr) => {
|
|
2869
|
+
const out = [...arr];
|
|
2870
|
+
for (let i = out.length - 1; i > 0; i -= 1) {
|
|
2871
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
2872
|
+
const tmp = out[i];
|
|
2873
|
+
out[i] = out[j];
|
|
2874
|
+
out[j] = tmp;
|
|
2875
|
+
}
|
|
2876
|
+
return out;
|
|
2877
|
+
};
|
|
2878
|
+
if (randomStart) {
|
|
2879
|
+
queue = shuffled(list);
|
|
2880
|
+
index = Math.floor(Math.random() * queue.length);
|
|
2881
|
+
} else {
|
|
2882
|
+
queue = [list[index], ...shuffled(list.filter((_, i) => i !== index))];
|
|
2883
|
+
index = 0;
|
|
1937
2884
|
}
|
|
1938
|
-
index = Math.floor(Math.random() * queue.length);
|
|
1939
2885
|
}
|
|
1940
2886
|
set({ queue, queueIndex: index, shuffle: wantShuffle });
|
|
1941
2887
|
if (opts && typeof opts.shuffle === 'boolean') writePrefs({ shuffle: wantShuffle });
|
|
@@ -1943,8 +2889,18 @@ window.__ModuleLoader__.load({
|
|
|
1943
2889
|
syncHost({ trackId: queue[index].id, queue: queue.map((tr) => tr.id).filter(Boolean) });
|
|
1944
2890
|
}
|
|
1945
2891
|
|
|
1946
|
-
|
|
1947
|
-
|
|
2892
|
+
/* Append one ready track without interrupting what plays now (十期②:
|
|
2893
|
+
* 整栏逐首缓存,就绪一首追加一首,队列自然续播). */
|
|
2894
|
+
function appendTrack(tr) {
|
|
2895
|
+
if (!tr || !tr.audioUrl) return;
|
|
2896
|
+
const snapNow = snap();
|
|
2897
|
+
if (!snapNow.track) { playTracks([tr], 0); return; }
|
|
2898
|
+
const queue = [...snapNow.queue, tr];
|
|
2899
|
+
set({ queue });
|
|
2900
|
+
syncHost({ queue: queue.map((x) => (x && x.id) || null).filter(Boolean) });
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
function jumpTo(index) { const { queue } = snap();
|
|
1948
2904
|
if (index < 0 || index >= queue.length) return;
|
|
1949
2905
|
report(snap().track, true);
|
|
1950
2906
|
set({ queueIndex: index });
|
|
@@ -2123,7 +3079,8 @@ window.__ModuleLoader__.load({
|
|
|
2123
3079
|
return {
|
|
2124
3080
|
source: store,
|
|
2125
3081
|
playTracks,
|
|
2126
|
-
|
|
3082
|
+
appendTrack,
|
|
3083
|
+
playAll: (tracks, opts) => playTracks(tracks, 0, { ...(opts || {}), shuffleStart: true }),
|
|
2127
3084
|
jumpTo,
|
|
2128
3085
|
toggle,
|
|
2129
3086
|
next: () => advance(false),
|
|
@@ -2233,15 +3190,57 @@ window.__ModuleLoader__.load({
|
|
|
2233
3190
|
|
|
2234
3191
|
/* First-run welcome flow: hero -> taste -> library choice -> starter progress.
|
|
2235
3192
|
* The host owns starter provisioning; this view only reflects its status. */
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
3193
|
+
/* ================================================================
|
|
3194
|
+
* 11d. 设置页(首启欢迎流程的继任者):一个页面收齐「喜欢列表同步 / 推荐口味 / 音乐库」。
|
|
3195
|
+
* - 首启(onboarding 未完成):顶部是真实 Logo 的欢迎区,底部「先随便看看 / 完成」;
|
|
3196
|
+
* 「完成」= 原欢迎流程的收尾(口味 + 曲库选择 → 选 starter 则展示进度 → 进入推荐)。
|
|
3197
|
+
* - 老用户:右上角「设置」进来,改完「保存设置」;section 可让入口直接滚到某个区块。
|
|
3198
|
+
* Logo 走主机 /dsh-music/icon.png(包内真实图标),取不到时退回内嵌 FishLogo。
|
|
3199
|
+
* ================================================================ */
|
|
3200
|
+
function PluginLogo({ size = 160 }) {
|
|
3201
|
+
const [failed, setFailed] = useState(false);
|
|
3202
|
+
if (failed) return h(FishLogo, { size });
|
|
3203
|
+
return h('img', {
|
|
3204
|
+
className: 'dshm-logo', src: resolveUrl('/dsh-music/icon.png'), width: size, height: size,
|
|
3205
|
+
alt: 'dsh-music', draggable: false, decoding: 'async',
|
|
3206
|
+
onError: () => setFailed(true),
|
|
3207
|
+
});
|
|
3208
|
+
}
|
|
3209
|
+
|
|
3210
|
+
function SettingsView({ t, onboarding, useOnboarding, sync, useSync, likedSync, useLikedSync, section, onExit, onRoute, onViewLikes }) {
|
|
3211
|
+
const snap = useOnboarding((st) => st) || {};
|
|
3212
|
+
const firstRun = snap.completed !== true;
|
|
3213
|
+
const taste = snap.taste || {};
|
|
3214
|
+
const [genres, setGenres] = useState(() => (taste.genres || []).slice());
|
|
3215
|
+
const [langs, setLangs] = useState(() => (taste.languages || []).slice());
|
|
3216
|
+
const [mode, setMode] = useState(snap.mode === 'starter' || snap.mode === 'none' ? 'starter' : (snap.completed === true ? 'local' : 'starter'));
|
|
3217
|
+
const [dirPath, setDirPath] = useState(snap.libraryPath || '');
|
|
2243
3218
|
const [busy, setBusy] = useState(false);
|
|
2244
3219
|
const [failed, setFailed] = useState(false);
|
|
3220
|
+
const [savedAt, setSavedAt] = useState(0);
|
|
3221
|
+
const [starterPhase, setStarterPhase] = useState(false);
|
|
3222
|
+
const likedRef = useRef(null);
|
|
3223
|
+
const tasteRef = useRef(null);
|
|
3224
|
+
const libRef = useRef(null);
|
|
3225
|
+
|
|
3226
|
+
/* 喜欢列表区块挂载期间保持登录态(网易云未登录则自动出二维码),离开时停轮询 */
|
|
3227
|
+
useEffect(() => {
|
|
3228
|
+
if (!likedSync) return undefined;
|
|
3229
|
+
if (!likedSync.source.getSnapshot().open) likedSync.open('netease');
|
|
3230
|
+
return () => likedSync.close();
|
|
3231
|
+
}, [likedSync]);
|
|
3232
|
+
/* 入口可指定区块(「我喜欢」页的导入按钮 → 直接滚到喜欢列表同步) */
|
|
3233
|
+
useEffect(() => {
|
|
3234
|
+
const el = section === 'liked' ? likedRef.current : section === 'taste' ? tasteRef.current : section === 'lib' ? libRef.current : null;
|
|
3235
|
+
if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ block: 'start' });
|
|
3236
|
+
}, [section]);
|
|
3237
|
+
/* 首启选了 starter:进度由 onboarding 服务轮询,就绪后刷新曲库 */
|
|
3238
|
+
useEffect(() => {
|
|
3239
|
+
if (!starterPhase || !onboarding) return undefined;
|
|
3240
|
+
const st = onboarding.source.getSnapshot().starter;
|
|
3241
|
+
if (!st || st.status !== 'downloading') onboarding.pollStarter();
|
|
3242
|
+
return undefined;
|
|
3243
|
+
}, [starterPhase, onboarding]);
|
|
2245
3244
|
|
|
2246
3245
|
const genreOptions = ['pop', 'rock', 'electronic', 'hip hop', 'jazz', 'classical', 'folk', 'blues', 'soul', 'funk', 'reggae', 'metal', 'punk', 'country', 'ambient'];
|
|
2247
3246
|
const genreLabel = (g) => 'genre_' + g.replace(/[^a-z]/g, '');
|
|
@@ -2260,29 +3259,42 @@ window.__ModuleLoader__.load({
|
|
|
2260
3259
|
const starterStatus = starter ? starter.status : 'idle';
|
|
2261
3260
|
const starterPct = starterTotal > 0 ? Math.min(100, Math.round((starterDone / starterTotal) * 100)) : (starterStatus === 'ready' ? 100 : 0);
|
|
2262
3261
|
|
|
3262
|
+
function payloadFor() {
|
|
3263
|
+
const payload = { taste: { genres, languages: langs }, libraryMode: mode };
|
|
3264
|
+
if (mode === 'starter') payload.useStarter = true;
|
|
3265
|
+
else if (dirPath.trim()) payload.libraryPath = dirPath.trim();
|
|
3266
|
+
return payload;
|
|
3267
|
+
}
|
|
3268
|
+
/* 首启「完成」:口味 + 曲库一起落盘;选 starter 则进入进度面板 */
|
|
2263
3269
|
async function finish() {
|
|
2264
|
-
/* Preview mode must never touch real state: no POST, no prefs, no route. */
|
|
2265
|
-
if (preview) { onExitPreview(); return; }
|
|
2266
3270
|
if (busy) return;
|
|
2267
3271
|
setBusy(true);
|
|
2268
3272
|
setFailed(false);
|
|
2269
3273
|
try {
|
|
2270
|
-
|
|
2271
|
-
if (mode === 'starter') payload.useStarter = true;
|
|
2272
|
-
else if (dirPath.trim()) payload.libraryPath = dirPath.trim();
|
|
2273
|
-
await onboarding.complete(payload);
|
|
3274
|
+
await onboarding.complete(payloadFor());
|
|
2274
3275
|
} catch (err) {
|
|
2275
3276
|
setFailed(true);
|
|
2276
3277
|
setBusy(false);
|
|
2277
3278
|
return;
|
|
2278
3279
|
}
|
|
2279
3280
|
setBusy(false);
|
|
2280
|
-
if (mode === 'starter')
|
|
3281
|
+
if (mode === 'starter' && starterStatus !== 'ready') setStarterPhase(true);
|
|
2281
3282
|
else onRoute('library');
|
|
2282
3283
|
}
|
|
2283
|
-
|
|
3284
|
+
/* 老用户「保存设置」:口味 / 目录改动落盘(主机对已就绪的 starter 不会重复下载) */
|
|
3285
|
+
async function save() {
|
|
3286
|
+
if (busy) return;
|
|
3287
|
+
setBusy(true);
|
|
3288
|
+
setFailed(false);
|
|
3289
|
+
try {
|
|
3290
|
+
await onboarding.complete(payloadFor());
|
|
3291
|
+
setSavedAt(Date.now());
|
|
3292
|
+
} catch (err) {
|
|
3293
|
+
setFailed(true);
|
|
3294
|
+
}
|
|
3295
|
+
setBusy(false);
|
|
3296
|
+
}
|
|
2284
3297
|
function skipAll() {
|
|
2285
|
-
if (preview) { onExitPreview(); return; }
|
|
2286
3298
|
onRoute('reco');
|
|
2287
3299
|
}
|
|
2288
3300
|
|
|
@@ -2293,40 +3305,6 @@ window.__ModuleLoader__.load({
|
|
|
2293
3305
|
onClick: () => toggle(list, setList, value),
|
|
2294
3306
|
}, label);
|
|
2295
3307
|
|
|
2296
|
-
const dots = h('div', { className: 'dshm-wdots', 'aria-hidden': true },
|
|
2297
|
-
[0, 1, 2, 3].map((i) => h('span', { key: i, className: cx('dshm-wdot', i === step && 'dshm-wdot-on') })));
|
|
2298
|
-
|
|
2299
|
-
const hero = h('div', { className: 'dshm-welcome-hero' },
|
|
2300
|
-
h('div', { className: 'dshm-welcome-glow', 'aria-hidden': true }),
|
|
2301
|
-
h('div', { className: 'dshm-welcome-fish' }, h(FishLogo, { size: 176 })),
|
|
2302
|
-
h('h1', { className: 'dshm-welcome-title' }, t('welcomeTitle')),
|
|
2303
|
-
h('p', { className: 'dshm-welcome-sub' }, t('welcomeSub')),
|
|
2304
|
-
h('div', { className: 'dshm-welcome-actions' },
|
|
2305
|
-
h('button', {
|
|
2306
|
-
type: 'button', className: 'dshm-wbtn dshm-wbtn-primary',
|
|
2307
|
-
onClick: () => setStep(1),
|
|
2308
|
-
}, h(IconSparkles, { size: 16 }), t('welcomeStart')),
|
|
2309
|
-
preview
|
|
2310
|
-
? h('button', { type: 'button', className: 'dshm-wbtn', onClick: onExitPreview }, t('welcomeBack'))
|
|
2311
|
-
: h('button', { type: 'button', className: 'dshm-wbtn', onClick: skipAll }, t('welcomeSkip'))),
|
|
2312
|
-
h('div', { className: 'dshm-welcome-points' },
|
|
2313
|
-
[t('welcomePoint1'), t('welcomePoint2'), t('welcomePoint3')]
|
|
2314
|
-
.map((text, i) => h('div', { className: 'dshm-wpoint', key: i }, h(IconCheck, { size: 13 }), h('span', null, text)))));
|
|
2315
|
-
|
|
2316
|
-
const taste = h('div', { className: 'dshm-welcome-panel' },
|
|
2317
|
-
h('h2', { className: 'dshm-wstep-title' }, t('welcomeTasteTitle')),
|
|
2318
|
-
h('p', { className: 'dshm-wstep-sub' }, t('welcomeTasteSub')),
|
|
2319
|
-
h('div', { className: 'dshm-wgroup' },
|
|
2320
|
-
h('div', { className: 'dshm-wlabel' }, t('welcomeGenres')),
|
|
2321
|
-
h('div', { className: 'dshm-wchips' }, genreOptions.map((g) => tasteChip(g, t(genreLabel(g)), genres, setGenres)))),
|
|
2322
|
-
h('div', { className: 'dshm-wgroup' },
|
|
2323
|
-
h('div', { className: 'dshm-wlabel' }, t('welcomeLanguages')),
|
|
2324
|
-
h('div', { className: 'dshm-wchips' }, langOptions.map((o) => tasteChip(o.value, t(o.key), langs, setLangs)))),
|
|
2325
|
-
h('p', { className: 'dshm-whint' }, t('welcomeTasteNote')),
|
|
2326
|
-
h('div', { className: 'dshm-welcome-actions' },
|
|
2327
|
-
h('button', { type: 'button', className: 'dshm-wbtn', onClick: () => setStep(0) }, t('welcomePrev')),
|
|
2328
|
-
h('button', { type: 'button', className: 'dshm-wbtn dshm-wbtn-primary', onClick: () => setStep(2) }, t('welcomeNext'))));
|
|
2329
|
-
|
|
2330
3308
|
const pickCard = (value, icon, title, body) => h('button', {
|
|
2331
3309
|
key: value, type: 'button',
|
|
2332
3310
|
className: cx('dshm-wcard', mode === value && 'dshm-wcard-on'),
|
|
@@ -2338,9 +3316,31 @@ window.__ModuleLoader__.load({
|
|
|
2338
3316
|
h('span', { className: 'dshm-wcard-title' }, title),
|
|
2339
3317
|
h('span', { className: 'dshm-wcard-body' }, body)));
|
|
2340
3318
|
|
|
2341
|
-
const
|
|
2342
|
-
h('
|
|
2343
|
-
h('
|
|
3319
|
+
const sectionHead = (ref, id, icon, title, sub, extra) => h('div', { className: 'dshm-set-head' },
|
|
3320
|
+
h('span', { className: 'dshm-set-head-icon' }, h(icon, { size: 16 })),
|
|
3321
|
+
h('h2', { className: 'dshm-wstep-title', id }, title),
|
|
3322
|
+
extra || null,
|
|
3323
|
+
sub ? h('p', { className: 'dshm-wstep-sub' }, sub) : null);
|
|
3324
|
+
|
|
3325
|
+
/* ── ① 喜欢列表同步:网易云 / QQ 音乐 / Spotify 各一行手风琴(新用户分步引导) ── */
|
|
3326
|
+
const likedSection = h('section', { className: 'dshm-set-section', ref: likedRef, 'aria-label': t('setLikedTitle') },
|
|
3327
|
+
sectionHead(null, 'dshm-set-liked', IconHeart, t('setLikedTitle'), t('setLikedSub')),
|
|
3328
|
+
h(LikedProviders, { t, sync, useSync, likedSync, useLikedSync, firstRun, onViewLikes }));
|
|
3329
|
+
|
|
3330
|
+
/* ── ② 推荐口味 ── */
|
|
3331
|
+
const tasteSection = h('section', { className: 'dshm-set-section', ref: tasteRef, 'aria-label': t('setTasteTitle') },
|
|
3332
|
+
sectionHead(null, 'dshm-set-taste', IconSparkles, t('setTasteTitle'), t('welcomeTasteSub')),
|
|
3333
|
+
h('div', { className: 'dshm-wgroup' },
|
|
3334
|
+
h('div', { className: 'dshm-wlabel' }, t('welcomeGenres')),
|
|
3335
|
+
h('div', { className: 'dshm-wchips' }, genreOptions.map((g) => tasteChip(g, t(genreLabel(g)), genres, setGenres)))),
|
|
3336
|
+
h('div', { className: 'dshm-wgroup' },
|
|
3337
|
+
h('div', { className: 'dshm-wlabel' }, t('welcomeLanguages')),
|
|
3338
|
+
h('div', { className: 'dshm-wchips' }, langOptions.map((o) => tasteChip(o.value, t(o.key), langs, setLangs)))),
|
|
3339
|
+
h('p', { className: 'dshm-whint' }, t('welcomeTasteNote')));
|
|
3340
|
+
|
|
3341
|
+
/* ── ③ 音乐库 ── */
|
|
3342
|
+
const libSection = h('section', { className: 'dshm-set-section', ref: libRef, 'aria-label': t('setLibTitle') },
|
|
3343
|
+
sectionHead(null, 'dshm-set-lib', IconFolder, t('setLibTitle'), firstRun ? t('welcomeLibSub') : t('setLibSubReturning')),
|
|
2344
3344
|
h('div', { className: 'dshm-wcards' },
|
|
2345
3345
|
pickCard('local', IconFolder, t('welcomeLocalTitle'), t('welcomeLocalBody')),
|
|
2346
3346
|
pickCard('starter', IconSparkles, t('welcomeStarterTitle'), t('welcomeStarterBody'))),
|
|
@@ -2353,16 +3353,10 @@ window.__ModuleLoader__.load({
|
|
|
2353
3353
|
placeholder: t('welcomePathPlaceholder'), value: dirPath,
|
|
2354
3354
|
onChange: (e) => setDirPath(e.target.value),
|
|
2355
3355
|
}),
|
|
2356
|
-
h('p', { className: 'dshm-whint' }, t('welcomePathHint')))
|
|
2357
|
-
failed ? h('p', { className: 'dshm-whint dshm-whint-err' }, t('welcomeSaveFail')) : null,
|
|
2358
|
-
h('div', { className: 'dshm-welcome-actions' },
|
|
2359
|
-
h('button', { type: 'button', className: 'dshm-wbtn', onClick: () => setStep(1) }, t('welcomePrev')),
|
|
2360
|
-
h('button', {
|
|
2361
|
-
type: 'button', className: 'dshm-wbtn dshm-wbtn-primary', disabled: busy,
|
|
2362
|
-
onClick: finish,
|
|
2363
|
-
}, h(IconCheck, { size: 15 }), t('welcomeFinish'))));
|
|
3356
|
+
h('p', { className: 'dshm-whint' }, t('welcomePathHint'))));
|
|
2364
3357
|
|
|
2365
|
-
|
|
3358
|
+
/* ── 首启选 starter 后的进度面板(原欢迎流程第 4 步) ── */
|
|
3359
|
+
const starterPanel = h('div', { className: 'dshm-welcome-panel dshm-set-section' },
|
|
2366
3360
|
h('h2', { className: 'dshm-wstep-title' }, t('welcomeStarterTitle')),
|
|
2367
3361
|
h('p', { className: 'dshm-wstep-sub' },
|
|
2368
3362
|
starterStatus === 'ready' ? t('welcomeStarterReady')
|
|
@@ -2382,17 +3376,59 @@ window.__ModuleLoader__.load({
|
|
|
2382
3376
|
h('div', { className: 'dshm-welcome-actions' },
|
|
2383
3377
|
h('button', {
|
|
2384
3378
|
type: 'button', className: 'dshm-wbtn dshm-wbtn-primary',
|
|
2385
|
-
onClick: () =>
|
|
3379
|
+
onClick: () => onRoute('reco'),
|
|
2386
3380
|
}, h(IconSparkles, { size: 15 }), t('welcomeEnter'))));
|
|
2387
3381
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
:
|
|
3382
|
+
if (firstRun && starterPhase) {
|
|
3383
|
+
return h('div', { className: 'dshm-settings' },
|
|
3384
|
+
h('div', { className: 'dshm-settings-inner dshm-settings-narrow' }, starterPanel));
|
|
3385
|
+
}
|
|
3386
|
+
|
|
3387
|
+
const hero = firstRun
|
|
3388
|
+
? h('div', { className: 'dshm-welcome-hero dshm-set-hero' },
|
|
3389
|
+
h('div', { className: 'dshm-welcome-glow', 'aria-hidden': true }),
|
|
3390
|
+
h('div', { className: 'dshm-welcome-fish' }, h(PluginLogo, { size: 160 })),
|
|
3391
|
+
h('h1', { className: 'dshm-welcome-title' }, t('welcomeTitle')),
|
|
3392
|
+
h('p', { className: 'dshm-welcome-sub' }, t('welcomeSub')),
|
|
3393
|
+
h('div', { className: 'dshm-welcome-points' },
|
|
3394
|
+
[t('welcomePoint1'), t('welcomePoint2'), t('welcomePoint3')]
|
|
3395
|
+
.map((text, i) => h('div', { className: 'dshm-wpoint', key: i }, h(IconCheck, { size: 13 }), h('span', null, text)))),
|
|
3396
|
+
h('p', { className: 'dshm-set-first-note' }, t('settingsFirstRunNote')))
|
|
3397
|
+
: null;
|
|
3398
|
+
|
|
3399
|
+
const statusLine = failed
|
|
3400
|
+
? h('span', { className: 'dshm-whint dshm-whint-err', role: 'alert' }, t('welcomeSaveFail'))
|
|
3401
|
+
: savedAt && Date.now() - savedAt < 4000
|
|
3402
|
+
? h('span', { className: 'dshm-set-saved', role: 'status' }, h(IconCheck, { size: 13 }), t('settingsSaved'))
|
|
3403
|
+
: null;
|
|
3404
|
+
|
|
3405
|
+
const foot = firstRun
|
|
3406
|
+
? h('div', { className: 'dshm-set-foot' },
|
|
3407
|
+
h('button', { type: 'button', className: 'dshm-wbtn', onClick: skipAll }, t('welcomeSkip')),
|
|
3408
|
+
h('button', {
|
|
3409
|
+
type: 'button', className: 'dshm-wbtn dshm-wbtn-primary', disabled: busy,
|
|
3410
|
+
onClick: finish,
|
|
3411
|
+
}, h(IconCheck, { size: 15 }), t('welcomeFinish')),
|
|
3412
|
+
h('span', { className: 'dshm-set-foot-hint' }, t('settingsFinishHint')))
|
|
3413
|
+
: h('div', { className: 'dshm-set-foot' },
|
|
3414
|
+
h('button', { type: 'button', className: 'dshm-wbtn', onClick: onExit }, h(IconChevronUp, { size: 14, style: { transform: 'rotate(-90deg)' } }), t('settingsBack')),
|
|
3415
|
+
statusLine,
|
|
3416
|
+
h('button', {
|
|
3417
|
+
type: 'button', className: 'dshm-wbtn dshm-wbtn-primary', disabled: busy,
|
|
3418
|
+
onClick: save,
|
|
3419
|
+
}, h(IconCheck, { size: 15 }), t('settingsSave')));
|
|
3420
|
+
|
|
3421
|
+
return h('div', { className: cx('dshm-settings', firstRun && 'dshm-settings-first') },
|
|
3422
|
+
h('div', { className: 'dshm-settings-inner' },
|
|
3423
|
+
hero,
|
|
3424
|
+
!firstRun ? h('div', { className: 'dshm-set-top' },
|
|
3425
|
+
h('div', { className: 'dshm-set-top-title' }, h(IconGear, { size: 16 }), h('h1', { className: 'dshm-wstep-title' }, t('settingsTitle'))),
|
|
3426
|
+
h('span', { className: 'dshm-count' }, t('settingsHint'))) : null,
|
|
3427
|
+
h('div', { className: 'dshm-set-sections' },
|
|
3428
|
+
likedSection,
|
|
3429
|
+
tasteSection,
|
|
3430
|
+
libSection),
|
|
3431
|
+
foot));
|
|
2396
3432
|
}
|
|
2397
3433
|
|
|
2398
3434
|
function Slider({ value, onChange, label, disabled, className }) {
|
|
@@ -2462,31 +3498,31 @@ window.__ModuleLoader__.load({
|
|
|
2462
3498
|
return source || '';
|
|
2463
3499
|
}
|
|
2464
3500
|
|
|
2465
|
-
function LikeButton({ t, item, likes, useLikes }) {
|
|
3501
|
+
function LikeButton({ t, item, likes, useLikes, size = 15, className }) {
|
|
2466
3502
|
const liked = useLikes((st) => !!st.keys[likeKey(item)]);
|
|
2467
3503
|
return h('button', {
|
|
2468
3504
|
type: 'button',
|
|
2469
|
-
className: cx('dshm-like-btn', liked && 'dshm-like-btn-on'),
|
|
3505
|
+
className: cx('dshm-like-btn', liked && 'dshm-like-btn-on', className),
|
|
2470
3506
|
'aria-label': liked ? t('unlikeBtn') : t('likeBtn'),
|
|
2471
3507
|
'aria-pressed': !!liked,
|
|
2472
3508
|
title: liked ? t('likedBtn') : t('likeBtn'),
|
|
2473
3509
|
onClick: (e) => { e.stopPropagation(); likes.toggle(item, !liked); },
|
|
2474
|
-
}, h(IconHeart, { size
|
|
3510
|
+
}, h(IconHeart, { size, style: liked ? { fill: 'currentColor' } : undefined }));
|
|
2475
3511
|
}
|
|
2476
3512
|
|
|
2477
|
-
function DislikeButton({ t, item, likes, useLikes }) {
|
|
3513
|
+
function DislikeButton({ t, item, likes, useLikes, size = 15, className }) {
|
|
2478
3514
|
const disliked = useLikes((st) => !!((st.dislikes || {})[likeKey(item)]));
|
|
2479
3515
|
return h('button', {
|
|
2480
3516
|
type: 'button',
|
|
2481
|
-
className: cx('dshm-like-btn', 'dshm-dislike-btn', disliked && 'dshm-dislike-btn-on'),
|
|
3517
|
+
className: cx('dshm-like-btn', 'dshm-dislike-btn', disliked && 'dshm-dislike-btn-on', className),
|
|
2482
3518
|
'aria-label': disliked ? t('undislikeBtn') : t('dislikeBtn'),
|
|
2483
3519
|
'aria-pressed': !!disliked,
|
|
2484
3520
|
title: disliked ? t('undislikedBtn') : t('dislikeBtn'),
|
|
2485
3521
|
onClick: (e) => { e.stopPropagation(); likes.setDislike(item, !disliked); },
|
|
2486
|
-
}, h(IconThumbDown, { size
|
|
3522
|
+
}, h(IconThumbDown, { size, style: disliked ? { fill: 'currentColor' } : undefined }));
|
|
2487
3523
|
}
|
|
2488
3524
|
|
|
2489
|
-
function TrackRow({ track, index, isCurrent, playing, onPlay, onDelete, onReveal, onOpenArtist, likes, useLikes, t, muted }) {
|
|
3525
|
+
function TrackRow({ track, index, isCurrent, playing, onPlay, onDelete, onReveal, onOpenArtist, likes, useLikes, t, muted, pending, onAdd }) {
|
|
2490
3526
|
return h('div', {
|
|
2491
3527
|
className: cx('dshm-row', isCurrent && 'dshm-row-current', muted && 'dshm-row-off'),
|
|
2492
3528
|
role: 'button', tabIndex: 0,
|
|
@@ -2509,20 +3545,39 @@ window.__ModuleLoader__.load({
|
|
|
2509
3545
|
onClick: (e) => { e.stopPropagation(); onOpenArtist(track.artist); },
|
|
2510
3546
|
}, track.artist)
|
|
2511
3547
|
: (track.artist || t('unknownArtist')),
|
|
2512
|
-
track.album ? ' · ' + track.album : ''
|
|
3548
|
+
track.album ? ' · ' + track.album : '',
|
|
3549
|
+
track.sources
|
|
3550
|
+
? h('span', { className: 'dshm-src-chips' }, Object.keys(track.sources).map((p) => {
|
|
3551
|
+
const label = p === 'netease' ? t('srcNetease') : p === 'qq' ? t('srcQq') : p;
|
|
3552
|
+
return h('span', { key: p, className: 'dshm-src-chip dshm-src-' + p, title: label }, label);
|
|
3553
|
+
}))
|
|
3554
|
+
: null)),
|
|
2513
3555
|
h('span', { className: 'dshm-row-dur' }, formatTime(track.duration)),
|
|
2514
3556
|
likes ? h(LikeButton, { t, item: track, likes, useLikes }) : null,
|
|
2515
3557
|
likes ? h(DislikeButton, { t, item: track, likes, useLikes }) : null,
|
|
3558
|
+
/* 十三期:后台扫描结果决定样式——found → 实心「可入库」药丸;none → 虚线淡色(点了会再找一次);未扫描 → 普通图标 */
|
|
3559
|
+
onAdd && track.inLibrary === false
|
|
3560
|
+
? (() => {
|
|
3561
|
+
const addState = track.source ? (track.source.status === 'found' && track.source.hit ? 'ready' : 'none') : 'unknown';
|
|
3562
|
+
return h(IconButton, {
|
|
3563
|
+
key: 'add',
|
|
3564
|
+
label: t(addState === 'ready' ? 'addReady' : addState === 'none' ? 'addNone' : 'addMissing'),
|
|
3565
|
+
className: cx('dshm-row-add', addState === 'ready' && 'dshm-row-add-ready', addState === 'none' && 'dshm-row-add-none'),
|
|
3566
|
+
onClick: (e) => { e.stopPropagation(); onAdd(track); },
|
|
3567
|
+
}, h(IconDownload, { size: addState === 'ready' ? 12 : 14 }), addState === 'ready' ? h('span', { className: 'dshm-row-add-text' }, t('addReadyShort')) : null);
|
|
3568
|
+
})()
|
|
3569
|
+
: null,
|
|
2516
3570
|
onDelete ? h('span', { className: 'dshm-row-actions', onClick: (e) => e.stopPropagation() },
|
|
2517
3571
|
h(IconButton, { label: t('revealTrack'), onClick: (e) => { e.stopPropagation(); onReveal(track); } }, h(IconDisc, { size: 14 })),
|
|
2518
3572
|
h(IconButton, { label: t('deleteTrack'), onClick: (e) => { e.stopPropagation(); onDelete(track); } }, h(IconClose, { size: 14 }))) : null,
|
|
2519
|
-
h('span', { className: 'dshm-row-play', 'aria-hidden': true },
|
|
3573
|
+
h('span', { className: cx('dshm-row-play', pending && 'dshm-playround-busy'), 'aria-hidden': true },
|
|
3574
|
+
pending ? h('span', { className: 'dshm-spin' }) : h(IconPlay, { size: 15 })));
|
|
2520
3575
|
}
|
|
2521
3576
|
|
|
2522
3577
|
/* ================================================================
|
|
2523
3578
|
* 9. Library view — search, grouping, play-all / shuffle
|
|
2524
3579
|
* ================================================================ */
|
|
2525
|
-
function LibraryView({ t, player, library, sync, download, preview, likes, openArtistPage, artistImages, useSync, useDownload, useLibrary, usePlayer, useLikes, useArtistImages }) {
|
|
3580
|
+
function LibraryView({ t, player, library, sync, download, preview, likes, openArtistPage, artistImages, likedSync, openSettings, useSync, useDownload, useLibrary, usePlayer, useLikes, useArtistImages, tabWish, onTabWishDone }) {
|
|
2526
3581
|
const status = useLibrary((s) => s.status);
|
|
2527
3582
|
const tracks = useLibrary((s) => s.tracks);
|
|
2528
3583
|
const error = useLibrary((s) => s.error);
|
|
@@ -2531,28 +3586,49 @@ window.__ModuleLoader__.load({
|
|
|
2531
3586
|
const [query, setQuery] = useState('');
|
|
2532
3587
|
const [searchState, setSearchState] = useState({ status: 'idle', local: [], remote: [] });
|
|
2533
3588
|
const [groupBy, setGroupBy] = useState('none');
|
|
2534
|
-
const [libTab, setLibTab] = useState('library');
|
|
3589
|
+
const [libTab, setLibTab] = useState(tabWish || 'library');
|
|
3590
|
+
/* 入口指定子页(设置页「查看我喜欢」):挂载后或 wish 变化时切过去,用完即清 */
|
|
3591
|
+
useEffect(() => {
|
|
3592
|
+
if (!tabWish) return;
|
|
3593
|
+
setLibTab(tabWish);
|
|
3594
|
+
if (onTabWishDone) onTabWishDone();
|
|
3595
|
+
}, [tabWish]);
|
|
2535
3596
|
const [rowError, setRowError] = useState('');
|
|
2536
3597
|
const [playNotice, setPlayNotice] = useState('');
|
|
2537
3598
|
const searchRef = useRef(null);
|
|
2538
3599
|
const shuffle = usePlayer((s) => s.shuffle);
|
|
2539
3600
|
const repeat = usePlayer((s) => s.repeat);
|
|
2540
3601
|
const mode = modeMeta(t, shuffle, repeat);
|
|
2541
|
-
const syncAvail = useSync ? useSync((st) => st.available) : null;
|
|
2542
|
-
const syncHint = useSync ? useSync((st) => st.hint) : null;
|
|
2543
|
-
const syncUsable = syncAvail !== false;
|
|
2544
3602
|
const syncState = useSync ? useSync((st) => st.phase) : 'idle';
|
|
2545
3603
|
const likeItems = useLikes((st) => st.items || []);
|
|
2546
3604
|
/* Liked rows reuse the library row layout; host resolves trackId/audioUrl
|
|
2547
3605
|
* for everything inside the library, so those rows are directly playable. */
|
|
2548
3606
|
const likedTracks = useMemo(() => likeItems.map((it) => ({
|
|
2549
3607
|
id: it.trackId || ('liked::' + it.key),
|
|
3608
|
+
key: it.key,
|
|
2550
3609
|
title: it.title, artist: it.artist, album: it.album,
|
|
2551
3610
|
duration: it.durationMs ? Math.round(it.durationMs / 1000) : (it.duration || 0),
|
|
2552
3611
|
audioUrl: it.audioUrl || null, coverUrl: it.coverUrl || null,
|
|
2553
3612
|
muted: !it.audioUrl,
|
|
3613
|
+
inLibrary: it.inLibrary == null ? !!it.audioUrl : !!it.inLibrary,
|
|
3614
|
+
/* 来自网易云 / QQ 音乐导入的条目带 sources,行内显示来源小标 */
|
|
3615
|
+
sources: it.sources && Object.keys(it.sources).length ? it.sources : null,
|
|
3616
|
+
/* 后台音源扫描结果:{ status: 'found'|'none', hit } */
|
|
3617
|
+
source: it.source && typeof it.source === 'object' ? it.source : null,
|
|
2554
3618
|
})), [likeItems]);
|
|
3619
|
+
const likesScan = useLikes((st) => st.scan) || null;
|
|
3620
|
+
/* 扫描进行中每 5 s 刷一次列表(本地读,便宜),让「可入库」按钮陆续亮起来 */
|
|
3621
|
+
const scanTimer = useRef(null);
|
|
3622
|
+
const scanRunning = !!(likesScan && likesScan.running);
|
|
3623
|
+
useEffect(() => {
|
|
3624
|
+
if (libTab !== 'likes' || !scanRunning || typeof setTimeout !== 'function') return undefined;
|
|
3625
|
+
const tickScan = () => { scanTimer.current = null; likes.load(); };
|
|
3626
|
+
scanTimer.current = setTimeout(tickScan, 5000);
|
|
3627
|
+
return () => { if (scanTimer.current) clearTimeout(scanTimer.current); scanTimer.current = null; };
|
|
3628
|
+
}, [libTab, scanRunning, likes]);
|
|
2555
3629
|
const likedPlayable = useMemo(() => likedTracks.filter((tr) => !!tr.audioUrl), [likedTracks]);
|
|
3630
|
+
/* 导入但还没入库的数量(行尾给「入库」按钮) */
|
|
3631
|
+
const likedMissing = useMemo(() => likedTracks.filter((tr) => !tr.inLibrary).length, [likedTracks]);
|
|
2556
3632
|
|
|
2557
3633
|
/* Backend search (local filter + MusicBrainz completion), debounced.
|
|
2558
3634
|
* Empty query keeps the pure client-side browse below. */
|
|
@@ -2635,12 +3711,107 @@ window.__ModuleLoader__.load({
|
|
|
2635
3711
|
try { setRowError(''); await library.reveal(track.id); }
|
|
2636
3712
|
catch (err) { setRowError((err && err.message) || t('deleteFailed')); }
|
|
2637
3713
|
}
|
|
3714
|
+
/* 导入的 ♥ 还没有本地音频:点一下 = 先入库(走核实下载管线),而不是只报「无法播放」 */
|
|
3715
|
+
const knownHit = (item) => (item && item.source && item.source.status === 'found' && item.source.hit ? item.source.hit : null);
|
|
2638
3716
|
function playLiked(track) {
|
|
2639
|
-
if (!track.audioUrl) {
|
|
3717
|
+
if (!track.audioUrl) {
|
|
3718
|
+
if (track.inLibrary === false && download) {
|
|
3719
|
+
/* 后台已找到可靠音源 → 直接置顶入库,不再当场搜(也就不会"没找到") */
|
|
3720
|
+
if (!knownHit(track)) setPlayNotice(fmt(t('addMissingSearching'), { title: track.title }));
|
|
3721
|
+
addMissing(track, { front: true });
|
|
3722
|
+
return;
|
|
3723
|
+
}
|
|
3724
|
+
setPlayNotice(t('topUnplayable'));
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
2640
3727
|
setPlayNotice('');
|
|
2641
3728
|
const idx = likedPlayable.indexOf(track);
|
|
2642
3729
|
player.playTracks(likedPlayable, idx >= 0 ? idx : 0);
|
|
2643
3730
|
}
|
|
3731
|
+
/* 「入库」:导入的喜欢条目还不在本地 → 曲库搜索找带核实记录的候选,交给既有下载管线
|
|
3732
|
+
* (每批 ≤20、串行、先核实再下载,只写 ~/Music/dsh-music)。歌名对不上就不下载。 */
|
|
3733
|
+
/* 匹配用繁→简补充(MusicBrainz 中文条目常是港台繁体;t2s.js 的常用表缺 費/麗/華 之类)——只用于打分,不改展示 */
|
|
3734
|
+
const T2S_MATCH = { '傑':'杰','劉':'刘','吳':'吴','嚴':'严','場':'场','塗':'涂','孫':'孙','島':'岛','嶼':'屿','帥':'帅','師':'师','擊':'击','東':'东','楊':'杨','橋':'桥','歐':'欧','湯':'汤','溫':'温','滅':'灭','澤':'泽','無':'无','獨':'独','盧':'卢','竇':'窦','簡':'简','練':'练','縉':'缙','繆':'缪','華':'华','萬':'万','葉':'叶','蔣':'蒋','蕭':'萧','蘇':'苏','蘭':'兰','衛':'卫','訓':'训','許':'许','諸':'诸','譚':'谭','費':'费','賀':'贺','賈':'贾','賴':'赖','趙':'赵','軍':'军','連':'连','進':'进','達':'达','遲':'迟','鄒':'邹','鄧':'邓','鄭':'郑','錢':'钱','鍾':'钟','閔':'闵','閻':'阎','陰':'阴','陸':'陆','陽':'阳','雲':'云','霑':'沾','鞏':'巩','韓':'韩','響':'响','頔':'𬱖','顏':'颜','顧':'顾','風':'风','馬':'马','馮':'冯','麗':'丽','黃':'黄','龍':'龙','龐':'庞','龔':'龚' };
|
|
3735
|
+
const normKey = (x) => normalizeZh(String(x || '')).replace(/[\u3400-\u9fff]/g, (c) => T2S_MATCH[c] || c).toLowerCase().replace(/\s+/g, '');
|
|
3736
|
+
/* 候选打分:歌名完全一致 > 包含;同分看歌手覆盖数(导入条目的歌手出现在候选歌手里的个数)。
|
|
3737
|
+
* 搜索结果里翻唱/同名曲很多(「千里之外」会混着 費玉清 单曲、刘芳 翻唱),不按歌手挑会入错。 */
|
|
3738
|
+
/* 当场找音源(后台没扫到的):歌名一致 + 歌手至少对上一个才要(与主机 source-scan.js 同一规则)——翻唱 / 同名歌不算 */
|
|
3739
|
+
function pickMissingHit(item, remote) {
|
|
3740
|
+
const want = normKey(item.title);
|
|
3741
|
+
const artists = String(item.artist || '').split(/\s*(?:\/|、|,|,|;|;|&|\+|feat\.?|ft\.?)\s*/i).map(normKey).filter((x) => x.length > 0);
|
|
3742
|
+
const unknownArtist = artists.length === 0 || /^(未知歌手|未知|unknown( artist)?|artist|群星|暂无|无|-)?$/i.test(String(item.artist || '').trim());
|
|
3743
|
+
const covers = (x) => artists.reduce((n, a) => n + (a && normKey(x.artist).includes(a) ? 1 : 0), 0);
|
|
3744
|
+
const near = (a, b) => a && b && a.length >= b.length * 0.8 && b.length >= a.length * 0.8;
|
|
3745
|
+
let best = null;
|
|
3746
|
+
for (const x of remote) {
|
|
3747
|
+
if (!x || !x.verification || x.kind === 'artist' || !x.title) continue;
|
|
3748
|
+
const nt = normKey(x.title);
|
|
3749
|
+
const titleScore = nt === want ? 3 : (near(nt, want) && (nt.includes(want) || want.includes(nt))) ? 1 : 0;
|
|
3750
|
+
if (!titleScore) continue;
|
|
3751
|
+
const c = covers(x);
|
|
3752
|
+
if (!unknownArtist && c === 0) continue;
|
|
3753
|
+
const score = titleScore * 10 + (unknownArtist ? 1 : c + (c === artists.length ? 1 : 0));
|
|
3754
|
+
if (!best || score > best.score) best = { x, score };
|
|
3755
|
+
}
|
|
3756
|
+
return best ? best.x : null;
|
|
3757
|
+
}
|
|
3758
|
+
async function addMissing(item, opts) {
|
|
3759
|
+
try {
|
|
3760
|
+
/* 后台扫描已命中的直接用(不联网);否则当场搜一次(none/未扫描的条目) */
|
|
3761
|
+
const hit = knownHit(item);
|
|
3762
|
+
if (!hit) {
|
|
3763
|
+
const r = await library.searchRemote((item.artist ? item.artist + ' ' : '') + item.title);
|
|
3764
|
+
const remote = (r && Array.isArray(r.remote) ? r.remote : []);
|
|
3765
|
+
const found = pickMissingHit(item, remote);
|
|
3766
|
+
if (!found) { setPlayNotice(fmt(t('addMissingNone'), { title: item.title })); return null; }
|
|
3767
|
+
return enqueueHit(item, found, opts);
|
|
3768
|
+
}
|
|
3769
|
+
return enqueueHit(item, hit, opts);
|
|
3770
|
+
} catch (err) {
|
|
3771
|
+
setPlayNotice((err && err.message) || t('downloadError'));
|
|
3772
|
+
return null;
|
|
3773
|
+
}
|
|
3774
|
+
}
|
|
3775
|
+
/* 单首点击 → front:置顶到待下载列表(正在下载的那首相让不了);批量 → 排队尾 */
|
|
3776
|
+
async function enqueueHit(item, hit, opts) {
|
|
3777
|
+
const ok = await download.start([hit], opts);
|
|
3778
|
+
setPlayNotice(ok
|
|
3779
|
+
? (opts && opts.front ? fmt(t('addMissingQueuedFront'), { title: item.title }) : t('addMissingQueued'))
|
|
3780
|
+
: (download.source.getSnapshot().error || t('downloadError')));
|
|
3781
|
+
return ok ? hit : null;
|
|
3782
|
+
}
|
|
3783
|
+
/* 「入库 N 首」:后台已命中的直接拿(不联网);其余逐个找核实候选(最多当场找 30 首),凑一批(≤20)一起交给下载队列 */
|
|
3784
|
+
const [adding, setAdding] = useState(false);
|
|
3785
|
+
async function addMissingBatch() {
|
|
3786
|
+
if (adding) return;
|
|
3787
|
+
const missing = likedTracks.filter((tr) => !tr.inLibrary);
|
|
3788
|
+
const items = missing.slice(0, 60);
|
|
3789
|
+
if (!items.length) return;
|
|
3790
|
+
setAdding(true);
|
|
3791
|
+
setPlayNotice(t('addMissingSearchingBatch'));
|
|
3792
|
+
const hits = [];
|
|
3793
|
+
let searched = 0;
|
|
3794
|
+
try {
|
|
3795
|
+
for (const item of items) {
|
|
3796
|
+
if (hits.length >= 20) break;
|
|
3797
|
+
const known = knownHit(item);
|
|
3798
|
+
if (known) { hits.push(known); continue; }
|
|
3799
|
+
if (searched >= 30) continue;
|
|
3800
|
+
searched += 1;
|
|
3801
|
+
const r = await library.searchRemote((item.artist ? item.artist + ' ' : '') + item.title).catch(() => null);
|
|
3802
|
+
const hit = pickMissingHit(item, (r && Array.isArray(r.remote) ? r.remote : []));
|
|
3803
|
+
if (hit) hits.push(hit);
|
|
3804
|
+
}
|
|
3805
|
+
} finally {
|
|
3806
|
+
setAdding(false);
|
|
3807
|
+
}
|
|
3808
|
+
if (!hits.length) { setPlayNotice(t('addMissingNoneBatch')); return; }
|
|
3809
|
+
const ok = await download.start(hits);
|
|
3810
|
+
const miss = items.length - hits.length;
|
|
3811
|
+
setPlayNotice(ok
|
|
3812
|
+
? fmt(t('addMissingBatchQueued'), { n: hits.length, m: miss })
|
|
3813
|
+
: (download.source.getSnapshot().error || t('downloadError')));
|
|
3814
|
+
}
|
|
2644
3815
|
|
|
2645
3816
|
const renderRow = (tr, i) => h(TrackRow, {
|
|
2646
3817
|
key: tr.id || i, track: tr, index: i,
|
|
@@ -2691,10 +3862,15 @@ window.__ModuleLoader__.load({
|
|
|
2691
3862
|
? h(EmptyState, {
|
|
2692
3863
|
icon: h(IconHeart, { size: 28 }),
|
|
2693
3864
|
title: t('likesEmptyTitle'), body: t('likesEmptyBody'),
|
|
2694
|
-
}, h('
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
3865
|
+
}, h('div', { className: 'dshm-state-actions' },
|
|
3866
|
+
likedSync ? h('button', {
|
|
3867
|
+
type: 'button', className: 'dshm-chipbtn dshm-chipbtn-primary',
|
|
3868
|
+
onClick: () => openSettings('liked'),
|
|
3869
|
+
}, h(IconImport, { size: 14 }), t('importBtn')) : null,
|
|
3870
|
+
h('button', {
|
|
3871
|
+
type: 'button', className: cx('dshm-chipbtn', likedSync && 'dshm-chipbtn-plain'),
|
|
3872
|
+
onClick: () => setLibTab('library'),
|
|
3873
|
+
}, h(IconNote, { size: 14 }), t('goLibrary'))))
|
|
2698
3874
|
: likedFiltered.length === 0
|
|
2699
3875
|
? h(EmptyState, {
|
|
2700
3876
|
icon: h(IconSearch, { size: 28 }),
|
|
@@ -2705,6 +3881,8 @@ window.__ModuleLoader__.load({
|
|
|
2705
3881
|
key: tr.id || ('liked' + i), track: tr, index: i,
|
|
2706
3882
|
isCurrent: currentId === tr.id, playing, muted: tr.muted,
|
|
2707
3883
|
onPlay: playLiked, onOpenArtist: openArtistPage, likes, useLikes, t,
|
|
3884
|
+
/* 行尾「入库」只给「导入且不在曲库」的条目(有 audioUrl 的已在曲库) */
|
|
3885
|
+
onAdd: download && !tr.inLibrary && !tr.audioUrl ? (tr2) => addMissing(tr2, { front: true }) : null,
|
|
2708
3886
|
})));
|
|
2709
3887
|
} else if (status === 'loading' && tracks.length === 0) {
|
|
2710
3888
|
content = h('div', { className: 'dshm-list' }, h(SkeletonRows));
|
|
@@ -2728,13 +3906,11 @@ window.__ModuleLoader__.load({
|
|
|
2728
3906
|
type: 'button', className: 'dshm-chipbtn',
|
|
2729
3907
|
onClick: () => library.rescan(),
|
|
2730
3908
|
}, h(IconRefresh, { size: 14 }), t('emptyRescanCta')),
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
className:
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
onClick: () => sync.start(),
|
|
2737
|
-
}, h(IconRefresh, { size: 14, className: syncState === 'running' ? 'dshm-spin' : undefined }), t('syncOptional')) : null),
|
|
3909
|
+
/* Spotify 同步 / 导入喜欢列表 都在「设置」里 */
|
|
3910
|
+
h('button', {
|
|
3911
|
+
type: 'button', className: 'dshm-chipbtn', title: t('settingsHint'),
|
|
3912
|
+
onClick: () => openSettings('liked'),
|
|
3913
|
+
}, h(IconGear, { size: 14 }), t('settingsTitle'))),
|
|
2738
3914
|
h('div', { className: 'dshm-empty-dirs' },
|
|
2739
3915
|
h('div', { className: 'dshm-empty-dirs-head' }, t('emptyAddDirHint')),
|
|
2740
3916
|
['~/Music/dsh-music', '~/Music/spotify-liked', '~/Music/Music/Media.localized']
|
|
@@ -2784,7 +3960,27 @@ window.__ModuleLoader__.load({
|
|
|
2784
3960
|
onClick: () => setLibTab('library'),
|
|
2785
3961
|
}, '← ' + t('favsBack')),
|
|
2786
3962
|
h('span', { className: 'dshm-favs-title', style: { marginLeft: '4px' } }, t('libTabLikes')),
|
|
2787
|
-
h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit'))
|
|
3963
|
+
h('span', { className: 'dshm-count' }, likeItems.length + ' ' + t('tracksUnit')),
|
|
3964
|
+
likedMissing > 0
|
|
3965
|
+
? h('span', { className: 'dshm-missing-chip', title: t('addMissingHint'), role: 'status' }, fmt(t('likesMissingCount'), { n: likedMissing }))
|
|
3966
|
+
: null,
|
|
3967
|
+
/* 后台找音源进行中:进度 chip(done 已处理 / found 已找到;列表会自动刷新,找到的行会亮起「可入库」) */
|
|
3968
|
+
scanRunning
|
|
3969
|
+
? h('span', { className: 'dshm-missing-chip dshm-scan-chip', title: t('scanHint'), role: 'status' },
|
|
3970
|
+
h(IconRefresh, { size: 11, className: 'dshm-spin' }),
|
|
3971
|
+
fmt(t('scanProgress'), { done: likesScan.done || 0, total: (likesScan.done || 0) + (likesScan.pending || 0), found: likesScan.found || 0 }))
|
|
3972
|
+
: null,
|
|
3973
|
+
likedMissing > 0 && download
|
|
3974
|
+
? h('button', {
|
|
3975
|
+
type: 'button', className: 'dshm-chipbtn', disabled: adding, title: t('addMissingHint'),
|
|
3976
|
+
onClick: () => addMissingBatch(),
|
|
3977
|
+
}, adding ? h(IconRefresh, { size: 12, className: 'dshm-spin' }) : h(IconDownload, { size: 12 }),
|
|
3978
|
+
fmt(t('addMissingBatch'), { n: Math.min(20, likedMissing) }))
|
|
3979
|
+
: null,
|
|
3980
|
+
likedSync ? h('button', {
|
|
3981
|
+
type: 'button', className: 'dshm-chipbtn', style: { marginLeft: 'auto' },
|
|
3982
|
+
title: t('importBtnHint'), onClick: () => openSettings('liked'),
|
|
3983
|
+
}, h(IconGear, { size: 13 }), t('setLikedTitle')) : null)
|
|
2788
3984
|
: h('div', { className: 'dshm-favs' },
|
|
2789
3985
|
h('div', { className: 'dshm-favs-head' },
|
|
2790
3986
|
h(IconHeart, { size: 14, style: { color: 'var(--dsw-alias-state-error-primary)' } }),
|
|
@@ -2843,13 +4039,13 @@ window.__ModuleLoader__.load({
|
|
|
2843
4039
|
'aria-label': mode.label, title: mode.hint + ' · ' + t('modeCycleHint'),
|
|
2844
4040
|
onClick: () => player.cycleMode(),
|
|
2845
4041
|
}, h(mode.icon, { size: 14 })),
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
4042
|
+
/* Spotify 同步 / 喜欢列表导入 都收在「设置」里;同步进行中给一个回到设置页的状态钮 */
|
|
4043
|
+
sync && syncState === 'running'
|
|
4044
|
+
? h('button', {
|
|
4045
|
+
type: 'button', className: 'dshm-chipbtn', title: t('settingsHint'),
|
|
4046
|
+
onClick: () => openSettings('liked'),
|
|
4047
|
+
}, h(IconRefresh, { size: 13, className: 'dshm-spin' }), t('syncing'))
|
|
4048
|
+
: null,
|
|
2853
4049
|
h('span', { className: 'dshm-count', style: { marginLeft: 'auto' } },
|
|
2854
4050
|
busy && tracks.length === 0 ? t('rescanning')
|
|
2855
4051
|
: (libTab === 'likes' ? likedFiltered.length : shownList.length) + ' ' + t('tracksUnit'))),
|
|
@@ -2862,7 +4058,7 @@ window.__ModuleLoader__.load({
|
|
|
2862
4058
|
/* ================================================================
|
|
2863
4059
|
* 10. Now-playing view — hero + transport + queue
|
|
2864
4060
|
* ================================================================ */
|
|
2865
|
-
function NowPlayingView({ t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages }) {
|
|
4061
|
+
function NowPlayingView({ t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages, likes, useLikes }) {
|
|
2866
4062
|
const track = usePlayer((s) => s.track);
|
|
2867
4063
|
const playing = usePlayer((s) => s.playing);
|
|
2868
4064
|
const position = usePlayer((s) => s.position);
|
|
@@ -2902,6 +4098,10 @@ window.__ModuleLoader__.load({
|
|
|
2902
4098
|
h(ArtistAvatar, { name: track.artist || '', size: 18, service: artistImages, useArtistImages }),
|
|
2903
4099
|
h('span', null, track.artist || t('unknownArtist'))),
|
|
2904
4100
|
track.album ? ' · ' + track.album : ''),
|
|
4101
|
+
/* ♥ / 👎:和迷你条、曲库行同一套语义;放大一号,放在歌手行下面 */
|
|
4102
|
+
likes ? h('div', { className: 'dshm-now-actions', role: 'group', 'aria-label': t('nowLikesLabel') },
|
|
4103
|
+
h(LikeButton, { t, item: track, likes, useLikes, size: 18, className: 'dshm-now-like' }),
|
|
4104
|
+
h(DislikeButton, { t, item: track, likes, useLikes, size: 18, className: 'dshm-now-like' })) : null,
|
|
2905
4105
|
error ? h('div', { className: 'dshm-errorline', role: 'alert' }, h(IconAlert, { size: 15 }), error) : null,
|
|
2906
4106
|
h('div', { className: 'dshm-seekrow' },
|
|
2907
4107
|
h('span', { className: 'dshm-time' }, formatTime(position)),
|
|
@@ -2945,34 +4145,9 @@ window.__ModuleLoader__.load({
|
|
|
2945
4145
|
/* ================================================================
|
|
2946
4146
|
* 11. Recommendations view (S3 live): batch cards + download queue
|
|
2947
4147
|
* ================================================================ */
|
|
2948
|
-
function DownloadPanel({ t, download, useDownload }) {
|
|
2949
|
-
const s = useDownload((st) => st);
|
|
2950
|
-
if (!s.running && s.items.length === 0 && !s.error) return null;
|
|
2951
|
-
const anyOk = s.items.some((it) => it.status === 'ok');
|
|
2952
|
-
return h('div', { className: 'dshm-dl' },
|
|
2953
|
-
h('div', { className: 'dshm-asec-title' },
|
|
2954
|
-
h(IconDownload, { size: 13 }), t('downloadTitle'),
|
|
2955
|
-
s.running ? h('span', { className: 'dshm-count' }, s.done + ' / ' + s.total) : null),
|
|
2956
|
-
s.total > 0 ? h('div', { className: 'dshm-dl-bar', 'aria-hidden': true },
|
|
2957
|
-
h('div', { style: { width: Math.round((s.done / s.total) * 100) + '%' } })) : null,
|
|
2958
|
-
s.error
|
|
2959
|
-
? h('div', { className: 'dshm-errorline', role: 'alert' }, h(IconAlert, { size: 14 }), t('downloadError') + ':' + s.error)
|
|
2960
|
-
: null,
|
|
2961
|
-
s.items.map((it, i) => h('div', { className: 'dshm-dl-row', key: i },
|
|
2962
|
-
h('span', { className: cx('dshm-dl-dot', it.status === 'ok' && 'dshm-dl-ok', it.status === 'fail' && 'dshm-dl-fail') }),
|
|
2963
|
-
h('span', { className: 'dshm-ellipsis', style: { flex: 1 } },
|
|
2964
|
-
(it.artist || '') + ' - ' + (it.title || '')),
|
|
2965
|
-
h('span', { className: 'dshm-dl-status' },
|
|
2966
|
-
it.status === 'ok' ? t('downloadDone')
|
|
2967
|
-
: it.status === 'fail' ? t('downloadFail')
|
|
2968
|
-
: t('downloading')),
|
|
2969
|
-
it.status === 'fail' && it.note ? h('span', { className: 'dshm-sim-chip-reason' }, it.note) : null)),
|
|
2970
|
-
!s.running && anyOk ? h('div', { className: 'dshm-lyrics-hint' }, t('downloadPlay')) : null);
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
4148
|
/* V3 helpers: shared play-or-preview flow (preview never enters the
|
|
2974
4149
|
* library; only ♥-like downloads it — the Host handles that on like). */
|
|
2975
|
-
function playSong(item, player, tracks, preview, setNotice, t) {
|
|
4150
|
+
function playSong(item, player, tracks, preview, setNotice, t, warm) {
|
|
2976
4151
|
const local = (item.trackId && tracks.find((tr) => tr.id === item.trackId))
|
|
2977
4152
|
|| tracks.find((tr) =>
|
|
2978
4153
|
normalizeZh(tr.artist) === normalizeZh(item.artist) &&
|
|
@@ -2983,6 +4158,14 @@ window.__ModuleLoader__.load({
|
|
|
2983
4158
|
return;
|
|
2984
4159
|
}
|
|
2985
4160
|
if (!item.verification) { setNotice(t('previewNoVerify')); return; }
|
|
4161
|
+
setNotice('');
|
|
4162
|
+
if (warm) {
|
|
4163
|
+
/* 十期②:该行 ▶ 变转圈直到缓存就绪;运行中再点被 warm 内部忽略。 */
|
|
4164
|
+
warm.playOne(item).then((res) => {
|
|
4165
|
+
if (res && res.error) setNotice(t('previewFail') + ':' + res.error);
|
|
4166
|
+
});
|
|
4167
|
+
return;
|
|
4168
|
+
}
|
|
2986
4169
|
setNotice(t('previewLoading'));
|
|
2987
4170
|
preview.start(item, (res) => {
|
|
2988
4171
|
if (res.error) { setNotice(t('previewFail') + ':' + res.error); return; }
|
|
@@ -3030,8 +4213,10 @@ window.__ModuleLoader__.load({
|
|
|
3030
4213
|
return h(Thumb, { src: url || null, size: size || 20, round: true, glyph: IconNote });
|
|
3031
4214
|
}
|
|
3032
4215
|
|
|
3033
|
-
function SongRow({ t, item, likes, useLikes, onPlay, onOpenArtist, isCurrent, playing, showReason }) {
|
|
4216
|
+
function SongRow({ t, item, likes, useLikes, onPlay, onOpenArtist, isCurrent, playing, showReason, warm, useWarm }) {
|
|
3034
4217
|
const liked = useLikes((st) => !!st.keys[likeKey(item)]);
|
|
4218
|
+
/* 十期②:该行的缓存转圈态由 warm store 驱动(整栏播放时整栏一起转)。 */
|
|
4219
|
+
const pending = warm && useWarm ? !!useWarm((st) => !!(st.pending && st.pending[likeKey(item)])) : false;
|
|
3035
4220
|
return h('div', { className: cx('dshm-srow', isCurrent && 'dshm-row-current') },
|
|
3036
4221
|
h(Thumb, { src: item.coverUrl, size: 38 }),
|
|
3037
4222
|
h('div', {
|
|
@@ -3061,11 +4246,15 @@ window.__ModuleLoader__.load({
|
|
|
3061
4246
|
}, h(IconHeart, { size: 15, style: liked ? { fill: 'currentColor' } : undefined })),
|
|
3062
4247
|
likes ? h(DislikeButton, { t, item, likes, useLikes }) : null,
|
|
3063
4248
|
h('button', {
|
|
3064
|
-
type: 'button', className: 'dshm-playround',
|
|
3065
|
-
'aria-label': isCurrent && playing ? t('pause') : t('play'),
|
|
3066
|
-
|
|
4249
|
+
type: 'button', className: cx('dshm-playround', pending && 'dshm-playround-busy'),
|
|
4250
|
+
'aria-label': pending ? t('previewLoading') : (isCurrent && playing ? t('pause') : t('play')),
|
|
4251
|
+
'aria-busy': pending ? 'true' : undefined,
|
|
4252
|
+
disabled: !!pending,
|
|
4253
|
+
title: pending ? t('previewLoading') : (isCurrent && playing ? t('pause') : t('previewLabel')),
|
|
3067
4254
|
onClick: () => onPlay(item),
|
|
3068
|
-
},
|
|
4255
|
+
}, pending
|
|
4256
|
+
? h('span', { className: 'dshm-spin', 'aria-hidden': true })
|
|
4257
|
+
: h(isCurrent && playing ? IconPause : IconPlay, { size: 13 })));
|
|
3069
4258
|
}
|
|
3070
4259
|
|
|
3071
4260
|
/* Artist column row: real artist/band image + name + genre hint + chevron. */
|
|
@@ -3082,7 +4271,7 @@ window.__ModuleLoader__.load({
|
|
|
3082
4271
|
h('span', { className: 'dshm-arow-arrow', 'aria-hidden': true }, '›'));
|
|
3083
4272
|
}
|
|
3084
4273
|
|
|
3085
|
-
function RecoView({ t, reco, download, player, library, likes, preview, history, openArtistPage, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory }) {
|
|
4274
|
+
function RecoView({ t, reco, download, player, library, likes, preview, history, openArtistPage, warm, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory, useWarm }) {
|
|
3086
4275
|
const s = useReco((st) => st);
|
|
3087
4276
|
const histStats = useHistory ? useHistory((st) => st.stats) : null;
|
|
3088
4277
|
const coldStart = !(histStats && histStats.totalPlays > 0);
|
|
@@ -3120,7 +4309,7 @@ window.__ModuleLoader__.load({
|
|
|
3120
4309
|
normalizeZh(tr.title) === normalizeZh(item.title));
|
|
3121
4310
|
}
|
|
3122
4311
|
function onPlay(item) {
|
|
3123
|
-
playSong(item, player, tracks, preview, setNotice, t);
|
|
4312
|
+
playSong(item, player, tracks, preview, setNotice, t, warm);
|
|
3124
4313
|
}
|
|
3125
4314
|
/* Clicking a row queues the whole visible list (deduped local matches)
|
|
3126
4315
|
* and jumps straight to the clicked song; preview-only items fall back
|
|
@@ -3137,7 +4326,14 @@ window.__ModuleLoader__.load({
|
|
|
3137
4326
|
if (localTracks.length) player.playTracks(localTracks, at);
|
|
3138
4327
|
else if (list.length) onPlay(item || list[0]);
|
|
3139
4328
|
}
|
|
3140
|
-
|
|
4329
|
+
/* 「播放本栏」:本地命中的立即入队,未入库的整栏一起转圈、串行预热,
|
|
4330
|
+
* 就绪一首追加一首(首首就绪即开播)。 */
|
|
4331
|
+
function playColumn(list) {
|
|
4332
|
+
if (!warm) { playListFrom(list, null); return; }
|
|
4333
|
+
warm.playList(list, findLocal).then((res) => {
|
|
4334
|
+
if (res && res.error) setNotice(t('previewFail') + ':' + res.error);
|
|
4335
|
+
});
|
|
4336
|
+
}
|
|
3141
4337
|
|
|
3142
4338
|
const sections = s.sections || { today: s.items, artist: [], new: [] };
|
|
3143
4339
|
const styleActive = styleState.status !== 'idle';
|
|
@@ -3150,15 +4346,35 @@ window.__ModuleLoader__.load({
|
|
|
3150
4346
|
if (!list.length) return h('div', { className: 'dshm-lyrics-hint' }, t('recoSectionEmpty'));
|
|
3151
4347
|
return list.map((item, i) => h(SongRow, {
|
|
3152
4348
|
key: i, t, item, likes, useLikes, onPlay: (it) => playListFrom(list, it), onOpenArtist: openArtistPage, showReason,
|
|
3153
|
-
isCurrent: isCur(item), playing,
|
|
4349
|
+
isCurrent: isCur(item), playing, warm, useWarm,
|
|
3154
4350
|
}));
|
|
3155
4351
|
}
|
|
3156
|
-
|
|
4352
|
+
/* 十期:每栏各自的「重新推荐」——只重算本栏,刷新中仅该栏转圈。 */
|
|
4353
|
+
function colRefresh(axis) {
|
|
4354
|
+
const refreshing = s.refreshing || {};
|
|
4355
|
+
const busy = !!refreshing[axis];
|
|
4356
|
+
return h('button', {
|
|
4357
|
+
type: 'button', className: cx('dshm-chipbtn dshm-col-refresh', busy && 'dshm-chipbtn-busy'),
|
|
4358
|
+
disabled: busy, title: t('recoRefreshHint'), 'aria-label': t('recoRefresh'),
|
|
4359
|
+
'aria-busy': busy ? 'true' : undefined,
|
|
4360
|
+
onClick: () => reco.refresh(axis),
|
|
4361
|
+
}, busy
|
|
4362
|
+
? h('span', { className: 'dshm-spin', 'aria-hidden': true })
|
|
4363
|
+
: h(IconRefresh, { size: 12 }));
|
|
4364
|
+
}
|
|
4365
|
+
function colRefreshBanner(axis) {
|
|
4366
|
+
const refreshing = s.refreshing || {};
|
|
4367
|
+
if (!refreshing[axis]) return null;
|
|
4368
|
+
return h('div', { className: 'dshm-col-loading', role: 'status' },
|
|
4369
|
+
h('span', { className: 'dshm-spin', 'aria-hidden': true }), t('recoRefreshing'));
|
|
4370
|
+
}
|
|
4371
|
+
function column(headKey, icon, list, extraHead, axis) {
|
|
3157
4372
|
return h('section', { className: 'dshm-column', key: headKey },
|
|
3158
4373
|
h('div', { className: 'dshm-col-head' },
|
|
3159
4374
|
h('div', { className: 'dshm-col-title' }, h(icon, { size: 14 }), t(headKey)),
|
|
3160
4375
|
h('span', { className: 'dshm-col-count' }, list.length + ' ' + t('tracksUnit')),
|
|
3161
|
-
extraHead),
|
|
4376
|
+
h('div', { className: 'dshm-col-actions' }, axis ? colRefresh(axis) : null, extraHead)),
|
|
4377
|
+
colRefreshBanner(axis),
|
|
3162
4378
|
h('div', { className: 'dshm-col-list' }, songRows(list, true)));
|
|
3163
4379
|
}
|
|
3164
4380
|
|
|
@@ -3234,24 +4450,30 @@ window.__ModuleLoader__.load({
|
|
|
3234
4450
|
}
|
|
3235
4451
|
return h('div', { className: 'dshm-reco-page', style: { padding: '12px 16px 0', display: 'flex', flexDirection: 'column' } },
|
|
3236
4452
|
toolbar,
|
|
3237
|
-
h(DownloadPanel, { t, download, useDownload }),
|
|
3238
4453
|
s.bootstrapNote
|
|
3239
4454
|
? h('div', { className: 'dshm-explore-note', role: 'note' },
|
|
3240
4455
|
h(IconSparkles, { size: 13 }),
|
|
3241
4456
|
h('span', { className: 'dshm-explore-chip' }, t('exploreChip')),
|
|
3242
4457
|
h('span', null, s.bootstrapNote))
|
|
3243
4458
|
: null,
|
|
4459
|
+
s.refreshError
|
|
4460
|
+
? h('div', { className: 'dshm-explore-note dshm-refresh-note', role: 'alert' },
|
|
4461
|
+
h(IconAlert, { size: 13 }),
|
|
4462
|
+
h('span', null, s.refreshBusy ? t('recoRefreshBusy') : s.refreshError))
|
|
4463
|
+
: null,
|
|
3244
4464
|
h('div', { className: 'dshm-columns' },
|
|
3245
4465
|
column('colToday', IconSparkles, sections.today || [],
|
|
3246
4466
|
h('button', {
|
|
3247
4467
|
type: 'button', className: 'dshm-chipbtn dshm-col-play',
|
|
3248
4468
|
disabled: !(sections.today || []).length,
|
|
3249
4469
|
onClick: () => playColumn(sections.today || []),
|
|
3250
|
-
}, h(IconPlay, { size: 12 }), t('playColumn'))),
|
|
4470
|
+
}, h(IconPlay, { size: 12 }), t('playColumn')), 'today'),
|
|
3251
4471
|
h('section', { className: 'dshm-column', key: 'colArtist' },
|
|
3252
4472
|
h('div', { className: 'dshm-col-head' },
|
|
3253
4473
|
h('div', { className: 'dshm-col-title' }, h(IconNote, { size: 14 }), t('colArtist')),
|
|
3254
|
-
h('span', { className: 'dshm-col-count' }, (sections.artist || []).length + ' ' + t('tracksUnit'))
|
|
4474
|
+
h('span', { className: 'dshm-col-count' }, (sections.artist || []).length + ' ' + t('tracksUnit')),
|
|
4475
|
+
h('div', { className: 'dshm-col-actions' }, colRefresh('artist'))),
|
|
4476
|
+
colRefreshBanner('artist'),
|
|
3255
4477
|
h('div', { className: 'dshm-col-list' },
|
|
3256
4478
|
(sections.artist || []).length === 0
|
|
3257
4479
|
? h('div', { className: 'dshm-lyrics-hint' }, t('recoSectionEmpty'))
|
|
@@ -3261,7 +4483,7 @@ window.__ModuleLoader__.load({
|
|
|
3261
4483
|
type: 'button', className: 'dshm-chipbtn dshm-col-play',
|
|
3262
4484
|
disabled: !(sections.new || []).length,
|
|
3263
4485
|
onClick: () => playColumn(sections.new || []),
|
|
3264
|
-
}, h(IconPlay, { size: 12 }), t('playColumn')))));
|
|
4486
|
+
}, h(IconPlay, { size: 12 }), t('playColumn')), 'new')));
|
|
3265
4487
|
}
|
|
3266
4488
|
|
|
3267
4489
|
/* Shared artist profile block (intro / news / trivia / similar), reused by
|
|
@@ -3419,7 +4641,8 @@ window.__ModuleLoader__.load({
|
|
|
3419
4641
|
/* ================================================================
|
|
3420
4642
|
* 11b. Spotify sync panel (S3): trigger + result chips
|
|
3421
4643
|
* ================================================================ */
|
|
3422
|
-
|
|
4644
|
+
/* bare:设置页卡片里已有平台标题,不再重复一行“同步 Spotify” */
|
|
4645
|
+
function SyncPanel({ t, sync, useSync, bare }) {
|
|
3423
4646
|
const s = useSync((st) => st);
|
|
3424
4647
|
if (s.phase === 'idle' && !s.result && !s.error) return null;
|
|
3425
4648
|
const r = s.result || {};
|
|
@@ -3428,9 +4651,11 @@ window.__ModuleLoader__.load({
|
|
|
3428
4651
|
['syncOk', r.ok], ['syncFail', r.fail], ['syncMissing', r.missing],
|
|
3429
4652
|
];
|
|
3430
4653
|
const problems = (s.tracks || []).filter((tr) => tr && (tr.status === 'fail' || tr.status === 'missing'));
|
|
3431
|
-
return h('div', { className: 'dshm-sync', role: 'status' },
|
|
3432
|
-
|
|
3433
|
-
s.phase === 'running' ?
|
|
4654
|
+
return h('div', { className: cx('dshm-sync', bare && 'dshm-sync-bare'), role: 'status' },
|
|
4655
|
+
bare
|
|
4656
|
+
? (s.phase === 'running' ? h('div', { className: 'dshm-imp-hint' }, t('syncing')) : null)
|
|
4657
|
+
: h('div', { className: 'dshm-asec-title' }, h(IconRefresh, { size: 13, className: s.phase === 'running' ? 'dshm-spin' : undefined }),
|
|
4658
|
+
s.phase === 'running' ? t('syncing') : s.phase === 'error' ? t('syncError') : t('syncBtn')),
|
|
3434
4659
|
s.error ? h('div', { className: 'dshm-errorline', role: 'alert' }, h(IconAlert, { size: 14 }), s.error) : null,
|
|
3435
4660
|
s.phase !== 'running' && s.result
|
|
3436
4661
|
? h('div', { className: 'dshm-sync-chips' },
|
|
@@ -3445,6 +4670,308 @@ window.__ModuleLoader__.load({
|
|
|
3445
4670
|
: null);
|
|
3446
4671
|
}
|
|
3447
4672
|
|
|
4673
|
+
/* ================================================================
|
|
4674
|
+
* 11b-2. 喜欢列表同步卡片(设置页):网易云扫码 / QQ 音乐 Cookie → 只读导入「我喜欢」
|
|
4675
|
+
* 二维码由本地 qrEncode 生成,以 SVG 渲染(静区 4 模块,crispEdges)。
|
|
4676
|
+
* ================================================================ */
|
|
4677
|
+
/* 上次同步时间:本地区域短格式,跨年才带年份(zh → 2025/12/31 23:59) */
|
|
4678
|
+
function formatSyncTime(ts) {
|
|
4679
|
+
const d = new Date(ts);
|
|
4680
|
+
if (!(d instanceof Date) || Number.isNaN(d.getTime())) return '';
|
|
4681
|
+
const sameYear = d.getFullYear() === new Date().getFullYear();
|
|
4682
|
+
return d.toLocaleString(undefined, Object.assign(
|
|
4683
|
+
sameYear ? {} : { year: 'numeric' },
|
|
4684
|
+
{ month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit' },
|
|
4685
|
+
));
|
|
4686
|
+
}
|
|
4687
|
+
|
|
4688
|
+
function QrSvg({ matrix, size = 196, label }) {
|
|
4689
|
+
if (!matrix) return null;
|
|
4690
|
+
const n = matrix.size;
|
|
4691
|
+
const quiet = 4;
|
|
4692
|
+
const cells = [];
|
|
4693
|
+
for (let y = 0; y < n; y++) {
|
|
4694
|
+
for (let x = 0; x < n; x++) {
|
|
4695
|
+
if (matrix.modules[y * n + x]) cells.push(h('rect', { key: y + ':' + x, x: quiet + x, y: quiet + y, width: 1, height: 1 }));
|
|
4696
|
+
}
|
|
4697
|
+
}
|
|
4698
|
+
return h('svg', {
|
|
4699
|
+
className: 'dshm-qr', viewBox: '-' + quiet + ' -' + quiet + ' ' + (n + 2 * quiet) + ' ' + (n + 2 * quiet),
|
|
4700
|
+
width: size, height: size, shapeRendering: 'crispEdges', role: 'img', 'aria-label': label,
|
|
4701
|
+
},
|
|
4702
|
+
h('rect', { x: -quiet, y: -quiet, width: n + 2 * quiet, height: n + 2 * quiet, fill: '#fff' }),
|
|
4703
|
+
h('g', { fill: '#000' }, cells));
|
|
4704
|
+
}
|
|
4705
|
+
/* 二维码区(网易云 / QQ 共用):左侧图(矩阵 → SVG;主机没解出矩阵就退回 PNG)+ 右侧状态与「重新生成」 */
|
|
4706
|
+
function QrBox({ t, s, provider, likedSync, hint }) {
|
|
4707
|
+
const qr = s.qr && s.qr.provider === provider ? s.qr : null;
|
|
4708
|
+
const alive = !!qr && (s.qrPhase === 'waiting' || s.qrPhase === 'confirmed');
|
|
4709
|
+
const loading = s.qrPhase === 'loading' || (s.qrPhase === 'idle' && !s.loaded);
|
|
4710
|
+
const text = {
|
|
4711
|
+
loading: t('importQrLoading'), waiting: t('importQrWaiting'), confirmed: t('importQrConfirmed'),
|
|
4712
|
+
done: t('importQrDone'), expired: s.qrMessage ? `${t('importQrExpired')}(${s.qrMessage})` : t('importQrExpired'),
|
|
4713
|
+
error: s.qrMessage || t('importQrExpired'),
|
|
4714
|
+
}[s.qrPhase] || '';
|
|
4715
|
+
return h('div', { className: 'dshm-imp-qr' },
|
|
4716
|
+
h('div', { className: 'dshm-imp-qr-box' },
|
|
4717
|
+
loading
|
|
4718
|
+
? h(IconRefresh, { size: 24, className: 'dshm-spin' })
|
|
4719
|
+
: alive
|
|
4720
|
+
? (qr.matrix
|
|
4721
|
+
? h(QrSvg, { matrix: qr.matrix, label: t('importQrWaiting') })
|
|
4722
|
+
: h('img', { className: 'dshm-qr dshm-qr-img', src: qr.png, alt: t('importQrWaiting') }))
|
|
4723
|
+
: h('div', { className: 'dshm-imp-qr-fallback' }, h(IconAlert, { size: 22 }), h('div', null, text),
|
|
4724
|
+
(s.qrPhase === 'expired' || s.qrPhase === 'error') && s.qrMessage
|
|
4725
|
+
? h('p', { className: 'dshm-imp-hint dshm-imp-hint-more' }, t('importQrReportHint'))
|
|
4726
|
+
: null)),
|
|
4727
|
+
h('div', { className: 'dshm-imp-qr-side' },
|
|
4728
|
+
h('p', { className: 'dshm-imp-hint' }, hint),
|
|
4729
|
+
h('div', { className: 'dshm-imp-step', role: 'status' }, text),
|
|
4730
|
+
h('div', null, h('button', {
|
|
4731
|
+
type: 'button', className: 'dshm-chipbtn', disabled: s.qrPhase === 'loading', onClick: () => likedSync.startQr(provider),
|
|
4732
|
+
}, h(IconRefresh, { size: 13 }), t('importQrRegenerate')))));
|
|
4733
|
+
}
|
|
4734
|
+
|
|
4735
|
+
/* ================================================================
|
|
4736
|
+
* 11b-3. 「喜欢列表同步」区块(设置页):三个平台各占一行(手风琴)。
|
|
4737
|
+
* 行头 = 图标 / 名称 / 状态;展开后是给新用户的分步引导(①②③)。
|
|
4738
|
+
* 连接成功即自动导入一次;结果只留一行主结论 + 异常项。
|
|
4739
|
+
* ================================================================ */
|
|
4740
|
+
function fmt(str, vars) {
|
|
4741
|
+
return String(str || '').replace(/\{(\w+)\}/g, (m, k) => (vars && vars[k] != null ? String(vars[k]) : m));
|
|
4742
|
+
}
|
|
4743
|
+
function devtoolsKeys() {
|
|
4744
|
+
return typeof navigator !== 'undefined' && /Mac/i.test(navigator.platform || '') ? '⌘⌥I' : 'F12';
|
|
4745
|
+
}
|
|
4746
|
+
|
|
4747
|
+
/* 分步引导:state = done(已完成)| active(进行中)| todo(还没轮到)| miss(没满足,可补救) */
|
|
4748
|
+
function Steps({ children }) { return h('ol', { className: 'dshm-steps' }, children); }
|
|
4749
|
+
function Step({ n, state, title, children }) {
|
|
4750
|
+
return h('li', { className: cx('dshm-step', 'dshm-step-' + state) },
|
|
4751
|
+
h('span', { className: 'dshm-step-n', 'aria-hidden': true }, state === 'done' ? h(IconCheck, { size: 12 }) : n),
|
|
4752
|
+
h('div', { className: 'dshm-step-body' },
|
|
4753
|
+
h('div', { className: 'dshm-step-title' }, title),
|
|
4754
|
+
children ? h('div', { className: 'dshm-step-content' }, children) : null));
|
|
4755
|
+
}
|
|
4756
|
+
|
|
4757
|
+
/* 导入结果:一行主结论;移除 / 下架 / 跳过 👎 这类异常才单独出 chip */
|
|
4758
|
+
function ImportResult({ t, result, onViewLikes }) {
|
|
4759
|
+
if (!result || result.total == null) return null;
|
|
4760
|
+
const extras = [
|
|
4761
|
+
['importResRemoved', result.removed, 'dshm-sync-chip-warn', 'importResRemovedHint'],
|
|
4762
|
+
['importResUnavailable', result.unavailable, '', null],
|
|
4763
|
+
['importResDisliked', result.skippedDisliked, '', null],
|
|
4764
|
+
].filter(([, v]) => v > 0);
|
|
4765
|
+
const removed = Array.isArray(result.removedItems) ? result.removedItems : [];
|
|
4766
|
+
return h('div', { className: 'dshm-imp-result', role: 'status' },
|
|
4767
|
+
h('div', { className: 'dshm-imp-summary' },
|
|
4768
|
+
h(IconCheck, { size: 14 }),
|
|
4769
|
+
h('span', null, fmt(t('importDoneLine'), { total: result.total, added: result.added || 0, existed: result.existed || 0 }))),
|
|
4770
|
+
extras.length
|
|
4771
|
+
? h('div', { className: 'dshm-sync-chips' }, extras.map(([key, v, cls, hint]) => h('span', {
|
|
4772
|
+
key, className: cx('dshm-sync-chip', cls), title: hint ? t(hint) : undefined,
|
|
4773
|
+
}, t(key) + ' ' + v)))
|
|
4774
|
+
: null,
|
|
4775
|
+
removed.length
|
|
4776
|
+
? h('div', { className: 'dshm-sync-detail' },
|
|
4777
|
+
removed.slice(0, 6).map((it, i) => h('div', { key: i }, '· ' + (it.artist || '') + ' - ' + (it.title || ''))),
|
|
4778
|
+
removed.length > 6 ? h('div', null, '… +' + (removed.length - 6)) : null)
|
|
4779
|
+
: null,
|
|
4780
|
+
onViewLikes
|
|
4781
|
+
? h('button', { type: 'button', className: 'dshm-linkbtn', onClick: onViewLikes }, t('importViewLikes'),
|
|
4782
|
+
h(IconChevronUp, { size: 12, style: { transform: 'rotate(90deg)' } }))
|
|
4783
|
+
: null);
|
|
4784
|
+
}
|
|
4785
|
+
|
|
4786
|
+
/* 平台行:整行是展开/收起按钮;stateTone = ok | busy | off */
|
|
4787
|
+
function ProviderRow({ provider, icon, title, stateText, stateTone, expanded, onToggle, children }) {
|
|
4788
|
+
return h('div', { className: cx('dshm-prv', 'dshm-prv-' + provider, expanded && 'dshm-prv-open'), 'data-provider': provider, role: 'listitem' },
|
|
4789
|
+
h('button', { type: 'button', className: 'dshm-prv-head', 'aria-expanded': expanded, onClick: onToggle },
|
|
4790
|
+
h('span', { className: 'dshm-prv-icon' }, h(icon, { size: 18 })),
|
|
4791
|
+
h('span', { className: 'dshm-prv-name' }, title),
|
|
4792
|
+
h('span', { className: cx('dshm-prv-state', stateTone && 'dshm-prv-state-' + stateTone) }, stateText),
|
|
4793
|
+
h(IconChevronDown, { size: 14, className: 'dshm-prv-chev' })),
|
|
4794
|
+
expanded ? h('div', { className: 'dshm-prv-body' }, children) : null);
|
|
4795
|
+
}
|
|
4796
|
+
|
|
4797
|
+
function LikedProviders({ t, sync, useSync, likedSync, useLikedSync, firstRun, onViewLikes }) {
|
|
4798
|
+
/* useLikedSync 由宿主 hooks 注入;直接读取服务 store 作为兜底(独立渲染/测试场景) */
|
|
4799
|
+
const s = (useLikedSync ? useLikedSync((st) => st) : (likedSync && likedSync.source ? likedSync.source.getSnapshot() : {})) || {};
|
|
4800
|
+
const ss = sync ? (useSync ? useSync((st) => st) : sync.source.getSnapshot()) : { phase: 'idle' };
|
|
4801
|
+
/* 展开的行(null = 全部收起);store 初值就是 'netease',新用户一进来先看到扫码 */
|
|
4802
|
+
const tab = s.tab || null;
|
|
4803
|
+
const providers = s.providers || {};
|
|
4804
|
+
const ne = providers.netease || null;
|
|
4805
|
+
const qq = providers.qq || null;
|
|
4806
|
+
const neOn = !!(ne && ne.connected);
|
|
4807
|
+
const qqOn = !!(qq && qq.connected);
|
|
4808
|
+
const enabled = !(s.loaded && !s.enabled);
|
|
4809
|
+
const spAvail = ss.available;
|
|
4810
|
+
const spAuth = ss.authorized;
|
|
4811
|
+
const spRunning = ss.phase === 'running';
|
|
4812
|
+
const toggle = (id) => likedSync.selectTab(tab === id ? null : id);
|
|
4813
|
+
|
|
4814
|
+
/* 错误按归属平台分行展示;主机文案里的「缺 qm_keyst」换成给新用户的说法 */
|
|
4815
|
+
const errLine = (provider) => {
|
|
4816
|
+
if (!s.error || s.errorProvider !== provider) return null;
|
|
4817
|
+
const text = s.error === 'importCookieEmpty' ? t('importCookieEmpty')
|
|
4818
|
+
: /qm_keyst|qqmusic_key/.test(s.error) ? t('importQqNeedKey') : s.error;
|
|
4819
|
+
return h('div', { className: 'dshm-errorline', role: 'alert' }, h(IconAlert, { size: 14 }), text);
|
|
4820
|
+
};
|
|
4821
|
+
const resOf = (provider) => (s.result && s.result.provider === provider ? s.result : null)
|
|
4822
|
+
|| (s.syncing === provider ? null : (providers[provider] && providers[provider].lastResult) || null);
|
|
4823
|
+
const nameOf = (prov) => (prov && prov.account && (prov.account.nickname || prov.account.uid)) || '';
|
|
4824
|
+
const accountLine = (prov) => h('div', { className: 'dshm-imp-account' },
|
|
4825
|
+
h('span', { className: 'dshm-ava', 'aria-hidden': true }, nameOf(prov).slice(0, 1) || '·'),
|
|
4826
|
+
h('span', { className: 'dshm-imp-nick' }, nameOf(prov)),
|
|
4827
|
+
prov && prov.knownCount != null ? h('span', { className: 'dshm-imp-time' }, fmt(t('importKnownLine'), { n: prov.knownCount })) : null,
|
|
4828
|
+
prov && prov.lastSyncAt ? h('span', { className: 'dshm-imp-time' }, fmt(t('importLastSyncLine'), { time: formatSyncTime(prov.lastSyncAt) })) : null);
|
|
4829
|
+
const syncActions = (provider, prov) => h('div', { className: 'dshm-imp-actions' },
|
|
4830
|
+
h('button', {
|
|
4831
|
+
type: 'button', className: 'dshm-chipbtn dshm-chipbtn-primary',
|
|
4832
|
+
disabled: !!s.syncing || !!(prov && prov.busy),
|
|
4833
|
+
onClick: () => likedSync.sync(provider),
|
|
4834
|
+
}, s.syncing === provider ? h(IconRefresh, { size: 13, className: 'dshm-spin' }) : h(IconHeart, { size: 13 }),
|
|
4835
|
+
s.syncing === provider ? t('importSyncing') : t('importSyncNow')),
|
|
4836
|
+
provider === 'netease'
|
|
4837
|
+
? h('button', { type: 'button', className: 'dshm-chipbtn', onClick: () => likedSync.startQr('netease') }, t('importReQr'))
|
|
4838
|
+
: null,
|
|
4839
|
+
h('button', { type: 'button', className: 'dshm-chipbtn', onClick: () => likedSync.disconnect(provider) }, t('importDisconnect')));
|
|
4840
|
+
const recheck = h('button', { type: 'button', className: 'dshm-chipbtn', onClick: () => sync.recheck() },
|
|
4841
|
+
h(IconRefresh, { size: 13 }), t('spRecheck'));
|
|
4842
|
+
|
|
4843
|
+
/* 展开的平台处于扫码模式且未登录 → 自动取码(同一时刻只有一个二维码会话) */
|
|
4844
|
+
const qqQr = (s.qqMode || 'qr') === 'qr';
|
|
4845
|
+
const qrProvider = tab === 'netease' ? 'netease' : (tab === 'qq' && qqQr ? 'qq' : null);
|
|
4846
|
+
const qrOn = qrProvider ? (qrProvider === 'netease' ? neOn : qqOn) : true;
|
|
4847
|
+
useEffect(() => {
|
|
4848
|
+
if (!enabled || !qrProvider || qrOn || s.qrPhase !== 'idle') return undefined;
|
|
4849
|
+
likedSync.startQr(qrProvider);
|
|
4850
|
+
return undefined;
|
|
4851
|
+
}, [enabled, qrProvider, qrOn, s.qrPhase]);
|
|
4852
|
+
|
|
4853
|
+
/* ── 网易云:扫码 → 自动导入 ── */
|
|
4854
|
+
let neteaseBody;
|
|
4855
|
+
if (!enabled) {
|
|
4856
|
+
neteaseBody = h('p', { className: 'dshm-imp-hint' }, t('importEnabledOff'));
|
|
4857
|
+
} else if (neOn) {
|
|
4858
|
+
neteaseBody = h('div', { className: 'dshm-imp-logged' }, accountLine(ne), syncActions('netease', ne),
|
|
4859
|
+
h(ImportResult, { t, result: resOf('netease'), onViewLikes: firstRun ? null : onViewLikes }), errLine('netease'));
|
|
4860
|
+
} else {
|
|
4861
|
+
const neRes = resOf('netease');
|
|
4862
|
+
const neBusy = s.syncing === 'netease';
|
|
4863
|
+
neteaseBody = h(Steps, null,
|
|
4864
|
+
h(Step, { n: 1, state: neRes ? 'done' : 'active', title: t('importQrStep1') },
|
|
4865
|
+
h(QrBox, { t, s, provider: 'netease', likedSync, hint: t('importQrHint') })),
|
|
4866
|
+
h(Step, { n: 2, state: neRes ? 'done' : neBusy ? 'active' : 'todo', title: t('importQrStep2') },
|
|
4867
|
+
h('p', { className: 'dshm-imp-hint' }, t('importAutoNote')),
|
|
4868
|
+
errLine('netease')));
|
|
4869
|
+
}
|
|
4870
|
+
|
|
4871
|
+
/* ── QQ 音乐:手机 QQ 扫码(默认)→ 自动导入;微信登录的账号改走 Cookie 三步 ── */
|
|
4872
|
+
let qqBody;
|
|
4873
|
+
if (!enabled) {
|
|
4874
|
+
qqBody = h('p', { className: 'dshm-imp-hint' }, t('importEnabledOff'));
|
|
4875
|
+
} else if (qqOn) {
|
|
4876
|
+
qqBody = h('div', { className: 'dshm-imp-logged' }, accountLine(qq), syncActions('qq', qq),
|
|
4877
|
+
h(ImportResult, { t, result: resOf('qq'), onViewLikes: firstRun ? null : onViewLikes }), errLine('qq'));
|
|
4878
|
+
} else if (qqQr) {
|
|
4879
|
+
const qqRes = resOf('qq');
|
|
4880
|
+
const qqBusy = s.syncing === 'qq';
|
|
4881
|
+
qqBody = h(Steps, null,
|
|
4882
|
+
h(Step, { n: 1, state: qqRes ? 'done' : 'active', title: t('importQqQrStep1') },
|
|
4883
|
+
h(QrBox, { t, s, provider: 'qq', likedSync, hint: t('importQqQrHint') }),
|
|
4884
|
+
h('p', { className: 'dshm-imp-hint dshm-imp-hint-more' }, t('importQqBusyHint'))),
|
|
4885
|
+
h(Step, { n: 2, state: qqRes ? 'done' : qqBusy ? 'active' : 'todo', title: t('importQrStep2') },
|
|
4886
|
+
h('p', { className: 'dshm-imp-hint' }, t('importQqQrNote')),
|
|
4887
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4888
|
+
type: 'button', className: 'dshm-linkbtn', onClick: () => likedSync.setQqMode('cookie'),
|
|
4889
|
+
}, t('importQqUseCookie'), h(IconChevronUp, { size: 12, style: { transform: 'rotate(90deg)' } }))),
|
|
4890
|
+
errLine('qq')));
|
|
4891
|
+
} else {
|
|
4892
|
+
const onCookieInput = (e) => {
|
|
4893
|
+
const v = e.target.value;
|
|
4894
|
+
likedSync.setQqCookie(v);
|
|
4895
|
+
/* 粘贴即连接:像 Cookie 的内容(够长且含 =)直接发起,省掉一次「连接」 */
|
|
4896
|
+
if (v.trim().length > 20 && v.indexOf('=') > 0 && !s.connecting) likedSync.connectQq();
|
|
4897
|
+
};
|
|
4898
|
+
qqBody = h(Steps, null,
|
|
4899
|
+
h(Step, { n: 1, state: 'active', title: t('importQqStep1') },
|
|
4900
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4901
|
+
type: 'button', className: 'dshm-chipbtn', onClick: () => likedSync.openUrl('https://y.qq.com/'),
|
|
4902
|
+
}, t('importQqOpen'), h(IconExternal, { size: 12 }))),
|
|
4903
|
+
h('p', { className: 'dshm-imp-hint' }, t('importQqLoginHint'))),
|
|
4904
|
+
h(Step, { n: 2, state: s.copied ? 'done' : 'active', title: t('importQqStep2') },
|
|
4905
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4906
|
+
type: 'button', className: 'dshm-chipbtn', onClick: () => likedSync.copyCookieCommand(),
|
|
4907
|
+
}, s.copied ? h(IconCheck, { size: 13 }) : null, s.copied ? t('importQqCopied') : t('importQqCopy'))),
|
|
4908
|
+
h('p', { className: 'dshm-imp-hint' }, fmt(t('importQqStep2Hint'), { keys: devtoolsKeys() })),
|
|
4909
|
+
h('p', { className: 'dshm-imp-hint dshm-imp-hint-more' }, fmt(t('importQqFallback'), { keys: devtoolsKeys() }))),
|
|
4910
|
+
h(Step, { n: 3, state: 'active', title: t('importQqStep3') },
|
|
4911
|
+
h('input', {
|
|
4912
|
+
className: 'dshm-imp-cookie', type: 'text', spellCheck: false, autoComplete: 'off', autoCapitalize: 'off',
|
|
4913
|
+
placeholder: t('importQqPlaceholder'), value: s.qqCookie, 'aria-label': t('importQqStep3'),
|
|
4914
|
+
onChange: onCookieInput,
|
|
4915
|
+
}),
|
|
4916
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4917
|
+
type: 'button', className: 'dshm-chipbtn dshm-chipbtn-primary',
|
|
4918
|
+
disabled: s.connecting || !s.qqCookie.trim(),
|
|
4919
|
+
onClick: () => likedSync.connectQq(),
|
|
4920
|
+
}, s.connecting ? h(IconRefresh, { size: 13, className: 'dshm-spin' }) : h(IconImport, { size: 13 }),
|
|
4921
|
+
s.connecting ? t('importConnecting') : t('importQqConnect'))),
|
|
4922
|
+
h('p', { className: 'dshm-imp-hint' }, t('importQqPrivacy')),
|
|
4923
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4924
|
+
type: 'button', className: 'dshm-linkbtn', onClick: () => likedSync.setQqMode('qr'),
|
|
4925
|
+
}, t('importQqUseQr'), h(IconChevronUp, { size: 12, style: { transform: 'rotate(90deg)' } }))),
|
|
4926
|
+
errLine('qq')));
|
|
4927
|
+
}
|
|
4928
|
+
|
|
4929
|
+
/* ── Spotify 收藏(可选):装 CLI → 授权 → 同步 ── */
|
|
4930
|
+
let spBody = null;
|
|
4931
|
+
if (sync) {
|
|
4932
|
+
const st1 = spAvail === true ? 'done' : spAvail === false ? 'miss' : 'active';
|
|
4933
|
+
const st2 = spAvail !== true ? 'todo' : spAuth === true ? 'done' : spAuth === false ? 'miss' : 'active';
|
|
4934
|
+
const st3 = spRunning ? 'active' : ss.result ? 'done' : spAvail === false ? 'todo' : 'active';
|
|
4935
|
+
spBody = h(Steps, null,
|
|
4936
|
+
h(Step, { n: 1, state: st1, title: t('spStep1') },
|
|
4937
|
+
h('p', { className: 'dshm-imp-hint' }, spAvail === true ? t('spStep1Ok') : t('spStep1Hint')),
|
|
4938
|
+
spAvail === true ? null : recheck),
|
|
4939
|
+
h(Step, { n: 2, state: st2, title: t('spStep2') },
|
|
4940
|
+
h('p', { className: 'dshm-imp-hint' }, spAuth === true ? t('spStep2Ok') : t('spStep2Hint')),
|
|
4941
|
+
spAvail === true ? recheck : null),
|
|
4942
|
+
h(Step, { n: 3, state: st3, title: t('spStep3') },
|
|
4943
|
+
h('p', { className: 'dshm-imp-hint' }, t('spBody')),
|
|
4944
|
+
h('div', { className: 'dshm-imp-actions' }, h('button', {
|
|
4945
|
+
type: 'button', className: cx('dshm-chipbtn', 'dshm-chipbtn-primary', spAvail === false && 'dshm-chipbtn-off'),
|
|
4946
|
+
disabled: spRunning || spAvail === false,
|
|
4947
|
+
onClick: () => sync.start(),
|
|
4948
|
+
}, h(IconRefresh, { size: 13, className: spRunning ? 'dshm-spin' : undefined }),
|
|
4949
|
+
spRunning ? t('syncing') : t('syncBtn'))),
|
|
4950
|
+
h(SyncPanel, { t, sync, useSync, bare: true })));
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4953
|
+
const neQrAlive = !!s.qr && s.qr.provider === 'netease' && (s.qrPhase === 'waiting' || s.qrPhase === 'confirmed');
|
|
4954
|
+
const qqQrAlive = !!s.qr && s.qr.provider === 'qq' && (s.qrPhase === 'waiting' || s.qrPhase === 'confirmed');
|
|
4955
|
+
const neState = neOn ? nameOf(ne) : (neQrAlive ? t('importQrWaiting') : t('prvNeteaseHow'));
|
|
4956
|
+
const qqState = qqOn ? nameOf(qq) : (qqQrAlive ? t('importQrWaiting') : t(qqQr ? 'prvQqHow' : 'prvQqHowCookie'));
|
|
4957
|
+
const spState = spAvail === false ? t('spStateNoCli') : spAvail === true ? (spAuth === false ? t('spStateNoAuth') : t('spStateReady')) : t('spStateChecking');
|
|
4958
|
+
return h('div', { className: 'dshm-prvs', role: 'list' },
|
|
4959
|
+
h(ProviderRow, {
|
|
4960
|
+
provider: 'netease', icon: IconDisc, title: t('importTabNetease'), stateText: neState,
|
|
4961
|
+
stateTone: neOn ? 'ok' : (neQrAlive ? 'busy' : 'off'),
|
|
4962
|
+
expanded: tab === 'netease', onToggle: () => toggle('netease'),
|
|
4963
|
+
}, neteaseBody),
|
|
4964
|
+
h(ProviderRow, {
|
|
4965
|
+
provider: 'qq', icon: IconNote, title: t('importTabQq'), stateText: qqState, stateTone: qqOn ? 'ok' : (qqQrAlive ? 'busy' : 'off'),
|
|
4966
|
+
expanded: tab === 'qq', onToggle: () => toggle('qq'),
|
|
4967
|
+
}, qqBody),
|
|
4968
|
+
sync ? h(ProviderRow, {
|
|
4969
|
+
provider: 'spotify', icon: IconSpotify, title: 'Spotify', stateText: spState,
|
|
4970
|
+
stateTone: spAvail === true && spAuth !== false ? 'ok' : spAvail === false ? 'off' : 'busy',
|
|
4971
|
+
expanded: tab === 'spotify', onToggle: () => toggle('spotify'),
|
|
4972
|
+
}, spBody) : null);
|
|
4973
|
+
}
|
|
4974
|
+
|
|
3448
4975
|
/* ================================================================
|
|
3449
4976
|
* 11c. History view (S3): plays, completion, skips
|
|
3450
4977
|
* ================================================================ */
|
|
@@ -3720,10 +5247,10 @@ window.__ModuleLoader__.load({
|
|
|
3720
5247
|
/* ================================================================
|
|
3721
5248
|
* 12. Music panel (main slot): header + tabs + per-view body
|
|
3722
5249
|
* ================================================================ */
|
|
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 }) {
|
|
5250
|
+
function MusicPanel({ t, player, library, lyrics, reco, download, sync, history, likes, preview, warm, openView, openArtistPage, setMiniHidden, ui, artistImages, artistPage, onboarding, likedSync, useUi, useLibrary, usePlayer, useLyrics, useReco, useDownload, useSync, useHistory, useLikes, usePreview, useWarm, useArtistImages, useArtistPage, useOnboarding, useLikedSync }) {
|
|
3724
5251
|
const view = useUi((s) => s.view);
|
|
3725
|
-
const
|
|
3726
|
-
const
|
|
5252
|
+
const settingsSection = useUi((s) => s.settingsSection);
|
|
5253
|
+
const libTabWish = useUi((s) => s.libTabWish);
|
|
3727
5254
|
const miniHidden = useUi((s) => s.miniHidden);
|
|
3728
5255
|
const hasTrack = usePlayer((s) => !!s.track);
|
|
3729
5256
|
const status = useLibrary((s) => s.status);
|
|
@@ -3749,13 +5276,18 @@ window.__ModuleLoader__.load({
|
|
|
3749
5276
|
return () => clearTimeout(timer);
|
|
3750
5277
|
}, [toast]);
|
|
3751
5278
|
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
5279
|
+
/* 设置页:首启(onboarding 未完成)自动进入;老用户从右上角「设置」进入。
|
|
5280
|
+
* section 让「我喜欢」页的入口直接滚到「喜欢列表同步」。 */
|
|
5281
|
+
const openSettings = (section) => ui.set({ view: 'settings', settingsSection: section || null });
|
|
5282
|
+
if (view === 'settings') {
|
|
5283
|
+
return h(SettingsView, {
|
|
5284
|
+
t, onboarding, useOnboarding, sync, useSync, likedSync, useLikedSync,
|
|
5285
|
+
section: settingsSection,
|
|
5286
|
+
/* 导入结果里的「查看我喜欢」:回曲库并直接打开「我喜欢」子页 */
|
|
5287
|
+
onViewLikes: () => { ui.set({ view: 'library', settingsSection: null, libTabWish: 'likes' }); openView('library'); },
|
|
5288
|
+
onExit: () => { ui.set({ view: 'library', settingsSection: null }); openView('library'); },
|
|
3757
5289
|
onRoute: (target) => {
|
|
3758
|
-
ui.set({
|
|
5290
|
+
ui.set({ settingsSection: null });
|
|
3759
5291
|
if (target === 'library') {
|
|
3760
5292
|
library.load();
|
|
3761
5293
|
setTimeout(() => library.load(), 1500);
|
|
@@ -3773,14 +5305,14 @@ window.__ModuleLoader__.load({
|
|
|
3773
5305
|
];
|
|
3774
5306
|
|
|
3775
5307
|
const body = view === 'library'
|
|
3776
|
-
? h(LibraryView, { t, player, library, sync, download, preview, likes, openArtistPage, artistImages, useLikes, useSync, useDownload, useLibrary, usePlayer, useArtistImages })
|
|
5308
|
+
? h(LibraryView, { t, player, library, sync, download, preview, likes, openArtistPage, artistImages, likedSync, openSettings, useLikes, useSync, useDownload, useLibrary, usePlayer, useArtistImages, useLikedSync, tabWish: libTabWish, onTabWishDone: () => ui.set({ libTabWish: null }) })
|
|
3777
5309
|
: view === 'reco'
|
|
3778
|
-
? h(RecoView, { t, reco, download, player, library, likes, preview, history, openArtistPage, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory })
|
|
5310
|
+
? h(RecoView, { t, reco, download, player, library, likes, preview, history, openArtistPage, warm, useReco, useDownload, useLibrary, useLikes, usePlayer, useHistory, useWarm })
|
|
3779
5311
|
: view === 'artist'
|
|
3780
5312
|
? h(ArtistPageView, { t, reco, player, likes, preview, library, openView, openArtistPage, artistImages, artistPage, useUi, useLikes, useLibrary, usePlayer, useArtistImages, useArtistPage })
|
|
3781
5313
|
: view === 'history'
|
|
3782
5314
|
? h(HistoryView, { t, history, player, openArtistPage, artistImages, likes, useHistory, useLibrary, useArtistImages, useLikes })
|
|
3783
|
-
: h(NowPlayingView, { t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages });
|
|
5315
|
+
: h(NowPlayingView, { t, player, lyrics, usePlayer, useLyrics, openView, openArtistPage, artistImages, useArtistImages, likes, useLikes });
|
|
3784
5316
|
|
|
3785
5317
|
return h(React.Fragment, null,
|
|
3786
5318
|
h('div', { className: 'dshm-panel' },
|
|
@@ -3789,12 +5321,10 @@ window.__ModuleLoader__.load({
|
|
|
3789
5321
|
h('h1', { className: 'dshm-title' }, t('panel')),
|
|
3790
5322
|
h('span', { className: 'dshm-count' }, count > 0 ? count + ' ' + t('tracksUnit') : ''),
|
|
3791
5323
|
h('div', { className: 'dshm-header-actions' },
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
}, h(IconSparkles, { size: 12 }), t('welcomePreview'))
|
|
3797
|
-
: null,
|
|
5324
|
+
h('button', {
|
|
5325
|
+
type: 'button', className: 'dshm-chipbtn',
|
|
5326
|
+
title: t('settingsHint'), 'aria-label': t('settingsTitle'), onClick: () => openSettings(),
|
|
5327
|
+
}, h(IconGear, { size: 13 }), t('settingsTitle')),
|
|
3798
5328
|
h('button', {
|
|
3799
5329
|
type: 'button', className: cx('dshm-chipbtn', !miniHidden && 'dshm-chipbtn-primary'),
|
|
3800
5330
|
disabled: miniHidden && !hasTrack,
|
|
@@ -3840,7 +5370,7 @@ window.__ModuleLoader__.load({
|
|
|
3840
5370
|
/* ================================================================
|
|
3841
5371
|
* 14. Mini player (shell.overlay — mounted across navigation)
|
|
3842
5372
|
* ================================================================ */
|
|
3843
|
-
function MiniPlayer({ t, player, lyrics, artistImages, usePlayer, useUi, useLyrics, useArtistImages, openNow, openArtistPage, setMiniHidden, setMiniCollapsed }) {
|
|
5373
|
+
function MiniPlayer({ t, player, lyrics, artistImages, likes, useLikes, usePlayer, useUi, useLyrics, useArtistImages, openNow, openArtistPage, setMiniHidden, setMiniCollapsed, publishRect }) {
|
|
3844
5374
|
const track = usePlayer((s) => s.track);
|
|
3845
5375
|
const playing = usePlayer((s) => s.playing);
|
|
3846
5376
|
const position = usePlayer((s) => s.position);
|
|
@@ -3865,6 +5395,53 @@ window.__ModuleLoader__.load({
|
|
|
3865
5395
|
const fabPosRef = useRef(fabPos);
|
|
3866
5396
|
fabPosRef.current = fabPos;
|
|
3867
5397
|
const fabMoved = useRef(0);
|
|
5398
|
+
/* 展开条的尺寸(收起时元素不在,用上次量到的值把圆标放到条的右下角) */
|
|
5399
|
+
const sizeRef = useRef({ w: 380, h: 72 });
|
|
5400
|
+
const FAB = 48;
|
|
5401
|
+
const inWindow = (next, w, h) => (typeof window === 'undefined'
|
|
5402
|
+
? next
|
|
5403
|
+
: { left: Math.max(0, Math.min(next.left, window.innerWidth - w - 8)), top: Math.max(0, Math.min(next.top, window.innerHeight - h - 8)) });
|
|
5404
|
+
/* 收起 / 展开共用同一个锚点:圆标的右下角 = 展开条的右下角。
|
|
5405
|
+
* 收起时圆标落在条的右下角;再从圆标展开时,条从圆标位置向左上长出来,不会跳回默认角。 */
|
|
5406
|
+
function collapseToFab() {
|
|
5407
|
+
const el = boxRef.current;
|
|
5408
|
+
let base = posRef.current;
|
|
5409
|
+
if (el && typeof window !== 'undefined') {
|
|
5410
|
+
const r = el.getBoundingClientRect();
|
|
5411
|
+
sizeRef.current = { w: r.width, h: r.height };
|
|
5412
|
+
base = { left: r.left, top: r.top };
|
|
5413
|
+
}
|
|
5414
|
+
if (!base) { setFabPos(null); writePrefs({ miniFabPos: null }); return; }
|
|
5415
|
+
const next = inWindow({ left: base.left + sizeRef.current.w - FAB, top: base.top + sizeRef.current.h - FAB }, FAB, FAB);
|
|
5416
|
+
fabPosRef.current = next;
|
|
5417
|
+
setFabPos(next);
|
|
5418
|
+
writePrefs({ miniFabPos: next });
|
|
5419
|
+
}
|
|
5420
|
+
function expandFromFab() {
|
|
5421
|
+
const el = fabRef.current;
|
|
5422
|
+
let f = fabPosRef.current;
|
|
5423
|
+
if (el && typeof window !== 'undefined') {
|
|
5424
|
+
const r = el.getBoundingClientRect();
|
|
5425
|
+
f = { left: r.left, top: r.top };
|
|
5426
|
+
} else if (!f && typeof window !== 'undefined') {
|
|
5427
|
+
f = { left: window.innerWidth - 16 - FAB, top: window.innerHeight - 16 - FAB };
|
|
5428
|
+
}
|
|
5429
|
+
if (!f) return;
|
|
5430
|
+
const next = inWindow({ left: f.left + FAB - sizeRef.current.w, top: f.top + FAB - sizeRef.current.h }, sizeRef.current.w, sizeRef.current.h);
|
|
5431
|
+
posRef.current = next;
|
|
5432
|
+
setPos(next);
|
|
5433
|
+
writePrefs({ miniPos: next });
|
|
5434
|
+
}
|
|
5435
|
+
/* 把迷你播放条(或圆标)的位置发布到 ui store:右下角的入库悬浮窗据此叠在它上方,不互相遮挡 */
|
|
5436
|
+
useEffect(() => {
|
|
5437
|
+
if (!publishRect || typeof window === 'undefined') return;
|
|
5438
|
+
if (hidden || !track) { publishRect(null); return; }
|
|
5439
|
+
const el = collapsed ? fabRef.current : boxRef.current;
|
|
5440
|
+
if (!el) return;
|
|
5441
|
+
const r = el.getBoundingClientRect();
|
|
5442
|
+
if (!collapsed) sizeRef.current = { w: r.width, h: r.height };
|
|
5443
|
+
publishRect({ left: r.left, top: r.top, w: r.width, h: r.height, collapsed: !!collapsed });
|
|
5444
|
+
}, [pos, fabPos, collapsed, hidden, track ? 1 : 0]);
|
|
3868
5445
|
|
|
3869
5446
|
useEffect(() => { if (trackId) lyrics.load(trackId); }, [trackId]);
|
|
3870
5447
|
|
|
@@ -3917,6 +5494,7 @@ window.__ModuleLoader__.load({
|
|
|
3917
5494
|
const dx = e.clientX - d.px, dy = e.clientY - d.py;
|
|
3918
5495
|
fabMoved.current = Math.max(fabMoved.current, Math.abs(dx) + Math.abs(dy));
|
|
3919
5496
|
if (fabMoved.current < 3) return;
|
|
5497
|
+
if (!dragging) setDragging(true);
|
|
3920
5498
|
const next = {
|
|
3921
5499
|
left: Math.max(0, Math.min(d.left + dx, window.innerWidth - 56)),
|
|
3922
5500
|
top: Math.max(0, Math.min(d.top + dy, window.innerHeight - 56)),
|
|
@@ -3927,7 +5505,8 @@ window.__ModuleLoader__.load({
|
|
|
3927
5505
|
const onFabUp = (e) => {
|
|
3928
5506
|
if (!fabDragRef.current) return;
|
|
3929
5507
|
fabDragRef.current = null;
|
|
3930
|
-
if (fabMoved.current < 5) { setMiniCollapsed(false); return; }
|
|
5508
|
+
if (fabMoved.current < 5) { expandFromFab(); setMiniCollapsed(false); return; }
|
|
5509
|
+
setDragging(false);
|
|
3931
5510
|
if (fabPosRef.current) writePrefs({ miniFabPos: fabPosRef.current });
|
|
3932
5511
|
try { if (fabRef.current) fabRef.current.releasePointerCapture(e.pointerId); } catch { /* released */ }
|
|
3933
5512
|
};
|
|
@@ -3939,7 +5518,7 @@ window.__ModuleLoader__.load({
|
|
|
3939
5518
|
title: t('miniExpand'), 'aria-label': t('miniExpand'),
|
|
3940
5519
|
onPointerDown: onFabDown, onPointerMove: onFabMove,
|
|
3941
5520
|
onPointerUp: onFabUp, onPointerCancel: onFabUp,
|
|
3942
|
-
onKeyDown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); setMiniCollapsed(false); } },
|
|
5521
|
+
onKeyDown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); expandFromFab(); setMiniCollapsed(false); } },
|
|
3943
5522
|
},
|
|
3944
5523
|
h(Thumb, { src: track.coverUrl, size: 48, round: true, glyph: IconNote }),
|
|
3945
5524
|
h('span', { className: 'dshm-mini-fab-badge', 'aria-hidden': true },
|
|
@@ -3947,34 +5526,59 @@ window.__ModuleLoader__.load({
|
|
|
3947
5526
|
}
|
|
3948
5527
|
|
|
3949
5528
|
/* ---------------- expanded: the full mini bar ---------------- */
|
|
3950
|
-
|
|
5529
|
+
/* 整条可拖:把手 / 标题 / 歌词 / 空白处按下并移动 ≥4px 即开始拖动;控件按钮、链接、滑块不参与,
|
|
5530
|
+
* 所以拖动不会吞掉播放/切歌/进度条的操作。指针捕获必须设在挂事件的元素上:
|
|
5531
|
+
* 旧实现把捕获设在 box、move/up 却挂在 grip 上,捕获后事件全部落到 box,
|
|
5532
|
+
* grip 收不到 move,整条只有在指针不离开把手的慢速拖动下才偶尔能动。
|
|
5533
|
+
* 这里统一挂在 box 上并按下即捕获(快速一甩时首个 move 可能已在条外,延迟捕获会丢拖动);
|
|
5534
|
+
* 捕获会让 Chrome 把 click 投递给 box,所以未拖动的轻点由我们转发给标题按钮,单击行为不变。 */
|
|
5535
|
+
const DRAG_THRESHOLD = 4;
|
|
5536
|
+
/* 只有真正的控件排除在拖动区之外;标题主按钮(.dshm-mini-main)既是拖动区也保留单击 */
|
|
5537
|
+
const interactiveTarget = (target) => Boolean(target && typeof target.closest === 'function'
|
|
5538
|
+
&& target.closest('button:not(.dshm-mini-main), a, input, textarea, select, [role="slider"], [role="button"]:not(.dshm-mini-grip)'));
|
|
5539
|
+
const barDown = (e) => {
|
|
5540
|
+
if (e.button !== 0 || interactiveTarget(e.target)) return;
|
|
3951
5541
|
const el = boxRef.current;
|
|
3952
5542
|
if (!el) return;
|
|
3953
|
-
e.preventDefault();
|
|
3954
5543
|
const box = el.getBoundingClientRect();
|
|
3955
|
-
dragRef.current = { px: e.clientX, py: e.clientY, left: box.left, top: box.top, w: box.width, h: box.height };
|
|
3956
|
-
|
|
5544
|
+
dragRef.current = { target: e.target, px: e.clientX, py: e.clientY, left: box.left, top: box.top, w: box.width, h: box.height, active: false, pointerId: e.pointerId };
|
|
5545
|
+
/* 按下即捕获:快速一甩时第一个 move 往往已落在条外,等越过阈值再捕获就收不到它(CDP 实测会丢拖动) */
|
|
3957
5546
|
try { el.setPointerCapture(e.pointerId); } catch { /* unsupported */ }
|
|
5547
|
+
/* 把手没有自己的 click,按下即阻止选中文本 */
|
|
5548
|
+
if (typeof e.target.closest === 'function' && e.target.closest('.dshm-mini-grip')) e.preventDefault();
|
|
3958
5549
|
};
|
|
3959
|
-
const
|
|
5550
|
+
const barMove = (e) => {
|
|
3960
5551
|
const d = dragRef.current;
|
|
3961
|
-
if (!d) return;
|
|
5552
|
+
if (!d || e.pointerId !== d.pointerId) return;
|
|
5553
|
+
const dx = e.clientX - d.px, dy = e.clientY - d.py;
|
|
5554
|
+
if (!d.active) {
|
|
5555
|
+
if (Math.abs(dx) + Math.abs(dy) < DRAG_THRESHOLD) return;
|
|
5556
|
+
d.active = true;
|
|
5557
|
+
setDragging(true);
|
|
5558
|
+
}
|
|
3962
5559
|
const next = {
|
|
3963
|
-
left: Math.max(0, Math.min(d.left +
|
|
3964
|
-
top: Math.max(0, Math.min(d.top +
|
|
5560
|
+
left: Math.max(0, Math.min(d.left + dx, window.innerWidth - d.w - 8)),
|
|
5561
|
+
top: Math.max(0, Math.min(d.top + dy, window.innerHeight - d.h - 8)),
|
|
3965
5562
|
};
|
|
3966
5563
|
posRef.current = next;
|
|
3967
5564
|
setPos(next);
|
|
3968
5565
|
};
|
|
3969
|
-
const
|
|
3970
|
-
|
|
5566
|
+
const barUp = (e, cancelled) => {
|
|
5567
|
+
const d = dragRef.current;
|
|
5568
|
+
if (!d || e.pointerId !== d.pointerId) return;
|
|
3971
5569
|
dragRef.current = null;
|
|
5570
|
+
try { if (boxRef.current) boxRef.current.releasePointerCapture(e.pointerId); } catch { /* released */ }
|
|
5571
|
+
if (!d.active) {
|
|
5572
|
+
/* 未拖动的轻点:捕获让 Chrome 把 click 投递给了 box,这里把标题按钮的单击补回去 */
|
|
5573
|
+
const main = !cancelled && d.target && typeof d.target.closest === 'function' ? d.target.closest('.dshm-mini-main') : null;
|
|
5574
|
+
if (main && boxRef.current && boxRef.current.contains(main)) main.click();
|
|
5575
|
+
return;
|
|
5576
|
+
}
|
|
3972
5577
|
setDragging(false);
|
|
3973
5578
|
if (posRef.current) writePrefs({ miniPos: posRef.current });
|
|
3974
|
-
try { if (boxRef.current) boxRef.current.releasePointerCapture(e.pointerId); } catch { /* released */ }
|
|
3975
5579
|
};
|
|
3976
5580
|
|
|
3977
|
-
|
|
5581
|
+
const frac = duration > 0 ? Math.min(1, position / duration) : 0;
|
|
3978
5582
|
const lines = snap && snap.data && snap.data.synced ? snap.data.lines : null;
|
|
3979
5583
|
let activeIdx = -1;
|
|
3980
5584
|
if (lines) {
|
|
@@ -3991,10 +5595,13 @@ window.__ModuleLoader__.load({
|
|
|
3991
5595
|
}
|
|
3992
5596
|
const style = pos ? { left: pos.left, top: pos.top, right: 'auto', bottom: 'auto' } : undefined;
|
|
3993
5597
|
const activeLine = activeIdx >= 0 && lines && lines[activeIdx] ? (lines[activeIdx].text || '♪') : '';
|
|
3994
|
-
|
|
3995
|
-
|
|
5598
|
+
/* 歌手入口用 span[role=button]:外层 .dshm-mini-main 已经是 <button>,HTML 不允许按钮嵌套(浏览器解析会把它拆开) */
|
|
5599
|
+
const openArtist = (e) => { e.stopPropagation(); openArtistPage(track.artist || ''); };
|
|
5600
|
+
const artistBtn = h('span', {
|
|
5601
|
+
role: 'button', tabIndex: 0, className: 'dshm-mini-artist',
|
|
3996
5602
|
title: t('artistOpen'), 'aria-label': t('artistOpen'),
|
|
3997
|
-
onClick:
|
|
5603
|
+
onClick: openArtist,
|
|
5604
|
+
onKeyDown: (e) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); openArtist(e); } },
|
|
3998
5605
|
},
|
|
3999
5606
|
track.artist
|
|
4000
5607
|
? h(ArtistAvatar, { name: track.artist, size: 14, service: artistImages, useArtistImages })
|
|
@@ -4005,12 +5612,12 @@ window.__ModuleLoader__.load({
|
|
|
4005
5612
|
ref: boxRef, style,
|
|
4006
5613
|
className: cx('dshm-mini', dragging && 'dshm-mini-dragging'),
|
|
4007
5614
|
role: 'region', 'aria-label': t('miniLabel'),
|
|
5615
|
+
onPointerDown: barDown, onPointerMove: barMove,
|
|
5616
|
+
onPointerUp: barUp, onPointerCancel: (e) => barUp(e, true),
|
|
4008
5617
|
},
|
|
4009
5618
|
h('div', {
|
|
4010
5619
|
className: 'dshm-mini-grip', role: 'button', tabIndex: 0,
|
|
4011
5620
|
title: t('miniDrag'), 'aria-label': t('miniDrag'),
|
|
4012
|
-
onPointerDown: gripDown, onPointerMove: gripMove,
|
|
4013
|
-
onPointerUp: gripUp, onPointerCancel: gripUp,
|
|
4014
5621
|
onKeyDown: (e) => {
|
|
4015
5622
|
const step = 12;
|
|
4016
5623
|
const cur = posRef.current || (boxRef.current ? { left: boxRef.current.getBoundingClientRect().left, top: boxRef.current.getBoundingClientRect().top } : { left: 0, top: 0 });
|
|
@@ -4039,6 +5646,9 @@ window.__ModuleLoader__.load({
|
|
|
4039
5646
|
onClick: () => player.toggle(),
|
|
4040
5647
|
}, h(playing ? IconPause : IconPlay, { size: 16 })),
|
|
4041
5648
|
h(IconButton, { label: t('next'), onClick: () => player.next() }, h(IconNext, { size: 15 })),
|
|
5649
|
+
/* ♥ / 👎:与曲库行、正在播放页同一套语义(喜欢才入库,不喜欢从推荐里剔除) */
|
|
5650
|
+
likes ? h(LikeButton, { t, item: track, likes, useLikes, size: 14, className: 'dshm-mini-like' }) : null,
|
|
5651
|
+
likes ? h(DislikeButton, { t, item: track, likes, useLikes, size: 14, className: 'dshm-mini-like' }) : null,
|
|
4042
5652
|
h(IconButton, {
|
|
4043
5653
|
label: mode.label, title: mode.hint + ' · ' + t('modeCycleHint'),
|
|
4044
5654
|
className: cx((shuffle || repeat === 'one') && 'dshm-iconbtn-active'),
|
|
@@ -4046,7 +5656,7 @@ window.__ModuleLoader__.load({
|
|
|
4046
5656
|
}, h(mode.icon, { size: 15 })),
|
|
4047
5657
|
h(IconButton, {
|
|
4048
5658
|
label: t('miniCollapse'), title: t('miniCollapse'),
|
|
4049
|
-
onClick: () => setMiniCollapsed(true),
|
|
5659
|
+
onClick: () => { collapseToFab(); setMiniCollapsed(true); },
|
|
4050
5660
|
}, h(IconChevronDown, { size: 15 })),
|
|
4051
5661
|
h(IconButton, { label: t('hideMini'), title: t('hideMini'), onClick: () => setMiniHidden(true) }, h(IconClose, { size: 13 })))),
|
|
4052
5662
|
h('div', { className: 'dshm-mini-seek' },
|
|
@@ -4064,6 +5674,87 @@ window.__ModuleLoader__.load({
|
|
|
4064
5674
|
: null));
|
|
4065
5675
|
}
|
|
4066
5676
|
|
|
5677
|
+
/* ================================================================
|
|
5678
|
+
* 14b. Download status float (shell.overlay — persistent, bottom-left)
|
|
5679
|
+
* 入库/下载进度悬浮面板:运行中自动弹出;结束后可收成胶囊或关闭;
|
|
5680
|
+
* 每行可播放已入库曲目;「打开曲库」跳回曲库。
|
|
5681
|
+
* ================================================================ */
|
|
5682
|
+
function DownloadFloat({ t, download, library, player, ui, useUi, useDownload, openLibrary }) {
|
|
5683
|
+
const s = useDownload((st) => st);
|
|
5684
|
+
const panel = useUi((st) => st.downloadFloat);
|
|
5685
|
+
const miniRect = useUi((st) => st.miniRect);
|
|
5686
|
+
/* 固定右下角;迷你播放条(或圆标)也在右侧时叠到它上方,两者互不遮挡 */
|
|
5687
|
+
const floatStyle = (() => {
|
|
5688
|
+
if (typeof window === 'undefined') return undefined;
|
|
5689
|
+
const width = Math.min(340, window.innerWidth - 32);
|
|
5690
|
+
const floatLeft = window.innerWidth - 16 - width;
|
|
5691
|
+
const overlapsX = !!miniRect && miniRect.left < window.innerWidth - 16 && (miniRect.left + miniRect.w) > floatLeft;
|
|
5692
|
+
return overlapsX ? { bottom: Math.max(16, window.innerHeight - miniRect.top + 12) + 'px' } : undefined;
|
|
5693
|
+
})();
|
|
5694
|
+
const running = !!s.running;
|
|
5695
|
+
useEffect(() => {
|
|
5696
|
+
if (running && !panel) ui.set({ downloadFloat: 'open' });
|
|
5697
|
+
return undefined;
|
|
5698
|
+
}, [running, panel]);
|
|
5699
|
+
if (!panel) return null;
|
|
5700
|
+
if (!running && s.items.length === 0 && !s.error) return null;
|
|
5701
|
+
const total = s.total || s.items.length;
|
|
5702
|
+
const done = s.done || s.items.filter((it) => it.status !== 'pending' && it.status !== 'downloading').length;
|
|
5703
|
+
const okN = s.items.filter((it) => it.status === 'ok' || it.status === 'skip').length;
|
|
5704
|
+
const failN = s.items.filter((it) => it.status === 'fail').length;
|
|
5705
|
+
const pct = total ? Math.min(100, Math.round((done / total) * 100)) : 0;
|
|
5706
|
+
const tracks = library && library.source ? (library.source.getSnapshot().tracks || []) : [];
|
|
5707
|
+
const playOne = (it) => {
|
|
5708
|
+
const tr = tracks.find((x) => x.id === it.trackId);
|
|
5709
|
+
if (tr && player) player.playTracks([tr], 0);
|
|
5710
|
+
};
|
|
5711
|
+
const close = () => ui.set({ downloadFloat: null });
|
|
5712
|
+
const statusText = (st) => (st === 'ok' ? t('downloadDone')
|
|
5713
|
+
: st === 'skip' ? t('downloadSkip')
|
|
5714
|
+
: st === 'fail' ? t('downloadFail')
|
|
5715
|
+
: st === 'downloading' ? t('downloading') : t('downloadQueued'));
|
|
5716
|
+
if (panel === 'collapsed') {
|
|
5717
|
+
return portalToBody(h('button', {
|
|
5718
|
+
type: 'button', className: 'dshm-dl-pill', style: floatStyle, title: t('downloadExpand'), 'aria-label': t('downloadTitle'),
|
|
5719
|
+
onClick: () => ui.set({ downloadFloat: 'open' }),
|
|
5720
|
+
},
|
|
5721
|
+
running ? h(IconRefresh, { size: 13, className: 'dshm-spin' }) : h(IconDownload, { size: 13 }),
|
|
5722
|
+
h('span', { className: 'dshm-ellipsis' }, running
|
|
5723
|
+
? fmt(t('downloadPillRunning'), { done, total })
|
|
5724
|
+
: (failN ? fmt(t('downloadPillDoneFail'), { ok: okN, fail: failN }) : fmt(t('downloadPillDone'), { ok: okN }))),
|
|
5725
|
+
h('span', { className: 'dshm-dl-pill-bar', 'aria-hidden': true }, h('span', { style: { width: pct + '%' } }))));
|
|
5726
|
+
}
|
|
5727
|
+
return portalToBody(h('div', { className: 'dshm-dl-float', style: floatStyle, role: 'region', 'aria-label': t('downloadTitle') },
|
|
5728
|
+
h('div', { className: 'dshm-dl-head' },
|
|
5729
|
+
h(IconDownload, { size: 14 }),
|
|
5730
|
+
h('span', { className: 'dshm-dl-title' }, t('downloadTitle')),
|
|
5731
|
+
h('span', { className: 'dshm-count' }, running ? done + ' / ' + total : t('downloadFinished')),
|
|
5732
|
+
h('span', { style: { marginLeft: 'auto' } }),
|
|
5733
|
+
h(IconButton, { label: t('downloadCollapse'), onClick: () => ui.set({ downloadFloat: 'collapsed' }) }, h(IconChevronDown, { size: 14 })),
|
|
5734
|
+
h(IconButton, { label: t('downloadClose'), onClick: close }, h(IconClose, { size: 14 }))),
|
|
5735
|
+
h('div', { className: 'dshm-dl-bar', 'aria-hidden': true }, h('div', { style: { width: pct + '%' } })),
|
|
5736
|
+
s.error
|
|
5737
|
+
? h('div', { className: 'dshm-errorline', role: 'alert' }, h(IconAlert, { size: 14 }), t('downloadError') + ':' + s.error)
|
|
5738
|
+
: null,
|
|
5739
|
+
h('div', { className: 'dshm-dl-list' },
|
|
5740
|
+
s.items.map((it, i) => h('div', { className: 'dshm-dl-row', key: i, title: it.note || '' },
|
|
5741
|
+
h('span', { className: cx('dshm-dl-dot', (it.status === 'ok' || it.status === 'skip') && 'dshm-dl-ok', it.status === 'fail' && 'dshm-dl-fail', (it.status === 'pending' || it.status === 'downloading') && 'dshm-dl-wait') }),
|
|
5742
|
+
h('span', { className: 'dshm-ellipsis', style: { flex: 1 } }, (it.artist || '') + ' - ' + (it.title || '')),
|
|
5743
|
+
it.note && it.status !== 'ok' && it.status !== 'skip'
|
|
5744
|
+
? h('span', { className: 'dshm-dl-note dshm-ellipsis', title: it.note }, it.note)
|
|
5745
|
+
: null,
|
|
5746
|
+
h('span', { className: 'dshm-dl-status' }, statusText(it.status)),
|
|
5747
|
+
(it.status === 'ok' || it.status === 'skip') && it.trackId && !running
|
|
5748
|
+
? h(IconButton, { label: t('downloadPlayOne'), onClick: () => playOne(it) }, h(IconPlay, { size: 12 }))
|
|
5749
|
+
: null))),
|
|
5750
|
+
!running
|
|
5751
|
+
? h('div', { className: 'dshm-dl-foot' },
|
|
5752
|
+
h('span', { className: cx('dshm-dl-sum', failN ? 'dshm-dl-sum-warn' : 'dshm-dl-sum-ok') },
|
|
5753
|
+
failN ? fmt(t('downloadSummary'), { ok: okN, fail: failN }) : fmt(t('downloadSummaryAll'), { ok: okN })),
|
|
5754
|
+
h('button', { className: 'dshm-chipbtn', type: 'button', onClick: () => { close(); openLibrary(); } }, t('downloadOpenLibrary')))
|
|
5755
|
+
: null));
|
|
5756
|
+
}
|
|
5757
|
+
|
|
4067
5758
|
/* ================================================================
|
|
4068
5759
|
* 15. Plugin body
|
|
4069
5760
|
* ================================================================ */
|
|
@@ -4086,18 +5777,23 @@ window.__ModuleLoader__.load({
|
|
|
4086
5777
|
const historyService = createHistoryService(api);
|
|
4087
5778
|
const player = createPlayer(t, api);
|
|
4088
5779
|
const previewService = createPreviewService(api);
|
|
5780
|
+
const warmService = createWarmService(previewService, player);
|
|
4089
5781
|
const likesService = createLikesService(api, () => downloadService.warm());
|
|
5782
|
+
/* 喜欢列表导入(网易云 / QQ 音乐):导入完成后刷新 ♥ 列表 */
|
|
5783
|
+
const likedSyncService = createLikedSyncService(api, () => likesService.load());
|
|
4090
5784
|
ctx.effect(() => () => {
|
|
4091
5785
|
downloadService.dispose();
|
|
4092
5786
|
syncService.dispose();
|
|
4093
5787
|
previewService.dispose();
|
|
5788
|
+
likedSyncService.dispose();
|
|
4094
5789
|
}, 'dsh-music: s3 poll timers');
|
|
5790
|
+
likedSyncService.load();
|
|
4095
5791
|
downloadService.warm();
|
|
4096
5792
|
syncService.warm();
|
|
4097
|
-
/* First run: open the
|
|
5793
|
+
/* First run: open the settings page only when the host explicitly says the
|
|
4098
5794
|
* flow is not completed (a missing endpoint must never interrupt users). */
|
|
4099
5795
|
onboardingService.load().then((data) => {
|
|
4100
|
-
if (data && data.completed === false) ui.set({ view: '
|
|
5796
|
+
if (data && data.completed === false) ui.set({ view: 'settings', settingsSection: null });
|
|
4101
5797
|
});
|
|
4102
5798
|
ctx.effect(() => () => onboardingService.dispose(), 'dsh-music: onboarding timer');
|
|
4103
5799
|
/* v6 mini-window semantics changed: close now means "hidden until shown".
|
|
@@ -4111,7 +5807,10 @@ window.__ModuleLoader__.load({
|
|
|
4111
5807
|
miniHidden: miniPrefsOk ? !!savedPrefs.miniHidden : false,
|
|
4112
5808
|
miniCollapsed: miniPrefsOk ? !!savedPrefs.miniCollapsed : false,
|
|
4113
5809
|
artistName: null,
|
|
4114
|
-
|
|
5810
|
+
settingsSection: null,
|
|
5811
|
+
libTabWish: null,
|
|
5812
|
+
downloadFloat: null,
|
|
5813
|
+
miniRect: null,
|
|
4115
5814
|
});
|
|
4116
5815
|
const openView = (view) => ui.set({ view });
|
|
4117
5816
|
const openArtistPage = (name) => ui.set({ view: 'artist', artistName: name });
|
|
@@ -4153,7 +5852,7 @@ window.__ModuleLoader__.load({
|
|
|
4153
5852
|
inject: () => ({
|
|
4154
5853
|
player, library, lyrics: lyricsService, artist: artistService, artistImages: artistImageService, onboarding: onboardingService,
|
|
4155
5854
|
reco: recoService, download: downloadService, sync: syncService, history: historyService,
|
|
4156
|
-
likes: likesService, preview: previewService,
|
|
5855
|
+
likes: likesService, preview: previewService, warm: warmService, likedSync: likedSyncService,
|
|
4157
5856
|
openView, openArtistPage, setMiniHidden, ui, artistPage: artistPageService,
|
|
4158
5857
|
hooks: {
|
|
4159
5858
|
player: player.source, library: library.source, ui,
|
|
@@ -4161,6 +5860,7 @@ window.__ModuleLoader__.load({
|
|
|
4161
5860
|
reco: recoService.source, download: downloadService.source,
|
|
4162
5861
|
sync: syncService.source, history: historyService.source,
|
|
4163
5862
|
likes: likesService.source, preview: previewService.source,
|
|
5863
|
+
warm: warmService.source, likedSync: likedSyncService.source,
|
|
4164
5864
|
},
|
|
4165
5865
|
}),
|
|
4166
5866
|
}, MusicPanel)), 'dsh-music: main panel');
|
|
@@ -4171,13 +5871,26 @@ window.__ModuleLoader__.load({
|
|
|
4171
5871
|
id: 'dsh-music.mini-player',
|
|
4172
5872
|
locale: NS,
|
|
4173
5873
|
inject: () => ({
|
|
4174
|
-
player, lyrics: lyricsService, artistImages: artistImageService, setMiniHidden, setMiniCollapsed,
|
|
5874
|
+
player, lyrics: lyricsService, artistImages: artistImageService, likes: likesService, setMiniHidden, setMiniCollapsed,
|
|
4175
5875
|
openNow: () => { openView('now'); ctx.layout.selectPanel(PANEL_ID); },
|
|
4176
5876
|
openArtistPage: (name) => { if (!name) return; openArtistPage(name); ctx.layout.selectPanel(PANEL_ID); },
|
|
4177
|
-
|
|
5877
|
+
publishRect: (rect) => ui.set({ miniRect: rect }),
|
|
5878
|
+
hooks: { player: player.source, ui, lyrics: lyricsService.source, artistImages: artistImageService.source, likes: likesService.source },
|
|
4178
5879
|
}),
|
|
4179
5880
|
}, MiniPlayer)), 'dsh-music: mini player');
|
|
4180
5881
|
|
|
5882
|
+
// Persistent download/add-to-library status float (bottom-right, stacked above the mini bar), above every column.
|
|
5883
|
+
ctx.effect(() => ctx.slots.inject('shell.overlay', () => ctx.slots.register({
|
|
5884
|
+
name: 'shell.overlay',
|
|
5885
|
+
id: 'dsh-music.download-float',
|
|
5886
|
+
locale: NS,
|
|
5887
|
+
inject: () => ({
|
|
5888
|
+
download: downloadService, library, player, ui,
|
|
5889
|
+
openLibrary: () => openView('library'),
|
|
5890
|
+
hooks: { download: downloadService.source, library: library.source, ui },
|
|
5891
|
+
}),
|
|
5892
|
+
}, DownloadFloat)), 'dsh-music: download float');
|
|
5893
|
+
|
|
4181
5894
|
// Warm the library so the panel opens populated; errors surface in-view.
|
|
4182
5895
|
library.load();
|
|
4183
5896
|
}
|