mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-23 15:47:23 +08:00
✨ feat: 添加专辑列表播放
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
<n-drawer :show="show" height="70vh" placement="bottom" :drawer-style="{ backgroundColor: 'transparent' }">
|
||||
<div class="music-page">
|
||||
<i class="iconfont icon-icon_error music-close" @click="close"></i>
|
||||
<div class="music-title">{{ musicList?.name }}</div>
|
||||
<div class="music-title">{{ name }}</div>
|
||||
<!-- 歌单歌曲列表 -->
|
||||
<div class="music-list">
|
||||
<n-scrollbar >
|
||||
<div v-for="(item, index) in musicList?.tracks" :key="item.id" :class="setAnimationClass('animate__bounceInUp')"
|
||||
<div v-for="(item, index) in songList" :key="item.id" :class="setAnimationClass('animate__bounceInUp')"
|
||||
:style="setAnimationDelay(index, 100)">
|
||||
<SongItem :item="formatDetail(item)" @play="handlePlay" />
|
||||
</div>
|
||||
@@ -28,7 +28,8 @@ const store = useStore()
|
||||
|
||||
const props = defineProps<{
|
||||
show: boolean;
|
||||
musicList: Playlist;
|
||||
name: string;
|
||||
songList: any[]
|
||||
}>()
|
||||
const emit = defineEmits(['update:show'])
|
||||
|
||||
@@ -45,7 +46,7 @@ const formatDetail = computed(() => (detail: any) => {
|
||||
})
|
||||
|
||||
const handlePlay = (item: any) => {
|
||||
const tracks = props.musicList?.tracks || []
|
||||
const tracks = props.songList || []
|
||||
const musicIndex = (tracks.findIndex((music: any) => music.id == item.id) || 0)
|
||||
store.commit('setPlayList', tracks)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
class="recommend-album-list-item"
|
||||
:class="setAnimationClass('animate__backInUp')"
|
||||
:style="setAnimationDelay(index, 100)"
|
||||
@click="handleClick(item)"
|
||||
>
|
||||
<n-image
|
||||
class="recommend-album-list-item-img"
|
||||
@@ -19,6 +20,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<MusicList v-model:show="showMusic" :name="albumName" :song-list="songList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -27,6 +29,7 @@ import { getNewAlbum } from "@/api/home"
|
||||
import { ref, onMounted } from "vue";
|
||||
import type { IAlbumNew } from "@/type/album"
|
||||
import { setAnimationClass, setAnimationDelay, getImgUrl } from "@/utils";
|
||||
import { getAlbum } from "@/api/list";
|
||||
|
||||
|
||||
const albumData = ref<IAlbumNew>()
|
||||
@@ -35,6 +38,20 @@ const loadAlbumList = async () => {
|
||||
albumData.value = data
|
||||
}
|
||||
|
||||
const showMusic = ref(false)
|
||||
const songList = ref([])
|
||||
const albumName = ref('')
|
||||
|
||||
const handleClick = async (item:any) => {
|
||||
albumName.value = item.name
|
||||
showMusic.value = true
|
||||
const res = await getAlbum(item.id)
|
||||
songList.value = res.data.songs.map((song:any)=>{
|
||||
song.al.picUrl = song.al.picUrl || item.picUrl
|
||||
return song
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadAlbumList()
|
||||
})
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<div class="search-item">
|
||||
<div class="search-item" @click="handleClick">
|
||||
<div class="search-item-img">
|
||||
<n-image
|
||||
:src="getImgUrl(item.picUrl, 'album')"
|
||||
@@ -11,20 +11,40 @@
|
||||
<div class="search-item-name">{{ item.name }}</div>
|
||||
<div class="search-item-artist">{{ item.desc}}</div>
|
||||
</div>
|
||||
|
||||
<MusicList v-model:show="showMusic" :name="item.name" :song-list="songList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { getImgUrl } from '@/utils'
|
||||
import type {Album} from '@/type/album'
|
||||
import { getAlbum } from '@/api/list';
|
||||
const props = defineProps<{
|
||||
item: {
|
||||
picUrl: string
|
||||
name: string
|
||||
desc: string
|
||||
type: string
|
||||
[key: string]: any
|
||||
}
|
||||
}>()
|
||||
|
||||
const songList = ref([])
|
||||
|
||||
const showMusic = ref(false)
|
||||
|
||||
const handleClick = async () => {
|
||||
showMusic.value = true
|
||||
if(props.item.type === '专辑'){
|
||||
const res = await getAlbum(props.item.id)
|
||||
songList.value = res.data.songs.map((song:any)=>{
|
||||
song.al.picUrl = song.al.picUrl || props.item.picUrl
|
||||
return song
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<div class="song-item" :class="{'song-mini': mini}">
|
||||
<n-image
|
||||
v-if="item.picUrl "
|
||||
:src="getImgUrl( item.picUrl, '40y40')"
|
||||
class="song-item-img"
|
||||
lazy
|
||||
|
||||
Reference in New Issue
Block a user