refactor: use discrete api for message
This commit is contained in:
parent
ae1d4f5215
commit
5a9fb00474
|
@ -88,7 +88,6 @@ const theme = computed(() => {
|
||||||
class="fill-height"
|
class="fill-height"
|
||||||
>
|
>
|
||||||
<n-global-style />
|
<n-global-style />
|
||||||
<n-message-provider>
|
|
||||||
<n-dialog-provider>
|
<n-dialog-provider>
|
||||||
<n-spin v-show="initializing" :theme-overrides="{ opacitySpinning: 0 }">
|
<n-spin v-show="initializing" :theme-overrides="{ opacitySpinning: 0 }">
|
||||||
<div id="launch-container" />
|
<div id="launch-container" />
|
||||||
|
@ -106,7 +105,6 @@ const theme = computed(() => {
|
||||||
<set-ttl-dialog />
|
<set-ttl-dialog />
|
||||||
<preferences-dialog />
|
<preferences-dialog />
|
||||||
</n-dialog-provider>
|
</n-dialog-provider>
|
||||||
</n-message-provider>
|
|
||||||
</n-config-provider>
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,12 @@ import Refresh from '@/components/icons/Refresh.vue'
|
||||||
import Timer from '@/components/icons/Timer.vue'
|
import Timer from '@/components/icons/Timer.vue'
|
||||||
import RedisTypeTag from '@/components/common/RedisTypeTag.vue'
|
import RedisTypeTag from '@/components/common/RedisTypeTag.vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import { useMessage } from 'naive-ui'
|
|
||||||
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 { 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,
|
||||||
|
|
|
@ -3,14 +3,15 @@ import { computed, h, reactive, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import { NButton, NCode, NIcon, NInput, useMessage } from 'naive-ui'
|
import { NButton, NCode, NIcon, NInput } from 'naive-ui'
|
||||||
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 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,
|
||||||
|
@ -197,7 +198,6 @@ const tableData = computed(() => {
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
const message = useMessage()
|
|
||||||
const onAddRow = () => {
|
const onAddRow = () => {
|
||||||
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.HASH)
|
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.HASH)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,16 @@ import { computed, h, reactive, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import { NButton, NCode, NIcon, NInput, useMessage } from 'naive-ui'
|
import { NButton, NCode, NIcon, NInput } from 'naive-ui'
|
||||||
import { size } from 'lodash'
|
import { size } from 'lodash'
|
||||||
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 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,
|
||||||
|
@ -151,7 +152,7 @@ const tableData = computed(() => {
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
const message = useMessage()
|
|
||||||
const onAddValue = (value) => {
|
const onAddValue = (value) => {
|
||||||
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.LIST)
|
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.LIST)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,14 +3,16 @@ import { computed, h, reactive, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import { NButton, NCode, NIcon, NInput, useMessage } from 'naive-ui'
|
import { NButton, NCode, NIcon, NInput } from 'naive-ui'
|
||||||
import { size } from 'lodash'
|
import { size } from 'lodash'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
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,
|
||||||
|
@ -147,7 +149,6 @@ const tableData = computed(() => {
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
|
|
||||||
const message = useMessage()
|
|
||||||
const onAddValue = (value) => {
|
const onAddValue = (value) => {
|
||||||
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.SET)
|
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.SET)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,16 @@ import { computed, h, reactive, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import { NButton, NCode, NIcon, NInput, useMessage } from 'naive-ui'
|
import { NButton, NCode, NIcon, NInput } from 'naive-ui'
|
||||||
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 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,
|
||||||
|
@ -120,7 +121,7 @@ const tableData = computed(() => {
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
const message = useMessage()
|
|
||||||
const onAddRow = () => {
|
const onAddRow = () => {
|
||||||
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.STREAM)
|
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.STREAM)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import Copy from '@/components/icons/Copy.vue'
|
import Copy from '@/components/icons/Copy.vue'
|
||||||
import Save from '@/components/icons/Save.vue'
|
import Save from '@/components/icons/Save.vue'
|
||||||
import { useMessage, useThemeVars } from 'naive-ui'
|
import { useThemeVars } from 'naive-ui'
|
||||||
import { types } from '@/consts/value_view_type.js'
|
import { types } from '@/consts/value_view_type.js'
|
||||||
import Close from '@/components/icons/Close.vue'
|
import Close from '@/components/icons/Close.vue'
|
||||||
import Edit from '@/components/icons/Edit.vue'
|
import Edit from '@/components/icons/Edit.vue'
|
||||||
|
@ -13,7 +13,10 @@ 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 message = useMessage()
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -106,8 +109,6 @@ const viewLanguage = computed(() => {
|
||||||
return 'plaintext'
|
return 'plaintext'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const i18n = useI18n()
|
|
||||||
const message = useMessage()
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy value
|
* Copy value
|
||||||
|
|
|
@ -3,15 +3,16 @@ import { computed, h, reactive, ref } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import ContentToolbar from './ContentToolbar.vue'
|
import ContentToolbar from './ContentToolbar.vue'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import { NButton, NCode, NIcon, NInput, NInputNumber, useMessage } from 'naive-ui'
|
import { NButton, NCode, NIcon, NInput, NInputNumber } from 'naive-ui'
|
||||||
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 { 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,
|
||||||
|
@ -220,7 +221,7 @@ const tableData = computed(() => {
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
})
|
})
|
||||||
const message = useMessage()
|
|
||||||
const onAddRow = () => {
|
const onAddRow = () => {
|
||||||
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.ZSET)
|
dialogStore.openAddFieldsDialog(props.name, props.db, props.keyPath, types.ZSET)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ 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 'naive-ui'
|
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'
|
||||||
|
|
|
@ -4,7 +4,7 @@ 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 'naive-ui'
|
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'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<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 'naive-ui'
|
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'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<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 'naive-ui'
|
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'
|
||||||
|
|
|
@ -10,9 +10,10 @@ import NewZSetValue from '@/components/new_value/NewZSetValue.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 useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { NSpace, useMessage } 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({
|
||||||
|
|
|
@ -3,7 +3,7 @@ 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 'naive-ui'
|
import { useMessage } from '@/utils/message.js'
|
||||||
|
|
||||||
const prefStore = usePreferencesStore()
|
const prefStore = usePreferencesStore()
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<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 'naive-ui'
|
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'
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useMessage, useThemeVars } from 'naive-ui'
|
import { useThemeVars } from 'naive-ui'
|
||||||
import AddLink from '@/components/icons/AddLink.vue'
|
import AddLink from '@/components/icons/AddLink.vue'
|
||||||
import BrowserTree from './BrowserTree.vue'
|
import BrowserTree from './BrowserTree.vue'
|
||||||
import IconButton from '@/components/common/IconButton.vue'
|
import IconButton from '@/components/common/IconButton.vue'
|
||||||
|
@ -9,7 +9,6 @@ import { get } from 'lodash'
|
||||||
import Delete from '@/components/icons/Delete.vue'
|
import Delete from '@/components/icons/Delete.vue'
|
||||||
import Refresh from '@/components/icons/Refresh.vue'
|
import Refresh from '@/components/icons/Refresh.vue'
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { types } from '@/consts/support_redis_type.js'
|
import { types } from '@/consts/support_redis_type.js'
|
||||||
|
@ -36,7 +35,6 @@ const onNewKey = () => {
|
||||||
|
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
const connectionStore = useConnectionStore()
|
const connectionStore = useConnectionStore()
|
||||||
const message = useMessage()
|
|
||||||
const onDeleteKey = () => {
|
const onDeleteKey = () => {
|
||||||
browserTreeRef.value?.handleSelectContextMenu('value_remove')
|
browserTreeRef.value?.handleSelectContextMenu('value_remove')
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, h, nextTick, onMounted, reactive, ref } from 'vue'
|
import { computed, h, nextTick, onMounted, reactive, ref } from 'vue'
|
||||||
import { ConnectionType } from '@/consts/connection_type.js'
|
import { ConnectionType } from '@/consts/connection_type.js'
|
||||||
import { NIcon, NSpace, NTag, useDialog, useMessage } from 'naive-ui'
|
import { NIcon, NSpace, NTag, useDialog } from 'naive-ui'
|
||||||
import Key from '@/components/icons/Key.vue'
|
import Key from '@/components/icons/Key.vue'
|
||||||
import ToggleDb from '@/components/icons/ToggleDb.vue'
|
import ToggleDb from '@/components/icons/ToggleDb.vue'
|
||||||
import { find, get, includes, indexOf, isEmpty, remove } from 'lodash'
|
import { find, get, includes, indexOf, isEmpty, remove } from 'lodash'
|
||||||
|
@ -23,6 +23,7 @@ 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,
|
||||||
|
@ -218,6 +219,82 @@ const expandKey = (key) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confirmDialog = useConfirmDialog()
|
||||||
|
const handleSelectContextMenu = (key) => {
|
||||||
|
contextMenuParam.show = false
|
||||||
|
const selectedKey = get(selectedKeys.value, 0)
|
||||||
|
if (selectedKey == null) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const node = connectionStore.getNode(selectedKey)
|
||||||
|
const { db, key: nodeKey, redisKey } = node || {}
|
||||||
|
switch (key) {
|
||||||
|
case 'server_reload':
|
||||||
|
expandedKeys.value = [props.server]
|
||||||
|
tabStore.setSelectedKeys(props.server)
|
||||||
|
connectionStore.openConnection(props.server, true).then(() => {
|
||||||
|
message.success(i18n.t('reload_succ'))
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'server_close':
|
||||||
|
connectionStore.closeConnection(props.server)
|
||||||
|
break
|
||||||
|
case 'db_open':
|
||||||
|
nextTick().then(() => expandKey(nodeKey))
|
||||||
|
break
|
||||||
|
case 'db_reload':
|
||||||
|
connectionStore.reopenDatabase(props.server, db)
|
||||||
|
break
|
||||||
|
case 'db_close':
|
||||||
|
remove(expandedKeys.value, (k) => k === `${props.server}/db${db}`)
|
||||||
|
connectionStore.closeDatabase(props.server, db)
|
||||||
|
break
|
||||||
|
case 'db_newkey':
|
||||||
|
case 'key_newkey':
|
||||||
|
dialogStore.openNewKeyDialog(redisKey, props.server, db)
|
||||||
|
break
|
||||||
|
case 'db_filter':
|
||||||
|
const { match: pattern, type } = connectionStore.getKeyFilter(props.server, db)
|
||||||
|
dialogStore.openKeyFilterDialog(props.server, db, pattern, type)
|
||||||
|
break
|
||||||
|
case 'key_reload':
|
||||||
|
connectionStore.loadKeys(props.server, db, redisKey)
|
||||||
|
break
|
||||||
|
case 'value_reload':
|
||||||
|
connectionStore.loadKeyValue(props.server, db, redisKey)
|
||||||
|
break
|
||||||
|
case 'key_remove':
|
||||||
|
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
|
||||||
|
break
|
||||||
|
case 'value_remove':
|
||||||
|
confirmDialog.warning(i18n.t('remove_tip', { name: redisKey }), () => {
|
||||||
|
connectionStore.deleteKey(props.server, db, redisKey).then((success) => {
|
||||||
|
if (success) {
|
||||||
|
message.success(i18n.t('delete_key_succ', { key: redisKey }))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
break
|
||||||
|
case 'key_copy':
|
||||||
|
case 'value_copy':
|
||||||
|
ClipboardSetText(redisKey)
|
||||||
|
.then((succ) => {
|
||||||
|
if (succ) {
|
||||||
|
message.success(i18n.t('copy_succ'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
message.error(e.message)
|
||||||
|
})
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
console.warn('TODO: handle context menu:' + key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
handleSelectContextMenu,
|
||||||
|
})
|
||||||
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const dialog = useDialog()
|
const dialog = useDialog()
|
||||||
const onUpdateExpanded = (value, option, meta) => {
|
const onUpdateExpanded = (value, option, meta) => {
|
||||||
|
@ -505,81 +582,6 @@ const onLoadTree = async (node) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDialog = useConfirmDialog()
|
|
||||||
defineExpose({
|
|
||||||
handleSelectContextMenu: (key) => {
|
|
||||||
contextMenuParam.show = false
|
|
||||||
const selectedKey = get(selectedKeys.value, 0)
|
|
||||||
if (selectedKey == null) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const node = connectionStore.getNode(selectedKey)
|
|
||||||
const { db, key: nodeKey, redisKey } = node || {}
|
|
||||||
switch (key) {
|
|
||||||
case 'server_reload':
|
|
||||||
expandedKeys.value = [props.server]
|
|
||||||
tabStore.setSelectedKeys(props.server)
|
|
||||||
connectionStore.openConnection(props.server, true).then(() => {
|
|
||||||
message.success(i18n.t('reload_succ'))
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'server_close':
|
|
||||||
connectionStore.closeConnection(props.server)
|
|
||||||
break
|
|
||||||
case 'db_open':
|
|
||||||
nextTick().then(() => expandKey(nodeKey))
|
|
||||||
break
|
|
||||||
case 'db_reload':
|
|
||||||
connectionStore.reopenDatabase(props.server, db)
|
|
||||||
break
|
|
||||||
case 'db_close':
|
|
||||||
remove(expandedKeys.value, (k) => k === `${props.server}/db${db}`)
|
|
||||||
connectionStore.closeDatabase(props.server, db)
|
|
||||||
break
|
|
||||||
case 'db_newkey':
|
|
||||||
case 'key_newkey':
|
|
||||||
dialogStore.openNewKeyDialog(redisKey, props.server, db)
|
|
||||||
break
|
|
||||||
case 'db_filter':
|
|
||||||
const { match: pattern, type } = connectionStore.getKeyFilter(props.server, db)
|
|
||||||
dialogStore.openKeyFilterDialog(props.server, db, pattern, type)
|
|
||||||
break
|
|
||||||
case 'key_reload':
|
|
||||||
connectionStore.loadKeys(props.server, db, redisKey)
|
|
||||||
break
|
|
||||||
case 'value_reload':
|
|
||||||
connectionStore.loadKeyValue(props.server, db, redisKey)
|
|
||||||
break
|
|
||||||
case 'key_remove':
|
|
||||||
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
|
|
||||||
break
|
|
||||||
case 'value_remove':
|
|
||||||
confirmDialog.warning(i18n.t('remove_tip', { name: redisKey }), () => {
|
|
||||||
connectionStore.deleteKey(props.server, db, redisKey).then((success) => {
|
|
||||||
if (success) {
|
|
||||||
message.success(i18n.t('delete_key_succ', { key: redisKey }))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
break
|
|
||||||
case 'key_copy':
|
|
||||||
case 'value_copy':
|
|
||||||
ClipboardSetText(redisKey)
|
|
||||||
.then((succ) => {
|
|
||||||
if (succ) {
|
|
||||||
message.success(i18n.t('copy_succ'))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
message.error(e.message)
|
|
||||||
})
|
|
||||||
break
|
|
||||||
default:
|
|
||||||
console.warn('TODO: handle context menu:' + key)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleOutsideContextMenu = () => {
|
const handleOutsideContextMenu = () => {
|
||||||
contextMenuParam.show = false
|
contextMenuParam.show = false
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
import useDialogStore from 'stores/dialog.js'
|
import useDialogStore from 'stores/dialog.js'
|
||||||
import { h, nextTick, reactive, ref } from 'vue'
|
import { h, nextTick, reactive, ref } from 'vue'
|
||||||
import useConnectionStore from 'stores/connections.js'
|
import useConnectionStore from 'stores/connections.js'
|
||||||
import { NIcon, useDialog, useMessage, useThemeVars } from 'naive-ui'
|
import { NIcon, useDialog, useThemeVars } from 'naive-ui'
|
||||||
import { ConnectionType } from '@/consts/connection_type.js'
|
import { ConnectionType } from '@/consts/connection_type.js'
|
||||||
import ToggleFolder from '@/components/icons/ToggleFolder.vue'
|
import ToggleFolder from '@/components/icons/ToggleFolder.vue'
|
||||||
import ToggleServer from '@/components/icons/ToggleServer.vue'
|
import ToggleServer from '@/components/icons/ToggleServer.vue'
|
||||||
|
@ -16,6 +16,7 @@ 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 { useConfirmDialog } from '@/utils/confirm_dialog.js'
|
||||||
|
import { useMessage } from '@/utils/message.js'
|
||||||
|
|
||||||
const themeVars = useThemeVars()
|
const themeVars = useThemeVars()
|
||||||
const i18n = useI18n()
|
const i18n = useI18n()
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
import { createDiscreteApi } from 'naive-ui'
|
||||||
|
|
||||||
|
const { message } = createDiscreteApi(['message'])
|
||||||
|
|
||||||
|
export function useMessage() {
|
||||||
|
return {
|
||||||
|
error: (content, option = null) => {
|
||||||
|
message.error(content, option)
|
||||||
|
},
|
||||||
|
info: (content, option = null) => {
|
||||||
|
message.info(content, option)
|
||||||
|
},
|
||||||
|
loading: (content, option = null) => {
|
||||||
|
message.loading(content, option)
|
||||||
|
},
|
||||||
|
success: (content, option = null) => {
|
||||||
|
message.success(content, option)
|
||||||
|
},
|
||||||
|
warning: (content, option = null) => {
|
||||||
|
message.warning(content, option)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue