Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Aug 23, 2024
2 parents ecc49f0 + 86321bb commit e86a4b4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/components/ui/context-menu/ContextMenuList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { ComputedRef, inject, ref } from 'vue';
import { ClickOutside as vClickOutside } from 'element-plus';
interface ContextMenuItem {
title: string;
Expand Down
19 changes: 19 additions & 0 deletions src/directives/click-outside/clickOutside.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Directive } from 'vue';

const clickOutsideDirective: Directive = {
beforeMount(el, binding) {
el.clickOutsideEvent = function (event: MouseEvent) {
// Check that click was outside the element
if (!(el == event.target || el.contains(event.target))) {
// If yes, call method provided in attribute value
binding.value(event);
}
};
document.addEventListener('click', el.clickOutsideEvent);
},
unmounted(el) {
document.removeEventListener('click', el.clickOutsideEvent);
},
};

export default clickOutsideDirective;
2 changes: 2 additions & 0 deletions src/package/create-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import 'normalize.css/normalize.css';
import 'element-plus/theme-chalk/index.css';
import '@/styles/index.scss';
import { initChartJS } from '@/utils/chart';
import clickOutsideDirective from '@/directives/click-outside/clickOutside';

export const getDefaultCreateAppOptions = (): CreateAppOptions => {
return {
Expand Down Expand Up @@ -97,6 +98,7 @@ const _createApp = async (options?: CreateAppOptions): Promise<App> => {
if (options.loadLocate) app.directive('locate', locate as any);
if (options.loadAuth) app.directive('auth', auth as any);
if (options.loadExport) app.directive('export', export_ as any);
app.directive('click-outside', clickOutsideDirective);

// mount
if (options.mount) {
Expand Down
2 changes: 2 additions & 0 deletions src/views/database/detail/tabs/DatabaseDetailTabDatabases.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ const getTablePreview = async () => {
const activeNavItem = ref<DatabaseNavItem>();
const onNodeClick = async (data: DatabaseNavItem) => {
console.debug('onNodeClick');
activeNavItem.value = data;
const { type } = data;
if (type === 'table') {
Expand Down Expand Up @@ -339,6 +340,7 @@ defineOptions({ name: 'ClDatabaseDetailTabDatabases' });
</div>
</template>
<cl-context-menu-list
v-if="isContextMenuVisible(data.id)"
:items="contextMenuItems"
@hide="onContextMenuHide(data.id)"
/>
Expand Down

0 comments on commit e86a4b4

Please sign in to comment.