From 34a0be4d08d2903b4a5d55ba469958c7747c9c56 Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Sat, 21 Oct 2023 00:11:23 +0800 Subject: [PATCH] feat: add new component "switch button" refactor: extract the file open input as a component --- .../src/components/common/FileOpenInput.vue | 31 ++++++ .../src/components/common/SwitchButton.vue | 59 ++++++++++++ .../components/dialogs/ConnectionDialog.vue | 96 ++++--------------- 3 files changed, 107 insertions(+), 79 deletions(-) create mode 100644 frontend/src/components/common/FileOpenInput.vue create mode 100644 frontend/src/components/common/SwitchButton.vue diff --git a/frontend/src/components/common/FileOpenInput.vue b/frontend/src/components/common/FileOpenInput.vue new file mode 100644 index 0000000..369cb9e --- /dev/null +++ b/frontend/src/components/common/FileOpenInput.vue @@ -0,0 +1,31 @@ + + + + + diff --git a/frontend/src/components/common/SwitchButton.vue b/frontend/src/components/common/SwitchButton.vue new file mode 100644 index 0000000..3dd33be --- /dev/null +++ b/frontend/src/components/common/SwitchButton.vue @@ -0,0 +1,59 @@ + + + + + diff --git a/frontend/src/components/dialogs/ConnectionDialog.vue b/frontend/src/components/dialogs/ConnectionDialog.vue index 9f53685..d396b5b 100644 --- a/frontend/src/components/dialogs/ConnectionDialog.vue +++ b/frontend/src/components/dialogs/ConnectionDialog.vue @@ -6,7 +6,7 @@ import { ListSentinelMasters, TestConnection } from 'wailsjs/go/services/connect import useDialog, { ConnDialogType } from 'stores/dialog' import Close from '@/components/icons/Close.vue' import useConnectionStore from 'stores/connections.js' -import { SelectFile } from 'wailsjs/go/services/systemService.js' +import FileOpenInput from '@/components/common/FileOpenInput.vue' /** * Dialog for new or edit connection @@ -83,39 +83,6 @@ const sshLoginType = computed(() => { return get(generalForm.value, 'ssh.loginType', 'pwd') }) -const onSSHChooseKey = async () => { - const { success, data } = await SelectFile() - const path = get(data, 'path', '') - if (!isEmpty(path)) { - generalForm.value.ssh.pkFile = path - } -} - -const onSSLChooseCert = async () => { - const { success, data } = await SelectFile() - const path = get(data, 'path', '') - if (!isEmpty(path)) { - generalForm.value.ssl.certFile = path - } -} - -const onSSLChooseKey = async () => { - const { success, data } = await SelectFile() - const path = get(data, 'path', '') - if (!isEmpty(path)) { - generalForm.value.ssl.keyFile = path - } -} - -const onSSLChooseCA = async () => { - const { success, data } = await SelectFile() - if (!success) { - generalForm.value.ssl.caFile = '' - } else { - generalForm.value.ssl.caFile = get(data, 'path', '') - } -} - const loadingSentinelMaster = ref(false) const masterNameOptions = ref([]) const onLoadSentinelMasters = async () => { @@ -434,43 +401,22 @@ const onClose = () => { :show-require-mark="false" label-placement="top"> - - - - ... - - + - - - - ... - - + - - - - ... - - + @@ -519,18 +465,10 @@ const onClose = () => { type="password" /> - - - - ... - - +