ahutchen commited on
Commit
71ebd26
·
1 Parent(s): 7468cf4

feat(search): 优化音乐源选择功能

Browse files

- 为移动端和 PC 端分别设计不同的音乐源选择界面
- 在 PC 端添加下拉选择框,支持按优先级排序的音乐源
- 优化选择框样式,增加过渡效果和交互反馈
- 移除 PWA 安装提示相关代码

src/components/common/ActionMenu.vue CHANGED
@@ -57,7 +57,7 @@ import { computed, ref } from 'vue'
57
  import { useFavoritesStore } from '@/stores/favorites'
58
  import { useToastStore } from '@/stores/toast'
59
  import PlaylistSelector from '@/components/playlist/PlaylistSelector.vue'
60
- import { utils } from '@/services/musicApi'
61
 
62
  const props = defineProps({
63
  // 项目类型:'song' | 'playlist'
@@ -240,10 +240,16 @@ const handleAction = async (action) => {
240
  case 'download':
241
  if (!props.song) return
242
  try {
243
- if (props.song.url) {
 
 
 
 
244
  const link = document.createElement('a')
245
- link.href = props.song.url
246
  link.download = `${utils.formatArtist(props.song.artist)} - ${props.song.name}.mp3`
 
 
247
  document.body.appendChild(link)
248
  link.click()
249
  document.body.removeChild(link)
 
57
  import { useFavoritesStore } from '@/stores/favorites'
58
  import { useToastStore } from '@/stores/toast'
59
  import PlaylistSelector from '@/components/playlist/PlaylistSelector.vue'
60
+ import { utils, musicApi } from '@/services/musicApi'
61
 
62
  const props = defineProps({
63
  // 项目类型:'song' | 'playlist'
 
240
  case 'download':
241
  if (!props.song) return
242
  try {
243
+ toastStore.info('正在获取下载链接...')
244
+
245
+ const audioUrl = await musicApi.getMusicUrl(props.song.source, props.song.id, '320')
246
+
247
+ if (audioUrl) {
248
  const link = document.createElement('a')
249
+ link.href = audioUrl
250
  link.download = `${utils.formatArtist(props.song.artist)} - ${props.song.name}.mp3`
251
+ link.target = '_blank'
252
+ link.rel = 'noopener noreferrer'
253
  document.body.appendChild(link)
254
  link.click()
255
  document.body.removeChild(link)
src/components/player/MoreActionsPanel.vue CHANGED
@@ -123,7 +123,7 @@ import { computed, ref } from 'vue'
123
  import { useFavoritesStore } from '@/stores/favorites'
124
  import { useToastStore } from '@/stores/toast'
125
  import PlaylistSelector from '@/components/playlist/PlaylistSelector.vue'
126
- import { utils } from '@/services/musicApi'
127
 
128
  const props = defineProps({
129
  song: {
@@ -225,12 +225,17 @@ const handleAction = async (action) => {
225
 
226
  case 'download':
227
  if (!props.song) return
228
- // 实现下载功能
229
  try {
230
- if (props.song.url) {
 
 
 
 
231
  const link = document.createElement('a')
232
- link.href = props.song.url
233
  link.download = `${utils.formatArtist(props.song.artist)} - ${props.song.name}.mp3`
 
 
234
  document.body.appendChild(link)
235
  link.click()
236
  document.body.removeChild(link)
 
123
  import { useFavoritesStore } from '@/stores/favorites'
124
  import { useToastStore } from '@/stores/toast'
125
  import PlaylistSelector from '@/components/playlist/PlaylistSelector.vue'
126
+ import { utils, musicApi } from '@/services/musicApi'
127
 
128
  const props = defineProps({
129
  song: {
 
225
 
226
  case 'download':
227
  if (!props.song) return
 
228
  try {
229
+ toastStore.info('正在获取下载链接...')
230
+
231
+ const audioUrl = await musicApi.getMusicUrl(props.song.source, props.song.id, '320')
232
+
233
+ if (audioUrl) {
234
  const link = document.createElement('a')
235
+ link.href = audioUrl
236
  link.download = `${utils.formatArtist(props.song.artist)} - ${props.song.name}.mp3`
237
+ link.target = '_blank'
238
+ link.rel = 'noopener noreferrer'
239
  document.body.appendChild(link)
240
  link.click()
241
  document.body.removeChild(link)