@neteasecloudmusicapienhanced/api 4.32.0 → 4.32.1

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.
Files changed (439) hide show
  1. package/LICENSE +21 -21
  2. package/README.MD +248 -251
  3. package/app.js +18 -18
  4. package/data/china_ip_ranges.txt +4147 -4147
  5. package/data/deviceid.txt +24641 -24641
  6. package/generateConfig.js +24 -24
  7. package/interface.d.ts +1843 -1836
  8. package/main.js +63 -63
  9. package/module/activate_init_profile.js +9 -9
  10. package/module/aidj_content_rcmd.js +28 -28
  11. package/module/album.js +6 -6
  12. package/module/album_detail.js +12 -12
  13. package/module/album_detail_dynamic.js +12 -12
  14. package/module/album_list.js +16 -16
  15. package/module/album_list_style.js +15 -15
  16. package/module/album_new.js +11 -11
  17. package/module/album_newest.js +6 -6
  18. package/module/album_privilege.js +9 -9
  19. package/module/album_songsaleboard.js +19 -19
  20. package/module/album_sub.js +10 -10
  21. package/module/album_sublist.js +11 -11
  22. package/module/api.js +21 -21
  23. package/module/artist_album.js +15 -15
  24. package/module/artist_desc.js +9 -9
  25. package/module/artist_detail.js +10 -10
  26. package/module/artist_detail_dynamic.js +9 -9
  27. package/module/artist_fans.js +11 -11
  28. package/module/artist_follow_count.js +13 -13
  29. package/module/artist_list.js +33 -33
  30. package/module/artist_mv.js +12 -12
  31. package/module/artist_new_mv.js +12 -12
  32. package/module/artist_new_song.js +12 -12
  33. package/module/artist_songs.js +12 -12
  34. package/module/artist_sub.js +11 -11
  35. package/module/artist_sublist.js +11 -11
  36. package/module/artist_top_song.js +8 -8
  37. package/module/artist_video.js +15 -15
  38. package/module/artists.js +6 -6
  39. package/module/audio_match.js +19 -19
  40. package/module/avatar_upload.js +22 -22
  41. package/module/banner.js +16 -16
  42. package/module/batch.js +12 -12
  43. package/module/broadcast_category_region_get.js +11 -11
  44. package/module/broadcast_channel_collect_list.js +12 -12
  45. package/module/broadcast_channel_currentinfo.js +13 -13
  46. package/module/broadcast_channel_list.js +13 -13
  47. package/module/broadcast_sub.js +12 -12
  48. package/module/calendar.js +8 -8
  49. package/module/captcha_sent.js +11 -11
  50. package/module/captcha_verify.js +11 -11
  51. package/module/cellphone_existence_check.js +10 -10
  52. package/module/check_music.js +30 -30
  53. package/module/cloud.js +164 -164
  54. package/module/cloud_import.js +39 -39
  55. package/module/cloud_lyric_get.js +11 -11
  56. package/module/cloud_match.js +13 -13
  57. package/module/cloud_upload_complete.js +72 -72
  58. package/module/cloud_upload_token.js +111 -111
  59. package/module/cloudsearch.js +13 -13
  60. package/module/comment.js +30 -30
  61. package/module/comment_album.js +16 -16
  62. package/module/comment_dj.js +16 -16
  63. package/module/comment_event.js +15 -15
  64. package/module/comment_floor.js +16 -16
  65. package/module/comment_hot.js +18 -18
  66. package/module/comment_hug_list.js +20 -20
  67. package/module/comment_info_list.js +30 -30
  68. package/module/comment_like.js +20 -20
  69. package/module/comment_music.js +16 -16
  70. package/module/comment_mv.js +16 -16
  71. package/module/comment_new.js +37 -37
  72. package/module/comment_playlist.js +16 -16
  73. package/module/{comment_delete.js → comment_report.js} +11 -10
  74. package/module/comment_video.js +16 -16
  75. package/module/countries_code_list.js +6 -6
  76. package/module/creator_authinfo_get.js +6 -6
  77. package/module/daily_signin.js +16 -16
  78. package/module/digitalAlbum_detail.js +13 -13
  79. package/module/digitalAlbum_ordering.js +22 -22
  80. package/module/digitalAlbum_purchased.js +15 -15
  81. package/module/digitalAlbum_sales.js +13 -13
  82. package/module/djRadio_top.js +15 -15
  83. package/module/dj_banner.js +6 -6
  84. package/module/dj_category_excludehot.js +10 -10
  85. package/module/dj_category_recommend.js +10 -10
  86. package/module/dj_catelist.js +6 -6
  87. package/module/dj_detail.js +9 -9
  88. package/module/dj_difm_all_style_channel.js +9 -9
  89. package/module/dj_difm_channel_subscribe.js +9 -9
  90. package/module/dj_difm_channel_unsubscribe.js +9 -9
  91. package/module/dj_difm_playing_tracks_list.js +11 -11
  92. package/module/dj_difm_subscribe_channels_get.js +13 -13
  93. package/module/dj_hot.js +10 -10
  94. package/module/dj_paygift.js +15 -15
  95. package/module/dj_personalize_recommend.js +12 -12
  96. package/module/dj_program.js +12 -12
  97. package/module/dj_program_detail.js +9 -9
  98. package/module/dj_program_toplist.js +10 -10
  99. package/module/dj_program_toplist_hours.js +13 -13
  100. package/module/dj_radio_hot.js +11 -11
  101. package/module/dj_recommend.js +6 -6
  102. package/module/dj_recommend_type.js +32 -32
  103. package/module/dj_sub.js +10 -10
  104. package/module/dj_sublist.js +11 -11
  105. package/module/dj_subscriber.js +12 -12
  106. package/module/dj_today_perfered.js +13 -13
  107. package/module/dj_toplist.js +14 -14
  108. package/module/dj_toplist_hours.js +10 -10
  109. package/module/dj_toplist_newcomer.js +9 -9
  110. package/module/dj_toplist_pay.js +9 -9
  111. package/module/dj_toplist_popular.js +10 -10
  112. package/module/eapi_decrypt.js +27 -27
  113. package/module/event.js +10 -10
  114. package/module/event_del.js +9 -9
  115. package/module/event_forward.js +11 -11
  116. package/module/fanscenter_basicinfo_age_get.js +6 -6
  117. package/module/fanscenter_basicinfo_gender_get.js +10 -10
  118. package/module/fanscenter_basicinfo_province_get.js +10 -10
  119. package/module/fanscenter_overview_get.js +6 -6
  120. package/module/fanscenter_trend_list.js +10 -10
  121. package/module/fm_trash.js +11 -11
  122. package/module/follow.js +11 -11
  123. package/module/get_userids.js +7 -7
  124. package/module/history_recommend_songs.js +11 -11
  125. package/module/history_recommend_songs_detail.js +13 -13
  126. package/module/homepage_block_page.js +8 -8
  127. package/module/homepage_dragon_ball.js +10 -10
  128. package/module/hot_topic.js +10 -10
  129. package/module/hug_comment.js +16 -16
  130. package/module/inner_version.js +16 -16
  131. package/module/like.js +13 -13
  132. package/module/likelist.js +9 -9
  133. package/module/listen_data_realtime_report.js +11 -11
  134. package/module/listen_data_report.js +12 -12
  135. package/module/listen_data_today_song.js +9 -9
  136. package/module/listen_data_total.js +9 -9
  137. package/module/listen_data_year_report.js +9 -9
  138. package/module/listentogether_accept.js +13 -13
  139. package/module/listentogether_end.js +9 -9
  140. package/module/listentogether_heatbeat.js +12 -12
  141. package/module/listentogether_play_command.js +21 -21
  142. package/module/listentogether_room_check.js +9 -9
  143. package/module/listentogether_room_create.js +9 -9
  144. package/module/listentogether_status.js +10 -10
  145. package/module/listentogether_sync_list_command.js +26 -26
  146. package/module/listentogether_sync_playlist_get.js +13 -13
  147. package/module/login.js +41 -41
  148. package/module/login_cellphone.js +40 -40
  149. package/module/login_qr_check.js +29 -29
  150. package/module/login_qr_create.js +30 -30
  151. package/module/login_qr_key.js +19 -19
  152. package/module/login_refresh.js +21 -21
  153. package/module/login_status.js +21 -21
  154. package/module/logout.js +6 -6
  155. package/module/lyric.js +14 -14
  156. package/module/lyric_new.js +17 -17
  157. package/module/mlog_music_rcmd.js +13 -13
  158. package/module/mlog_to_video.js +13 -13
  159. package/module/mlog_url.js +11 -11
  160. package/module/msg_comments.js +17 -17
  161. package/module/msg_forwards.js +11 -11
  162. package/module/msg_notices.js +10 -10
  163. package/module/msg_private.js +11 -11
  164. package/module/msg_private_history.js +12 -12
  165. package/module/msg_recentcontact.js +11 -11
  166. package/module/music_first_listen_info.js +13 -13
  167. package/module/musician_cloudbean.js +7 -7
  168. package/module/musician_cloudbean_obtain.js +14 -14
  169. package/module/musician_data_overview.js +11 -11
  170. package/module/musician_play_trend.js +14 -14
  171. package/module/musician_sign.js +7 -7
  172. package/module/musician_tasks.js +11 -11
  173. package/module/musician_tasks_new.js +11 -11
  174. package/module/musician_vip_tasks.js +11 -11
  175. package/module/mv_all.js +16 -16
  176. package/module/mv_detail.js +9 -9
  177. package/module/mv_detail_info.js +14 -14
  178. package/module/mv_exclusive_rcmd.js +10 -10
  179. package/module/mv_first.js +12 -12
  180. package/module/mv_sub.js +11 -11
  181. package/module/mv_sublist.js +15 -15
  182. package/module/mv_url.js +14 -14
  183. package/module/nickname_check.js +7 -7
  184. package/module/personal_fm.js +6 -6
  185. package/module/personal_fm_mode.js +14 -14
  186. package/module/personalized.js +16 -16
  187. package/module/personalized_djprogram.js +10 -10
  188. package/module/personalized_mv.js +6 -6
  189. package/module/personalized_newsong.js +15 -15
  190. package/module/personalized_privatecontent.js +10 -10
  191. package/module/personalized_privatecontent_list.js +15 -15
  192. package/module/pl_count.js +6 -6
  193. package/module/playlist_category_list.js +11 -11
  194. package/module/playlist_catlist.js +6 -6
  195. package/module/playlist_cover_update.js +32 -32
  196. package/module/playlist_create.js +11 -11
  197. package/module/playlist_delete.js +9 -9
  198. package/module/playlist_desc_update.js +10 -10
  199. package/module/playlist_detail.js +11 -11
  200. package/module/playlist_detail_dynamic.js +11 -11
  201. package/module/playlist_detail_rcmd_get.js +11 -11
  202. package/module/playlist_highquality_tags.js +10 -10
  203. package/module/playlist_hot.js +6 -6
  204. package/module/playlist_import_name_task_create.js +62 -62
  205. package/module/playlist_import_task_status.js +11 -11
  206. package/module/playlist_mylike.js +12 -12
  207. package/module/playlist_name_update.js +10 -10
  208. package/module/playlist_order_update.js +13 -13
  209. package/module/playlist_privacy.js +10 -10
  210. package/module/playlist_subscribe.js +14 -14
  211. package/module/playlist_subscribers.js +11 -11
  212. package/module/playlist_tags_update.js +10 -10
  213. package/module/playlist_track_add.js +16 -16
  214. package/module/playlist_track_all.js +31 -31
  215. package/module/playlist_track_delete.js +20 -20
  216. package/module/playlist_tracks.js +45 -45
  217. package/module/playlist_update.js +13 -13
  218. package/module/playlist_update_playcount.js +9 -9
  219. package/module/playlist_video_recent.js +9 -9
  220. package/module/playmode_intelligence_list.js +13 -13
  221. package/module/playmode_song_vector.js +8 -8
  222. package/module/program_recommend.js +15 -15
  223. package/module/radio_sport_get.js +9 -9
  224. package/module/rebind.js +16 -16
  225. package/module/recent_listen_list.js +7 -7
  226. package/module/recommend_resource.js +10 -10
  227. package/module/recommend_songs.js +13 -11
  228. package/module/recommend_songs_dislike.js +14 -14
  229. package/module/record_recent_album.js +11 -11
  230. package/module/record_recent_dj.js +11 -11
  231. package/module/record_recent_playlist.js +11 -11
  232. package/module/record_recent_song.js +11 -11
  233. package/module/record_recent_video.js +11 -11
  234. package/module/record_recent_voice.js +11 -11
  235. package/module/register_anonimous.js +53 -53
  236. package/module/register_cellphone.js +15 -15
  237. package/module/related_allvideo.js +14 -14
  238. package/module/related_playlist.js +32 -32
  239. package/module/resource_like.js +14 -14
  240. package/module/sati_resource_list.js +11 -11
  241. package/module/sati_resource_list_more.js +13 -13
  242. package/module/sati_resource_sub.js +10 -10
  243. package/module/sati_resource_sub_list.js +7 -7
  244. package/module/sati_tag_list.js +7 -7
  245. package/module/sati_timescene_resources_get.js +13 -13
  246. package/module/scrobble.js +26 -26
  247. package/module/search.js +21 -21
  248. package/module/search_default.js +6 -6
  249. package/module/search_hot.js +9 -9
  250. package/module/search_hot_detail.js +6 -6
  251. package/module/search_match.js +18 -18
  252. package/module/search_multimatch.js +14 -14
  253. package/module/search_suggest.js +14 -14
  254. package/module/search_suggest_pc.js +13 -13
  255. package/module/send_album.js +12 -12
  256. package/module/send_playlist.js +12 -12
  257. package/module/send_song.js +12 -12
  258. package/module/send_text.js +11 -11
  259. package/module/setting.js +7 -7
  260. package/module/share_resource.js +11 -11
  261. package/module/sheet_list.js +9 -9
  262. package/module/sheet_preview.js +8 -8
  263. package/module/sign_happy_info.js +5 -5
  264. package/module/signin_progress.js +13 -13
  265. package/module/simi_artist.js +12 -12
  266. package/module/simi_mv.js +9 -9
  267. package/module/simi_playlist.js +15 -15
  268. package/module/simi_song.js +15 -15
  269. package/module/simi_user.js +11 -11
  270. package/module/song_chorus.js +11 -11
  271. package/module/song_copyright_rcmd.js +9 -0
  272. package/module/song_creators.js +9 -9
  273. package/module/song_detail.js +11 -11
  274. package/module/song_downlist.js +11 -11
  275. package/module/song_download_url.js +10 -10
  276. package/module/song_download_url_v1.js +13 -13
  277. package/module/song_dynamic_cover.js +9 -9
  278. package/module/song_like.js +12 -12
  279. package/module/song_like_check.js +9 -9
  280. package/module/song_lyrics_mark.js +9 -9
  281. package/module/song_lyrics_mark_add.js +12 -12
  282. package/module/song_lyrics_mark_del.js +9 -9
  283. package/module/song_lyrics_mark_user_page.js +14 -14
  284. package/module/song_monthdownlist.js +11 -11
  285. package/module/song_music_detail.js +9 -9
  286. package/module/song_order_update.js +12 -12
  287. package/module/song_purchased.js +14 -14
  288. package/module/song_red_count.js +9 -9
  289. package/module/song_singledownlist.js +11 -11
  290. package/module/song_url.js +26 -26
  291. package/module/song_url_match.js +38 -38
  292. package/module/song_url_ncmget.js +5 -5
  293. package/module/song_url_v1.js +57 -57
  294. package/module/song_url_v1_302.js +53 -53
  295. package/module/song_wiki_summary.js +8 -8
  296. package/module/starpick_comments_summary.js +12 -12
  297. package/module/style_album.js +16 -16
  298. package/module/style_artist.js +16 -16
  299. package/module/style_detail.js +9 -9
  300. package/module/style_list.js +7 -7
  301. package/module/style_playlist.js +16 -16
  302. package/module/style_preference.js +11 -11
  303. package/module/style_song.js +12 -12
  304. package/module/summary_annual.js +12 -12
  305. package/module/threshold_detail_get.js +10 -10
  306. package/module/top_album.js +22 -22
  307. package/module/top_artists.js +11 -11
  308. package/module/top_list.js +20 -20
  309. package/module/top_mv.js +12 -12
  310. package/module/top_playlist.js +22 -22
  311. package/module/top_playlist_highquality.js +16 -16
  312. package/module/top_song.js +16 -16
  313. package/module/topic_detail.js +7 -7
  314. package/module/topic_detail_event_hot.js +7 -7
  315. package/module/topic_sublist.js +11 -11
  316. package/module/toplist.js +6 -6
  317. package/module/toplist_artist.js +12 -12
  318. package/module/toplist_detail.js +6 -6
  319. package/module/toplist_detail_v2.js +6 -6
  320. package/module/ugc_album_get.js +8 -8
  321. package/module/ugc_artist_get.js +8 -8
  322. package/module/ugc_artist_search.js +10 -10
  323. package/module/ugc_detail.js +17 -17
  324. package/module/ugc_mv_get.js +8 -8
  325. package/module/ugc_song_get.js +8 -8
  326. package/module/ugc_user_devote.js +6 -6
  327. package/module/user_account.js +5 -5
  328. package/module/user_audio.js +9 -9
  329. package/module/user_binding.js +9 -9
  330. package/module/user_bindingcellphone.js +15 -15
  331. package/module/user_cloud.js +10 -10
  332. package/module/user_cloud_del.js +9 -9
  333. package/module/user_cloud_detail.js +10 -10
  334. package/module/user_comment_history.js +15 -15
  335. package/module/user_detail.js +15 -15
  336. package/module/user_detail_new.js +20 -20
  337. package/module/user_dj.js +14 -14
  338. package/module/user_event.js +12 -12
  339. package/module/user_follow_mixed.js +23 -23
  340. package/module/user_followeds.js +17 -17
  341. package/module/user_follows.js +15 -15
  342. package/module/user_level.js +7 -7
  343. package/module/user_medal.js +11 -11
  344. package/module/user_mutualfollow_get.js +9 -9
  345. package/module/user_playlist.js +12 -12
  346. package/module/user_playlist_collect.js +14 -14
  347. package/module/user_playlist_create.js +14 -14
  348. package/module/user_record.js +10 -10
  349. package/module/user_replacephone.js +14 -14
  350. package/module/user_social_status.js +11 -11
  351. package/module/user_social_status_edit.js +16 -16
  352. package/module/user_social_status_rcmd.js +5 -5
  353. package/module/user_social_status_support.js +5 -5
  354. package/module/user_subcount.js +6 -6
  355. package/module/user_update.js +15 -15
  356. package/module/verify_getQr.js +39 -39
  357. package/module/verify_qrcodestatus.js +12 -12
  358. package/module/video_category_list.js +15 -15
  359. package/module/video_detail.js +13 -13
  360. package/module/video_detail_info.js +14 -14
  361. package/module/video_group.js +16 -16
  362. package/module/video_group_list.js +11 -11
  363. package/module/video_sub.js +14 -14
  364. package/module/video_timeline_all.js +17 -17
  365. package/module/video_timeline_recommend.js +13 -13
  366. package/module/video_url.js +10 -10
  367. package/module/vip_growthpoint.js +11 -11
  368. package/module/vip_growthpoint_details.js +14 -14
  369. package/module/vip_growthpoint_get.js +13 -13
  370. package/module/vip_info.js +12 -12
  371. package/module/vip_info_v2.js +12 -12
  372. package/module/vip_sign.js +7 -11
  373. package/module/vip_sign_info.js +11 -11
  374. package/module/vip_tasks.js +11 -11
  375. package/module/vip_timemachine.js +17 -17
  376. package/module/voice_delete.js +7 -7
  377. package/module/voice_detail.js +7 -7
  378. package/module/voice_lyric.js +7 -7
  379. package/module/voice_upload.js +200 -200
  380. package/module/voicelist_detail.js +11 -11
  381. package/module/voicelist_list.js +13 -13
  382. package/module/voicelist_list_search.js +14 -14
  383. package/module/voicelist_my_created.js +13 -13
  384. package/module/voicelist_search.js +11 -11
  385. package/module/voicelist_trans.js +15 -15
  386. package/module/weblog.js +10 -10
  387. package/module/yunbei.js +6 -6
  388. package/module/yunbei_expense.js +8 -8
  389. package/module/yunbei_info.js +5 -5
  390. package/module/yunbei_rcmd_song.js +17 -17
  391. package/module/yunbei_rcmd_song_history.js +16 -16
  392. package/module/yunbei_receipt.js +8 -8
  393. package/module/yunbei_sign.js +5 -5
  394. package/module/yunbei_task_finish.js +12 -12
  395. package/module/yunbei_tasks.js +9 -9
  396. package/module/yunbei_tasks_todo.js +9 -9
  397. package/module/yunbei_today.js +5 -5
  398. package/package.json +8 -8
  399. package/plugins/songUpload.js +109 -109
  400. package/plugins/upload.js +35 -35
  401. package/public/api.html +222 -222
  402. package/public/audio_match_demo/afp.js +1626 -1626
  403. package/public/audio_match_demo/afp.wasm.js +5 -5
  404. package/public/audio_match_demo/index.html +367 -367
  405. package/public/audio_match_demo/rec.js +49 -49
  406. package/public/avatar_update.html +326 -326
  407. package/public/cloud.html +578 -578
  408. package/public/docs/_coverpage.md +13 -13
  409. package/public/docs/home.md +5318 -5325
  410. package/public/docs/index.html +129 -47
  411. package/public/docs/logo.svg +6 -6
  412. package/public/docs/netease.png +0 -0
  413. package/public/docs/sw.js +90 -90
  414. package/public/eapi_decrypt.html +264 -264
  415. package/public/home.html +40 -40
  416. package/public/index.html +124 -124
  417. package/public/listen_together_host.html +552 -552
  418. package/public/login.html +219 -219
  419. package/public/playlist_cover_update.html +323 -323
  420. package/public/playlist_import.html +416 -416
  421. package/public/qrlogin-nocookie.html +199 -199
  422. package/public/qrlogin.html +199 -199
  423. package/public/static/2169.png +0 -0
  424. package/public/static/neteaselogo.png +0 -0
  425. package/public/unblock_test.html +153 -153
  426. package/public/voice_upload.html +326 -326
  427. package/server.js +454 -454
  428. package/util/apicache.js +836 -836
  429. package/util/client-sign.js +169 -169
  430. package/util/config.json +20 -20
  431. package/util/crypto.js +153 -153
  432. package/util/fileHelper.js +88 -88
  433. package/util/index.js +233 -233
  434. package/util/logger.js +42 -42
  435. package/util/memory-cache.js +71 -71
  436. package/util/option.js +14 -14
  437. package/util/request.js +367 -367
  438. package/module/comment_add.js +0 -15
  439. package/module/comment_reply.js +0 -13
