2025-03-22 13:45:23 +08:00
|
|
|
<template>
|
|
|
|
|
<div
|
2025-12-19 00:23:24 +08:00
|
|
|
ref="playBarRef"
|
2025-03-22 13:45:23 +08:00
|
|
|
class="mobile-play-bar"
|
|
|
|
|
:class="[
|
|
|
|
|
setAnimationClass('animate__fadeInUp'),
|
2025-12-19 00:23:24 +08:00
|
|
|
playerStore.musicFull ? 'play-bar-expanded' : 'play-bar-mini',
|
|
|
|
|
shouldShowMobileMenu ? 'is-menu-show' : 'is-menu-hide'
|
2025-03-22 13:45:23 +08:00
|
|
|
]"
|
|
|
|
|
:style="{
|
2025-12-19 00:23:24 +08:00
|
|
|
color: playerStore.musicFull
|
2025-03-22 13:45:23 +08:00
|
|
|
? textColors.theme === 'dark'
|
|
|
|
|
? '#ffffff'
|
|
|
|
|
: '#ffffff'
|
|
|
|
|
: settingsStore.theme === 'dark'
|
|
|
|
|
? '#ffffff'
|
|
|
|
|
: '#000000'
|
|
|
|
|
}"
|
|
|
|
|
>
|
|
|
|
|
<!-- Mini模式 - 在musicFullVisible为false时显示 -->
|
2025-12-19 00:23:24 +08:00
|
|
|
<div v-if="!playerStore.musicFull" class="mobile-mini-controls">
|
2025-03-22 13:45:23 +08:00
|
|
|
<!-- 歌曲信息 -->
|
|
|
|
|
<div class="mini-song-info" @click="setMusicFull">
|
|
|
|
|
<n-image
|
|
|
|
|
:src="getImgUrl(playMusic?.picUrl, '100y100')"
|
|
|
|
|
class="mini-song-cover"
|
|
|
|
|
lazy
|
|
|
|
|
preview-disabled
|
|
|
|
|
/>
|
|
|
|
|
<div class="mini-song-text">
|
2025-06-07 10:48:54 +08:00
|
|
|
<n-ellipsis line-clamp="1">
|
|
|
|
|
<span class="mini-song-title">{{ playMusic.name }}</span>
|
|
|
|
|
<span class="mx-2 text-gray-500 dark:text-gray-400">-</span>
|
2025-12-19 00:23:24 +08:00
|
|
|
<span
|
|
|
|
|
class="mini-song-artist"
|
|
|
|
|
v-for="(artists, artistsindex) in artistList"
|
|
|
|
|
:key="artistsindex"
|
|
|
|
|
>
|
|
|
|
|
{{ artists.name }}{{ artistsindex < artistList.length - 1 ? ' / ' : '' }}
|
2025-03-22 13:45:23 +08:00
|
|
|
</span>
|
|
|
|
|
</n-ellipsis>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="mini-playback-controls">
|
|
|
|
|
<div class="mini-control-btn play" @click="playMusicEvent">
|
|
|
|
|
<i class="iconfont icon" :class="play ? 'icon-stop' : 'icon-play'"></i>
|
|
|
|
|
</div>
|
2025-06-07 10:48:54 +08:00
|
|
|
<i class="iconfont icon-list mini-list-icon" @click="openPlayListDrawer"></i>
|
2025-03-22 13:45:23 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- 全屏播放器 -->
|
2025-12-19 00:23:24 +08:00
|
|
|
<music-full-wrapper
|
|
|
|
|
ref="MusicFullRef"
|
|
|
|
|
v-model="playerStore.musicFull"
|
|
|
|
|
:background="background"
|
|
|
|
|
/>
|
2025-03-22 13:45:23 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-12-19 00:23:24 +08:00
|
|
|
import { useSwipe } from '@vueuse/core';
|
|
|
|
|
import type { Ref } from 'vue';
|
|
|
|
|
import { computed, inject, onMounted, ref, watch } from 'vue';
|
2025-03-22 13:45:23 +08:00
|
|
|
|
2025-06-07 22:30:39 +08:00
|
|
|
import MusicFullWrapper from '@/components/lyric/MusicFullWrapper.vue';
|
2025-12-19 00:23:24 +08:00
|
|
|
import { artistList, playMusic, textColors } from '@/hooks/MusicHook';
|
2025-03-22 13:45:23 +08:00
|
|
|
import { usePlayerStore } from '@/store/modules/player';
|
|
|
|
|
import { useSettingsStore } from '@/store/modules/settings';
|
2025-12-19 00:23:24 +08:00
|
|
|
import { getImgUrl, setAnimationClass } from '@/utils';
|
2025-03-22 13:45:23 +08:00
|
|
|
|
2025-12-19 00:23:24 +08:00
|
|
|
const shouldShowMobileMenu = inject('shouldShowMobileMenu') as Ref<boolean>;
|
2025-06-07 10:48:54 +08:00
|
|
|
|
2025-03-22 13:45:23 +08:00
|
|
|
const playerStore = usePlayerStore();
|
|
|
|
|
const settingsStore = useSettingsStore();
|
|
|
|
|
|
|
|
|
|
// 是否播放
|
|
|
|
|
const play = computed(() => playerStore.isPlay);
|
|
|
|
|
// 背景颜色
|
|
|
|
|
const background = ref('#000');
|
|
|
|
|
|
|
|
|
|
// 播放控制
|
|
|
|
|
function handleNext() {
|
|
|
|
|
playerStore.nextPlay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handlePrev() {
|
|
|
|
|
playerStore.prevPlay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 全屏播放器
|
|
|
|
|
const MusicFullRef = ref<any>(null);
|
|
|
|
|
|
|
|
|
|
// 设置musicFull
|
|
|
|
|
const setMusicFull = () => {
|
2025-12-19 00:23:24 +08:00
|
|
|
playerStore.setMusicFull(!playerStore.musicFull);
|
|
|
|
|
if (playerStore.musicFull) {
|
2025-03-22 13:45:23 +08:00
|
|
|
settingsStore.showArtistDrawer = false;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-19 00:23:24 +08:00
|
|
|
watch(
|
|
|
|
|
() => playerStore.musicFull,
|
|
|
|
|
(_newVal) => {
|
|
|
|
|
// 状态栏样式更新已在 Web 环境下禁用
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2025-06-07 10:48:54 +08:00
|
|
|
// 打开播放列表抽屉
|
|
|
|
|
const openPlayListDrawer = () => {
|
|
|
|
|
playerStore.setPlayListDrawerVisible(true);
|
2025-03-22 13:45:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 播放暂停按钮事件
|
|
|
|
|
const playMusicEvent = async () => {
|
|
|
|
|
try {
|
2025-05-17 13:27:50 +08:00
|
|
|
playerStore.setPlay(playMusic.value);
|
2025-03-22 13:45:23 +08:00
|
|
|
} catch (error) {
|
|
|
|
|
console.error('播放出错:', error);
|
|
|
|
|
playerStore.nextPlay();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2025-12-19 00:23:24 +08:00
|
|
|
// 滑动切歌
|
|
|
|
|
const playBarRef = ref<HTMLElement | null>(null);
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
if (playBarRef.value) {
|
|
|
|
|
const { direction } = useSwipe(playBarRef, {
|
|
|
|
|
onSwipeEnd: () => {
|
|
|
|
|
if (direction.value === 'left') handleNext();
|
|
|
|
|
if (direction.value === 'right') handlePrev();
|
|
|
|
|
},
|
|
|
|
|
threshold: 30
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2025-03-22 13:45:23 +08:00
|
|
|
watch(
|
|
|
|
|
() => playerStore.playMusic,
|
|
|
|
|
async () => {
|
|
|
|
|
background.value = playMusic.value.backgroundColor as string;
|
|
|
|
|
},
|
|
|
|
|
{ immediate: true, deep: true }
|
|
|
|
|
);
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.mobile-play-bar {
|
2025-10-11 20:23:54 +08:00
|
|
|
@apply fixed bottom-[76px] left-0 w-full flex flex-col;
|
2025-03-22 13:45:23 +08:00
|
|
|
z-index: 10000;
|
|
|
|
|
animation-duration: 0.3s !important;
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
2025-12-19 00:23:24 +08:00
|
|
|
&.is-menu-show {
|
|
|
|
|
bottom: calc(var(--safe-area-inset-bottom, 0) + 66px);
|
|
|
|
|
}
|
|
|
|
|
&.is-menu-hide {
|
|
|
|
|
bottom: calc(var(--safe-area-inset-bottom, 0) + 10px);
|
2025-06-07 10:48:54 +08:00
|
|
|
}
|
|
|
|
|
|
2025-03-22 13:45:23 +08:00
|
|
|
&.play-bar-expanded {
|
|
|
|
|
@apply bg-transparent;
|
|
|
|
|
height: auto; /* 自动适应内容高度 */
|
|
|
|
|
max-height: 230px; /* 限制最大高度 */
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
to bottom,
|
|
|
|
|
rgba(0, 0, 0, 0) 0%,
|
|
|
|
|
rgba(0, 0, 0, 0.5) 20%,
|
|
|
|
|
rgba(0, 0, 0, 0.8) 80%,
|
|
|
|
|
rgba(0, 0, 0, 0.9) 100%
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.play-bar-mini {
|
2025-06-07 10:48:54 +08:00
|
|
|
@apply h-14 py-0;
|
2025-03-22 13:45:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 进度条
|
|
|
|
|
.music-progress-bar {
|
|
|
|
|
@apply flex items-center justify-between px-4 py-2 relative z-10;
|
|
|
|
|
|
|
|
|
|
.current-time,
|
|
|
|
|
.total-time {
|
|
|
|
|
@apply text-xs text-white opacity-80;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.progress-wrapper {
|
|
|
|
|
@apply flex-1 mx-3 flex flex-col items-center;
|
|
|
|
|
|
|
|
|
|
.progress-slider {
|
|
|
|
|
@apply w-full;
|
|
|
|
|
|
|
|
|
|
:deep(.n-slider) {
|
|
|
|
|
--n-rail-height: 3px;
|
|
|
|
|
--n-rail-color: rgba(255, 255, 255, 0.15);
|
|
|
|
|
--n-rail-color-dark: rgba(255, 255, 255, 0.15);
|
|
|
|
|
--n-fill-color: #1ed760; /* Spotify绿色,可调整为其他绿色 */
|
|
|
|
|
--n-handle-size: 0px; /* 隐藏滑块 */
|
|
|
|
|
--n-handle-color: #1ed760;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
--n-handle-size: 10px; /* 鼠标悬停时显示滑块 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.n-slider-rail {
|
|
|
|
|
@apply rounded-full !important; /* 圆角进度条 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.n-slider-fill {
|
|
|
|
|
@apply rounded-full !important;
|
|
|
|
|
box-shadow: 0 0 4px rgba(30, 215, 96, 0.5); /* 发光效果 */
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.n-slider-handle {
|
|
|
|
|
@apply transition-all duration-200;
|
|
|
|
|
opacity: 0;
|
|
|
|
|
box-shadow: 0 0 4px rgba(255, 255, 255, 0.7);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:hover .n-slider-handle,
|
|
|
|
|
&:active .n-slider-handle {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.quality-label {
|
|
|
|
|
@apply text-xs text-white opacity-70 mt-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 主控制区
|
|
|
|
|
.player-controls {
|
|
|
|
|
@apply flex items-center justify-between px-8 py-3 relative z-10 pb-8;
|
|
|
|
|
|
|
|
|
|
.control-btn {
|
|
|
|
|
@apply flex items-center justify-center cursor-pointer transition;
|
|
|
|
|
|
|
|
|
|
i {
|
|
|
|
|
@apply text-white transition-all;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.like i {
|
|
|
|
|
@apply text-2xl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.prev i,
|
|
|
|
|
&.next i {
|
|
|
|
|
@apply text-3xl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.play-pause {
|
|
|
|
|
@apply w-12 h-12 rounded-full flex items-center justify-center;
|
|
|
|
|
background: rgba(255, 255, 255, 0.2);
|
|
|
|
|
|
|
|
|
|
i {
|
|
|
|
|
@apply text-4xl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.list i {
|
|
|
|
|
@apply text-2xl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.like-active {
|
|
|
|
|
@apply text-red-500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mini模式样式
|
|
|
|
|
.mobile-mini-controls {
|
2025-06-07 10:48:54 +08:00
|
|
|
@apply flex items-center justify-between pr-4 mx-3 h-12 rounded-full bg-light-100 dark:bg-dark-100 shadow-lg;
|
2025-03-22 13:45:23 +08:00
|
|
|
|
|
|
|
|
.mini-song-info {
|
|
|
|
|
@apply flex items-center flex-1 min-w-0 cursor-pointer;
|
|
|
|
|
|
|
|
|
|
.mini-song-cover {
|
2025-06-07 10:48:54 +08:00
|
|
|
@apply w-12 h-12 rounded-full border-8 border-dark-300 dark:border-light-300;
|
2025-03-22 13:45:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mini-song-text {
|
2025-12-19 00:23:24 +08:00
|
|
|
@apply ml-3 min-w-0 flex-1 flex items-center;
|
2025-03-22 13:45:23 +08:00
|
|
|
|
|
|
|
|
.mini-song-title {
|
|
|
|
|
@apply text-sm font-medium;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mini-song-artist {
|
2025-06-07 10:48:54 +08:00
|
|
|
@apply text-xs text-gray-500 dark:text-gray-400;
|
2025-03-22 13:45:23 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mini-playback-controls {
|
|
|
|
|
@apply flex items-center;
|
|
|
|
|
|
|
|
|
|
.mini-control-btn {
|
|
|
|
|
@apply flex items-center justify-center cursor-pointer transition;
|
|
|
|
|
|
|
|
|
|
&.play {
|
|
|
|
|
@apply w-9 h-9 rounded-full flex items-center justify-center mr-2;
|
|
|
|
|
@apply bg-gray-100 dark:bg-gray-800;
|
|
|
|
|
|
|
|
|
|
.iconfont {
|
|
|
|
|
@apply text-xl text-green-500 transition hover:text-green-600;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mini-list-icon {
|
|
|
|
|
@apply text-xl p-1 transition cursor-pointer;
|
|
|
|
|
@apply hover:text-green-500;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mobile-play-list-container {
|
|
|
|
|
height: 60vh;
|
|
|
|
|
width: 90vw;
|
|
|
|
|
max-width: 400px;
|
|
|
|
|
@apply relative rounded-t-2xl overflow-hidden;
|
|
|
|
|
|
|
|
|
|
.mobile-play-list-back {
|
|
|
|
|
backdrop-filter: blur(20px);
|
|
|
|
|
@apply absolute top-0 left-0 w-full h-full;
|
|
|
|
|
@apply bg-light dark:bg-black bg-opacity-90;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.mobile-play-list-item {
|
|
|
|
|
@apply px-3 py-1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|