mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-04 11:44:42 +08:00
lint
This commit is contained in:
@@ -212,18 +212,9 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
);
|
||||
|
||||
const handleClick = useCallback(() => {
|
||||
console.log('🎬 VideoCard handleClick - 被调用', {
|
||||
from,
|
||||
actualSource,
|
||||
actualId,
|
||||
actualTitle,
|
||||
isAggregate
|
||||
});
|
||||
|
||||
if (from === 'douban' || (isAggregate && !actualSource && !actualId)) {
|
||||
const url = `/play?title=${encodeURIComponent(actualTitle.trim())}${actualYear ? `&year=${actualYear}` : ''
|
||||
}${actualSearchType ? `&stype=${actualSearchType}` : ''}${isAggregate ? '&prefer=true' : ''}${actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : ''}`;
|
||||
console.log('🎬 VideoCard handleClick - 导航到豆瓣/聚合:', url);
|
||||
router.push(url);
|
||||
} else if (actualSource && actualId) {
|
||||
const url = `/play?source=${actualSource}&id=${actualId}&title=${encodeURIComponent(
|
||||
@@ -231,10 +222,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
||||
)}${actualYear ? `&year=${actualYear}` : ''}${isAggregate ? '&prefer=true' : ''
|
||||
}${actualQuery ? `&stitle=${encodeURIComponent(actualQuery.trim())}` : ''
|
||||
}${actualSearchType ? `&stype=${actualSearchType}` : ''}`;
|
||||
console.log('🎬 VideoCard handleClick - 导航到播放页:', url);
|
||||
router.push(url);
|
||||
} else {
|
||||
console.log('🔴 VideoCard handleClick - 无法导航,缺少必要参数');
|
||||
}
|
||||
}, [
|
||||
from,
|
||||
|
||||
@@ -32,12 +32,9 @@ export const useLongPress = ({
|
||||
}, []);
|
||||
|
||||
const handleStart = useCallback(
|
||||
(clientX: number, clientY: number, isButton: boolean = false) => {
|
||||
console.log('🟡 handleStart - isButton:', isButton, 'isActive:', isActive.current);
|
||||
|
||||
(clientX: number, clientY: number, isButton = false) => {
|
||||
// 如果已经有活跃的手势,忽略新的开始
|
||||
if (isActive.current) {
|
||||
console.log('🔴 handleStart - 已有活跃手势,忽略');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -47,16 +44,13 @@ export const useLongPress = ({
|
||||
|
||||
// 记录触摸开始时是否是按钮
|
||||
wasButton.current = isButton;
|
||||
console.log('🟢 handleStart - 设置状态完成,wasButton:', wasButton.current);
|
||||
|
||||
pressTimer.current = setTimeout(() => {
|
||||
// 再次检查是否仍然活跃
|
||||
if (!isActive.current) return;
|
||||
|
||||
isLongPress.current = true;
|
||||
console.log('🔵 长按触发');
|
||||
|
||||
// 添加触觉反馈(如果支持)
|
||||
if (navigator.vibrate) {
|
||||
navigator.vibrate(50);
|
||||
}
|
||||
@@ -79,7 +73,6 @@ export const useLongPress = ({
|
||||
|
||||
// 如果移动距离超过阈值,取消长按
|
||||
if (distance > moveThreshold) {
|
||||
console.log('🔴 handleMove - 移动距离超过阈值,取消手势, distance:', distance, 'threshold:', moveThreshold);
|
||||
clearTimer();
|
||||
isActive.current = false;
|
||||
}
|
||||
@@ -88,8 +81,6 @@ export const useLongPress = ({
|
||||
);
|
||||
|
||||
const handleEnd = useCallback(() => {
|
||||
console.log('🟡 handleEnd - isLongPress:', isLongPress.current, 'wasButton:', wasButton.current, 'isActive:', isActive.current, 'hasOnClick:', !!onClick);
|
||||
|
||||
clearTimer();
|
||||
|
||||
// 根据情况决定是否触发点击事件:
|
||||
@@ -97,18 +88,9 @@ export const useLongPress = ({
|
||||
// 2. 如果不是长按且触摸开始时是按钮,不触发点击
|
||||
// 3. 否则触发点击
|
||||
const shouldClick = !isLongPress.current && !wasButton.current && onClick && isActive.current;
|
||||
console.log('🟢 handleEnd - shouldClick:', shouldClick);
|
||||
|
||||
if (shouldClick) {
|
||||
console.log('🚀 触发点击事件');
|
||||
onClick();
|
||||
} else {
|
||||
console.log('❌ 不触发点击事件 - 原因:', {
|
||||
isLongPress: isLongPress.current,
|
||||
wasButton: wasButton.current,
|
||||
hasOnClick: !!onClick,
|
||||
isActive: isActive.current
|
||||
});
|
||||
}
|
||||
|
||||
// 重置所有状态
|
||||
@@ -121,8 +103,6 @@ export const useLongPress = ({
|
||||
// 触摸事件处理器
|
||||
const onTouchStart = useCallback(
|
||||
(e: React.TouchEvent) => {
|
||||
console.log('📱 onTouchStart - 开始');
|
||||
|
||||
// 检查是否触摸的是按钮或其他交互元素
|
||||
const target = e.target as HTMLElement;
|
||||
const buttonElement = target.closest('[data-button]');
|
||||
@@ -131,11 +111,6 @@ export const useLongPress = ({
|
||||
const isDirectButton = target.hasAttribute('data-button');
|
||||
const isButton = !!buttonElement && isDirectButton;
|
||||
|
||||
console.log('📱 onTouchStart - target:', target.tagName, target.className);
|
||||
console.log('📱 onTouchStart - buttonElement:', buttonElement);
|
||||
console.log('📱 onTouchStart - isDirectButton:', isDirectButton);
|
||||
console.log('📱 onTouchStart - isButton:', isButton);
|
||||
|
||||
// 阻止默认的长按行为,但不阻止触摸开始事件
|
||||
const touch = e.touches[0];
|
||||
handleStart(touch.clientX, touch.clientY, !!isButton);
|
||||
@@ -146,7 +121,6 @@ export const useLongPress = ({
|
||||
const onTouchMove = useCallback(
|
||||
(e: React.TouchEvent) => {
|
||||
const touch = e.touches[0];
|
||||
console.log('📱 onTouchMove - 移动');
|
||||
handleMove(touch.clientX, touch.clientY);
|
||||
},
|
||||
[handleMove]
|
||||
@@ -154,7 +128,6 @@ export const useLongPress = ({
|
||||
|
||||
const onTouchEnd = useCallback(
|
||||
(e: React.TouchEvent) => {
|
||||
console.log('📱 onTouchEnd - 结束');
|
||||
// 始终阻止默认行为,避免任何系统长按菜单
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
Reference in New Issue
Block a user