package/public/cloud.html CHANGED
@@ -1,578 +1,578 @@
1
- <!DOCTYPE html>
2
- <html lang="zh">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>云盘上传</title>
7
- <style>
8
- * {
9
- margin: 0;
10
- padding: 0;
11
- box-sizing: border-box;
12
- }
13
-
14
- body {
15
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
16
- min-height: 100vh;
17
- background: #f5f5f5;
18
- padding: 20px;
19
- }
20
-
21
- .container {
22
- max-width: 800px;
23
- margin: 0 auto;
24
- background: white;
25
- border-radius: 12px;
26
- padding: 32px;
27
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
28
- }
29
-
30
- h1 {
31
- font-size: 24px;
32
- font-weight: 600;
33
- color: #333;
34
- margin-bottom: 24px;
35
- }
36
-
37
- .login-link {
38
- display: block;
39
- margin-bottom: 24px;
40
- color: #666;
41
- font-size: 14px;
42
- text-decoration: none;
43
- }
44
-
45
- .login-link:hover {
46
- color: #333;
47
- text-decoration: underline;
48
- }
49
-
50
- .mode-section {
51
- margin-bottom: 24px;
52
- padding: 16px;
53
- background: #f9f9f9;
54
- border-radius: 8px;
55
- }
56
-
57
- .mode-section label {
58
- display: block;
59
- font-size: 14px;
60
- font-weight: 500;
61
- color: #333;
62
- margin-bottom: 12px;
63
- }
64
-
65
- .mode-options {
66
- display: flex;
67
- gap: 16px;
68
- flex-wrap: wrap;
69
- }
70
-
71
- .mode-option {
72
- display: flex;
73
- align-items: flex-start;
74
- gap: 8px;
75
- cursor: pointer;
76
- }
77
-
78
- .mode-option input[type="radio"] {
79
- margin-top: 3px;
80
- }
81
-
82
- .mode-option-text {
83
- display: flex;
84
- flex-direction: column;
85
- }
86
-
87
- .mode-option-title {
88
- font-size: 14px;
89
- color: #333;
90
- }
91
-
92
- .mode-option-desc {
93
- font-size: 12px;
94
- color: #999;
95
- margin-top: 2px;
96
- }
97
-
98
- .mode-option input[type="radio"]:checked + .mode-option-text .mode-option-title {
99
- color: #333;
100
- font-weight: 500;
101
- }
102
-
103
- .upload-section {
104
- margin-bottom: 32px;
105
- }
106
-
107
- .upload-btn {
108
- display: inline-block;
109
- padding: 12px 28px;
110
- background: #333;
111
- color: white;
112
- font-size: 15px;
113
- font-weight: 500;
114
- border-radius: 6px;
115
- cursor: pointer;
116
- transition: background 0.2s ease;
117
- border: none;
118
- }
119
-
120
- .upload-btn:hover {
121
- background: #555;
122
- }
123
-
124
- .upload-btn input[type="file"] {
125
- display: none;
126
- }
127
-
128
- .upload-btn.disabled {
129
- background: #ccc;
130
- cursor: not-allowed;
131
- }
132
-
133
- .songs-list {
134
- list-style: none;
135
- }
136
-
137
- .song-item {
138
- padding: 12px 16px;
139
- border-bottom: 1px solid #eee;
140
- font-size: 14px;
141
- color: #333;
142
- }
143
-
144
- .song-item:last-child {
145
- border-bottom: none;
146
- }
147
-
148
- .empty-state {
149
- text-align: center;
150
- padding: 40px 20px;
151
- color: #999;
152
- font-size: 14px;
153
- }
154
-
155
- .loading {
156
- text-align: center;
157
- padding: 20px;
158
- color: #666;
159
- }
160
-
161
- .progress-section {
162
- margin-bottom: 24px;
163
- display: none;
164
- }
165
-
166
- .progress-section.active {
167
- display: block;
168
- }
169
-
170
- .progress-item {
171
- margin-bottom: 12px;
172
- padding: 12px;
173
- background: #f9f9f9;
174
- border-radius: 6px;
175
- }
176
-
177
- .progress-item .name {
178
- font-size: 14px;
179
- color: #333;
180
- margin-bottom: 8px;
181
- word-break: break-all;
182
- }
183
-
184
- .progress-item .status {
185
- font-size: 12px;
186
- color: #666;
187
- margin-bottom: 6px;
188
- }
189
-
190
- .progress-bar {
191
- height: 6px;
192
- background: #e0e0e0;
193
- border-radius: 3px;
194
- overflow: hidden;
195
- }
196
-
197
- .progress-bar .fill {
198
- height: 100%;
199
- background: #333;
200
- border-radius: 3px;
201
- transition: width 0.3s ease;
202
- width: 0%;
203
- }
204
-
205
- .progress-item.success .fill {
206
- background: #4caf50;
207
- }
208
-
209
- .progress-item.error .fill {
210
- background: #f44336;
211
- }
212
-
213
- .progress-item.error .status {
214
- color: #f44336;
215
- }
216
-
217
- .info-text {
218
- font-size: 12px;
219
- color: #999;
220
- margin-top: 8px;
221
- }
222
-
223
- .warning-text {
224
- font-size: 12px;
225
- color: #e65100;
226
- margin-top: 8px;
227
- }
228
- </style>
229
- </head>
230
-
231
- <body>
232
- <div class="container">
233
- <h1>云盘上传</h1>
234
- <a href="/qrlogin-nocookie.html" class="login-link">还没登录?点击登录</a>
235
-
236
- <div class="mode-section">
237
- <label>上传模式</label>
238
- <div class="mode-options">
239
- <label class="mode-option">
240
- <input type="radio" name="uploadMode" value="direct" checked />
241
- <span class="mode-option-text">
242
- <span class="mode-option-title">客户端直传</span>
243
- <span class="mode-option-desc">文件直接上传到云存储,支持大文件,适合 Vercel 等平台</span>
244
- </span>
245
- </label>
246
- <label class="mode-option">
247
- <input type="radio" name="uploadMode" value="proxy" />
248
- <span class="mode-option-text">
249
- <span class="mode-option-title">后端代理</span>
250
- <span class="mode-option-desc">文件通过服务器转发,更简洁,需要服务器支持大文件</span>
251
- </span>
252
- </label>
253
- </div>
254
- </div>
255
-
256
- <div class="upload-section">
257
- <label class="upload-btn" id="uploadBtn">
258
- 选择文件(支持多选)
259
- <input id="file" type="file" multiple accept="audio/*" />
260
- </label>
261
- <p class="info-text" id="modeInfo">支持大文件上传,文件将直接传输到云存储服务器</p>
262
- </div>
263
-
264
- <div id="progressSection" class="progress-section"></div>
265
-
266
- <div id="app">
267
- <div v-if="loading" class="loading">加载中...</div>
268
- <ul v-else-if="songs.length > 0" class="songs-list">
269
- <li v-for="(item, index) in songs" :key="index" class="song-item">
270
- {{ item.songName }}
271
- </li>
272
- </ul>
273
- <div v-else class="empty-state">暂无云盘歌曲</div>
274
- </div>
275
- </div>
276
-
277
- <script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
278
- <script src="https://fastly.jsdelivr.net/npm/vue@3"></script>
279
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jsmediatags/3.9.5/jsmediatags.min.js"></script>
280
- <script>
281
- const app = Vue.createApp({
282
- data() {
283
- return {
284
- songs: [],
285
- loading: false,
286
- }
287
- },
288
- created() {
289
- this.getData()
290
- },
291
- methods: {
292
- getData() {
293
- this.loading = true
294
- axios({
295
- url: `/user/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
296
- })
297
- .then((res) => {
298
- this.songs = res.data.data || []
299
- })
300
- .catch((err) => {
301
- console.error('获取云盘数据失败:', err)
302
- })
303
- .finally(() => {
304
- this.loading = false
305
- })
306
- },
307
- },
308
- }).mount('#app')
309
-
310
- let isUploading = false
311
- let uploadMode = 'direct'
312
- const progressSection = document.getElementById('progressSection')
313
- const uploadBtn = document.getElementById('uploadBtn')
314
- const fileInput = document.querySelector('input[type="file"]')
315
- const modeInfo = document.getElementById('modeInfo')
316
-
317
- document.querySelectorAll('input[name="uploadMode"]').forEach(radio => {
318
- radio.addEventListener('change', function() {
319
- uploadMode = this.value
320
- if (uploadMode === 'direct') {
321
- modeInfo.textContent = '支持大文件上传,文件将直接传输到云存储服务器'
322
- modeInfo.className = 'info-text'
323
- } else {
324
- modeInfo.textContent = '文件将通过服务器转发,服务器需支持大文件上传(Vercel 限制 4.5MB)'
325
- modeInfo.className = 'warning-text'
326
- }
327
- })
328
- })
329
-
330
- function main() {
331
- fileInput.addEventListener('change', function (e) {
332
- const files = this.files
333
- if (files.length === 0) return
334
- if (isUploading) return
335
-
336
- uploadFilesSequentially(Array.from(files))
337
- this.value = ''
338
- })
339
- }
340
- main()
341
-
342
- async function uploadFilesSequentially(files) {
343
- isUploading = true
344
- uploadBtn.classList.add('disabled')
345
- progressSection.classList.add('active')
346
- progressSection.innerHTML = ''
347
-
348
- for (let i = 0; i < files.length; i++) {
349
- if (uploadMode === 'direct') {
350
- await uploadFileDirect(files[i], i + 1, files.length)
351
- } else {
352
- await uploadFileProxy(files[i], i + 1, files.length)
353
- }
354
- }
355
-
356
- isUploading = false
357
- uploadBtn.classList.remove('disabled')
358
- app.getData()
359
- }
360
-
361
- function createProgressItem(file, index, total) {
362
- const item = document.createElement('div')
363
- item.className = 'progress-item'
364
- item.id = `progress-${index}`
365
- item.innerHTML = `
366
- <div class="name">${file.name} (${formatSize(file.size)})</div>
367
- <div class="status">准备中...</div>
368
- <div class="progress-bar"><div class="fill"></div></div>
369
- `
370
- progressSection.appendChild(item)
371
- return item
372
- }
373
-
374
- function updateProgress(index, status, percent, isError = false) {
375
- const item = document.getElementById(`progress-${index}`)
376
- if (!item) return
377
- item.querySelector('.status').textContent = status
378
- item.querySelector('.fill').style.width = `${percent}%`
379
- if (isError) {
380
- item.classList.add('error')
381
- } else if (percent >= 100) {
382
- item.classList.add('success')
383
- }
384
- }
385
-
386
- function formatSize(bytes) {
387
- if (bytes < 1024) return bytes + ' B'
388
- if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
389
- return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
390
- }
391
-
392
- async function uploadFileProxy(file, index, total) {
393
- createProgressItem(file, index, total)
394
-
395
- try {
396
- updateProgress(index, '上传中...', 10)
397
-
398
- const formData = new FormData()
399
- formData.append('songFile', file)
400
-
401
- await axios({
402
- method: 'post',
403
- url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
404
- headers: {
405
- 'Content-Type': 'multipart/form-data',
406
- },
407
- data: formData,
408
- onUploadProgress: (progressEvent) => {
409
- const percent = Math.round((progressEvent.loaded / progressEvent.total) * 90) + 10
410
- updateProgress(index, `上传中... ${Math.round(progressEvent.loaded / progressEvent.total * 100)}%`, Math.min(percent, 100))
411
- },
412
- timeout: 600000,
413
- })
414
-
415
- updateProgress(index, '上传完成!', 100)
416
-
417
- } catch (err) {
418
- console.error(`${file.name} 上传失败:`, err)
419
- const errorMsg = err.response?.data?.msg || err.message || '未知错误'
420
- if (err.response?.status === 413 || errorMsg.includes('PAYLOAD_TOO_LARGE')) {
421
- updateProgress(index, '文件过大,请切换到客户端直传模式', 0, true)
422
- } else {
423
- updateProgress(index, `上传失败: ${errorMsg}`, 0, true)
424
- }
425
- }
426
- }
427
-
428
- async function calculateMD5(file) {
429
- return new Promise((resolve, reject) => {
430
- const chunkSize = 2 * 1024 * 1024
431
- const chunks = Math.ceil(file.size / chunkSize)
432
- let currentChunk = 0
433
- const spark = new SparkMD5.ArrayBuffer()
434
- const reader = new FileReader()
435
-
436
- reader.onload = (e) => {
437
- spark.append(e.target.result)
438
- currentChunk++
439
- if (currentChunk < chunks) {
440
- loadNext()
441
- } else {
442
- resolve(spark.end())
443
- }
444
- }
445
-
446
- reader.onerror = () => reject(reader.error)
447
-
448
- function loadNext() {
449
- const start = currentChunk * chunkSize
450
- const end = Math.min(start + chunkSize, file.size)
451
- reader.readAsArrayBuffer(file.slice(start, end))
452
- }
453
-
454
- loadNext()
455
- })
456
- }
457
-
458
- async function parseMediaTags(file) {
459
- return new Promise((resolve) => {
460
- jsmediatags.read(file, {
461
- onSuccess: function(tag) {
462
- resolve({
463
- title: tag.tags.title || null,
464
- artist: tag.tags.artist || null,
465
- album: tag.tags.album || null,
466
- })
467
- },
468
- onError: function() {
469
- resolve({ title: null, artist: null, album: null })
470
- }
471
- })
472
- })
473
- }
474
-
475
- async function uploadFileDirect(file, index, total) {
476
- createProgressItem(file, index, total)
477
-
478
- try {
479
- updateProgress(index, '计算文件MD5...', 5)
480
-
481
- const md5 = await calculateMD5(file)
482
- const fileSize = file.size
483
- const filename = file.name
484
-
485
- updateProgress(index, '解析音频元数据...', 8)
486
-
487
- const mediaTags = await parseMediaTags(file)
488
-
489
- updateProgress(index, '获取上传凭证...', 10)
490
-
491
- const tokenRes = await axios({
492
- method: 'post',
493
- url: `/cloud/upload/token?time=${Date.now()}`,
494
- data: {
495
- cookie: localStorage.getItem('cookie'),
496
- md5: md5,
497
- fileSize: fileSize,
498
- filename: filename,
499
- },
500
- })
501
-
502
- if (tokenRes.data.code !== 200) {
503
- throw new Error(tokenRes.data.msg || '获取上传凭证失败')
504
- }
505
-
506
- const tokenData = tokenRes.data.data
507
-
508
- if (!tokenData.needUpload) {
509
- updateProgress(index, '文件已存在,直接导入云盘...', 80)
510
- await completeUpload(tokenData, file, mediaTags)
511
- updateProgress(index, '上传完成!', 100)
512
- return
513
- }
514
-
515
- updateProgress(index, '开始上传到云存储...', 15)
516
-
517
- await axios({
518
- method: 'post',
519
- url: tokenData.uploadUrl,
520
- headers: {
521
- 'x-nos-token': tokenData.uploadToken,
522
- 'Content-MD5': md5,
523
- 'Content-Type': 'audio/mpeg',
524
- 'Content-Length': String(fileSize),
525
- },
526
- data: file,
527
- onUploadProgress: (progressEvent) => {
528
- const percent = Math.round((progressEvent.loaded / progressEvent.total) * 70) + 15
529
- updateProgress(index, `上传中... ${Math.round(progressEvent.loaded / progressEvent.total * 100)}%`, Math.min(percent, 85))
530
- },
531
- maxContentLength: Infinity,
532
- maxBodyLength: Infinity,
533
- timeout: 600000,
534
- })
535
-
536
- updateProgress(index, '上传完成,正在导入云盘...', 90)
537
-
538
- await completeUpload(tokenData, file, mediaTags)
539
-
540
- updateProgress(index, '上传完成!', 100)
541
-
542
- } catch (err) {
543
- console.error(`${file.name} 上传失败:`, err)
544
- const errorMsg = err.response?.data?.msg || err.message || '未知错误'
545
- updateProgress(index, `上传失败: ${errorMsg}`, 0, true)
546
- }
547
- }
548
-
549
- async function completeUpload(tokenData, file, mediaTags = {}) {
550
- const songName = mediaTags.title || file.name.replace(/\.[^.]+$/, '')
551
- const artist = mediaTags.artist || '未知艺术家'
552
- const album = mediaTags.album || '未知专辑'
553
-
554
- const completeRes = await axios({
555
- method: 'post',
556
- url: `/cloud/upload/complete?time=${Date.now()}`,
557
- data: {
558
- cookie: localStorage.getItem('cookie'),
559
- songId: tokenData.songId,
560
- resourceId: tokenData.resourceId,
561
- md5: tokenData.md5,
562
- filename: file.name,
563
- song: songName,
564
- artist: artist,
565
- album: album,
566
- },
567
- })
568
-
569
- if (completeRes.data.code !== 200) {
570
- throw new Error(completeRes.data.msg || '导入云盘失败')
571
- }
572
-
573
- return completeRes.data
574
- }
575
- </script>
576
- <script src="https://fastly.jsdelivr.net/npm/spark-md5@3.0.2/spark-md5.min.js"></script>
577
- </body>
578
- </html>
1
+ <!DOCTYPE html>
2
+ <html lang="zh">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>云盘上传</title>
7
+ <style>
8
+ * {
9
+ margin: 0;
10
+ padding: 0;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ body {
15
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
16
+ min-height: 100vh;
17
+ background: #f5f5f5;
18
+ padding: 20px;
19
+ }
20
+
21
+ .container {
22
+ max-width: 800px;
23
+ margin: 0 auto;
24
+ background: white;
25
+ border-radius: 12px;
26
+ padding: 32px;
27
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
28
+ }
29
+
30
+ h1 {
31
+ font-size: 24px;
32
+ font-weight: 600;
33
+ color: #333;
34
+ margin-bottom: 24px;
35
+ }
36
+
37
+ .login-link {
38
+ display: block;
39
+ margin-bottom: 24px;
40
+ color: #666;
41
+ font-size: 14px;
42
+ text-decoration: none;
43
+ }
44
+
45
+ .login-link:hover {
46
+ color: #333;
47
+ text-decoration: underline;
48
+ }
49
+
50
+ .mode-section {
51
+ margin-bottom: 24px;
52
+ padding: 16px;
53
+ background: #f9f9f9;
54
+ border-radius: 8px;
55
+ }
56
+
57
+ .mode-section label {
58
+ display: block;
59
+ font-size: 14px;
60
+ font-weight: 500;
61
+ color: #333;
62
+ margin-bottom: 12px;
63
+ }
64
+
65
+ .mode-options {
66
+ display: flex;
67
+ gap: 16px;
68
+ flex-wrap: wrap;
69
+ }
70
+
71
+ .mode-option {
72
+ display: flex;
73
+ align-items: flex-start;
74
+ gap: 8px;
75
+ cursor: pointer;
76
+ }
77
+
78
+ .mode-option input[type="radio"] {
79
+ margin-top: 3px;
80
+ }
81
+
82
+ .mode-option-text {
83
+ display: flex;
84
+ flex-direction: column;
85
+ }
86
+
87
+ .mode-option-title {
88
+ font-size: 14px;
89
+ color: #333;
90
+ }
91
+
92
+ .mode-option-desc {
93
+ font-size: 12px;
94
+ color: #999;
95
+ margin-top: 2px;
96
+ }
97
+
98
+ .mode-option input[type="radio"]:checked + .mode-option-text .mode-option-title {
99
+ color: #333;
100
+ font-weight: 500;
101
+ }
102
+
103
+ .upload-section {
104
+ margin-bottom: 32px;
105
+ }
106
+
107
+ .upload-btn {
108
+ display: inline-block;
109
+ padding: 12px 28px;
110
+ background: #333;
111
+ color: white;
112
+ font-size: 15px;
113
+ font-weight: 500;
114
+ border-radius: 6px;
115
+ cursor: pointer;
116
+ transition: background 0.2s ease;
117
+ border: none;
118
+ }
119
+
120
+ .upload-btn:hover {
121
+ background: #555;
122
+ }
123
+
124
+ .upload-btn input[type="file"] {
125
+ display: none;
126
+ }
127
+
128
+ .upload-btn.disabled {
129
+ background: #ccc;
130
+ cursor: not-allowed;
131
+ }
132
+
133
+ .songs-list {
134
+ list-style: none;
135
+ }
136
+
137
+ .song-item {
138
+ padding: 12px 16px;
139
+ border-bottom: 1px solid #eee;
140
+ font-size: 14px;
141
+ color: #333;
142
+ }
143
+
144
+ .song-item:last-child {
145
+ border-bottom: none;
146
+ }
147
+
148
+ .empty-state {
149
+ text-align: center;
150
+ padding: 40px 20px;
151
+ color: #999;
152
+ font-size: 14px;
153
+ }
154
+
155
+ .loading {
156
+ text-align: center;
157
+ padding: 20px;
158
+ color: #666;
159
+ }
160
+
161
+ .progress-section {
162
+ margin-bottom: 24px;
163
+ display: none;
164
+ }
165
+
166
+ .progress-section.active {
167
+ display: block;
168
+ }
169
+
170
+ .progress-item {
171
+ margin-bottom: 12px;
172
+ padding: 12px;
173
+ background: #f9f9f9;
174
+ border-radius: 6px;
175
+ }
176
+
177
+ .progress-item .name {
178
+ font-size: 14px;
179
+ color: #333;
180
+ margin-bottom: 8px;
181
+ word-break: break-all;
182
+ }
183
+
184
+ .progress-item .status {
185
+ font-size: 12px;
186
+ color: #666;
187
+ margin-bottom: 6px;
188
+ }
189
+
190
+ .progress-bar {
191
+ height: 6px;
192
+ background: #e0e0e0;
193
+ border-radius: 3px;
194
+ overflow: hidden;
195
+ }
196
+
197
+ .progress-bar .fill {
198
+ height: 100%;
199
+ background: #333;
200
+ border-radius: 3px;
201
+ transition: width 0.3s ease;
202
+ width: 0%;
203
+ }
204
+
205
+ .progress-item.success .fill {
206
+ background: #4caf50;
207
+ }
208
+
209
+ .progress-item.error .fill {
210
+ background: #f44336;
211
+ }
212
+
213
+ .progress-item.error .status {
214
+ color: #f44336;
215
+ }
216
+
217
+ .info-text {
218
+ font-size: 12px;
219
+ color: #999;
220
+ margin-top: 8px;
221
+ }
222
+
223
+ .warning-text {
224
+ font-size: 12px;
225
+ color: #e65100;
226
+ margin-top: 8px;
227
+ }
228
+ </style>
229
+ </head>
230
+
231
+ <body>
232
+ <div class="container">
233
+ <h1>云盘上传</h1>
234
+ <a href="/qrlogin-nocookie.html" class="login-link">还没登录?点击登录</a>
235
+
236
+ <div class="mode-section">
237
+ <label>上传模式</label>
238
+ <div class="mode-options">
239
+ <label class="mode-option">
240
+ <input type="radio" name="uploadMode" value="direct" checked />
241
+ <span class="mode-option-text">
242
+ <span class="mode-option-title">客户端直传</span>
243
+ <span class="mode-option-desc">文件直接上传到云存储,支持大文件,适合 Vercel 等平台</span>
244
+ </span>
245
+ </label>
246
+ <label class="mode-option">
247
+ <input type="radio" name="uploadMode" value="proxy" />
248
+ <span class="mode-option-text">
249
+ <span class="mode-option-title">后端代理</span>
250
+ <span class="mode-option-desc">文件通过服务器转发,更简洁,需要服务器支持大文件</span>
251
+ </span>
252
+ </label>
253
+ </div>
254
+ </div>
255
+
256
+ <div class="upload-section">
257
+ <label class="upload-btn" id="uploadBtn">
258
+ 选择文件(支持多选)
259
+ <input id="file" type="file" multiple accept="audio/*" />
260
+ </label>
261
+ <p class="info-text" id="modeInfo">支持大文件上传,文件将直接传输到云存储服务器</p>
262
+ </div>
263
+
264
+ <div id="progressSection" class="progress-section"></div>
265
+
266
+ <div id="app">
267
+ <div v-if="loading" class="loading">加载中...</div>
268
+ <ul v-else-if="songs.length > 0" class="songs-list">
269
+ <li v-for="(item, index) in songs" :key="index" class="song-item">
270
+ {{ item.songName }}
271
+ </li>
272
+ </ul>
273
+ <div v-else class="empty-state">暂无云盘歌曲</div>
274
+ </div>
275
+ </div>
276
+
277
+ <script src="https://fastly.jsdelivr.net/npm/axios@0.26.1/dist/axios.min.js"></script>
278
+ <script src="https://fastly.jsdelivr.net/npm/vue@3"></script>
279
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/jsmediatags/3.9.5/jsmediatags.min.js"></script>
280
+ <script>
281
+ const app = Vue.createApp({
282
+ data() {
283
+ return {
284
+ songs: [],
285
+ loading: false,
286
+ }
287
+ },
288
+ created() {
289
+ this.getData()
290
+ },
291
+ methods: {
292
+ getData() {
293
+ this.loading = true
294
+ axios({
295
+ url: `/user/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
296
+ })
297
+ .then((res) => {
298
+ this.songs = res.data.data || []
299
+ })
300
+ .catch((err) => {
301
+ console.error('获取云盘数据失败:', err)
302
+ })
303
+ .finally(() => {
304
+ this.loading = false
305
+ })
306
+ },
307
+ },
308
+ }).mount('#app')
309
+
310
+ let isUploading = false
311
+ let uploadMode = 'direct'
312
+ const progressSection = document.getElementById('progressSection')
313
+ const uploadBtn = document.getElementById('uploadBtn')
314
+ const fileInput = document.querySelector('input[type="file"]')
315
+ const modeInfo = document.getElementById('modeInfo')
316
+
317
+ document.querySelectorAll('input[name="uploadMode"]').forEach(radio => {
318
+ radio.addEventListener('change', function() {
319
+ uploadMode = this.value
320
+ if (uploadMode === 'direct') {
321
+ modeInfo.textContent = '支持大文件上传,文件将直接传输到云存储服务器'
322
+ modeInfo.className = 'info-text'
323
+ } else {
324
+ modeInfo.textContent = '文件将通过服务器转发,服务器需支持大文件上传(Vercel 限制 4.5MB)'
325
+ modeInfo.className = 'warning-text'
326
+ }
327
+ })
328
+ })
329
+
330
+ function main() {
331
+ fileInput.addEventListener('change', function (e) {
332
+ const files = this.files
333
+ if (files.length === 0) return
334
+ if (isUploading) return
335
+
336
+ uploadFilesSequentially(Array.from(files))
337
+ this.value = ''
338
+ })
339
+ }
340
+ main()
341
+
342
+ async function uploadFilesSequentially(files) {
343
+ isUploading = true
344
+ uploadBtn.classList.add('disabled')
345
+ progressSection.classList.add('active')
346
+ progressSection.innerHTML = ''
347
+
348
+ for (let i = 0; i < files.length; i++) {
349
+ if (uploadMode === 'direct') {
350
+ await uploadFileDirect(files[i], i + 1, files.length)
351
+ } else {
352
+ await uploadFileProxy(files[i], i + 1, files.length)
353
+ }
354
+ }
355
+
356
+ isUploading = false
357
+ uploadBtn.classList.remove('disabled')
358
+ app.getData()
359
+ }
360
+
361
+ function createProgressItem(file, index, total) {
362
+ const item = document.createElement('div')
363
+ item.className = 'progress-item'
364
+ item.id = `progress-${index}`
365
+ item.innerHTML = `
366
+ <div class="name">${file.name} (${formatSize(file.size)})</div>
367
+ <div class="status">准备中...</div>
368
+ <div class="progress-bar"><div class="fill"></div></div>
369
+ `
370
+ progressSection.appendChild(item)
371
+ return item
372
+ }
373
+
374
+ function updateProgress(index, status, percent, isError = false) {
375
+ const item = document.getElementById(`progress-${index}`)
376
+ if (!item) return
377
+ item.querySelector('.status').textContent = status
378
+ item.querySelector('.fill').style.width = `${percent}%`
379
+ if (isError) {
380
+ item.classList.add('error')
381
+ } else if (percent >= 100) {
382
+ item.classList.add('success')
383
+ }
384
+ }
385
+
386
+ function formatSize(bytes) {
387
+ if (bytes < 1024) return bytes + ' B'
388
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
389
+ return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
390
+ }
391
+
392
+ async function uploadFileProxy(file, index, total) {
393
+ createProgressItem(file, index, total)
394
+
395
+ try {
396
+ updateProgress(index, '上传中...', 10)
397
+
398
+ const formData = new FormData()
399
+ formData.append('songFile', file)
400
+
401
+ await axios({
402
+ method: 'post',
403
+ url: `/cloud?time=${Date.now()}&cookie=${localStorage.getItem('cookie')}`,
404
+ headers: {
405
+ 'Content-Type': 'multipart/form-data',
406
+ },
407
+ data: formData,
408
+ onUploadProgress: (progressEvent) => {
409
+ const percent = Math.round((progressEvent.loaded / progressEvent.total) * 90) + 10
410
+ updateProgress(index, `上传中... ${Math.round(progressEvent.loaded / progressEvent.total * 100)}%`, Math.min(percent, 100))
411
+ },
412
+ timeout: 600000,
413
+ })
414
+
415
+ updateProgress(index, '上传完成!', 100)
416
+
417
+ } catch (err) {
418
+ console.error(`${file.name} 上传失败:`, err)
419
+ const errorMsg = err.response?.data?.msg || err.message || '未知错误'
420
+ if (err.response?.status === 413 || errorMsg.includes('PAYLOAD_TOO_LARGE')) {
421
+ updateProgress(index, '文件过大,请切换到客户端直传模式', 0, true)
422
+ } else {
423
+ updateProgress(index, `上传失败: ${errorMsg}`, 0, true)
424
+ }
425
+ }
426
+ }
427
+
428
+ async function calculateMD5(file) {
429
+ return new Promise((resolve, reject) => {
430
+ const chunkSize = 2 * 1024 * 1024
431
+ const chunks = Math.ceil(file.size / chunkSize)
432
+ let currentChunk = 0
433
+ const spark = new SparkMD5.ArrayBuffer()
434
+ const reader = new FileReader()
435
+
436
+ reader.onload = (e) => {
437
+ spark.append(e.target.result)
438
+ currentChunk++
439
+ if (currentChunk < chunks) {
440
+ loadNext()
441
+ } else {
442
+ resolve(spark.end())
443
+ }
444
+ }
445
+
446
+ reader.onerror = () => reject(reader.error)
447
+
448
+ function loadNext() {
449
+ const start = currentChunk * chunkSize
450
+ const end = Math.min(start + chunkSize, file.size)
451
+ reader.readAsArrayBuffer(file.slice(start, end))
452
+ }
453
+
454
+ loadNext()
455
+ })
456
+ }
457
+
458
+ async function parseMediaTags(file) {
459
+ return new Promise((resolve) => {
460
+ jsmediatags.read(file, {
461
+ onSuccess: function(tag) {
462
+ resolve({
463
+ title: tag.tags.title || null,
464
+ artist: tag.tags.artist || null,
465
+ album: tag.tags.album || null,
466
+ })
467
+ },
468
+ onError: function() {
469
+ resolve({ title: null, artist: null, album: null })
470
+ }
471
+ })
472
+ })
473
+ }
474
+
475
+ async function uploadFileDirect(file, index, total) {
476
+ createProgressItem(file, index, total)
477
+
478
+ try {
479
+ updateProgress(index, '计算文件MD5...', 5)
480
+
481
+ const md5 = await calculateMD5(file)
482
+ const fileSize = file.size
483
+ const filename = file.name
484
+
485
+ updateProgress(index, '解析音频元数据...', 8)
486
+
487
+ const mediaTags = await parseMediaTags(file)
488
+
489
+ updateProgress(index, '获取上传凭证...', 10)
490
+
491
+ const tokenRes = await axios({
492
+ method: 'post',
493
+ url: `/cloud/upload/token?time=${Date.now()}`,
494
+ data: {
495
+ cookie: localStorage.getItem('cookie'),
496
+ md5: md5,
497
+ fileSize: fileSize,
498
+ filename: filename,
499
+ },
500
+ })
501
+
502
+ if (tokenRes.data.code !== 200) {
503
+ throw new Error(tokenRes.data.msg || '获取上传凭证失败')
504
+ }
505
+
506
+ const tokenData = tokenRes.data.data
507
+
508
+ if (!tokenData.needUpload) {
509
+ updateProgress(index, '文件已存在,直接导入云盘...', 80)
510
+ await completeUpload(tokenData, file, mediaTags)
511
+ updateProgress(index, '上传完成!', 100)
512
+ return
513
+ }
514
+
515
+ updateProgress(index, '开始上传到云存储...', 15)
516
+
517
+ await axios({
518
+ method: 'post',
519
+ url: tokenData.uploadUrl,
520
+ headers: {
521
+ 'x-nos-token': tokenData.uploadToken,
522
+ 'Content-MD5': md5,
523
+ 'Content-Type': 'audio/mpeg',
524
+ 'Content-Length': String(fileSize),
525
+ },
526
+ data: file,
527
+ onUploadProgress: (progressEvent) => {
528
+ const percent = Math.round((progressEvent.loaded / progressEvent.total) * 70) + 15
529
+ updateProgress(index, `上传中... ${Math.round(progressEvent.loaded / progressEvent.total * 100)}%`, Math.min(percent, 85))
530
+ },
531
+ maxContentLength: Infinity,
532
+ maxBodyLength: Infinity,
533
+ timeout: 600000,
534
+ })
535
+
536
+ updateProgress(index, '上传完成,正在导入云盘...', 90)
537
+
538
+ await completeUpload(tokenData, file, mediaTags)
539
+
540
+ updateProgress(index, '上传完成!', 100)
541
+
542
+ } catch (err) {
543
+ console.error(`${file.name} 上传失败:`, err)
544
+ const errorMsg = err.response?.data?.msg || err.message || '未知错误'
545
+ updateProgress(index, `上传失败: ${errorMsg}`, 0, true)
546
+ }
547
+ }
548
+
549
+ async function completeUpload(tokenData, file, mediaTags = {}) {
550
+ const songName = mediaTags.title || file.name.replace(/\.[^.]+$/, '')
551
+ const artist = mediaTags.artist || '未知艺术家'
552
+ const album = mediaTags.album || '未知专辑'
553
+
554
+ const completeRes = await axios({
555
+ method: 'post',
556
+ url: `/cloud/upload/complete?time=${Date.now()}`,
557
+ data: {
558
+ cookie: localStorage.getItem('cookie'),
559
+ songId: tokenData.songId,
560
+ resourceId: tokenData.resourceId,
561
+ md5: tokenData.md5,
562
+ filename: file.name,
563
+ song: songName,
564
+ artist: artist,
565
+ album: album,
566
+ },
567
+ })
568
+
569
+ if (completeRes.data.code !== 200) {
570
+ throw new Error(completeRes.data.msg || '导入云盘失败')
571
+ }
572
+
573
+ return completeRes.data
574
+ }
575
+ </script>
576
+ <script src="https://fastly.jsdelivr.net/npm/spark-md5@3.0.2/spark-md5.min.js"></script>
577
+ </body>
578
+ </html>