Skip to content

Commit bd643f9

Browse files
author
xiaohong
committed
feat: 音乐卡片新增播放和暂停按钮
1 parent b7f06ec commit bd643f9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/views/ai/music/components/list/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<el-tab-pane v-loading="loading" label="我的创作" name="mine">
77
<el-row v-if="mySongList.length" :gutter="12">
88
<el-col v-for="song in mySongList" :key="song.id" :span="24">
9-
<songCard :songInfo="song" @click="setCurrentSong(song)"/>
9+
<songCard :songInfo="song" @play="setCurrentSong(song)"/>
1010
</el-col>
1111
</el-row>
1212
<el-empty v-else description="暂无音乐"/>
@@ -16,7 +16,7 @@
1616
<el-tab-pane v-loading="loading" label="试听广场" name="square">
1717
<el-row v-if="squareSongList.length" v-loading="loading" :gutter="12">
1818
<el-col v-for="song in squareSongList" :key="song.id" :span="24">
19-
<songCard :songInfo="song" @click="setCurrentSong(song)"/>
19+
<songCard :songInfo="song" @play="setCurrentSong(song)"/>
2020
</el-col>
2121
</el-row>
2222
<el-empty v-else description="暂无音乐"/>

src/views/ai/music/components/list/songCard/index.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<template>
22
<div class="flex bg-[var(--el-bg-color-overlay)] p-12px mb-12px rounded-1">
3-
<el-image :src="songInfo.imageUrl" class="flex-none w-80px"/>
3+
<div class="relative" @click="playSong">
4+
<el-image :src="songInfo.imageUrl" class="flex-none w-80px"/>
5+
<div class="bg-black bg-op-40 absolute top-0 left-0 w-full h-full flex items-center justify-center cursor-pointer">
6+
<Icon :icon="currentSong.id === songInfo.id ? 'solar:pause-circle-bold':'mdi:arrow-right-drop-circle'" :size="30" />
7+
</div>
8+
</div>
49
<div class="ml-8px">
510
<div>{{ songInfo.title }}</div>
611
<div class="mt-8px text-12px text-[var(--el-text-color-secondary)] line-clamp-2">
@@ -20,4 +25,12 @@ defineProps({
2025
default: () => ({})
2126
}
2227
})
28+
29+
const emits = defineEmits(['play'])
30+
31+
const currentSong = inject('currentSong', {})
32+
33+
function playSong () {
34+
emits('play')
35+
}
2336
</script>

0 commit comments

Comments
 (0)