feat: 双击播放由双击歌曲名改为双击整个组件都可以

This commit is contained in:
alger
2025-05-22 20:12:55 +08:00
parent 91b1ff7df9
commit 258828ffbd
+3 -3
View File
@@ -5,6 +5,7 @@
@contextmenu.prevent="handleContextMenu" @contextmenu.prevent="handleContextMenu"
@mouseenter="handleMouseEnter" @mouseenter="handleMouseEnter"
@mouseleave="handleMouseLeave" @mouseleave="handleMouseLeave"
@dblclick.stop="playMusicEvent(item)"
> >
<div v-if="compact && index !== undefined" class="song-item-index" :class="{ 'text-green-500': isPlaying }"> <div v-if="compact && index !== undefined" class="song-item-index" :class="{ 'text-green-500': isPlaying }">
{{ index + 1 }} {{ index + 1 }}
@@ -42,7 +43,7 @@
</div> </div>
<template v-else-if="compact"> <template v-else-if="compact">
<div class="song-item-content-compact-wrapper"> <div class="song-item-content-compact-wrapper">
<div class="w-60 flex-shrink-0 flex items-center" @dblclick="playMusicEvent(item)"> <div class="w-60 flex-shrink-0 flex items-center">
<n-ellipsis class="song-item-content-title text-ellipsis" line-clamp="1" :class="{ 'text-green-500': isPlaying }"> <n-ellipsis class="song-item-content-title text-ellipsis" line-clamp="1" :class="{ 'text-green-500': isPlaying }">
{{ item.name }} {{ item.name }}
</n-ellipsis> </n-ellipsis>
@@ -68,7 +69,7 @@
</div> </div>
</template> </template>
<template v-else> <template v-else>
<div class="song-item-content-title" @dblclick="playMusicEvent(item)"> <div class="song-item-content-title">
<n-ellipsis class="text-ellipsis" line-clamp="1" :class="{ 'text-green-500': isPlaying }">{{ item.name }}</n-ellipsis> <n-ellipsis class="text-ellipsis" line-clamp="1" :class="{ 'text-green-500': isPlaying }">{{ item.name }}</n-ellipsis>
</div> </div>
<div class="song-item-content-name"> <div class="song-item-content-name">
@@ -449,7 +450,6 @@ const playMusicEvent = async (item: SongResult) => {
if (!result) { if (!result) {
throw new Error('播放失败'); throw new Error('播放失败');
} }
playerStore.isPlay = true;
emits('play', item); emits('play', item);
} catch (error) { } catch (error) {
console.error('播放出错:', error); console.error('播放出错:', error);