Compare commits
3 Commits
ab8077999d
...
7934fc275a
Author | SHA1 | Date |
---|---|---|
Lykin | 7934fc275a | |
Lykin | 2d3225dbcf | |
Lykin | 988e8e3339 |
|
@ -198,8 +198,9 @@ func (b *browserService) OpenConnection(name string) (resp types.JSResp) {
|
|||
|
||||
resp.Success = true
|
||||
resp.Data = map[string]any{
|
||||
"db": dbs,
|
||||
"view": selConn.KeyView,
|
||||
"db": dbs,
|
||||
"view": selConn.KeyView,
|
||||
"lastDB": selConn.LastDB,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -358,3 +358,20 @@ func (c *connectionService) DeleteGroup(name string, includeConn bool) (resp typ
|
|||
resp.Success = true
|
||||
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
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ type ConnectionCategory int
|
|||
type ConnectionConfig struct {
|
||||
Name string `json:"name" yaml:"name"`
|
||||
Group string `json:"group,omitempty" yaml:"-"`
|
||||
LastDB int `json:"lastDB" yaml:"last_db"`
|
||||
Addr string `json:"addr,omitempty" yaml:"addr,omitempty"`
|
||||
Port int `json:"port,omitempty" yaml:"port,omitempty"`
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
||||
|
|
|
@ -4,6 +4,7 @@ import Delete from '@/components/icons/Delete.vue'
|
|||
import Edit from '@/components/icons/Edit.vue'
|
||||
import Close from '@/components/icons/Close.vue'
|
||||
import Save from '@/components/icons/Save.vue'
|
||||
import Copy from '@/components/icons/Copy.vue'
|
||||
|
||||
const props = defineProps({
|
||||
bindKey: String,
|
||||
|
@ -11,7 +12,7 @@ const props = defineProps({
|
|||
readonly: Boolean,
|
||||
})
|
||||
|
||||
const emit = defineEmits(['edit', 'delete', 'save', 'cancel'])
|
||||
const emit = defineEmits(['edit', 'delete', 'copy', 'save', 'cancel'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -21,13 +22,14 @@ const emit = defineEmits(['edit', 'delete', 'save', 'cancel'])
|
|||
<icon-button :icon="Close" @click="emit('cancel')" />
|
||||
</div>
|
||||
<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
|
||||
:negative-text="$t('common.cancel')"
|
||||
:positive-text="$t('common.confirm')"
|
||||
@positive-click="emit('delete')">
|
||||
<template #trigger>
|
||||
<icon-button :icon="Delete" />
|
||||
<icon-button :icon="Delete" :title="$t('interface.delete_row')" />
|
||||
</template>
|
||||
{{ $t('dialogue.remove_tip', { name: props.bindKey }) }}
|
||||
</n-popconfirm>
|
||||
|
|
|
@ -65,7 +65,7 @@ const onCopyKey = () => {
|
|||
ClipboardSetText(props.keyPath)
|
||||
.then((succ) => {
|
||||
if (succ) {
|
||||
$message.success(i18n.t('dialogue.copy_succ'))
|
||||
$message.success(i18n.t('interface.copy_succ'))
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
@ -19,6 +19,7 @@ import Edit from '@/components/icons/Edit.vue'
|
|||
import FormatSelector from '@/components/content_value/FormatSelector.vue'
|
||||
import { decodeRedisKey } from '@/utils/key_convert.js'
|
||||
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
|
||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||
|
||||
const i18n = useI18n()
|
||||
const themeVars = useThemeVars()
|
||||
|
@ -163,7 +164,7 @@ const saveEdit = async (field, value, decode, format) => {
|
|||
})
|
||||
if (success) {
|
||||
currentEditRow.value = value
|
||||
$message.success(i18n.t('dialogue.save_value_succ'))
|
||||
$message.success(i18n.t('interface.save_value_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -183,7 +184,7 @@ const resetEdit = () => {
|
|||
const actionColumn = {
|
||||
key: 'action',
|
||||
title: i18n.t('interface.action'),
|
||||
width: 100,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
|
@ -191,6 +192,16 @@ const actionColumn = {
|
|||
return h(EditableTableColumn, {
|
||||
editing: false,
|
||||
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),
|
||||
onDelete: async () => {
|
||||
try {
|
||||
|
|
|
@ -18,6 +18,7 @@ import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vu
|
|||
import FormatSelector from '@/components/content_value/FormatSelector.vue'
|
||||
import Edit from '@/components/icons/Edit.vue'
|
||||
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
|
||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||
|
||||
const i18n = useI18n()
|
||||
const themeVars = useThemeVars()
|
||||
|
@ -142,7 +143,7 @@ const saveEdit = async (pos, value, decode, format) => {
|
|||
format,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.save_value_succ'))
|
||||
$message.success(i18n.t('interface.save_value_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -159,7 +160,7 @@ const resetEdit = () => {
|
|||
const actionColumn = {
|
||||
key: 'action',
|
||||
title: i18n.t('interface.action'),
|
||||
width: 100,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
|
@ -167,6 +168,16 @@ const actionColumn = {
|
|||
return h(EditableTableColumn, {
|
||||
editing: false,
|
||||
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: () => {
|
||||
startEdit(index + 1, row.v)
|
||||
},
|
||||
|
|
|
@ -18,6 +18,7 @@ import Edit from '@/components/icons/Edit.vue'
|
|||
import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vue'
|
||||
import FormatSelector from '@/components/content_value/FormatSelector.vue'
|
||||
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
|
||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||
|
||||
const i18n = useI18n()
|
||||
const themeVars = useThemeVars()
|
||||
|
@ -139,7 +140,7 @@ const saveEdit = async (pos, value, decode, format) => {
|
|||
retFormat: props.format,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.save_value_succ'))
|
||||
$message.success(i18n.t('interface.save_value_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -156,7 +157,7 @@ const resetEdit = () => {
|
|||
const actionColumn = {
|
||||
key: 'action',
|
||||
title: i18n.t('interface.action'),
|
||||
width: 100,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
|
@ -164,6 +165,16 @@ const actionColumn = {
|
|||
return h(EditableTableColumn, {
|
||||
editing: false,
|
||||
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: () => {
|
||||
startEdit(index + 1, row.v)
|
||||
},
|
||||
|
|
|
@ -15,6 +15,7 @@ import LoadList from '@/components/icons/LoadList.vue'
|
|||
import LoadAll from '@/components/icons/LoadAll.vue'
|
||||
import IconButton from '@/components/common/IconButton.vue'
|
||||
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
|
||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||
|
||||
const i18n = useI18n()
|
||||
const themeVars = useThemeVars()
|
||||
|
@ -99,7 +100,7 @@ const valueColumn = computed(() => ({
|
|||
const actionColumn = {
|
||||
key: 'action',
|
||||
title: i18n.t('interface.action'),
|
||||
width: 60,
|
||||
width: 80,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
|
@ -107,6 +108,16 @@ const actionColumn = {
|
|||
return h(EditableTableColumn, {
|
||||
bindKey: row.id,
|
||||
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 () => {
|
||||
try {
|
||||
const { success, msg } = await browserStore.removeStreamValues(
|
||||
|
@ -175,20 +186,6 @@ defineExpose({
|
|||
@rename="emit('rename')" />
|
||||
<div class="tb2 value-item-part 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
|
||||
ref="searchInputRef"
|
||||
@filter-changed="onFilterInput"
|
||||
|
|
|
@ -77,25 +77,31 @@ const displayValue = computed(() => {
|
|||
watch(
|
||||
() => props.value,
|
||||
(val, oldVal) => {
|
||||
if (val !== undefined && oldVal !== undefined) {
|
||||
if (val !== undefined) {
|
||||
onFormatChanged(viewAs.decode, viewAs.format)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
const converting = ref(false)
|
||||
const onFormatChanged = async (decode = '', format = '') => {
|
||||
const {
|
||||
value,
|
||||
decode: retDecode,
|
||||
format: retFormat,
|
||||
} = await browserStore.convertValue({
|
||||
value: props.value,
|
||||
decode,
|
||||
format,
|
||||
})
|
||||
editingContent.value = viewAs.value = value
|
||||
viewAs.decode = decode || retDecode
|
||||
viewAs.format = format || retFormat
|
||||
try {
|
||||
converting.value = true
|
||||
const {
|
||||
value,
|
||||
decode: retDecode,
|
||||
format: retFormat,
|
||||
} = await browserStore.convertValue({
|
||||
value: props.value,
|
||||
decode,
|
||||
format,
|
||||
})
|
||||
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)
|
||||
.then((succ) => {
|
||||
if (succ) {
|
||||
$message.success(i18n.t('dialogue.copy_succ'))
|
||||
$message.success(i18n.t('interface.copy_succ'))
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
|
@ -138,7 +144,7 @@ const onSave = async () => {
|
|||
})
|
||||
if (success) {
|
||||
// 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 {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -152,9 +158,10 @@ const onSave = async () => {
|
|||
defineExpose({
|
||||
reset: () => {
|
||||
viewAs.value = ''
|
||||
viewAs.decode = ''
|
||||
viewAs.format = ''
|
||||
editingContent.value = ''
|
||||
},
|
||||
beforeShow: () => onFormatChanged(),
|
||||
})
|
||||
</script>
|
||||
|
||||
|
@ -195,9 +202,9 @@ defineExpose({
|
|||
</n-button-group>
|
||||
</div>
|
||||
<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
|
||||
v-show="!props.loading"
|
||||
v-show="!(props.loading || converting)"
|
||||
:content="displayValue"
|
||||
:language="viewLanguage"
|
||||
:loading="props.loading"
|
||||
|
|
|
@ -156,9 +156,6 @@ const initContent = async () => {
|
|||
contentRef.value?.reset()
|
||||
}
|
||||
await loadData(true, false, '')
|
||||
if (contentRef.value?.beforeShow != null) {
|
||||
await contentRef.value?.beforeShow()
|
||||
}
|
||||
} finally {
|
||||
initializing.value = false
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import ContentEntryEditor from '@/components/content_value/ContentEntryEditor.vu
|
|||
import FormatSelector from '@/components/content_value/FormatSelector.vue'
|
||||
import Edit from '@/components/icons/Edit.vue'
|
||||
import ContentSearchInput from '@/components/content_value/ContentSearchInput.vue'
|
||||
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
|
||||
|
||||
const i18n = useI18n()
|
||||
const themeVars = useThemeVars()
|
||||
|
@ -185,7 +186,7 @@ const saveEdit = async (field, value, decode, format) => {
|
|||
format,
|
||||
})
|
||||
if (success) {
|
||||
$message.success(i18n.t('dialogue.save_value_succ'))
|
||||
$message.success(i18n.t('interface.save_value_succ'))
|
||||
} else {
|
||||
$message.error(msg)
|
||||
}
|
||||
|
@ -205,7 +206,7 @@ const resetEdit = () => {
|
|||
const actionColumn = {
|
||||
key: 'action',
|
||||
title: i18n.t('interface.action'),
|
||||
width: 100,
|
||||
width: 120,
|
||||
align: 'center',
|
||||
titleAlign: 'center',
|
||||
fixed: 'right',
|
||||
|
@ -213,6 +214,16 @@ const actionColumn = {
|
|||
return h(EditableTableColumn, {
|
||||
editing: false,
|
||||
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),
|
||||
onDelete: async () => {
|
||||
try {
|
||||
|
|
|
@ -3,7 +3,7 @@ import { useThemeVars } from 'naive-ui'
|
|||
import BrowserTree from './BrowserTree.vue'
|
||||
import IconButton from '@/components/common/IconButton.vue'
|
||||
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 Refresh from '@/components/icons/Refresh.vue'
|
||||
import useDialogStore from 'stores/dialog.js'
|
||||
|
@ -19,6 +19,7 @@ import { useRender } from '@/utils/render.js'
|
|||
import RedisTypeSelector from '@/components/common/RedisTypeSelector.vue'
|
||||
import { types } from '@/consts/support_redis_type.js'
|
||||
import Plus from '@/components/icons/Plus.vue'
|
||||
import useConnectionStore from 'stores/connections.js'
|
||||
|
||||
const themeVars = useThemeVars()
|
||||
const i18n = useI18n()
|
||||
|
@ -26,6 +27,7 @@ const dialogStore = useDialogStore()
|
|||
// const prefStore = usePreferencesStore()
|
||||
const tabStore = useTabStore()
|
||||
const browserStore = useBrowserStore()
|
||||
const connectionStore = useConnectionStore()
|
||||
const render = useRender()
|
||||
const currentName = computed(() => get(tabStore.currentTab, 'name', ''))
|
||||
const browserTreeRef = ref(null)
|
||||
|
@ -159,6 +161,8 @@ watch(
|
|||
browserTreeRef.value?.resetExpandKey(currentName.value, db)
|
||||
fullyLoaded.value = await browserStore.loadMoreKeys(currentName.value, db)
|
||||
browserTreeRef.value?.refreshTree()
|
||||
|
||||
nextTick().then(() => connectionStore.saveLastDB(currentName.value, db))
|
||||
} catch (e) {
|
||||
$message.error(e.message)
|
||||
} finally {
|
||||
|
@ -269,7 +273,7 @@ onMounted(() => onReload())
|
|||
size="20"
|
||||
t-tooltip="interface.load_all"
|
||||
@click="onLoadAll" />
|
||||
<div class="flex-item-expand" />
|
||||
<div class="flex-item-expand" style="min-width: 10px" />
|
||||
<icon-button
|
||||
:button-class="['nav-pane-func-btn']"
|
||||
:icon="Delete"
|
||||
|
|
|
@ -220,7 +220,7 @@ const handleSelectContextMenu = (key) => {
|
|||
ClipboardSetText(redisKey)
|
||||
.then((succ) => {
|
||||
if (succ) {
|
||||
$message.success(i18n.t('dialogue.copy_succ'))
|
||||
$message.success(i18n.t('interface.copy_succ'))
|
||||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
|
|
|
@ -94,6 +94,8 @@
|
|||
"open_connection": "Open Connection",
|
||||
"copy_path": "Copy Path",
|
||||
"copy_key": "Copy Key",
|
||||
"save_value_succ": "Value Saved !",
|
||||
"copy_succ": "Value Copied !",
|
||||
"binary_key": "Binary Key Name",
|
||||
"remove_key": "Remove Key",
|
||||
"new_key": "Add Key",
|
||||
|
@ -130,8 +132,6 @@
|
|||
"remove_tip": "{type} \"{name}\" will be deleted",
|
||||
"remove_group_tip": "Group \"{name}\" and all connections in it will be 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",
|
||||
"handle_succ": "Success!",
|
||||
"reload_succ": "Reloaded!",
|
||||
|
|
|
@ -88,6 +88,8 @@
|
|||
"open_connection": "Abrir Conexão",
|
||||
"copy_path": "Copiar Caminho",
|
||||
"copy_key": "Copiar Chave",
|
||||
"save_value_succ": "Valor Salvo!",
|
||||
"copy_succ": "Valor Copiado!",
|
||||
"binary_key": "Nome da Chave Binária",
|
||||
"remove_key": "Remover Chave",
|
||||
"new_key": "Adicionar Chave",
|
||||
|
@ -122,8 +124,6 @@
|
|||
"remove_tip": "{type} \"{name}\" será excluído",
|
||||
"remove_group_tip": "O grupo \"{name}\" e todas as conexões nele serão excluídos",
|
||||
"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",
|
||||
"handle_succ": "Sucesso!",
|
||||
"reload_succ": "Recarregado!",
|
||||
|
|
|
@ -94,6 +94,8 @@
|
|||
"open_connection": "打开连接",
|
||||
"copy_path": "复制路径",
|
||||
"copy_key": "复制键名",
|
||||
"save_value_succ": "已保存值",
|
||||
"copy_succ": "已复制到剪切板",
|
||||
"binary_key": "二进制键名",
|
||||
"remove_key": "删除键",
|
||||
"new_key": "添加新键",
|
||||
|
@ -130,8 +132,6 @@
|
|||
"remove_tip": "{type} \"{name}\" 将会被删除",
|
||||
"remove_group_tip": "分组 \"{name}\"及其所有连接将会被删除",
|
||||
"delete_key_succ": "{key} 已被删除",
|
||||
"save_value_succ": "已保存值",
|
||||
"copy_succ": "已复制到剪切板",
|
||||
"rename_binary_key_fail": "不支持重命名二进制键名",
|
||||
"handle_succ": "操作成功",
|
||||
"reload_succ": "已重新载入",
|
||||
|
|
|
@ -255,11 +255,12 @@ const useBrowserStore = defineStore('browser', {
|
|||
// if (connNode == null) {
|
||||
// throw new Error('no such connection')
|
||||
// }
|
||||
const { db, view = KeyViewType.Tree } = data
|
||||
const { db, view = KeyViewType.Tree, lastDB } = data
|
||||
if (isEmpty(db)) {
|
||||
throw new Error('no db loaded')
|
||||
}
|
||||
const dbs = []
|
||||
let containLastDB = false
|
||||
for (let i = 0; i < db.length; i++) {
|
||||
this._getNodeMap(name, i).clear()
|
||||
this._getKeySet(name, i).clear()
|
||||
|
@ -274,10 +275,18 @@ const useBrowserStore = defineStore('browser', {
|
|||
isLeaf: false,
|
||||
children: undefined,
|
||||
})
|
||||
if (db[i].index === lastDB) {
|
||||
containLastDB = true
|
||||
}
|
||||
}
|
||||
this.databases[name] = dbs
|
||||
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)
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
ListConnection,
|
||||
RenameGroup,
|
||||
SaveConnection,
|
||||
SaveLastDB,
|
||||
SaveSortedConnection,
|
||||
} from 'wailsjs/go/services/connectionService.js'
|
||||
import { ConnectionType } from '@/consts/connection_type.js'
|
||||
|
@ -333,6 +334,20 @@ const useConnectionStore = defineStore('connections', {
|
|||
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
|
||||
* @param name
|
||||
|
|
|
@ -235,7 +235,7 @@ const useTabStore = defineStore('tab', {
|
|||
tabData.value = assign(value, tabData.value || {})
|
||||
}
|
||||
} else {
|
||||
tabData.value = value || []
|
||||
tabData.value = value
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue