修复歌词显示错误
This commit is contained in:
parent
b0e8e8aab3
commit
289d7e0b8b
@ -18,10 +18,10 @@
|
||||
<script lang="ts" setup>
|
||||
import { computed, watch, ref } from 'vue'
|
||||
import { parseLrc } from '../utils'
|
||||
import { MusicPlayerItem, StatType } from '@/model/api/music'
|
||||
import { StatType } from '@/model/api/music'
|
||||
|
||||
const props = defineProps<{
|
||||
currentMusic: MusicPlayerItem,
|
||||
lrcSource: string,
|
||||
playStat: StatType
|
||||
}>()
|
||||
|
||||
@ -37,22 +37,14 @@ const transformStyle = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const applyLrc = (lrc: string) => {
|
||||
if (/^https?:\/\//.test(lrc)) {
|
||||
fetch(lrc)
|
||||
.then(response => response.text())
|
||||
.then((lrc) => displayLrc.value = lrc)
|
||||
} else {
|
||||
displayLrc.value = lrc
|
||||
}
|
||||
}
|
||||
|
||||
watch(props.currentMusic, (music: MusicPlayerItem) => {
|
||||
watch(() => props.lrcSource, (lrcSource: string) => {
|
||||
currentLineIndex.value = 0
|
||||
if (music.lrc) {
|
||||
applyLrc(music.lrc)
|
||||
if (/^https?:\/\//.test(lrcSource)) {
|
||||
fetch(lrcSource)
|
||||
.then(response => response.text())
|
||||
.then(lrc => displayLrc.value = lrc)
|
||||
} else {
|
||||
displayLrc.value = ''
|
||||
displayLrc.value = lrcSource
|
||||
}
|
||||
}, { immediate: true })
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<span class="aplayer-author">{{ currentMusic.artist || currentMusic.author || 'Unknown' }}</span>
|
||||
</div>
|
||||
<slot name="display" :current-music="currentMusic" :play-stat="playStat">
|
||||
<lyrics :current-music="currentMusic" :play-stat="playStat" v-if="showLrc && currentMusic.lrc" />
|
||||
<lyrics :lrc-source="currentMusic.lrc" :play-stat="playStat" v-if="showLrc && currentMusic.lrc" />
|
||||
</slot>
|
||||
<controls
|
||||
:shuffle="shouldShuffle"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user