初次提交
Build VoiceHub FPK / build-fpk (push) Failing after 56m5s
Build and Push Docker Image / build-and-push (push) Canceled after 1h9m35s

This commit is contained in:
2026-09-06 08:19:02 +08:00
commit 4ce4649aaf
1061 changed files with 337258 additions and 0 deletions
@@ -0,0 +1,73 @@
<template>
<audio
v-if="song?.musicUrl"
ref="audioPlayer"
:src="song.musicUrl"
crossorigin="anonymous"
autoplay
preload="auto"
referrerpolicy="no-referrer"
@canplay="$emit('canplay', $event)"
@ended="$emit('ended', $event)"
@error="$emit('error', $event)"
@loadedmetadata="$emit('loadedmetadata', $event)"
@loadstart="$emit('loadstart', $event)"
@pause="$emit('pause', $event)"
@play="$emit('play', $event)"
@timeupdate="$emit('timeupdate', $event)"
/>
<!-- 如果没有 musicUrl(如哔哩哔哩视频),创建一个虚拟的 audio 元素 -->
<audio v-else-if="song" ref="audioPlayer" style="display: none" />
</template>
<script setup>
import { ref, watch, nextTick } from 'vue'
const props = defineProps({
song: {
type: Object,
default: null
}
})
const emit = defineEmits([
'timeupdate',
'ended',
'loadedmetadata',
'error',
'play',
'pause',
'loadstart',
'canplay'
])
const audioPlayer = ref(null)
// 错误消息常量,避免使用魔法字符串
const ERROR_MESSAGES = {
BILIBILI_NO_AUDIO: 'No audio URL available for Bilibili video'
}
// 监听 song 变化,如果没有 musicUrl 则立即触发错误
watch(
() => props.song,
(newSong, oldSong) => {
if (newSong && !newSong.musicUrl) {
// 使用 nextTick 确保 DOM 已更新
nextTick(() => {
// 创建一个自定义错误对象
const error = new Error(ERROR_MESSAGES.BILIBILI_NO_AUDIO)
error.name = 'BilibiliNoAudioError'
// 立即触发错误事件
emit('error', error)
})
}
},
{ immediate: true }
)
defineExpose({
audioPlayer
})
</script>
@@ -0,0 +1,331 @@
<template>
<div class="player-controls">
<div class="progress-container">
<div class="control-with-progress">
<!-- 上一首按钮 -->
<button
:disabled="!hasPrevious"
:title="hasPrevious ? '上一首' : '没有上一首'"
class="control-btn prev-btn"
@click="$emit('previous')"
>
<Icon :size="24" color="white" name="skip-back" />
</button>
<!-- 播放/暂停按钮 -->
<button
:disabled="hasError || isLoadingTrack"
class="control-btn play-pause-btn"
@click="$emit('togglePlay')"
>
<div v-if="isLoadingTrack" class="loading-spinner" />
<Icon v-else-if="isPlaying" :size="18" color="white" name="pause" />
<Icon v-else :size="18" color="white" name="play" />
</button>
<!-- 下一首按钮 -->
<button
:disabled="!hasNext"
:title="hasNext ? '下一首' : '没有下一首'"
class="control-btn next-btn"
@click="$emit('next')"
>
<Icon :size="24" color="white" name="skip-forward" />
</button>
<div class="progress-container-wrapper">
<div
ref="progressBar"
class="progress-bar"
@click="handleProgressClick"
@mousedown="handleProgressMouseDown"
@touchstart="handleProgressTouchStart"
>
<div
:class="{ dragging: isDragging }"
:style="{ '--progress-width': `${progress}%` }"
class="progress"
>
<div :class="{ dragging: isDragging }" class="progress-thumb" />
</div>
</div>
</div>
</div>
<div class="time-display">
<span class="current-time">{{ formatTime(currentTime) }}</span>
<span class="duration">{{ formatTime(duration) }}</span>
</div>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import Icon from '~/components/UI/Icon.vue'
const props = defineProps({
isPlaying: {
type: Boolean,
default: false
},
hasError: {
type: Boolean,
default: false
},
hasPrevious: {
type: Boolean,
default: false
},
hasNext: {
type: Boolean,
default: false
},
progress: {
type: Number,
default: 0
},
isDragging: {
type: Boolean,
default: false
},
currentTime: {
type: Number,
default: 0
},
duration: {
type: Number,
default: 0
},
isLoading: {
type: Boolean,
default: false
},
isLoadingTrack: {
type: Boolean,
default: false
}
})
const emit = defineEmits([
'togglePlay',
'previous',
'next',
'startDrag',
'startTouchDrag',
'seekToPosition'
])
const progressBar = ref(null)
const formatTime = (time) => {
if (!time || isNaN(time)) return '0:00'
const minutes = Math.floor(time / 60)
const seconds = Math.floor(time % 60)
return `${minutes}:${seconds.toString().padStart(2, '0')}`
}
// 进度条事件处理
const handleProgressMouseDown = (event) => {
emit('startDrag', event, progressBar.value)
}
const handleProgressTouchStart = (event) => {
emit('startTouchDrag', event, progressBar.value)
}
const handleProgressClick = (event) => {
// 防止拖拽时触发点击
if (props.isDragging) return
emit('seekToPosition', event)
}
defineExpose({
progressBar
})
</script>
<style scoped>
.player-controls {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
min-width: 0;
}
.progress-container {
width: 100%;
display: flex;
flex-direction: column;
gap: 8px;
}
.control-with-progress {
display: flex;
align-items: center;
gap: 12px;
width: 100%;
}
.control-btn {
background: rgba(255, 255, 255, 0.1);
border: none;
border-radius: 50%;
width: 36px;
height: 36px;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
backdrop-filter: blur(10px);
flex-shrink: 0;
}
.control-btn:hover:not(:disabled) {
background: rgba(255, 255, 255, 0.2);
transform: scale(1.05);
}
.control-btn:active:not(:disabled) {
transform: scale(0.95);
}
.control-btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.play-pause-btn {
width: 44px;
height: 44px;
background: rgba(255, 255, 255, 0.15);
}
.loading-spinner {
width: 18px;
height: 18px;
border: 2px solid rgba(255, 255, 255, 0.3);
border-top: 2px solid white;
border-radius: 50%;
animation: spin 1s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.progress-container-wrapper {
flex: 1;
min-width: 0;
}
.progress-bar {
width: 100%;
height: 20px; /* 增加触摸区域 */
cursor: pointer;
position: relative;
display: flex;
align-items: center;
touch-action: none; /* 防止移动端滚动 */
}
.progress {
width: 100%;
height: 4px;
background: rgba(255, 255, 255, 0.2);
border-radius: 2px;
position: relative;
overflow: hidden;
transition: height 0.2s ease;
}
.progress::before {
content: '';
position: absolute;
top: 0;
left: 0;
height: 100%;
width: var(--progress-width, 0%);
background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
border-radius: 2px;
transition: width 0.05s linear;
will-change: width;
}
.progress-thumb {
position: absolute;
left: calc(var(--progress-width, 0%) - 6px);
top: 50%;
transform: translateY(-50%);
width: 12px;
height: 12px;
background: white;
border-radius: 50%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
opacity: 0;
transition:
opacity 0.2s ease,
transform 0.1s ease;
will-change: opacity, transform;
pointer-events: none;
}
.progress-bar:hover .progress,
.progress.dragging {
height: 6px;
}
.progress-bar:hover .progress-thumb,
.progress-thumb.dragging {
opacity: 1;
}
.progress-thumb.dragging {
transform: translateY(-50%) scale(1.2);
}
/* 移动端优化 */
@media (hover: none) and (pointer: coarse) {
.progress-bar {
height: 24px;
}
.progress {
height: 6px;
}
.progress-thumb {
width: 16px;
height: 16px;
left: calc(var(--progress-width, 0%) - 8px);
opacity: 1;
}
.progress-bar:active .progress {
height: 8px;
}
}
.time-display {
display: flex;
justify-content: space-between;
align-items: center;
font-size: 11px;
color: rgba(255, 255, 255, 0.8);
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
width: 100%;
}
.current-time,
.duration {
font-variant-numeric: tabular-nums;
}
</style>
@@ -0,0 +1,186 @@
<template>
<div class="player-info">
<div class="cover-container" title="点击打开歌词" @click="openLyrics">
<template v-if="song.cover && !coverError">
<img
:src="convertToHttps(song.cover)"
alt="封面"
class="player-cover"
referrerpolicy="no-referrer"
@error="handleImageError"
>
</template>
<div v-else class="text-cover">
{{ getFirstChar(song.title || '') }}
</div>
<!-- 悬浮提示层 -->
<div class="lyrics-overlay">
<svg
fill="none"
height="20"
viewBox="0 0 24 24"
width="20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M3 5h18v2H3V5zm0 4h14v2H3V9zm0 4h18v2H3v-2zm0 4h10v2H3v-2z"
fill="currentColor"
opacity="0.9"
/>
<circle cx="20" cy="11" fill="currentColor" opacity="0.7" r="2" />
<circle cx="18" cy="15" fill="currentColor" opacity="0.7" r="1.5" />
</svg>
<span class="lyrics-text">歌词</span>
</div>
</div>
<div class="player-text">
<h4>{{ song.title }}</h4>
<p>{{ song.artist }}</p>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
import { convertToHttps } from '~/utils/url'
const props = defineProps({
song: {
type: Object,
required: true
}
})
const emit = defineEmits(['openLyrics'])
const coverError = ref(false)
const handleImageError = () => {
coverError.value = true
}
const getFirstChar = (title) => {
if (!title) return '音'
return title.trim().charAt(0)
}
const openLyrics = () => {
emit('openLyrics')
}
</script>
<style scoped>
.player-info {
display: flex;
align-items: center;
gap: 12px;
min-width: 0;
flex: 1;
}
.cover-container {
width: 48px;
height: 48px;
aspect-ratio: 1;
border-radius: 8px;
overflow: hidden;
flex-shrink: 0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
display: flex;
align-items: center;
justify-content: center;
position: relative;
cursor: pointer;
transition: transform 0.2s ease;
}
.cover-container:hover {
transform: scale(1.05);
}
.lyrics-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.7);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
opacity: 0;
transition: opacity 0.3s ease;
color: white;
gap: 2px;
}
.cover-container:hover .lyrics-overlay {
opacity: 1;
}
.lyrics-text {
font-size: 10px;
font-weight: 500;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.player-cover {
width: 100%;
height: 100%;
object-fit: cover;
/* 添加辉光效果 */
box-shadow:
0 0 10px rgba(255, 255, 255, 0.3),
0 0 20px rgba(255, 255, 255, 0.2),
0 0 30px rgba(255, 255, 255, 0.1);
transition: box-shadow 0.3s ease;
}
.player-cover:hover {
box-shadow:
0 0 15px rgba(255, 255, 255, 0.4),
0 0 30px rgba(255, 255, 255, 0.3),
0 0 45px rgba(255, 255, 255, 0.2);
}
.text-cover {
width: 100%;
height: 100%;
aspect-ratio: 1;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
font-size: 18px;
font-weight: bold;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.player-text {
min-width: 0;
flex: 1;
}
.player-text h4 {
margin: 0;
font-size: 14px;
font-weight: 600;
color: white;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.player-text p {
margin: 2px 0 0 0;
font-size: 12px;
color: rgba(255, 255, 255, 0.8);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
</style>