Files
AlgerMusicPlayer/src/views/mv/index.vue
T

159 lines
4.0 KiB
Vue
Raw Normal View History

2023-12-27 18:21:01 +08:00
<template>
<div class="mv-list">
<div class="mv-list-title">
<h2>推荐MV</h2>
</div>
<n-scrollbar :size="100">
<div class="mv-list-content" :class="setAnimationClass('animate__bounceInLeft')">
<div class="mv-item" v-for="(item, index) in mvList" :key="item.id"
:class="setAnimationClass('animate__bounceIn')" :style="setAnimationDelay(index, 30)">
<div class="mv-item-img" @click="handleShowMv(item)">
<n-image class="mv-item-img-img" :src="getImgUrl((item.cover), '200y200')" lazy preview-disabled />
<div class="top">
<div class="play-count">{{ formatNumber(item.playCount) }}</div>
<i class="iconfont icon-videofill"></i>
</div>
</div>
<div class="mv-item-title">{{ item.name }}</div>
</div>
</div>
</n-scrollbar>
2023-12-27 21:44:32 +08:00
<n-drawer :show="showMv" height="100vh" placement="bottom" :z-index="999999999">
2023-12-27 18:21:01 +08:00
<div class="mv-detail">
2023-12-27 21:44:32 +08:00
<video :src="playMvUrl" controls autoplay></video>
2023-12-27 18:21:01 +08:00
<div class="mv-detail-title">
<div class="title">{{ playMvItem?.name }}</div>
<button @click="close">
<i class="iconfont icon-xiasanjiaoxing"></i>
</button>
</div>
</div>
</n-drawer>
</div>
</template>
<script setup lang="ts">
import { onMounted } from 'vue';
import { getTopMv, getMvUrl } from '@/api/mv';
import { IMvItem } from '@/type/mv';
import { setAnimationClass, setAnimationDelay, getImgUrl, formatNumber } from "@/utils";
import { useStore } from 'vuex';
const showMv = ref(false)
const mvList = ref<Array<IMvItem>>([])
const playMvItem = ref<IMvItem>()
const playMvUrl = ref<string>()
const store = useStore()
onMounted(async () => {
const res = await getTopMv(30)
mvList.value = res.data.data
console.log('mvList.value', mvList.value)
})
const handleShowMv = async (item: IMvItem) => {
store.commit('setIsPlay', false)
store.commit('setPlayMusic', false)
2023-12-27 18:21:01 +08:00
showMv.value = true
const res = await getMvUrl(item.id)
playMvItem.value = item;
playMvUrl.value = res.data.data.url
}
const close = () => {
showMv.value = false
if (store.state.playMusicUrl) {
store.commit('setIsPlay', true)
}
}
</script>
<style scoped lang="scss">
.mv-list {
2024-01-02 22:19:39 +08:00
@apply relative h-full w-full;
2023-12-29 16:04:44 +08:00
&-title {
@apply text-xl font-bold;
}
2023-12-27 18:21:01 +08:00
&-content {
2024-01-02 22:19:39 +08:00
@apply grid gap-6 pb-4 mt-2;
2023-12-29 16:04:44 +08:00
grid-template-columns: repeat(auto-fill, minmax(14%, 1fr));
2023-12-27 18:21:01 +08:00
}
.mv-item {
2023-12-29 16:04:44 +08:00
@apply p-2 rounded-lg;
background-color: #454545;
2023-12-27 18:21:01 +08:00
&-img {
2023-12-29 16:04:44 +08:00
@apply rounded-lg overflow-hidden relative;
2023-12-27 18:21:01 +08:00
&:hover img {
2023-12-29 16:04:44 +08:00
@apply hover:scale-110 transition-all duration-300 ease-in-out object-top;
2023-12-27 18:21:01 +08:00
}
&-img {
@apply h-full w-full rounded-xl overflow-hidden;
}
.top {
@apply absolute w-full h-full top-0 left-0 flex justify-center items-center transition-all duration-300 ease-in-out cursor-pointer;
2023-12-29 16:04:44 +08:00
background-color: #0000009b;
2023-12-27 18:21:01 +08:00
opacity: 0;
i {
2023-12-29 16:04:44 +08:00
font-size: 40px;
2023-12-27 18:21:01 +08:00
transition: all 0.5s ease-in-out;
opacity: 0;
}
&:hover {
@apply opacity-100;
}
&:hover i {
2023-12-29 16:04:44 +08:00
@apply transform scale-150 opacity-80;
2023-12-27 18:21:01 +08:00
}
.play-count {
position: absolute;
top: 10px;
left: 10px;
font-size: 14px;
}
}
}
&-title {
@apply p-2 text-sm text-white truncate;
}
}
}
.mv-detail {
@apply w-full h-full bg-black relative;
&-title {
2023-12-27 21:44:32 +08:00
@apply absolute w-full left-0 flex justify-between h-16 px-6 py-2 text-xl font-bold items-center z-50 transition-all duration-300 ease-in-out -top-24;
background: linear-gradient(0, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) 100%);
2023-12-27 18:21:01 +08:00
button .icon-xiasanjiaoxing {
2023-12-27 21:44:32 +08:00
@apply text-3xl;
2023-12-27 18:21:01 +08:00
}
button:hover {
@apply text-green-400;
}
}
video {
@apply w-full h-full;
}
2023-12-27 21:44:32 +08:00
video:hover + .mv-detail-title {
@apply top-0;
}
.mv-detail-title:hover {
@apply top-0;
}
2023-12-27 18:21:01 +08:00
}</style>