perf: hide context menu in tree view when press 'esc'

This commit is contained in:
Lykin 2024-01-24 11:25:59 +08:00
parent edaef2a78c
commit 124d221b9f
2 changed files with 69 additions and 58 deletions

View File

@ -567,7 +567,11 @@ defineExpose({
</script> </script>
<template> <template>
<div :style="{ backgroundColor }" class="flex-box-v browser-tree-wrapper" @contextmenu="(e) => e.preventDefault()"> <div
:style="{ backgroundColor }"
class="flex-box-v browser-tree-wrapper"
@contextmenu="(e) => e.preventDefault()"
@keydown.esc="contextMenuParam.show = false">
<n-spin v-if="props.loading" class="fill-height" /> <n-spin v-if="props.loading" class="fill-height" />
<n-empty v-else-if="!props.loading && isEmpty(data)" class="empty-content" /> <n-empty v-else-if="!props.loading && isEmpty(data)" class="empty-content" />
<n-tree <n-tree

View File

@ -479,6 +479,7 @@ const onCancelOpen = () => {
</script> </script>
<template> <template>
<div class="connection-tree-wrapper" @keydown.esc="contextMenuParam.show = false">
<n-empty <n-empty
v-if="isEmpty(connectionStore.connections)" v-if="isEmpty(connectionStore.connections)"
:description="$t('interface.empty_server_list')" :description="$t('interface.empty_server_list')"
@ -538,8 +539,14 @@ const onCancelOpen = () => {
trigger="manual" trigger="manual"
@clickoutside="contextMenuParam.show = false" @clickoutside="contextMenuParam.show = false"
@select="handleSelectContextMenu" /> @select="handleSelectContextMenu" />
</div>
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>
@import '@/styles/content'; @import '@/styles/content';
.connection-tree-wrapper {
height: 100%;
overflow: hidden;
}
</style> </style>