Skip to content

Commit cebf8bb

Browse files
committed
fix(taskbar-lyrics): 现在控制按钮会在依附任务栏时显示
注意:此提交由 AI 生成!
1 parent cc8d3cd commit cebf8bb

1 file changed

Lines changed: 104 additions & 2 deletions

File tree

src/views/TaskbarLyric/index.vue

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,33 @@
33
class="taskbar-lyric"
44
:class="{ dark: state.isDark, 'layout-reverse': !state.isCenter, floating: isFloating }"
55
:style="rootStyle"
6+
@mouseenter="handleMouseEnter"
7+
@mouseleave="handleMouseLeave"
68
>
79
<div class="cover-wrapper" v-if="coverSrc && settingStore.taskbarLyricShowCover">
810
<Transition name="cross-fade">
911
<img :key="coverSrc" :src="coverSrc" class="cover" alt="cover" @error="onCoverError" />
1012
</Transition>
1113
</div>
1214

15+
<Transition name="controls-expand">
16+
<div class="media-controls" v-if="showControls">
17+
<div class="control-btn" @click.stop="controlAction('playPrev')">
18+
<SvgIcon name="SkipPrev" />
19+
</div>
20+
<div class="control-btn" @click.stop="controlAction('playOrPause')">
21+
<SvgIcon :name="state.isPlaying ? 'Pause' : 'Play'" />
22+
</div>
23+
<div class="control-btn" @click.stop="controlAction('playNext')">
24+
<SvgIcon name="SkipNext" />
25+
</div>
26+
</div>
27+
</Transition>
28+
1329
<div class="content" :style="contentStyle">
1430
<Transition :name="settingStore.taskbarLyricAnimationMode" mode="out-in">
1531
<TransitionGroup tag="div" class="lyric-list-wrapper" name="lyric-list" :key="transitionKey">
16-
<div
32+
<div
1733
v-for="item in displayItems"
1834
:key="item.key"
1935
class="lyric-item"
@@ -57,6 +73,8 @@ import LyricScroll from "./LyricScroll.vue";
5773
const settingStore = useSettingStore();
5874
const route = useRoute();
5975
const isFloating = computed(() => route.query.mode === "floating");
76+
const isHovering = ref(false);
77+
const showControls = computed(() => !isFloating.value && isHovering.value);
6078
6179
/**
6280
* 只有当 IPC 时间与本地时间误差超过 250ms 时,才同步 IPC 的时间
@@ -138,6 +156,25 @@ const lyricFontFamily = computed(() => {
138156
return font === "default" ? "inherit" : font;
139157
});
140158
159+
const handleMouseEnter = () => {
160+
if (!isFloating.value) isHovering.value = true;
161+
};
162+
163+
const handleMouseLeave = () => {
164+
isHovering.value = false;
165+
};
166+
167+
const controlAction = (action: "playPrev" | "playOrPause" | "playNext") => {
168+
const ipc = window.electron?.ipcRenderer;
169+
if (!ipc) return;
170+
171+
if (action === "playOrPause") {
172+
state.isPlaying = !state.isPlaying;
173+
}
174+
175+
ipc.send("send-to-main-win", action);
176+
};
177+
141178
const transitionKey = computed(() => {
142179
if (!currentLyricText.value) {
143180
return `meta-${state.title}-${state.artist}`;
@@ -597,6 +634,11 @@ $radius: 4px;
597634
font-size: clamp(12px, 29vh, 26px);
598635
-webkit-app-region: drag;
599636
637+
.media-controls,
638+
.control-btn {
639+
-webkit-app-region: no-drag;
640+
}
641+
600642
&:hover,
601643
&:active {
602644
background-color: transparent;
@@ -666,7 +708,7 @@ $radius: 4px;
666708
);
667709
--mask-horizontal: linear-gradient(
668710
to right,
669-
transparent 0,
711+
transparent 0%,
670712
black var(--mask-gap),
671713
black calc(100% - var(--mask-gap)),
672714
transparent 100%
@@ -825,6 +867,66 @@ $radius: 4px;
825867
transform: translate3d(-5px, 0, 0);
826868
}
827869
}
870+
871+
.media-controls {
872+
display: flex;
873+
align-items: center;
874+
justify-content: center;
875+
height: 100%;
876+
max-width: 8.6em;
877+
gap: 0.4em;
878+
overflow: hidden;
879+
z-index: 10;
880+
881+
.control-btn {
882+
display: flex;
883+
align-items: center;
884+
justify-content: center;
885+
width: 4.4em;
886+
height: 2.3em;
887+
font-size: 1.3em;
888+
color: inherit;
889+
border-radius: $radius;
890+
border: 1px solid rgba(128, 128, 128, 0.4);
891+
box-sizing: border-box;
892+
transition:
893+
background-color 0.2s,
894+
transform 0.1s,
895+
border-color 0.2s;
896+
897+
&:hover {
898+
background-color: rgba(128, 128, 128, 0.2);
899+
border-color: rgba(128, 128, 128, 0.7);
900+
opacity: 1;
901+
}
902+
903+
&:active {
904+
transform: scale(0.92);
905+
background-color: rgba(128, 128, 128, 0.3);
906+
border-color: rgba(128, 128, 128, 0.9);
907+
}
908+
}
909+
}
910+
911+
.controls-expand {
912+
&-enter-active,
913+
&-leave-active {
914+
transition: all 0.4s var(--lyric-ease);
915+
}
916+
917+
&-enter-from,
918+
&-leave-to {
919+
max-width: 0;
920+
opacity: 0;
921+
margin: 0;
922+
}
923+
924+
&-enter-to,
925+
&-leave-from {
926+
max-width: 8.6em;
927+
opacity: 1;
928+
}
929+
}
828930
</style>
829931

830932
<style lang="scss">

0 commit comments

Comments
 (0)