Skip to content

Commit

Permalink
feat: tag菜单加上body点击时关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
yuntian001 committed Aug 10, 2023
1 parent 499861d commit 4553bde
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/layout/components/header/components/tagBar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<div
v-if="themeConfig.tagBarMenu"
class="icon pointer"
@click="setContextmenu($event.currentTarget as any, currentTag)"
@click.stop="setContextmenu($event.currentTarget as any, currentTag)"
>
<mel-icon-menu></mel-icon-menu>
</div>
Expand Down Expand Up @@ -180,6 +180,15 @@ const close = async (event: HTMLElement, current: RouteLocationNormalized) => {
await nextTick();
contextmenuRef.value?.closeCurrent();
};
const closeContextMenu = () => {
showContextmenu.value = false;
};
onMounted(() => {
document.body.addEventListener('click', closeContextMenu);
});
onBeforeUnmount(() => {
document.body.removeEventListener('click', closeContextMenu);
});
const reload = () => {
// 刷新
router.replace('/redirect/' + encodeURIComponent(route.fullPath));
Expand Down

0 comments on commit 4553bde

Please sign in to comment.