mirror of
https://github.com/algerkong/AlgerMusicPlayer.git
synced 2026-04-25 00:37:24 +08:00
✨ feat: 添加播放列表自动滚动到播放的那个
This commit is contained in:
@@ -75,6 +75,9 @@ const emits = defineEmits(['play']);
|
|||||||
const songImageRef = useTemplateRef('songImg');
|
const songImageRef = useTemplateRef('songImg');
|
||||||
|
|
||||||
const imageLoad = async () => {
|
const imageLoad = async () => {
|
||||||
|
if (!songImageRef.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const background = await getImageBackground((songImageRef.value as any).imageRef as unknown as HTMLImageElement);
|
const background = await getImageBackground((songImageRef.value as any).imageRef as unknown as HTMLImageElement);
|
||||||
// eslint-disable-next-line vue/no-mutating-props
|
// eslint-disable-next-line vue/no-mutating-props
|
||||||
props.item.backgroundColor = background;
|
props.item.backgroundColor = background;
|
||||||
|
|||||||
@@ -73,7 +73,15 @@
|
|||||||
</template>
|
</template>
|
||||||
歌词
|
歌词
|
||||||
</n-tooltip>
|
</n-tooltip>
|
||||||
<n-popover trigger="click" :z-index="99999999" content-class="music-play" raw :show-arrow="false" :delay="200">
|
<n-popover
|
||||||
|
trigger="click"
|
||||||
|
:z-index="99999999"
|
||||||
|
content-class="music-play"
|
||||||
|
raw
|
||||||
|
:show-arrow="false"
|
||||||
|
:delay="200"
|
||||||
|
@update-show="scrollToPlayList"
|
||||||
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
<n-tooltip trigger="manual" :z-index="9999999">
|
<n-tooltip trigger="manual" :z-index="9999999">
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
@@ -84,7 +92,7 @@
|
|||||||
</template>
|
</template>
|
||||||
<div class="music-play-list">
|
<div class="music-play-list">
|
||||||
<div class="music-play-list-back"></div>
|
<div class="music-play-list-back"></div>
|
||||||
<n-virtual-list :item-size="57" item-resizable :items="playList">
|
<n-virtual-list ref="palyListRef" :item-size="62" item-resizable :items="playList">
|
||||||
<template #default="{ item }">
|
<template #default="{ item }">
|
||||||
<div class="music-play-list-content">
|
<div class="music-play-list-content">
|
||||||
<song-item :key="item.id" :item="item" mini></song-item>
|
<song-item :key="item.id" :item="item" mini></song-item>
|
||||||
@@ -99,13 +107,13 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { useTemplateRef } from 'vue';
|
||||||
import { useStore } from 'vuex';
|
import { useStore } from 'vuex';
|
||||||
|
|
||||||
import SongItem from '@/components/common/SongItem.vue';
|
import SongItem from '@/components/common/SongItem.vue';
|
||||||
import { allTime, isElectron, loadLrc, nowTime, openLyric, sendLyricToWin } from '@/hooks/MusicHook';
|
import { allTime, isElectron, loadLrc, nowTime, openLyric, sendLyricToWin } from '@/hooks/MusicHook';
|
||||||
import type { SongResult } from '@/type/music';
|
import type { SongResult } from '@/type/music';
|
||||||
import { getImgUrl, secondToMinute, setAnimationClass } from '@/utils';
|
import { getImgUrl, secondToMinute, setAnimationClass } from '@/utils';
|
||||||
import { getImageLinearBackground } from '@/utils/linearColor';
|
|
||||||
|
|
||||||
import MusicFull from './MusicFull.vue';
|
import MusicFull from './MusicFull.vue';
|
||||||
|
|
||||||
@@ -227,6 +235,15 @@ const musicFullVisible = ref(false);
|
|||||||
const setMusicFull = () => {
|
const setMusicFull = () => {
|
||||||
musicFullVisible.value = !musicFullVisible.value;
|
musicFullVisible.value = !musicFullVisible.value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const palyListRef = useTemplateRef('palyListRef');
|
||||||
|
|
||||||
|
const scrollToPlayList = (val: boolean) => {
|
||||||
|
if (!val) return;
|
||||||
|
setTimeout(() => {
|
||||||
|
palyListRef.value?.scrollTo({ top: store.state.playListIndex * 62 });
|
||||||
|
}, 50);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
|
|||||||
Reference in New Issue
Block a user