mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-25 00:37:24 +08:00
✨ feat: 优化歌词下一首的滚动
This commit is contained in:
@@ -227,9 +227,21 @@ const isVisible = computed({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 歌词滚动方法
|
// 歌词滚动方法
|
||||||
const lrcScroll = (behavior: ScrollBehavior = 'smooth') => {
|
const lrcScroll = (behavior: ScrollBehavior = 'smooth', forceTop: boolean = false) => {
|
||||||
|
if (!isVisible.value || !lrcSider.value) return;
|
||||||
|
|
||||||
|
if (forceTop) {
|
||||||
|
lrcSider.value.scrollTo({
|
||||||
|
top: 0,
|
||||||
|
behavior
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMouse.value) return;
|
||||||
|
|
||||||
const nowEl = document.querySelector(`#music-lrc-text-${nowIndex.value}`) as HTMLElement;
|
const nowEl = document.querySelector(`#music-lrc-text-${nowIndex.value}`) as HTMLElement;
|
||||||
if (isVisible.value && !isMouse.value && nowEl && lrcSider.value) {
|
if (nowEl) {
|
||||||
const containerHeight = lrcSider.value.$el.clientHeight;
|
const containerHeight = lrcSider.value.$el.clientHeight;
|
||||||
const elementTop = nowEl.offsetTop;
|
const elementTop = nowEl.offsetTop;
|
||||||
const scrollTop = elementTop - containerHeight / 2 + nowEl.clientHeight / 2;
|
const scrollTop = elementTop - containerHeight / 2 + nowEl.clientHeight / 2;
|
||||||
@@ -479,6 +491,13 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 添加对 playMusic 的监听
|
||||||
|
watch(playMusic, () => {
|
||||||
|
nextTick(() => {
|
||||||
|
lrcScroll('instant', true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
lrcScroll,
|
lrcScroll,
|
||||||
config
|
config
|
||||||
|
|||||||
@@ -152,7 +152,6 @@ export const getTextColors = (gradient: string = ''): ITextColors => {
|
|||||||
if (!gradient) return defaultColors;
|
if (!gradient) return defaultColors;
|
||||||
|
|
||||||
const colors = parseGradient(gradient);
|
const colors = parseGradient(gradient);
|
||||||
console.log('colors', colors);
|
|
||||||
if (!colors.length) return defaultColors;
|
if (!colors.length) return defaultColors;
|
||||||
|
|
||||||
const mainColor = colors.length === 1 ? colors[0] : colors[1] || colors[0];
|
const mainColor = colors.length === 1 ? colors[0] : colors[1] || colors[0];
|
||||||
|
|||||||
Reference in New Issue
Block a user