perf: bind message and dialog to window
This commit is contained in:
parent
22f71e4676
commit
95e48e75d3
|
@ -1090,9 +1090,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/immutable": {
|
"node_modules/immutable": {
|
||||||
"version": "4.3.2",
|
"version": "4.3.3",
|
||||||
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.2.tgz",
|
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.3.tgz",
|
||||||
"integrity": "sha512-oGXzbEDem9OOpDWZu88jGiYCvIsLHMvGw+8OXlpsvTFvIQplQbjg1B1cvKg8f7Hoch6+NGjpPsH1Fr+Mc2D1aA=="
|
"integrity": "sha512-808ZFYMsIRAjLAu5xkKo0TsbY9LBy9H5MazTKIEHerNkg0ymgilGfBPMR/3G7d/ihGmuK2Hw8S1izY2d3kd3wA=="
|
||||||
},
|
},
|
||||||
"node_modules/is-binary-path": {
|
"node_modules/is-binary-path": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
|
@ -2720,9 +2720,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"immutable": {
|
"immutable": {
|
||||||
"version": "4.3.2",
|
"version": "4.3.3",
|
||||||
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.2.tgz",
|
"resolved": "https://registry.npmmirror.com/immutable/-/immutable-4.3.3.tgz",
|
||||||
"integrity": "sha512-oGXzbEDem9OOpDWZu88jGiYCvIsLHMvGw+8OXlpsvTFvIQplQbjg1B1cvKg8f7Hoch6+NGjpPsH1Fr+Mc2D1aA=="
|
"integrity": "sha512-808ZFYMsIRAjLAu5xkKo0TsbY9LBy9H5MazTKIEHerNkg0ymgilGfBPMR/3G7d/ihGmuK2Hw8S1izY2d3kd3wA=="
|
||||||
},
|
},
|
||||||
"is-binary-path": {
|
"is-binary-path": {
|
||||||
"version": "2.1.0",
|
"version": "2.1.0",
|
||||||
|
|
|
@ -11,11 +11,11 @@ import AddFieldsDialog from './components/dialogs/AddFieldsDialog.vue'
|
||||||
import AppContent from './AppContent.vue'
|
import AppContent from './AppContent.vue'
|
||||||
import GroupDialog from './components/dialogs/GroupDialog.vue'
|
import GroupDialog from './components/dialogs/GroupDialog.vue'
|
||||||
import DeleteKeyDialog from './components/dialogs/DeleteKeyDialog.vue'
|
import DeleteKeyDialog from './components/dialogs/DeleteKeyDialog.vue'
|
||||||
import { computed, onBeforeMount, ref } from 'vue'
|
import { onMounted, ref, watch } from 'vue'
|
||||||
import usePreferencesStore from './stores/preferences.js'
|
import usePreferencesStore from './stores/preferences.js'
|
||||||
import useConnectionStore from './stores/connections.js'
|
import useConnectionStore from './stores/connections.js'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { darkTheme, lightTheme, useOsTheme } from 'naive-ui'
|
import { darkTheme } from 'naive-ui'
|
||||||
import KeyFilterDialog from './components/dialogs/KeyFilterDialog.vue'
|
import KeyFilterDialog from './components/dialogs/KeyFilterDialog.vue'
|
||||||
import { WindowSetDarkTheme, WindowSetLightTheme } from 'wailsjs/runtime/runtime.js'
|
import { WindowSetDarkTheme, WindowSetLightTheme } from 'wailsjs/runtime/runtime.js'
|
||||||
import { themeOverrides } from '@/utils/theme.js'
|
import { themeOverrides } from '@/utils/theme.js'
|
||||||
|
@ -27,12 +27,10 @@ const prefStore = usePreferencesStore()
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const initializing = ref(false)
|
const initializing = ref(false)
|
||||||
onBeforeMount(async () => {
|
onMounted(async () => {
|
||||||
try {
|
try {
|
||||||
initializing.value = true
|
initializing.value = true
|
||||||
await prefStore.loadPreferences()
|
|
||||||
i18n.locale.value = prefStore.currentLanguage
|
i18n.locale.value = prefStore.currentLanguage
|
||||||
await prefStore.loadFontList()
|
|
||||||
await connectionStore.initConnections()
|
await connectionStore.initConnections()
|
||||||
if (prefStore.autoCheckUpdate) {
|
if (prefStore.autoCheckUpdate) {
|
||||||
prefStore.checkForUpdate()
|
prefStore.checkForUpdate()
|
||||||
|
@ -42,27 +40,17 @@ onBeforeMount(async () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const osTheme = useOsTheme()
|
watch(
|
||||||
const theme = computed(() => {
|
() => prefStore.isDark,
|
||||||
if (prefStore.general.theme === 'auto') {
|
(isDark) => (isDark ? WindowSetDarkTheme() : WindowSetLightTheme()),
|
||||||
if (osTheme.value === 'dark') {
|
)
|
||||||
WindowSetDarkTheme()
|
|
||||||
return darkTheme
|
|
||||||
}
|
|
||||||
} else if (prefStore.general.theme === 'dark') {
|
|
||||||
WindowSetDarkTheme()
|
|
||||||
return darkTheme
|
|
||||||
}
|
|
||||||
WindowSetLightTheme()
|
|
||||||
return lightTheme
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<n-config-provider
|
<n-config-provider
|
||||||
:hljs="hljs"
|
:hljs="hljs"
|
||||||
:inline-theme-disabled="true"
|
:inline-theme-disabled="true"
|
||||||
:theme="theme"
|
:theme="prefStore.isDark ? darkTheme : undefined"
|
||||||
:theme-overrides="themeOverrides"
|
:theme-overrides="themeOverrides"
|
||||||
class="fill-height"
|
class="fill-height"
|
||||||
>
|
>
|
||||||
|
|
|
@ -11,7 +11,6 @@ import useTabStore from 'stores/tab.js'
|
||||||
import { useDialog } from 'naive-ui'
|
import { useDialog } from 'naive-ui'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import ContentServerStatus from '@/components/content_value/ContentServerStatus.vue'
|
import ContentServerStatus from '@/components/content_value/ContentServerStatus.vue'
|
||||||
import ContentValueStream from '@/components/content_value/ContentValueStream.vue'
|
import ContentValueStream from '@/components/content_value/ContentValueStream.vue'
|
||||||
|
|
||||||
|
@ -125,9 +124,8 @@ const onReloadKey = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
const onCloseTab = (tabIndex) => {
|
const onCloseTab = (tabIndex) => {
|
||||||
confirmDialog.warning(i18n.t('close_confirm'), () => {
|
$dialog.warning(i18n.t('close_confirm'), () => {
|
||||||
const tab = get(tabStore.tabs, tabIndex)
|
const tab = get(tabStore.tabs, tabIndex)
|
||||||
if (tab != null) {
|
if (tab != null) {
|
||||||
connectionStore.closeConnection(tab.name)
|
connectionStore.closeConnection(tab.name)
|
||||||
|
|
|
@ -9,10 +9,8 @@ import RedisTypeTag from '@/components/common/RedisTypeTag.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import IconButton from '@/components/common/IconButton.vue'
|
import IconButton from '@/components/common/IconButton.vue'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import Copy from '@/components/icons/Copy.vue'
|
import Copy from '@/components/icons/Copy.vue'
|
||||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
server: String,
|
server: String,
|
||||||
|
@ -33,7 +31,6 @@ const props = defineProps({
|
||||||
|
|
||||||
const dialogStore = useDialog()
|
const dialogStore = useDialog()
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const message = useMessage()
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
|
|
||||||
const onReloadKey = () => {
|
const onReloadKey = () => {
|
||||||
|
@ -44,20 +41,19 @@ const onCopyKey = () => {
|
||||||
ClipboardSetText(props.keyPath)
|
ClipboardSetText(props.keyPath)
|
||||||
.then((succ) => {
|
.then((succ) => {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
message.success(i18n.t('copy_succ'))
|
$message.success(i18n.t('copy_succ'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
const onDeleteKey = () => {
|
const onDeleteKey = () => {
|
||||||
confirmDialog.warning(i18n.t('remove_tip', { name: props.keyPath }), () => {
|
$dialog.warning(i18n.t('remove_tip', { name: props.keyPath }), () => {
|
||||||
connectionStore.deleteKey(props.server, props.db, props.keyPath).then((success) => {
|
connectionStore.deleteKey(props.server, props.db, props.keyPath).then((success) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('delete_key_succ', { key: props.keyPath }))
|
$message.success(i18n.t('delete_key_succ', { key: props.keyPath }))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,10 +8,8 @@ import { types, types as redisTypes } from '@/consts/support_redis_type.js'
|
||||||
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
name: String,
|
||||||
db: Number,
|
db: Number,
|
||||||
|
@ -125,7 +123,7 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('delete_key_succ', { key: row.key }))
|
$message.success(i18n.t('delete_key_succ', { key: row.key }))
|
||||||
// update display value
|
// update display value
|
||||||
// if (!isEmpty(removed)) {
|
// if (!isEmpty(removed)) {
|
||||||
// for (const elem of removed) {
|
// for (const elem of removed) {
|
||||||
|
@ -133,10 +131,10 @@ const actionColumn = {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSave: async () => {
|
onSave: async () => {
|
||||||
|
@ -151,7 +149,7 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('save_value_succ'))
|
$message.success(i18n.t('save_value_succ'))
|
||||||
// update display value
|
// update display value
|
||||||
// if (!isEmpty(updated)) {
|
// if (!isEmpty(updated)) {
|
||||||
// for (const key in updated) {
|
// for (const key in updated) {
|
||||||
|
@ -159,10 +157,10 @@ const actionColumn = {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
currentEditRow.value.no = 0
|
currentEditRow.value.no = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,8 @@ import { types, types as redisTypes } from '@/consts/support_redis_type.js'
|
||||||
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
name: String,
|
||||||
db: Number,
|
db: Number,
|
||||||
|
@ -82,16 +80,16 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('delete_key_succ', { key: '#' + row.no }))
|
$message.success(i18n.t('delete_key_succ', { key: '#' + row.no }))
|
||||||
// update display value
|
// update display value
|
||||||
// if (!isEmpty(removed)) {
|
// if (!isEmpty(removed)) {
|
||||||
// props.value.splice(removed[0], 1)
|
// props.value.splice(removed[0], 1)
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSave: async () => {
|
onSave: async () => {
|
||||||
|
@ -105,7 +103,7 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('save_value_succ'))
|
$message.success(i18n.t('save_value_succ'))
|
||||||
// update display value
|
// update display value
|
||||||
// if (!isEmpty(updated)) {
|
// if (!isEmpty(updated)) {
|
||||||
// for (const key in updated) {
|
// for (const key in updated) {
|
||||||
|
@ -113,10 +111,10 @@ const actionColumn = {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
currentEditRow.value.no = 0
|
currentEditRow.value.no = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,8 @@ import useDialogStore from 'stores/dialog.js'
|
||||||
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
|
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
|
||||||
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
name: String,
|
||||||
db: Number,
|
db: Number,
|
||||||
|
@ -84,14 +82,14 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('delete_key_succ', { key: row.value }))
|
$message.success(i18n.t('delete_key_succ', { key: row.value }))
|
||||||
// update display value
|
// update display value
|
||||||
// props.value.splice(row.no - 1, 1)
|
// props.value.splice(row.no - 1, 1)
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSave: async () => {
|
onSave: async () => {
|
||||||
|
@ -105,14 +103,14 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('save_value_succ'))
|
$message.success(i18n.t('save_value_succ'))
|
||||||
// update display value
|
// update display value
|
||||||
// props.value[row.no - 1] = currentEditRow.value.value
|
// props.value[row.no - 1] = currentEditRow.value.value
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
currentEditRow.value.no = 0
|
currentEditRow.value.no = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,10 +9,8 @@ import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { includes, keys, some, values } from 'lodash'
|
import { includes, keys, some, values } from 'lodash'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
name: String,
|
||||||
db: Number,
|
db: Number,
|
||||||
|
@ -92,7 +90,7 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('delete_key_succ', { key: row.id }))
|
$message.success(i18n.t('delete_key_succ', { key: row.id }))
|
||||||
// update display value
|
// update display value
|
||||||
// if (!isEmpty(removed)) {
|
// if (!isEmpty(removed)) {
|
||||||
// for (const elem of removed) {
|
// for (const elem of removed) {
|
||||||
|
@ -100,10 +98,10 @@ const actionColumn = {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -13,10 +13,8 @@ import { types as redisTypes } from '@/consts/support_redis_type.js'
|
||||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||||
import { toLower } from 'lodash'
|
import { toLower } from 'lodash'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -117,11 +115,11 @@ const onCopyValue = () => {
|
||||||
ClipboardSetText(viewValue.value)
|
ClipboardSetText(viewValue.value)
|
||||||
.then((succ) => {
|
.then((succ) => {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
message.success(i18n.t('copy_succ'))
|
$message.success(i18n.t('copy_succ'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,12 +152,12 @@ const onSaveValue = async () => {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
await connectionStore.loadKeyValue(props.name, props.db, props.keyPath)
|
await connectionStore.loadKeyValue(props.name, props.db, props.keyPath)
|
||||||
message.success(i18n.t('save_value_succ'))
|
$message.success(i18n.t('save_value_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
inEdit.value = false
|
inEdit.value = false
|
||||||
saving.value = false
|
saving.value = false
|
||||||
|
|
|
@ -9,10 +9,8 @@ import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
|
||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
name: String,
|
name: String,
|
||||||
db: Number,
|
db: Number,
|
||||||
|
@ -155,19 +153,19 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('delete_key_succ', { key: row.value }))
|
$message.success(i18n.t('delete_key_succ', { key: row.value }))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSave: async () => {
|
onSave: async () => {
|
||||||
try {
|
try {
|
||||||
const newValue = currentEditRow.value.value
|
const newValue = currentEditRow.value.value
|
||||||
if (isEmpty(newValue)) {
|
if (isEmpty(newValue)) {
|
||||||
message.error(i18n.t('spec_field_required', { key: i18n.t('value') }))
|
$message.error(i18n.t('spec_field_required', { key: i18n.t('value') }))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const { success, msg } = await connectionStore.updateZSetItem(
|
const { success, msg } = await connectionStore.updateZSetItem(
|
||||||
|
@ -180,12 +178,12 @@ const actionColumn = {
|
||||||
)
|
)
|
||||||
if (success) {
|
if (success) {
|
||||||
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
connectionStore.loadKeyValue(props.name, props.db, props.keyPath).then((r) => {})
|
||||||
message.success(i18n.t('save_value_succ'))
|
$message.success(i18n.t('save_value_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
currentEditRow.value.no = 0
|
currentEditRow.value.no = 0
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import useDialog from 'stores/dialog'
|
||||||
import NewStringValue from '@/components/new_value/NewStringValue.vue'
|
import NewStringValue from '@/components/new_value/NewStringValue.vue'
|
||||||
import NewSetValue from '@/components/new_value/NewSetValue.vue'
|
import NewSetValue from '@/components/new_value/NewSetValue.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import AddListValue from '@/components/new_value/AddListValue.vue'
|
import AddListValue from '@/components/new_value/AddListValue.vue'
|
||||||
import AddHashValue from '@/components/new_value/AddHashValue.vue'
|
import AddHashValue from '@/components/new_value/AddHashValue.vue'
|
||||||
import AddZSetValue from '@/components/new_value/AddZSetValue.vue'
|
import AddZSetValue from '@/components/new_value/AddZSetValue.vue'
|
||||||
|
@ -78,7 +77,6 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const message = useMessage()
|
|
||||||
const onAdd = async () => {
|
const onAdd = async () => {
|
||||||
try {
|
try {
|
||||||
const { server, db, key, type } = newForm
|
const { server, db, key, type } = newForm
|
||||||
|
@ -100,9 +98,9 @@ const onAdd = async () => {
|
||||||
if (newForm.reload) {
|
if (newForm.reload) {
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
}
|
}
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -114,9 +112,9 @@ const onAdd = async () => {
|
||||||
if (newForm.reload) {
|
if (newForm.reload) {
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
}
|
}
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -128,9 +126,9 @@ const onAdd = async () => {
|
||||||
if (newForm.reload) {
|
if (newForm.reload) {
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
}
|
}
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -142,9 +140,9 @@ const onAdd = async () => {
|
||||||
if (newForm.reload) {
|
if (newForm.reload) {
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
}
|
}
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
@ -163,9 +161,9 @@ const onAdd = async () => {
|
||||||
if (newForm.reload) {
|
if (newForm.reload) {
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
}
|
}
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +171,7 @@ const onAdd = async () => {
|
||||||
}
|
}
|
||||||
dialogStore.closeAddFieldsDialog()
|
dialogStore.closeAddFieldsDialog()
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { computed, nextTick, ref, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { TestConnection } from 'wailsjs/go/services/connectionService.js'
|
import { TestConnection } from 'wailsjs/go/services/connectionService.js'
|
||||||
import useDialog from 'stores/dialog'
|
import useDialog from 'stores/dialog'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import Close from '@/components/icons/Close.vue'
|
import Close from '@/components/icons/Close.vue'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
|
|
||||||
|
@ -14,7 +13,6 @@ import useConnectionStore from 'stores/connections.js'
|
||||||
|
|
||||||
const dialogStore = useDialog()
|
const dialogStore = useDialog()
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const message = useMessage()
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
|
|
||||||
const editName = ref('')
|
const editName = ref('')
|
||||||
|
@ -74,11 +72,11 @@ const onSaveConnection = async () => {
|
||||||
// store new connection
|
// store new connection
|
||||||
const { success, msg } = await connectionStore.saveConnection(editName.value, generalForm.value)
|
const { success, msg } = await connectionStore.saveConnection(editName.value, generalForm.value)
|
||||||
if (!success) {
|
if (!success) {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, watch } from 'vue'
|
import { reactive, watch } from 'vue'
|
||||||
import useDialog from 'stores/dialog'
|
import useDialog from 'stores/dialog'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { isEmpty, size } from 'lodash'
|
import { isEmpty, size } from 'lodash'
|
||||||
|
@ -49,16 +48,15 @@ const resetAffected = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const onConfirmDelete = async () => {
|
const onConfirmDelete = async () => {
|
||||||
try {
|
try {
|
||||||
const { server, db, key } = deleteForm
|
const { server, db, key } = deleteForm
|
||||||
const success = await connectionStore.deleteKeyPrefix(server, db, key)
|
const success = await connectionStore.deleteKeyPrefix(server, db, key)
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
dialogStore.closeDeleteKeyDialog()
|
dialogStore.closeDeleteKeyDialog()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, reactive, ref, watch } from 'vue'
|
import { computed, reactive, ref, watch } from 'vue'
|
||||||
import useDialog from 'stores/dialog'
|
import useDialog from 'stores/dialog'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { isEmpty } from 'lodash'
|
import { isEmpty } from 'lodash'
|
||||||
|
@ -29,27 +28,26 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const onConfirm = async () => {
|
const onConfirm = async () => {
|
||||||
try {
|
try {
|
||||||
const { name } = groupForm
|
const { name } = groupForm
|
||||||
if (isRenameMode.value) {
|
if (isRenameMode.value) {
|
||||||
const { success, msg } = await connectionStore.renameGroup(editGroup.value, name)
|
const { success, msg } = await connectionStore.renameGroup(editGroup.value, name)
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const { success, msg } = await connectionStore.createGroup(name)
|
const { success, msg } = await connectionStore.createGroup(name)
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import useConnectionStore from 'stores/connections.js'
|
||||||
import { NSpace } from 'naive-ui'
|
import { NSpace } from 'naive-ui'
|
||||||
import useTabStore from 'stores/tab.js'
|
import useTabStore from 'stores/tab.js'
|
||||||
import NewStreamValue from '@/components/new_value/NewStreamValue.vue'
|
import NewStreamValue from '@/components/new_value/NewStreamValue.vue'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const newForm = reactive({
|
const newForm = reactive({
|
||||||
|
@ -103,13 +102,12 @@ const renderTypeLabel = (option) => {
|
||||||
|
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const tabStore = useTabStore()
|
const tabStore = useTabStore()
|
||||||
const message = useMessage()
|
|
||||||
const onAdd = async () => {
|
const onAdd = async () => {
|
||||||
await newFormRef.value?.validate().catch((err) => {
|
await newFormRef.value?.validate().catch((err) => {
|
||||||
message.error(err.message)
|
$message.error(err.message)
|
||||||
})
|
})
|
||||||
if (subFormRef.value?.validate && !subFormRef.value?.validate()) {
|
if (subFormRef.value?.validate && !subFormRef.value?.validate()) {
|
||||||
message.error(i18n.t('spec_field_required', { key: i18n.t('element') }))
|
$message.error(i18n.t('spec_field_required', { key: i18n.t('element') }))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -124,7 +122,7 @@ const onAdd = async () => {
|
||||||
tabStore.setSelectedKeys(server, nodeKey)
|
tabStore.setSelectedKeys(server, nodeKey)
|
||||||
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
connectionStore.loadKeyValue(server, db, key).then(() => {})
|
||||||
} else if (!isEmpty(msg)) {
|
} else if (!isEmpty(msg)) {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
dialogStore.closeNewKeyDialog()
|
dialogStore.closeNewKeyDialog()
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
|
@ -3,7 +3,6 @@ import { ref, watch } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useDialog from 'stores/dialog'
|
import useDialog from 'stores/dialog'
|
||||||
import usePreferencesStore from 'stores/preferences.js'
|
import usePreferencesStore from 'stores/preferences.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const prefStore = usePreferencesStore()
|
const prefStore = usePreferencesStore()
|
||||||
|
|
||||||
|
@ -11,7 +10,6 @@ const prevPreferences = ref({})
|
||||||
const tab = ref('general')
|
const tab = ref('general')
|
||||||
const dialogStore = useDialog()
|
const dialogStore = useDialog()
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
|
||||||
const initPreferences = async () => {
|
const initPreferences = async () => {
|
||||||
|
@ -41,7 +39,7 @@ watch(
|
||||||
const onSavePreferences = async () => {
|
const onSavePreferences = async () => {
|
||||||
const success = await prefStore.savePreferences()
|
const success = await prefStore.savePreferences()
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
dialogStore.closePreferencesDialog()
|
dialogStore.closePreferencesDialog()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { reactive, watch } from 'vue'
|
import { reactive, watch } from 'vue'
|
||||||
import useDialog from 'stores/dialog'
|
import useDialog from 'stores/dialog'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
|
|
||||||
|
@ -28,19 +27,18 @@ watch(
|
||||||
)
|
)
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const message = useMessage()
|
|
||||||
const onRename = async () => {
|
const onRename = async () => {
|
||||||
try {
|
try {
|
||||||
const { server, db, key, newKey } = renameForm
|
const { server, db, key, newKey } = renameForm
|
||||||
const { success, msg } = await connectionStore.renameKey(server, db, key, newKey)
|
const { success, msg } = await connectionStore.renameKey(server, db, key, newKey)
|
||||||
if (success) {
|
if (success) {
|
||||||
await connectionStore.loadKeyValue(server, db, newKey)
|
await connectionStore.loadKeyValue(server, db, newKey)
|
||||||
message.success(i18n.t('handle_succ'))
|
$message.success(i18n.t('handle_succ'))
|
||||||
} else {
|
} else {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
}
|
}
|
||||||
dialogStore.closeRenameKeyDialog()
|
dialogStore.closeRenameKeyDialog()
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,6 @@ import Connect from '@/components/icons/Connect.vue'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import ToggleServer from '@/components/icons/ToggleServer.vue'
|
import ToggleServer from '@/components/icons/ToggleServer.vue'
|
||||||
import Unlink from '@/components/icons/Unlink.vue'
|
import Unlink from '@/components/icons/Unlink.vue'
|
||||||
import Filter from '@/components/icons/Filter.vue'
|
import Filter from '@/components/icons/Filter.vue'
|
||||||
|
@ -23,7 +22,6 @@ import Close from '@/components/icons/Close.vue'
|
||||||
import { typesBgColor, typesColor } from '@/consts/support_redis_type.js'
|
import { typesBgColor, typesColor } from '@/consts/support_redis_type.js'
|
||||||
import useTabStore from 'stores/tab.js'
|
import useTabStore from 'stores/tab.js'
|
||||||
import IconButton from '@/components/common/IconButton.vue'
|
import IconButton from '@/components/common/IconButton.vue'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
server: String,
|
server: String,
|
||||||
|
@ -219,7 +217,6 @@ const expandKey = (key) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
const handleSelectContextMenu = (key) => {
|
const handleSelectContextMenu = (key) => {
|
||||||
contextMenuParam.show = false
|
contextMenuParam.show = false
|
||||||
const selectedKey = get(selectedKeys.value, 0)
|
const selectedKey = get(selectedKeys.value, 0)
|
||||||
|
@ -233,7 +230,7 @@ const handleSelectContextMenu = (key) => {
|
||||||
expandedKeys.value = [props.server]
|
expandedKeys.value = [props.server]
|
||||||
tabStore.setSelectedKeys(props.server)
|
tabStore.setSelectedKeys(props.server)
|
||||||
connectionStore.openConnection(props.server, true).then(() => {
|
connectionStore.openConnection(props.server, true).then(() => {
|
||||||
message.success(i18n.t('reload_succ'))
|
$message.success(i18n.t('reload_succ'))
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
case 'server_close':
|
case 'server_close':
|
||||||
|
@ -267,10 +264,10 @@ const handleSelectContextMenu = (key) => {
|
||||||
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
|
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
|
||||||
break
|
break
|
||||||
case 'value_remove':
|
case 'value_remove':
|
||||||
confirmDialog.warning(i18n.t('remove_tip', { name: redisKey }), () => {
|
$dialog.warning(i18n.t('remove_tip', { name: redisKey }), () => {
|
||||||
connectionStore.deleteKey(props.server, db, redisKey).then((success) => {
|
connectionStore.deleteKey(props.server, db, redisKey).then((success) => {
|
||||||
if (success) {
|
if (success) {
|
||||||
message.success(i18n.t('delete_key_succ', { key: redisKey }))
|
$message.success(i18n.t('delete_key_succ', { key: redisKey }))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -280,11 +277,11 @@ const handleSelectContextMenu = (key) => {
|
||||||
ClipboardSetText(redisKey)
|
ClipboardSetText(redisKey)
|
||||||
.then((succ) => {
|
.then((succ) => {
|
||||||
if (succ) {
|
if (succ) {
|
||||||
message.success(i18n.t('copy_succ'))
|
$message.success(i18n.t('copy_succ'))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
@ -295,7 +292,6 @@ defineExpose({
|
||||||
handleSelectContextMenu,
|
handleSelectContextMenu,
|
||||||
})
|
})
|
||||||
|
|
||||||
const message = useMessage()
|
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const onUpdateExpanded = (value, option, meta) => {
|
const onUpdateExpanded = (value, option, meta) => {
|
||||||
expandedKeys.value = value
|
expandedKeys.value = value
|
||||||
|
@ -566,7 +562,7 @@ const onLoadTree = async (node) => {
|
||||||
try {
|
try {
|
||||||
await connectionStore.openDatabase(props.server, node.db)
|
await connectionStore.openDatabase(props.server, node.db)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
node.isLeaf = undefined
|
node.isLeaf = undefined
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|
|
@ -15,8 +15,6 @@ import Connect from '@/components/icons/Connect.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useTabStore from 'stores/tab.js'
|
import useTabStore from 'stores/tab.js'
|
||||||
import Edit from '@/components/icons/Edit.vue'
|
import Edit from '@/components/icons/Edit.vue'
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
|
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
|
@ -24,7 +22,6 @@ const openingConnection = ref(false)
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const tabStore = useTabStore()
|
const tabStore = useTabStore()
|
||||||
const dialogStore = useDialogStore()
|
const dialogStore = useDialogStore()
|
||||||
const message = useMessage()
|
|
||||||
|
|
||||||
const expandedKeys = ref([])
|
const expandedKeys = ref([])
|
||||||
const selectedKeys = ref([])
|
const selectedKeys = ref([])
|
||||||
|
@ -187,7 +184,7 @@ const openConnection = async (name) => {
|
||||||
server: name,
|
server: name,
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
message.error(e.message)
|
$message.error(e.message)
|
||||||
// node.isLeaf = undefined
|
// node.isLeaf = undefined
|
||||||
} finally {
|
} finally {
|
||||||
openingConnection.value = false
|
openingConnection.value = false
|
||||||
|
@ -196,21 +193,20 @@ const openConnection = async (name) => {
|
||||||
|
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const removeConnection = (name) => {
|
const removeConnection = (name) => {
|
||||||
confirmDialog.warning(i18n.t('remove_tip', { type: i18n.t('conn_name'), name }), async () => {
|
$dialog.warning(i18n.t('remove_tip', { type: i18n.t('conn_name'), name }), async () => {
|
||||||
connectionStore.deleteConnection(name).then(({ success, msg }) => {
|
connectionStore.deleteConnection(name).then(({ success, msg }) => {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
const removeGroup = async (name) => {
|
const removeGroup = async (name) => {
|
||||||
confirmDialog.warning(i18n.t('remove_tip', { type: i18n.t('conn_group'), name }), async () => {
|
$dialog.warning(i18n.t('remove_tip', { type: i18n.t('conn_group'), name }), async () => {
|
||||||
connectionStore.deleteGroup(name).then(({ success, msg }) => {
|
connectionStore.deleteGroup(name).then(({ success, msg }) => {
|
||||||
if (!success) {
|
if (!success) {
|
||||||
message.error(msg)
|
$message.error(msg)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -268,7 +264,7 @@ const handleSelectContextMenu = (key) => {
|
||||||
case 'server_edit':
|
case 'server_edit':
|
||||||
// ask for close relevant connections before edit
|
// ask for close relevant connections before edit
|
||||||
if (connectionStore.isConnected(name)) {
|
if (connectionStore.isConnected(name)) {
|
||||||
confirmDialog.warning(i18n.t('edit_close_confirm'), () => {
|
$dialog.warning(i18n.t('edit_close_confirm'), () => {
|
||||||
connectionStore.closeConnection(name)
|
connectionStore.closeConnection(name)
|
||||||
dialogStore.openEditDialog(name)
|
dialogStore.openEditDialog(name)
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,11 +6,21 @@ import dayjs from 'dayjs'
|
||||||
import duration from 'dayjs/plugin/duration'
|
import duration from 'dayjs/plugin/duration'
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime'
|
import relativeTime from 'dayjs/plugin/relativeTime'
|
||||||
import { i18n } from '@/utils/i18n.js'
|
import { i18n } from '@/utils/i18n.js'
|
||||||
|
import { setupDiscreteApi } from '@/utils/discrete.js'
|
||||||
|
import usePreferencesStore from 'stores/preferences.js'
|
||||||
|
|
||||||
dayjs.extend(duration)
|
dayjs.extend(duration)
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
|
async function setupApp() {
|
||||||
const app = createApp(App)
|
const app = createApp(App)
|
||||||
app.use(i18n)
|
app.use(i18n)
|
||||||
app.use(createPinia())
|
app.use(createPinia())
|
||||||
|
|
||||||
|
const prefStore = usePreferencesStore()
|
||||||
|
await prefStore.loadPreferences()
|
||||||
|
await setupDiscreteApi()
|
||||||
app.mount('#app')
|
app.mount('#app')
|
||||||
|
}
|
||||||
|
|
||||||
|
setupApp()
|
||||||
|
|
|
@ -7,11 +7,11 @@ import {
|
||||||
RestorePreferences,
|
RestorePreferences,
|
||||||
SetPreferences,
|
SetPreferences,
|
||||||
} from 'wailsjs/go/services/preferencesService.js'
|
} from 'wailsjs/go/services/preferencesService.js'
|
||||||
import { useMessage } from '@/utils/message.js'
|
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js'
|
import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js'
|
||||||
import { i18nGlobal } from '@/utils/i18n.js'
|
import { i18nGlobal } from '@/utils/i18n.js'
|
||||||
|
import { useOsTheme } from 'naive-ui'
|
||||||
|
|
||||||
|
const osTheme = useOsTheme()
|
||||||
const usePreferencesStore = defineStore('preferences', {
|
const usePreferencesStore = defineStore('preferences', {
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} FontItem
|
* @typedef {Object} FontItem
|
||||||
|
@ -132,6 +132,18 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
return lang || 'en'
|
return lang || 'en'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isDark() {
|
||||||
|
const th = get(this.general, 'theme', 'auto')
|
||||||
|
if (th === 'auto') {
|
||||||
|
if (osTheme.value === 'dark') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
} else if (th === 'dark') {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
|
||||||
autoCheckUpdate() {
|
autoCheckUpdate() {
|
||||||
return get(this.general, 'checkUpdate', false)
|
return get(this.general, 'checkUpdate', false)
|
||||||
},
|
},
|
||||||
|
@ -222,11 +234,9 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
},
|
},
|
||||||
|
|
||||||
async checkForUpdate(manual = false) {
|
async checkForUpdate(manual = false) {
|
||||||
const message = useMessage()
|
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
let msgRef = null
|
let msgRef = null
|
||||||
if (manual) {
|
if (manual) {
|
||||||
msgRef = message.loading('Retrieving for new version', { duration: 0 })
|
msgRef = $message.loading('Retrieving for new version', { duration: 0 })
|
||||||
}
|
}
|
||||||
let respObj = null
|
let respObj = null
|
||||||
try {
|
try {
|
||||||
|
@ -243,12 +253,12 @@ const usePreferencesStore = defineStore('preferences', {
|
||||||
|
|
||||||
// TODO: check current version is older then remote
|
// TODO: check current version is older then remote
|
||||||
if (respObj != null && !isEmpty(respObj['html_url'])) {
|
if (respObj != null && !isEmpty(respObj['html_url'])) {
|
||||||
confirmDialog.warning(i18nGlobal.t('new_version_tip'), () => {
|
$dialog.warning(i18nGlobal.t('new_version_tip'), () => {
|
||||||
BrowserOpenURL(respObj['html_url'])
|
BrowserOpenURL(respObj['html_url'])
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (manual) {
|
if (manual) {
|
||||||
message.info(i18nGlobal.t('no_update'))
|
$message.info(i18nGlobal.t('no_update'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,28 +0,0 @@
|
||||||
import { createDiscreteApi } from 'naive-ui'
|
|
||||||
import { i18nGlobal } from '@/utils/i18n.js'
|
|
||||||
import { themeOverrides } from '@/utils/theme.js'
|
|
||||||
|
|
||||||
const { dialog } = createDiscreteApi(['dialog'], {
|
|
||||||
configProviderProps: {
|
|
||||||
themeOverrides,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export function useConfirmDialog() {
|
|
||||||
return {
|
|
||||||
warning: (content, onConfirm) => {
|
|
||||||
dialog.warning({
|
|
||||||
title: i18nGlobal.t('warning'),
|
|
||||||
content: content,
|
|
||||||
closable: false,
|
|
||||||
autoFocus: false,
|
|
||||||
transformOrigin: 'center',
|
|
||||||
positiveText: i18nGlobal.t('confirm'),
|
|
||||||
negativeText: i18nGlobal.t('cancel'),
|
|
||||||
onPositiveClick: () => {
|
|
||||||
onConfirm && onConfirm()
|
|
||||||
},
|
|
||||||
})
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
import usePreferencesStore from 'stores/preferences.js'
|
||||||
|
import { createDiscreteApi, darkTheme } from 'naive-ui'
|
||||||
|
import { themeOverrides } from '@/utils/theme.js'
|
||||||
|
import { i18nGlobal } from '@/utils/i18n.js'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
function setupMessage(message) {
|
||||||
|
return {
|
||||||
|
error: (content, option = null) => {
|
||||||
|
return message.error(content, option)
|
||||||
|
},
|
||||||
|
info: (content, option = null) => {
|
||||||
|
return message.info(content, option)
|
||||||
|
},
|
||||||
|
loading: (content, option = null) => {
|
||||||
|
return message.loading(content, option)
|
||||||
|
},
|
||||||
|
success: (content, option = null) => {
|
||||||
|
return message.success(content, option)
|
||||||
|
},
|
||||||
|
warning: (content, option = null) => {
|
||||||
|
return message.warning(content, option)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupDialog(dialog) {
|
||||||
|
return {
|
||||||
|
warning: (content, onConfirm) => {
|
||||||
|
return dialog.warning({
|
||||||
|
title: i18nGlobal.t('warning'),
|
||||||
|
content: content,
|
||||||
|
closable: false,
|
||||||
|
autoFocus: false,
|
||||||
|
transformOrigin: 'center',
|
||||||
|
positiveText: i18nGlobal.t('confirm'),
|
||||||
|
negativeText: i18nGlobal.t('cancel'),
|
||||||
|
onPositiveClick: () => {
|
||||||
|
onConfirm && onConfirm()
|
||||||
|
},
|
||||||
|
})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* setup discrete api and bind global component (like dialog, message, alert) to window
|
||||||
|
* @return {Promise<void>}
|
||||||
|
*/
|
||||||
|
export async function setupDiscreteApi() {
|
||||||
|
const prefStore = usePreferencesStore()
|
||||||
|
const configProviderProps = computed(() => ({
|
||||||
|
theme: prefStore.isDark ? darkTheme : undefined,
|
||||||
|
themeOverrides,
|
||||||
|
}))
|
||||||
|
const { message, dialog } = createDiscreteApi(['message', 'dialog'], { configProviderProps })
|
||||||
|
|
||||||
|
window.$message = setupMessage(message)
|
||||||
|
window.$dialog = setupDialog(dialog)
|
||||||
|
}
|
|
@ -1,28 +0,0 @@
|
||||||
import { createDiscreteApi } from 'naive-ui'
|
|
||||||
import { themeOverrides } from '@/utils/theme.js'
|
|
||||||
|
|
||||||
const { message } = createDiscreteApi(['message'], {
|
|
||||||
configProviderProps: {
|
|
||||||
themeOverrides,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
export function useMessage() {
|
|
||||||
return {
|
|
||||||
error: (content, option = null) => {
|
|
||||||
return message.error(content, option)
|
|
||||||
},
|
|
||||||
info: (content, option = null) => {
|
|
||||||
return message.info(content, option)
|
|
||||||
},
|
|
||||||
loading: (content, option = null) => {
|
|
||||||
return message.loading(content, option)
|
|
||||||
},
|
|
||||||
success: (content, option = null) => {
|
|
||||||
return message.success(content, option)
|
|
||||||
},
|
|
||||||
warning: (content, option = null) => {
|
|
||||||
return message.warning(content, option)
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue