From e37caa7f7910906fd71691455a73ffe20cd723b5 Mon Sep 17 00:00:00 2001 From: lzy1960 <40552111+lzy1960@users.noreply.github.com> Date: Sun, 5 May 2024 15:26:07 +0800 Subject: [PATCH] fix(VideoCard): preview control cannot be dragged while pressing (#714) * fix(VideoCard): preview control cannot be dragged while pressing * Update VideoCard.vue --------- Co-authored-by: Hakadao --- src/components/VideoCard/VideoCard.vue | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/components/VideoCard/VideoCard.vue b/src/components/VideoCard/VideoCard.vue index 2530d26f..fb666a1b 100644 --- a/src/components/VideoCard/VideoCard.vue +++ b/src/components/VideoCard/VideoCard.vue @@ -54,7 +54,12 @@ const emit = defineEmits<{ const api = useApiClient() +// Used to click and control herf attribute +const isClick = ref(false) + const videoUrl = computed(() => { + if (!isClick.value) + return undefined if (props.bvid || props.aid) return `https://www.bilibili.com/video/${props.bvid ?? `av${props.aid}`}` else if (props.epid) @@ -149,6 +154,17 @@ function handelMouseLeave() { }, 300) } +function switchClickState(flag: boolean) { + if (flag) { + isClick.value = flag + } + else { + setTimeout(() => { + isClick.value = flag + }) + } +} + function handleMoreBtnClick(event: MouseEvent) { emit('moreClick', event) } @@ -212,6 +228,9 @@ function handleUndo() { :href="videoUrl" target="_blank" rel="noopener noreferrer" @mouseenter="handleMouseEnter" @mouseleave="handelMouseLeave" + @mousedown="switchClickState(true)" + @mouseup="switchClickState(false)" + @dragend="switchClickState(false)" >