mirror of
https://github.com/MoonTechLab/LunaTV.git
synced 2026-02-28 09:23:14 +08:00
fix: video card button cannot click
This commit is contained in:
@@ -583,6 +583,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
|||||||
{config.showCheckCircle && (
|
{config.showCheckCircle && (
|
||||||
<Trash2
|
<Trash2
|
||||||
onClick={handleDeleteRecord}
|
onClick={handleDeleteRecord}
|
||||||
|
data-role="button"
|
||||||
size={20}
|
size={20}
|
||||||
className='text-white transition-all duration-300 ease-out hover:stroke-red-500 hover:scale-[1.1]'
|
className='text-white transition-all duration-300 ease-out hover:stroke-red-500 hover:scale-[1.1]'
|
||||||
style={{
|
style={{
|
||||||
@@ -599,6 +600,7 @@ const VideoCard = forwardRef<VideoCardHandle, VideoCardProps>(function VideoCard
|
|||||||
{config.showHeart && (
|
{config.showHeart && (
|
||||||
<Heart
|
<Heart
|
||||||
onClick={handleToggleFavorite}
|
onClick={handleToggleFavorite}
|
||||||
|
data-role="button"
|
||||||
size={20}
|
size={20}
|
||||||
className={`transition-all duration-300 ease-out ${favorited
|
className={`transition-all duration-300 ease-out ${favorited
|
||||||
? 'fill-red-600 stroke-red-600'
|
? 'fill-red-600 stroke-red-600'
|
||||||
|
|||||||
@@ -31,10 +31,19 @@ export const useLongPress = ({
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const handleStart = useCallback(
|
const handleStart = useCallback(
|
||||||
(clientX: number, clientY: number) => {
|
(clientX: number, clientY: number, target?: EventTarget) => {
|
||||||
// 如果已经有活跃的手势,忽略新的开始
|
// 如果已经有活跃的手势,忽略新的开始
|
||||||
if (isActive.current) return;
|
if (isActive.current) return;
|
||||||
|
|
||||||
|
// 检查是否点击的是按钮元素
|
||||||
|
if (target && target instanceof Element) {
|
||||||
|
const isButton = target.closest('button, [role="button"], [data-role="button"], .cursor-pointer, svg, a');
|
||||||
|
if (isButton) {
|
||||||
|
// 如果点击的是按钮,不启动长按计时器
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isActive.current = true;
|
isActive.current = true;
|
||||||
isLongPress.current = false;
|
isLongPress.current = false;
|
||||||
startPosition.current = { x: clientX, y: clientY };
|
startPosition.current = { x: clientX, y: clientY };
|
||||||
@@ -94,7 +103,7 @@ export const useLongPress = ({
|
|||||||
(e: React.TouchEvent) => {
|
(e: React.TouchEvent) => {
|
||||||
// 阻止默认的长按行为,但不阻止触摸开始事件
|
// 阻止默认的长按行为,但不阻止触摸开始事件
|
||||||
const touch = e.touches[0];
|
const touch = e.touches[0];
|
||||||
handleStart(touch.clientX, touch.clientY);
|
handleStart(touch.clientX, touch.clientY, e.target);
|
||||||
},
|
},
|
||||||
[handleStart]
|
[handleStart]
|
||||||
);
|
);
|
||||||
@@ -120,7 +129,7 @@ export const useLongPress = ({
|
|||||||
// 鼠标事件处理器(用于桌面端测试)
|
// 鼠标事件处理器(用于桌面端测试)
|
||||||
const onMouseDown = useCallback(
|
const onMouseDown = useCallback(
|
||||||
(e: React.MouseEvent) => {
|
(e: React.MouseEvent) => {
|
||||||
handleStart(e.clientX, e.clientY);
|
handleStart(e.clientX, e.clientY, e.target);
|
||||||
},
|
},
|
||||||
[handleStart]
|
[handleStart]
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user