2021-11-09 11:34:09 +08:00
|
|
|
<template>
|
2023-12-18 15:24:57 +08:00
|
|
|
<n-drawer
|
|
|
|
|
:show="musicFull"
|
|
|
|
|
height="100vh"
|
|
|
|
|
placement="bottom"
|
|
|
|
|
:drawer-style="{ backgroundColor: 'transparent' }"
|
|
|
|
|
>
|
2023-12-17 14:48:21 +08:00
|
|
|
<div id="drawer-target">
|
|
|
|
|
<div class="music-img">
|
|
|
|
|
<n-image
|
2023-12-18 15:24:57 +08:00
|
|
|
ref="PicImgRef"
|
2023-12-17 14:48:21 +08:00
|
|
|
:src="getImgUrl(playMusic?.picUrl, '300y300')"
|
|
|
|
|
class="img"
|
|
|
|
|
lazy
|
|
|
|
|
preview-disabled
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="music-content">
|
|
|
|
|
<div class="music-content-name">{{ playMusic.song.name }}</div>
|
|
|
|
|
<div class="music-content-singer">
|
|
|
|
|
<span v-for="(item, index) in playMusic.song.artists" :key="index">
|
|
|
|
|
{{ item.name
|
|
|
|
|
}}{{ index < playMusic.song.artists.length - 1 ? ' / ' : '' }}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<n-layout
|
|
|
|
|
class="music-lrc"
|
|
|
|
|
style="height: 550px"
|
|
|
|
|
ref="lrcSider"
|
|
|
|
|
:native-scrollbar="false"
|
|
|
|
|
@mouseover="mouseOverLayout"
|
|
|
|
|
@mouseleave="mouseLeaveLayout"
|
|
|
|
|
>
|
|
|
|
|
<template v-for="(item, index) in lrcArray" :key="index">
|
|
|
|
|
<div
|
|
|
|
|
class="music-lrc-text"
|
|
|
|
|
:class="{ 'now-text': isCurrentLrc(index, nowTime) }"
|
2023-12-18 15:24:57 +08:00
|
|
|
@click="setAudioTime(index, audio)"
|
2023-12-17 14:48:21 +08:00
|
|
|
>
|
|
|
|
|
{{ item.text }}
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
</n-layout>
|
|
|
|
|
<!-- 时间矫正 -->
|
|
|
|
|
<div class="music-content-time"></div>
|
|
|
|
|
<n-button @click="reduceCorrectionTime(0.2)">-0.2</n-button>
|
|
|
|
|
<n-button @click="addCorrectionTime(0.2)">+0.2</n-button>
|
2021-11-09 11:34:09 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2023-12-18 15:24:57 +08:00
|
|
|
</n-drawer>
|
2021-11-09 11:34:09 +08:00
|
|
|
</template>
|
2023-12-17 14:48:21 +08:00
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
|
|
import type { SongResult } from '@/type/music'
|
2023-12-15 14:24:58 +08:00
|
|
|
import { getImgUrl } from '@/utils'
|
2023-12-17 14:48:21 +08:00
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
import { useStore } from 'vuex'
|
|
|
|
|
import {
|
|
|
|
|
lrcArray,
|
|
|
|
|
newLrcIndex,
|
|
|
|
|
isCurrentLrc,
|
|
|
|
|
addCorrectionTime,
|
|
|
|
|
reduceCorrectionTime,
|
|
|
|
|
setAudioTime,
|
|
|
|
|
nowTime,
|
|
|
|
|
} from '@/hooks/MusicHook'
|
|
|
|
|
|
|
|
|
|
const store = useStore()
|
2021-11-09 11:34:09 +08:00
|
|
|
|
|
|
|
|
const props = defineProps({
|
2023-12-17 14:48:21 +08:00
|
|
|
musicFull: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false,
|
2021-11-09 11:34:09 +08:00
|
|
|
},
|
|
|
|
|
audio: {
|
2023-12-17 14:48:21 +08:00
|
|
|
type: HTMLAudioElement,
|
|
|
|
|
default: null,
|
|
|
|
|
},
|
2021-11-09 11:34:09 +08:00
|
|
|
})
|
|
|
|
|
|
2023-12-17 14:48:21 +08:00
|
|
|
const emit = defineEmits(['update:musicFull'])
|
2021-11-09 11:34:09 +08:00
|
|
|
|
2023-12-17 14:48:21 +08:00
|
|
|
// 播放的音乐信息
|
|
|
|
|
const playMusic = computed(() => store.state.playMusic as SongResult)
|
2021-11-09 11:34:09 +08:00
|
|
|
// 获取歌词滚动dom
|
|
|
|
|
const lrcSider = ref<any>(null)
|
2023-12-17 14:48:21 +08:00
|
|
|
const isMouse = ref(false)
|
2021-11-09 11:34:09 +08:00
|
|
|
// 歌词滚动方法
|
|
|
|
|
const lrcScroll = () => {
|
2023-12-17 14:48:21 +08:00
|
|
|
if (props.musicFull && !isMouse.value) {
|
|
|
|
|
let top = newLrcIndex.value * 50 - 225
|
2021-11-09 11:34:09 +08:00
|
|
|
lrcSider.value.scrollTo({ top: top, behavior: 'smooth' })
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const mouseOverLayout = () => {
|
|
|
|
|
isMouse.value = true
|
|
|
|
|
}
|
|
|
|
|
const mouseLeaveLayout = () => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
isMouse.value = false
|
2023-12-17 14:48:21 +08:00
|
|
|
}, 3000)
|
2021-11-09 11:34:09 +08:00
|
|
|
}
|
2023-12-17 14:48:21 +08:00
|
|
|
|
|
|
|
|
defineExpose({
|
2023-12-18 15:24:57 +08:00
|
|
|
lrcScroll,
|
2023-12-17 14:48:21 +08:00
|
|
|
})
|
2021-11-09 11:34:09 +08:00
|
|
|
</script>
|
|
|
|
|
|
2023-12-17 14:48:21 +08:00
|
|
|
<style scoped lang="scss">
|
2021-11-09 11:34:09 +08:00
|
|
|
#drawer-target {
|
|
|
|
|
@apply top-0 left-0 absolute w-full h-full overflow-hidden rounded px-24 pt-24 pb-48 flex items-center;
|
2023-12-17 14:48:21 +08:00
|
|
|
backdrop-filter: blur(20px);
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.747);
|
2021-11-09 11:34:09 +08:00
|
|
|
animation-duration: 300ms;
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
.music-img {
|
2023-12-17 14:48:21 +08:00
|
|
|
@apply flex-1 flex justify-center mr-24;
|
|
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
.img {
|
2023-12-18 19:39:36 +08:00
|
|
|
width: 350px;
|
|
|
|
|
height: 350px;
|
2021-11-09 11:34:09 +08:00
|
|
|
@apply rounded-xl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.music-content {
|
|
|
|
|
@apply flex flex-col justify-center items-center;
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
&-name {
|
|
|
|
|
@apply font-bold text-3xl py-2;
|
|
|
|
|
}
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
&-singer {
|
|
|
|
|
@apply text-base py-2;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
.music-lrc {
|
2023-12-17 14:48:21 +08:00
|
|
|
background-color: inherit;
|
2023-12-18 19:39:36 +08:00
|
|
|
min-width: 400px;
|
|
|
|
|
max-width: 800px;
|
2021-11-09 11:34:09 +08:00
|
|
|
height: 550px;
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
&-text {
|
|
|
|
|
@apply text-white text-lg flex justify-center items-center cursor-pointer;
|
|
|
|
|
height: 50px;
|
|
|
|
|
transition: all 0.2s ease-out;
|
2023-12-17 14:48:21 +08:00
|
|
|
|
2021-11-09 11:34:09 +08:00
|
|
|
&:hover {
|
|
|
|
|
@apply font-bold text-xl text-red-500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.now-text {
|
|
|
|
|
@apply font-bold text-xl text-red-500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-18 15:24:57 +08:00
|
|
|
</style>
|