mirror of
https://github.com/qier222/YesPlayMusic.git
synced 2025-02-03 03:44:00 +08:00
fix: lyrics won't scroll to top after switch track
This commit is contained in:
parent
f3c8576bd4
commit
cfc42be2db
|
@ -156,7 +156,7 @@ export default {
|
|||
mounted() {
|
||||
setInterval(() => {
|
||||
this.progress = ~~this.player.seek();
|
||||
}, 1000);
|
||||
}, 500);
|
||||
if (isAccountLoggedIn()) {
|
||||
userLikedSongsIDs(this.data.user.userId).then((data) => {
|
||||
this.updateLikedSongs(data.ids);
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
export function lyricParser(lrc) {
|
||||
return {
|
||||
lyric: parseLyric(lrc.lrc.lyric || ""),
|
||||
tlyric: parseLyric(lrc.tlyric.lyric || ""),
|
||||
lyric: parseLyric(lrc?.lrc?.lyric || ""),
|
||||
tlyric: parseLyric(lrc?.tlyric?.lyric || ""),
|
||||
lyricuser: lrc.lyricUser,
|
||||
transuser: lrc.transUser,
|
||||
};
|
||||
|
|
|
@ -119,6 +119,7 @@
|
|||
<div class="right-side">
|
||||
<transition name="slide-fade">
|
||||
<div class="lyrics-container" ref="lyricsContainer" v-show="!noLyric">
|
||||
<div class="line" id="line-1"></div>
|
||||
<div
|
||||
class="line"
|
||||
:class="{
|
||||
|
@ -127,7 +128,7 @@
|
|||
:style="lineStyles"
|
||||
v-for="(line, index) in lyricWithTranslation"
|
||||
:key="index"
|
||||
:id="`line-${index}`"
|
||||
:id="`line${index}`"
|
||||
v-html="formatLine(line)"
|
||||
></div>
|
||||
</div>
|
||||
|
@ -162,7 +163,7 @@ export default {
|
|||
lyricsInterval: null,
|
||||
lyric: [],
|
||||
tlyric: [],
|
||||
highlightLyricIndex: -1,
|
||||
highlightLyricIndex: 0,
|
||||
minimize: true,
|
||||
};
|
||||
},
|
||||
|
@ -244,7 +245,7 @@ export default {
|
|||
...mapMutations(["toggleLyrics"]),
|
||||
getLyric() {
|
||||
return getLyric(this.currentTrack.id).then((data) => {
|
||||
if (data.nolyric) {
|
||||
if (!data?.lrc?.lyric) {
|
||||
this.lyric = [];
|
||||
this.tlyric = [];
|
||||
return false;
|
||||
|
@ -275,10 +276,12 @@ export default {
|
|||
);
|
||||
});
|
||||
if (oldHighlightLyricIndex !== this.highlightLyricIndex) {
|
||||
const el = document.getElementById(
|
||||
`line-${this.highlightLyricIndex}`
|
||||
);
|
||||
if (el) el.scrollIntoView({ behavior: "smooth", block: "center" });
|
||||
const el = document.getElementById(`line${this.highlightLyricIndex}`);
|
||||
if (el)
|
||||
el.scrollIntoView({
|
||||
behavior: "smooth",
|
||||
block: "center",
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
},
|
||||
|
@ -294,12 +297,7 @@ export default {
|
|||
},
|
||||
watch: {
|
||||
currentTrack() {
|
||||
this.getLyric().then((result) => {
|
||||
if (result) {
|
||||
const el = document.getElementById(`line-0`);
|
||||
el.scrollIntoView({ block: "center" });
|
||||
}
|
||||
});
|
||||
this.getLyric();
|
||||
},
|
||||
showLyrics(show) {
|
||||
if (show) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user