Compare commits

...

3 Commits

20 changed files with 156 additions and 62 deletions

View File

@ -198,8 +198,9 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
resp.Success = true resp.Success = true
resp.Data = map[string]any{ resp.Data = map[string]any{
"db": dbs, "db": dbs,
"view": selConn.KeyView, "view": selConn.KeyView,
"lastDB": selConn.LastDB,
} }
return return
} }

View File

@ -358,3 +358,20 @@ func (c *connectionService) DeleteGroup(name string, includeConn bool) (resp typ
resp.Success = true resp.Success = true
return return
} }
// SaveLastDB save last selected database index
func (c *connectionService) SaveLastDB(name string, db int) (resp types.JSResp) {
param := c.conns.GetConnection(name)
if param == nil {
resp.Msg = "no connection named \"" + name + "\""
return
}
param.LastDB = db
if err := c.conns.UpdateConnection(name, param.ConnectionConfig); err != nil {
resp.Msg = "save connection fail:" + err.Error()
return
}
resp.Success = true
return
}

View File

@ -5,6 +5,7 @@ type ConnectionCategory int
type ConnectionConfig struct { type ConnectionConfig struct {
Name string `json:"name" yaml:"name"` Name string `json:"name" yaml:"name"`
Group string `json:"group,omitempty" yaml:"-"` Group string `json:"group,omitempty" yaml:"-"`
LastDB int `json:"lastDB" yaml:"last_db"`
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"` Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
Port int `json:"port,omitempty" yaml:"port,omitempty"` Port int `json:"port,omitempty" yaml:"port,omitempty"`
Username string `json:"username,omitempty" yaml:"username,omitempty"` Username string `json:"username,omitempty" yaml:"username,omitempty"`

View File

@ -4,6 +4,7 @@ import Delete from '@/components/icons/Delete.vue'
import Edit from '@/components/icons/Edit.vue' import Edit from '@/components/icons/Edit.vue'
import Close from '@/components/icons/Close.vue' import Close from '@/components/icons/Close.vue'
import Save from '@/components/icons/Save.vue' import Save from '@/components/icons/Save.vue'
import Copy from '@/components/icons/Copy.vue'
const props = defineProps({ const props = defineProps({
bindKey: String, bindKey: String,
@ -11,7 +12,7 @@ const props = defineProps({
readonly: Boolean, readonly: Boolean,
}) })
const emit = defineEmits(['edit', 'delete', 'save', 'cancel']) const emit = defineEmits(['edit', 'delete', 'copy', 'save', 'cancel'])
</script> </script>
<template> <template>
@ -21,13 +22,14 @@ const emit = defineEmits(['edit', 'delete', 'save', 'cancel'])
<icon-button :icon="Close" @click="emit('cancel')" /> <icon-button :icon="Close" @click="emit('cancel')" />
</div> </div>
<div v-else class="flex-box-h edit-column-func"> <div v-else class="flex-box-h edit-column-func">
<icon-button v-if="!props.readonly" :icon="Edit" @click="emit('edit')" /> <icon-button :icon="Copy" :title="$t('interface.copy_value')" @click="emit('copy')" />
<icon-button v-if="!props.readonly" :icon="Edit" :title="$t('interface.edit_row')" @click="emit('edit')" />
<n-popconfirm <n-popconfirm
:negative-text="$t('common.cancel')" :negative-text="$t('common.cancel')"
:positive-text="$t('common.confirm')" :positive-text="$t('common.confirm')"
@positive-click="emit('delete')"> @positive-click="emit('delete')">
<template #trigger> <template #trigger>
<icon-button :icon="Delete" /> <icon-button :icon="Delete" :title="$t('interface.delete_row')" />
</template> </template>
{{ $t('dialogue.remove_tip', { name: props.bindKey }) }} {{ $t('dialogue.remove_tip', { name: props.bindKey }) }}
</n-popconfirm> </n-popconfirm>

View File

@ -65,7 +65,7 @@ const onCopyKey = () => {
ClipboardSetText(props.keyPath) ClipboardSetText(props.keyPath)
.then((succ) => { .then((succ) => {
if (succ) { if (succ) {
$message.success(i18n.t('dialogue.copy_succ')) $message.success(i18n.t('interface.copy_succ'))
} }
}) })
.catch((e) => { .catch((e) => {

View File

@ -19,6 +19,7 @@ import Edit from '@/components/icons/Edit.vue'
import FormatSelector from '@/components/content_value/FormatSelector.vue' import FormatSelector from '@/components/content_value/FormatSelector.vue'
import { decodeRedisKey } from '@/utils/key_convert.js' import { decodeRedisKey } from '@/utils/key_convert.js'
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue' import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
const i18n = useI18n() const i18n = useI18n()
const themeVars = useThemeVars() const themeVars = useThemeVars()
@ -163,7 +164,7 @@ const saveEdit = async (field, value, decode, format) => {
}) })
if (success) { if (success) {
currentEditRow.value = value currentEditRow.value = value
$message.success(i18n.t('dialogue.save_value_succ')) $message.success(i18n.t('interface.save_value_succ'))
} else { } else {
$message.error(msg) $message.error(msg)
} }
@ -183,7 +184,7 @@ const resetEdit = () => {
const actionColumn = { const actionColumn = {
key: 'action', key: 'action',
title: i18n.t('interface.action'), title: i18n.t('interface.action'),
width: 100, width: 120,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
@ -191,6 +192,16 @@ const actionColumn = {
return h(EditableTableColumn, { return h(EditableTableColumn, {
editing: false, editing: false,
bindKey: row.k, bindKey: row.k,
onCopy: async () => {
try {
const succ = await ClipboardSetText(row.v)
if (succ) {
$message.success(i18n.t('interface.copy_succ'))
}
} catch (e) {
$message.error(e.message)
}
},
onEdit: () => startEdit(index + 1, row.k, row.v), onEdit: () => startEdit(index + 1, row.k, row.v),
onDelete: async () => { onDelete: async () => {
try { try {

View File

@ -18,6 +18,7 @@ import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vu
import FormatSelector from '@/components/content_value/FormatSelector.vue' import FormatSelector from '@/components/content_value/FormatSelector.vue'
import Edit from '@/components/icons/Edit.vue' import Edit from '@/components/icons/Edit.vue'
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue' import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
const i18n = useI18n() const i18n = useI18n()
const themeVars = useThemeVars() const themeVars = useThemeVars()
@ -142,7 +143,7 @@ const saveEdit = async (pos, value, decode, format) => {
format, format,
}) })
if (success) { if (success) {
$message.success(i18n.t('dialogue.save_value_succ')) $message.success(i18n.t('interface.save_value_succ'))
} else { } else {
$message.error(msg) $message.error(msg)
} }
@ -159,7 +160,7 @@ const resetEdit = () => {
const actionColumn = { const actionColumn = {
key: 'action', key: 'action',
title: i18n.t('interface.action'), title: i18n.t('interface.action'),
width: 100, width: 120,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
@ -167,6 +168,16 @@ const actionColumn = {
return h(EditableTableColumn, { return h(EditableTableColumn, {
editing: false, editing: false,
bindKey: `#${index + 1}`, bindKey: `#${index + 1}`,
onCopy: async () => {
try {
const succ = await ClipboardSetText(row.v)
if (succ) {
$message.success(i18n.t('interface.copy_succ'))
}
} catch (e) {
$message.error(e.message)
}
},
onEdit: () => { onEdit: () => {
startEdit(index + 1, row.v) startEdit(index + 1, row.v)
}, },

View File

@ -18,6 +18,7 @@ import Edit from '@/components/icons/Edit.vue'
import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vue' import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vue'
import FormatSelector from '@/components/content_value/FormatSelector.vue' import FormatSelector from '@/components/content_value/FormatSelector.vue'
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue' import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
const i18n = useI18n() const i18n = useI18n()
const themeVars = useThemeVars() const themeVars = useThemeVars()
@ -139,7 +140,7 @@ const saveEdit = async (pos, value, decode, format) => {
retFormat: props.format, retFormat: props.format,
}) })
if (success) { if (success) {
$message.success(i18n.t('dialogue.save_value_succ')) $message.success(i18n.t('interface.save_value_succ'))
} else { } else {
$message.error(msg) $message.error(msg)
} }
@ -156,7 +157,7 @@ const resetEdit = () => {
const actionColumn = { const actionColumn = {
key: 'action', key: 'action',
title: i18n.t('interface.action'), title: i18n.t('interface.action'),
width: 100, width: 120,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
@ -164,6 +165,16 @@ const actionColumn = {
return h(EditableTableColumn, { return h(EditableTableColumn, {
editing: false, editing: false,
bindKey: `#${index + 1}`, bindKey: `#${index + 1}`,
onCopy: async () => {
try {
const succ = await ClipboardSetText(row.v)
if (succ) {
$message.success(i18n.t('interface.copy_succ'))
}
} catch (e) {
$message.error(e.message)
}
},
onEdit: () => { onEdit: () => {
startEdit(index + 1, row.v) startEdit(index + 1, row.v)
}, },

View File

@ -15,6 +15,7 @@ import LoadList from '@/components/icons/LoadList.vue'
import LoadAll from '@/components/icons/LoadAll.vue' import LoadAll from '@/components/icons/LoadAll.vue'
import IconButton from '@/components/common/IconButton.vue' import IconButton from '@/components/common/IconButton.vue'
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue' import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
const i18n = useI18n() const i18n = useI18n()
const themeVars = useThemeVars() const themeVars = useThemeVars()
@ -99,7 +100,7 @@ const valueColumn = computed(() => ({
const actionColumn = { const actionColumn = {
key: 'action', key: 'action',
title: i18n.t('interface.action'), title: i18n.t('interface.action'),
width: 60, width: 80,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
@ -107,6 +108,16 @@ const actionColumn = {
return h(EditableTableColumn, { return h(EditableTableColumn, {
bindKey: row.id, bindKey: row.id,
readonly: true, readonly: true,
onCopy: async () => {
try {
const succ = await ClipboardSetText(JSON.stringify(row.v))
if (succ) {
$message.success(i18n.t('interface.copy_succ'))
}
} catch (e) {
$message.error(e.message)
}
},
onDelete: async () => { onDelete: async () => {
try { try {
const { success, msg } = await browserStore.removeStreamValues( const { success, msg } = await browserStore.removeStreamValues(
@ -175,20 +186,6 @@ defineExpose({
@rename="emit('rename')" /> @rename="emit('rename')" />
<div class="tb2 value-item-part flex-box-h"> <div class="tb2 value-item-part flex-box-h">
<div class="flex-box-h"> <div class="flex-box-h">
<!-- <n-input-group>-->
<!-- <n-select-->
<!-- v-model:value="filterType"-->
<!-- :consistent-menu-width="false"-->
<!-- :options="filterOption"-->
<!-- style="width: 120px"-->
<!-- @update:value="onChangeFilterType" />-->
<!-- <n-input-->
<!-- v-model:value="filterValue"-->
<!-- :placeholder="$t('interface.search')"-->
<!-- clearable-->
<!-- @clear="clearFilter"-->
<!-- @update:value="onFilterInput" />-->
<!-- </n-input-group>-->
<content-search-input <content-search-input
ref="searchInputRef" ref="searchInputRef"
@filter-changed="onFilterInput" @filter-changed="onFilterInput"

View File

@ -77,25 +77,31 @@ const displayValue = computed(() => {
watch( watch(
() => props.value, () => props.value,
(val, oldVal) => { (val, oldVal) => {
if (val !== undefined && oldVal !== undefined) { if (val !== undefined) {
onFormatChanged(viewAs.decode, viewAs.format) onFormatChanged(viewAs.decode, viewAs.format)
} }
}, },
) )
const converting = ref(false)
const onFormatChanged = async (decode = '', format = '') => { const onFormatChanged = async (decode = '', format = '') => {
const { try {
value, converting.value = true
decode: retDecode, const {
format: retFormat, value,
} = await browserStore.convertValue({ decode: retDecode,
value: props.value, format: retFormat,
decode, } = await browserStore.convertValue({
format, value: props.value,
}) decode,
editingContent.value = viewAs.value = value format,
viewAs.decode = decode || retDecode })
viewAs.format = format || retFormat editingContent.value = viewAs.value = value
viewAs.decode = decode || retDecode
viewAs.format = format || retFormat
} finally {
converting.value = false
}
} }
/** /**
@ -105,7 +111,7 @@ const onCopyValue = () => {
ClipboardSetText(displayValue.value) ClipboardSetText(displayValue.value)
.then((succ) => { .then((succ) => {
if (succ) { if (succ) {
$message.success(i18n.t('dialogue.copy_succ')) $message.success(i18n.t('interface.copy_succ'))
} }
}) })
.catch((e) => { .catch((e) => {
@ -138,7 +144,7 @@ const onSave = async () => {
}) })
if (success) { if (success) {
// await browserStore.loadKeyDetail({ server: props.name, db: props.db, key: keyName.value }) // await browserStore.loadKeyDetail({ server: props.name, db: props.db, key: keyName.value })
$message.success(i18n.t('dialogue.save_value_succ')) $message.success(i18n.t('interface.save_value_succ'))
} else { } else {
$message.error(msg) $message.error(msg)
} }
@ -152,9 +158,10 @@ const onSave = async () => {
defineExpose({ defineExpose({
reset: () => { reset: () => {
viewAs.value = '' viewAs.value = ''
viewAs.decode = ''
viewAs.format = ''
editingContent.value = '' editingContent.value = ''
}, },
beforeShow: () => onFormatChanged(),
}) })
</script> </script>
@ -195,9 +202,9 @@ defineExpose({
</n-button-group> </n-button-group>
</div> </div>
<div class="value-wrapper value-item-part flex-item-expand flex-box-v"> <div class="value-wrapper value-item-part flex-item-expand flex-box-v">
<n-spin :show="props.loading" /> <n-spin :show="props.loading || converting" />
<content-editor <content-editor
v-show="!props.loading" v-show="!(props.loading || converting)"
:content="displayValue" :content="displayValue"
:language="viewLanguage" :language="viewLanguage"
:loading="props.loading" :loading="props.loading"

View File

@ -156,9 +156,6 @@ const initContent = async () => {
contentRef.value?.reset() contentRef.value?.reset()
} }
await loadData(true, false, '') await loadData(true, false, '')
if (contentRef.value?.beforeShow != null) {
await contentRef.value?.beforeShow()
}
} finally { } finally {
initializing.value = false initializing.value = false
} }

View File

@ -18,6 +18,7 @@ import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vu
import FormatSelector from '@/components/content_value/FormatSelector.vue' import FormatSelector from '@/components/content_value/FormatSelector.vue'
import Edit from '@/components/icons/Edit.vue' import Edit from '@/components/icons/Edit.vue'
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue' import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
const i18n = useI18n() const i18n = useI18n()
const themeVars = useThemeVars() const themeVars = useThemeVars()
@ -185,7 +186,7 @@ const saveEdit = async (field, value, decode, format) => {
format, format,
}) })
if (success) { if (success) {
$message.success(i18n.t('dialogue.save_value_succ')) $message.success(i18n.t('interface.save_value_succ'))
} else { } else {
$message.error(msg) $message.error(msg)
} }
@ -205,7 +206,7 @@ const resetEdit = () => {
const actionColumn = { const actionColumn = {
key: 'action', key: 'action',
title: i18n.t('interface.action'), title: i18n.t('interface.action'),
width: 100, width: 120,
align: 'center', align: 'center',
titleAlign: 'center', titleAlign: 'center',
fixed: 'right', fixed: 'right',
@ -213,6 +214,16 @@ const actionColumn = {
return h(EditableTableColumn, { return h(EditableTableColumn, {
editing: false, editing: false,
bindKey: row.v, bindKey: row.v,
onCopy: async () => {
try {
const succ = await ClipboardSetText(row.v)
if (succ) {
$message.success(i18n.t('interface.copy_succ'))
}
} catch (e) {
$message.error(e.message)
}
},
onEdit: () => startEdit(index + 1, row.s, row.v), onEdit: () => startEdit(index + 1, row.s, row.v),
onDelete: async () => { onDelete: async () => {
try { try {

View File

@ -3,7 +3,7 @@ import { useThemeVars } from 'naive-ui'
import BrowserTree from './BrowserTree.vue' import BrowserTree from './BrowserTree.vue'
import IconButton from '@/components/common/IconButton.vue' import IconButton from '@/components/common/IconButton.vue'
import useTabStore from 'stores/tab.js' import useTabStore from 'stores/tab.js'
import { computed, onMounted, reactive, ref, unref, watch } from 'vue' import { computed, nextTick, onMounted, reactive, ref, unref, watch } from 'vue'
import { get, map } from 'lodash' import { get, map } from 'lodash'
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'
@ -19,6 +19,7 @@ import { useRender } from '@/utils/render.js'
import RedisTypeSelector from '@/components/common/RedisTypeSelector.vue' import RedisTypeSelector from '@/components/common/RedisTypeSelector.vue'
import { types } from '@/consts/support_redis_type.js' import { types } from '@/consts/support_redis_type.js'
import Plus from '@/components/icons/Plus.vue' import Plus from '@/components/icons/Plus.vue'
import useConnectionStore from 'stores/connections.js'
const themeVars = useThemeVars() const themeVars = useThemeVars()
const i18n = useI18n() const i18n = useI18n()
@ -26,6 +27,7 @@ const dialogStore = useDialogStore()
// const prefStore = usePreferencesStore() // const prefStore = usePreferencesStore()
const tabStore = useTabStore() const tabStore = useTabStore()
const browserStore = useBrowserStore() const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const render = useRender() const render = useRender()
const currentName = computed(() => get(tabStore.currentTab, 'name', '')) const currentName = computed(() => get(tabStore.currentTab, 'name', ''))
const browserTreeRef = ref(null) const browserTreeRef = ref(null)
@ -159,6 +161,8 @@ watch(
browserTreeRef.value?.resetExpandKey(currentName.value, db) browserTreeRef.value?.resetExpandKey(currentName.value, db)
fullyLoaded.value = await browserStore.loadMoreKeys(currentName.value, db) fullyLoaded.value = await browserStore.loadMoreKeys(currentName.value, db)
browserTreeRef.value?.refreshTree() browserTreeRef.value?.refreshTree()
nextTick().then(() => connectionStore.saveLastDB(currentName.value, db))
} catch (e) { } catch (e) {
$message.error(e.message) $message.error(e.message)
} finally { } finally {
@ -269,7 +273,7 @@ onMounted(() => onReload())
size="20" size="20"
t-tooltip="interface.load_all" t-tooltip="interface.load_all"
@click="onLoadAll" /> @click="onLoadAll" />
<div class="flex-item-expand" /> <div class="flex-item-expand" style="min-width: 10px" />
<icon-button <icon-button
:button-class="['nav-pane-func-btn']" :button-class="['nav-pane-func-btn']"
:icon="Delete" :icon="Delete"

View File

@ -220,7 +220,7 @@ const handleSelectContextMenu = (key) => {
ClipboardSetText(redisKey) ClipboardSetText(redisKey)
.then((succ) => { .then((succ) => {
if (succ) { if (succ) {
$message.success(i18n.t('dialogue.copy_succ')) $message.success(i18n.t('interface.copy_succ'))
} }
}) })
.catch((e) => { .catch((e) => {

View File

@ -94,6 +94,8 @@
"open_connection": "Open Connection", "open_connection": "Open Connection",
"copy_path": "Copy Path", "copy_path": "Copy Path",
"copy_key": "Copy Key", "copy_key": "Copy Key",
"save_value_succ": "Value Saved !",
"copy_succ": "Value Copied !",
"binary_key": "Binary Key Name", "binary_key": "Binary Key Name",
"remove_key": "Remove Key", "remove_key": "Remove Key",
"new_key": "Add Key", "new_key": "Add Key",
@ -130,8 +132,6 @@
"remove_tip": "{type} \"{name}\" will be deleted", "remove_tip": "{type} \"{name}\" will be deleted",
"remove_group_tip": "Group \"{name}\" and all connections in it will be deleted", "remove_group_tip": "Group \"{name}\" and all connections in it will be deleted",
"delete_key_succ": "\"{key}\" has been deleted", "delete_key_succ": "\"{key}\" has been deleted",
"save_value_succ": "Value Saved !",
"copy_succ": "Value Copied !",
"rename_binary_key_fail": "Rename binary key name is unsupported", "rename_binary_key_fail": "Rename binary key name is unsupported",
"handle_succ": "Success!", "handle_succ": "Success!",
"reload_succ": "Reloaded!", "reload_succ": "Reloaded!",

View File

@ -88,6 +88,8 @@
"open_connection": "Abrir Conexão", "open_connection": "Abrir Conexão",
"copy_path": "Copiar Caminho", "copy_path": "Copiar Caminho",
"copy_key": "Copiar Chave", "copy_key": "Copiar Chave",
"save_value_succ": "Valor Salvo!",
"copy_succ": "Valor Copiado!",
"binary_key": "Nome da Chave Binária", "binary_key": "Nome da Chave Binária",
"remove_key": "Remover Chave", "remove_key": "Remover Chave",
"new_key": "Adicionar Chave", "new_key": "Adicionar Chave",
@ -122,8 +124,6 @@
"remove_tip": "{type} \"{name}\" será excluído", "remove_tip": "{type} \"{name}\" será excluído",
"remove_group_tip": "O grupo \"{name}\" e todas as conexões nele serão excluídos", "remove_group_tip": "O grupo \"{name}\" e todas as conexões nele serão excluídos",
"delete_key_succ": "\"{key}\" foi excluída", "delete_key_succ": "\"{key}\" foi excluída",
"save_value_succ": "Valor Salvo!",
"copy_succ": "Valor Copiado!",
"rename_binary_key_fail": "Renomear nome de chave binária não é suportado", "rename_binary_key_fail": "Renomear nome de chave binária não é suportado",
"handle_succ": "Sucesso!", "handle_succ": "Sucesso!",
"reload_succ": "Recarregado!", "reload_succ": "Recarregado!",

View File

@ -94,6 +94,8 @@
"open_connection": "打开连接", "open_connection": "打开连接",
"copy_path": "复制路径", "copy_path": "复制路径",
"copy_key": "复制键名", "copy_key": "复制键名",
"save_value_succ": "已保存值",
"copy_succ": "已复制到剪切板",
"binary_key": "二进制键名", "binary_key": "二进制键名",
"remove_key": "删除键", "remove_key": "删除键",
"new_key": "添加新键", "new_key": "添加新键",
@ -130,8 +132,6 @@
"remove_tip": "{type} \"{name}\" 将会被删除", "remove_tip": "{type} \"{name}\" 将会被删除",
"remove_group_tip": "分组 \"{name}\"及其所有连接将会被删除", "remove_group_tip": "分组 \"{name}\"及其所有连接将会被删除",
"delete_key_succ": "{key} 已被删除", "delete_key_succ": "{key} 已被删除",
"save_value_succ": "已保存值",
"copy_succ": "已复制到剪切板",
"rename_binary_key_fail": "不支持重命名二进制键名", "rename_binary_key_fail": "不支持重命名二进制键名",
"handle_succ": "操作成功", "handle_succ": "操作成功",
"reload_succ": "已重新载入", "reload_succ": "已重新载入",

View File

@ -255,11 +255,12 @@ const useBrowserStore = defineStore('browser', {
// if (connNode == null) { // if (connNode == null) {
// throw new Error('no such connection') // throw new Error('no such connection')
// } // }
const { db, view = KeyViewType.Tree } = data const { db, view = KeyViewType.Tree, lastDB } = data
if (isEmpty(db)) { if (isEmpty(db)) {
throw new Error('no db loaded') throw new Error('no db loaded')
} }
const dbs = [] const dbs = []
let containLastDB = false
for (let i = 0; i < db.length; i++) { for (let i = 0; i < db.length; i++) {
this._getNodeMap(name, i).clear() this._getNodeMap(name, i).clear()
this._getKeySet(name, i).clear() this._getKeySet(name, i).clear()
@ -274,10 +275,18 @@ const useBrowserStore = defineStore('browser', {
isLeaf: false, isLeaf: false,
children: undefined, children: undefined,
}) })
if (db[i].index === lastDB) {
containLastDB = true
}
} }
this.databases[name] = dbs this.databases[name] = dbs
this.viewType[name] = view this.viewType[name] = view
this.openedDB[name] = get(dbs, '0.db', 0) // get last selected db
if (containLastDB) {
this.openedDB[name] = lastDB
} else {
this.openedDB[name] = get(dbs, '0.db', 0)
}
}, },
/** /**

View File

@ -8,6 +8,7 @@ import {
ListConnection, ListConnection,
RenameGroup, RenameGroup,
SaveConnection, SaveConnection,
SaveLastDB,
SaveSortedConnection, SaveSortedConnection,
} from 'wailsjs/go/services/connectionService.js' } from 'wailsjs/go/services/connectionService.js'
import { ConnectionType } from '@/consts/connection_type.js' import { ConnectionType } from '@/consts/connection_type.js'
@ -333,6 +334,20 @@ const useConnectionStore = defineStore('connections', {
return { success: true } return { success: true }
}, },
/**
* save last selected database
* @param {string} name
* @param {number} db
* @return {Promise<{success: boolean, [msg]: string}>}
*/
async saveLastDB(name, db) {
const { success, msg } = await SaveLastDB(name, db)
if (!success) {
return { success: false, msg }
}
return { success: true }
},
/** /**
* get default key filter pattern by server name * get default key filter pattern by server name
* @param name * @param name

View File

@ -235,7 +235,7 @@ const useTabStore = defineStore('tab', {
tabData.value = assign(value, tabData.value || {}) tabData.value = assign(value, tabData.value || {})
} }
} else { } else {
tabData.value = value || [] tabData.value = value
} }
}, },