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 <a578457889743@gmail.com>
This commit is contained in:
lzy1960
2024-05-05 15:26:07 +08:00
committed by GitHub
parent 6cd2e4e4e5
commit e37caa7f79

View File

@@ -54,7 +54,12 @@ const emit = defineEmits<{
const api = useApiClient()
// Used to click and control herf attribute
const isClick = ref<boolean>(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)"
>
<!-- Cover -->
<div