Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
monorepo
/
venus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
1
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 182f1c9d
authored
Feb 12, 2025
by
Netfan
Committed by
GitHub
Feb 12, 2025
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
fix: userDropdown triggered unnecessary while overlay shown (#5520)
* 修复顶部的用户资料下拉在弹窗被打开时,仍然可以被触发的问题
1 parent
e7b00978
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
packages/effects/hooks/src/use-hover-toggle.ts
packages/effects/hooks/src/use-hover-toggle.ts
View file @
182f1c9
...
...
@@ -2,11 +2,11 @@ import type { Arrayable, MaybeElementRef } from '@vueuse/core';
import
type
{
Ref
}
from
'vue'
;
import
{
computed
,
onUnmounted
,
ref
,
watch
}
from
'vue'
;
import
{
computed
,
onUnmounted
,
ref
,
unref
,
watch
}
from
'vue'
;
import
{
isFunction
}
from
'@vben/utils'
;
import
{
use
MouseInElement
}
from
'@vueuse/core'
;
import
{
use
ElementHover
}
from
'@vueuse/core'
;
/**
* 监测鼠标是否在元素内部,如果在元素内部则返回 true,否则返回 false
...
...
@@ -18,15 +18,19 @@ export function useHoverToggle(
refElement
:
Arrayable
<
MaybeElementRef
>
,
delay
:
(()
=>
number
)
|
number
=
500
,
)
{
const
is
Outside
s
:
Array
<
Ref
<
boolean
>>
=
[];
const
is
Hover
s
:
Array
<
Ref
<
boolean
>>
=
[];
const
value
=
ref
(
false
);
const
timer
=
ref
<
ReturnType
<
typeof
setTimeout
>
|
undefined
>
();
const
refs
=
Array
.
isArray
(
refElement
)
?
refElement
:
[
refElement
];
refs
.
forEach
((
refEle
)
=>
{
const
listener
=
useMouseInElement
(
refEle
,
{
handleOutside
:
true
});
isOutsides
.
push
(
listener
.
isOutside
);
const
eleRef
=
computed
(()
=>
{
const
ele
=
unref
(
refEle
);
return
ele
instanceof
Element
?
ele
:
(
ele
?.
$el
as
Element
);
});
const
isHover
=
useElementHover
(
eleRef
);
isHovers
.
push
(
isHover
);
});
const
isOutsideAll
=
computed
(()
=>
is
Outsides
.
every
((
v
)
=>
v
.
value
));
const
isOutsideAll
=
computed
(()
=>
is
Hovers
.
every
((
v
)
=>
!
v
.
value
));
function
setValueDelay
(
val
:
boolean
)
{
timer
.
value
&&
clearTimeout
(
timer
.
value
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment