Skip to content

Commit 5c72785

Browse files
committed
feat: 添加mini播放栏鼠标滚轮调整音量 并优化音量滑块数字不展示问题
1 parent 4c24bb9 commit 5c72785

File tree

2 files changed

+58
-4
lines changed

2 files changed

+58
-4
lines changed

src/renderer/components/player/MiniPlayBar.vue

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555
<n-popover v-if="component" trigger="hover" :z-index="99999999" placement="top" :show-arrow="false">
5656
<template #trigger>
57-
<div class="function-button" @click="mute">
57+
<div class="function-button" @click="mute" @wheel.prevent="handleVolumeWheel">
5858
<i class="iconfont" :class="getVolumeIcon"></i>
5959
</div>
6060
</template>
@@ -64,6 +64,7 @@
6464
:step="0.01"
6565
:tooltip="false"
6666
vertical
67+
@wheel.prevent="handleVolumeWheel"
6768
></n-slider>
6869
</div>
6970
</n-popover>
@@ -183,6 +184,14 @@ const mute = () => {
183184
}
184185
};
185186
187+
// 鼠标滚轮调整音量
188+
const handleVolumeWheel = (e: WheelEvent) => {
189+
// 向上滚动增加音量,向下滚动减少音量
190+
const delta = e.deltaY < 0 ? 5 : -5;
191+
const newValue = Math.min(Math.max(volumeSlider.value + delta, 0), 100);
192+
volumeSlider.value = newValue;
193+
};
194+
186195
// 收藏相关
187196
const isFavorite = computed(() => {
188197
// 对于B站视频,使用ID匹配函数
@@ -529,6 +538,50 @@ const setMusicFull = () => {
529538
.volume-slider-wrapper {
530539
@apply p-2 py-4 rounded-xl bg-white dark:bg-dark-100 shadow-lg bg-opacity-90 backdrop-blur;
531540
height: 160px;
541+
542+
:deep(.n-slider) {
543+
--n-rail-height: 4px;
544+
--n-rail-color: theme('colors.gray.200');
545+
--n-rail-color-dark: theme('colors.gray.700');
546+
--n-fill-color: theme('colors.green.500');
547+
--n-handle-size: 12px;
548+
--n-handle-color: theme('colors.green.500');
549+
550+
&.n-slider--vertical {
551+
height: 100%;
552+
553+
.n-slider-rail {
554+
width: 4px;
555+
}
556+
557+
&:hover {
558+
.n-slider-rail {
559+
width: 6px;
560+
}
561+
562+
.n-slider-handle {
563+
width: 14px;
564+
height: 14px;
565+
}
566+
}
567+
}
568+
569+
.n-slider-rail {
570+
@apply overflow-hidden transition-all duration-200;
571+
@apply bg-gray-500 dark:bg-dark-300 bg-opacity-10 !important;
572+
}
573+
574+
.n-slider-handle {
575+
@apply transition-all duration-200;
576+
opacity: 0;
577+
}
578+
579+
&:hover {
580+
.n-slider-handle {
581+
opacity: 1;
582+
}
583+
}
584+
}
532585
}
533586
534587
// 播放列表样式

src/renderer/components/player/PlayBar.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,12 +483,13 @@ const openPlayListDrawer = () => {
483483
484484
.volume-slider {
485485
@apply absolute opacity-0 invisible transition-all duration-300 bottom-[30px] left-1/2 -translate-x-1/2 h-[180px] px-2 py-4 rounded-xl;
486-
@apply bg-light dark:bg-gray-800;
486+
@apply bg-light dark:bg-dark-200;
487487
@apply border border-gray-200 dark:border-gray-700;
488488
489489
.volume-percentage {
490-
@apply absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-medium bg-light dark:bg-gray-800 px-2 py-1 rounded-md;
490+
@apply absolute -top-6 left-1/2 -translate-x-1/2 text-xs font-medium bg-light dark:bg-dark-200 px-2 py-1 rounded-md;
491491
@apply border border-gray-200 dark:border-gray-700;
492+
@apply text-gray-800 dark:text-white;
492493
white-space: nowrap;
493494
}
494495
}
@@ -597,7 +598,7 @@ const openPlayListDrawer = () => {
597598
598599
// 确保悬停时提示样式正确
599600
.n-slider-tooltip {
600-
@apply bg-gray-800 text-white text-xs py-1 px-2 rounded;
601+
@apply bg-dark-200 text-white text-xs py-1 px-2 rounded;
601602
z-index: 999999;
602603
}
603604
}

0 commit comments

Comments
 (0)