11<template >
22 <div
33 class =" full-player-mobile"
4- ref =" mobileStart"
54 @touchstart.capture =" onTouchStart"
65 @touchmove.capture =" onTouchMove"
76 @touchend.capture =" onTouchEnd"
130129
131130 <!-- 歌词页 -->
132131 <div class =" page lyric-page" >
133- <div class =" lyric-header" >
132+ <div class =" lyric-header" ref = " lyricHeaderRef " >
134133 <s-image :src =" musicStore.getSongCover('s')" class =" lyric-cover" />
135134 <div class =" lyric-info" >
136135 <div class =" name text-hidden" >
166165 v-if =" hasLyric"
167166 class =" lyric-overlay"
168167 :class =" { swiping: isSwipingX }"
169- :style =" { transform: lyricPageTransform }"
168+ :style =" { transform: lyricPageTransform, paddingTop: lyricOverlayPaddingTop }"
170169 >
171170 <PlayerLyric />
172171 </div >
184183</template >
185184
186185<script setup lang="ts">
186+ import { useElementSize } from " @vueuse/core" ;
187187import { useMusicStore , useStatusStore , useDataStore , useSettingStore } from " @/stores" ;
188188import { usePlayerController } from " @/core/player/PlayerController" ;
189189import { useTimeFormat } from " @/composables/useTimeFormat" ;
@@ -198,7 +198,6 @@ const dataStore = useDataStore();
198198const player = usePlayerController ();
199199const { timeDisplay, toggleTimeFormat } = useTimeFormat ();
200200
201- const mobileStart = ref <HTMLElement | null >(null );
202201const pageIndex = ref (0 );
203202
204203const hasLyric = computed (() => {
@@ -218,8 +217,14 @@ watch(hasLyric, (val) => {
218217 if (! val ) pageIndex .value = 0 ;
219218});
220219
221- // 滑动偏移量
222- const swipeOffset = ref (0 );
220+ // 动态计算歌词覆盖层高度以对齐
221+ const lyricHeaderRef = ref <HTMLElement | null >(null );
222+ const { height : lyricHeaderHeight } = useElementSize (lyricHeaderRef );
223+ const lyricOverlayPaddingTop = computed (() => {
224+ // 60px (lyric-page padding-top) + header height + 20px (margin-bottom)
225+ return lyricHeaderHeight .value ? ` ${60 + lyricHeaderHeight .value + 20 }px ` : " 140px" ;
226+ });
227+
223228// 轴锁定:null=未确定, 'x'=水平翻页, 'y'=纵向滚动
224229const axisLock = ref <" x" | " y" | null >(null );
225230const isSwiping = ref (false );
@@ -250,7 +255,16 @@ const onTouchMove = (e: TouchEvent) => {
250255 axisLock .value = Math .abs (deltaX ) >= Math .abs (deltaY ) ? " x" : " y" ;
251256 // 确认是水平滑动时,在捕获阶段下发 touchcancel 终止子组件(如AMLL)内部的滑动状态
252257 if (axisLock .value === " x" && e .target instanceof EventTarget ) {
253- e .target .dispatchEvent (new TouchEvent (" touchcancel" , { bubbles: true , cancelable: true }));
258+ const touchList = e .touches ;
259+ e .target .dispatchEvent (
260+ new TouchEvent (" touchcancel" , {
261+ bubbles: true ,
262+ cancelable: true ,
263+ touches: Array .from (touchList ),
264+ targetTouches: Array .from (e .targetTouches ),
265+ changedTouches: Array .from (e .changedTouches ),
266+ }),
267+ );
254268 }
255269 }
256270 }
@@ -260,7 +274,6 @@ const onTouchMove = (e: TouchEvent) => {
260274 e .preventDefault ();
261275 e .stopPropagation ();
262276 lengthX .value = deltaX ;
263- swipeOffset .value = lengthX .value ;
264277 }
265278};
266279
@@ -269,7 +282,8 @@ const onTouchEnd = (e: TouchEvent) => {
269282 isSwiping .value = false ;
270283
271284 if (axisLock .value === " x" ) {
272- e .stopPropagation (); // 防止拦截事件造成点击误触
285+ // 防止拦截事件造成点击误触
286+ e .preventDefault ();
273287 const finalLengthX = startX - e .changedTouches [0 ].clientX ;
274288 const direction = finalLengthX > 0 ? " left" : " right" ;
275289
@@ -280,8 +294,7 @@ const onTouchEnd = (e: TouchEvent) => {
280294 pageIndex .value = 0 ;
281295 }
282296 }
283-
284- swipeOffset .value = 0 ;
297+
285298 axisLock .value = null ;
286299 lengthX .value = 0 ;
287300};
@@ -619,8 +632,7 @@ const contentTransform = computed(() => {
619632 left : 0 ;
620633 width : 100% ;
621634 height : 100% ;
622- // 顶部留出 lyric-page padding-top(60px) + lyric-header 高度(约 80px)
623- padding : 140px 24px 0 ;
635+ padding : 0 24px ;
624636 box-sizing : border-box ;
625637 mix-blend-mode : var (--lyric-blend-mode );
626638 transition : transform 0.3s cubic-bezier (0.25 , 1 , 0.5 , 1 );
0 commit comments