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