From bf16e226476dfbd1150516a6ddec969dda90a978 Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Sat, 19 Aug 2023 01:47:19 +0800 Subject: [PATCH] fix: collapse all keys after server reload refactor: expose context menu handler for outside reference caller --- .../src/components/sidebar/BrowserPane.vue | 19 +-- .../src/components/sidebar/BrowserTree.vue | 138 +++++++++--------- 2 files changed, 76 insertions(+), 81 deletions(-) diff --git a/frontend/src/components/sidebar/BrowserPane.vue b/frontend/src/components/sidebar/BrowserPane.vue index 872e3e1..7759bd7 100644 --- a/frontend/src/components/sidebar/BrowserPane.vue +++ b/frontend/src/components/sidebar/BrowserPane.vue @@ -4,7 +4,7 @@ import AddLink from '@/components/icons/AddLink.vue' import BrowserTree from './BrowserTree.vue' import IconButton from '@/components/common/IconButton.vue' import useTabStore from 'stores/tab.js' -import { computed, reactive } from 'vue' +import { computed, reactive, ref } from 'vue' import { get } from 'lodash' import Delete from '@/components/icons/Delete.vue' import Refresh from '@/components/icons/Refresh.vue' @@ -19,6 +19,7 @@ const themeVars = useThemeVars() const dialogStore = useDialogStore() const tabStore = useTabStore() const currentName = computed(() => get(tabStore.currentTab, 'name', '')) +const browserTreeRef = ref(null) /** * * @type {ComputedRef<{server: string, db: number, key: string}>} @@ -35,23 +36,13 @@ const onNewKey = () => { const i18n = useI18n() const connectionStore = useConnectionStore() -const confirmDialog = useConfirmDialog() const message = useMessage() const onDeleteKey = () => { - const { server, db, key } = currentSelect.value - confirmDialog.warning(i18n.t('remove_tip', { name: key }), () => { - connectionStore.deleteKey(server, db, key).then((success) => { - if (success) { - message.success(i18n.t('delete_key_succ', { key })) - } - }) - }) + browserTreeRef.value?.handleSelectContextMenu('value_remove') } const onRefresh = () => { - connectionStore.openConnection(currentSelect.value.server, true).then(() => { - message.success(i18n.t('reload_succ')) - }) + browserTreeRef.value?.handleSelectContextMenu('server_reload') } const filterForm = reactive({ @@ -75,7 +66,7 @@ const filterTypeOptions = computed(() => {