Compare commits

..

No commits in common. "7934fc275ac11e49a8099e9a936017c6b9a59965" and "ab8077999d08dd6dc4590ab20481e081b80ddab0" have entirely different histories.

20 changed files with 62 additions and 156 deletions

View File

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

View File

@ -358,20 +358,3 @@ 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
}

View File

@ -5,7 +5,6 @@ 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"`

View File

@ -4,7 +4,6 @@ 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,
@ -12,7 +11,7 @@ const props = defineProps({
readonly: Boolean,
})
const emit = defineEmits(['edit', 'delete', 'copy', 'save', 'cancel'])
const emit = defineEmits(['edit', 'delete', 'save', 'cancel'])
</script>
<template>
@ -22,14 +21,13 @@ const emit = defineEmits(['edit', 'delete', 'copy', 'save', 'cancel'])
<icon-button :icon="Close" @click="emit('cancel')" />
</div>
<div v-else class="flex-box-h edit-column-func">
<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')" />
<icon-button v-if="!props.readonly" :icon="Edit" @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" :title="$t('interface.delete_row')" />
<icon-button :icon="Delete" />
</template>
{{ $t('dialogue.remove_tip', { name: props.bindKey }) }}
</n-popconfirm>

View File

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

View File

@ -19,7 +19,6 @@ 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()
@ -164,7 +163,7 @@ const saveEdit = async (field, value, decode, format) => {
})
if (success) {
currentEditRow.value = value
$message.success(i18n.t('interface.save_value_succ'))
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)
}
@ -184,7 +183,7 @@ const resetEdit = () => {
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
width: 120,
width: 100,
align: 'center',
titleAlign: 'center',
fixed: 'right',
@ -192,16 +191,6 @@ 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 {

View File

@ -18,7 +18,6 @@ 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()
@ -143,7 +142,7 @@ const saveEdit = async (pos, value, decode, format) => {
format,
})
if (success) {
$message.success(i18n.t('interface.save_value_succ'))
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)
}
@ -160,7 +159,7 @@ const resetEdit = () => {
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
width: 120,
width: 100,
align: 'center',
titleAlign: 'center',
fixed: 'right',
@ -168,16 +167,6 @@ 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)
},

View File

@ -18,7 +18,6 @@ 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()
@ -140,7 +139,7 @@ const saveEdit = async (pos, value, decode, format) => {
retFormat: props.format,
})
if (success) {
$message.success(i18n.t('interface.save_value_succ'))
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)
}
@ -157,7 +156,7 @@ const resetEdit = () => {
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
width: 120,
width: 100,
align: 'center',
titleAlign: 'center',
fixed: 'right',
@ -165,16 +164,6 @@ 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)
},

View File

@ -15,7 +15,6 @@ 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()
@ -100,7 +99,7 @@ const valueColumn = computed(() => ({
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
width: 80,
width: 60,
align: 'center',
titleAlign: 'center',
fixed: 'right',
@ -108,16 +107,6 @@ 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(
@ -186,6 +175,20 @@ 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"

View File

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

View File

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

View File

@ -18,7 +18,6 @@ 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()
@ -186,7 +185,7 @@ const saveEdit = async (field, value, decode, format) => {
format,
})
if (success) {
$message.success(i18n.t('interface.save_value_succ'))
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)
}
@ -206,7 +205,7 @@ const resetEdit = () => {
const actionColumn = {
key: 'action',
title: i18n.t('interface.action'),
width: 120,
width: 100,
align: 'center',
titleAlign: 'center',
fixed: 'right',
@ -214,16 +213,6 @@ 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 {

View File

@ -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, nextTick, onMounted, reactive, ref, unref, watch } from 'vue'
import { computed, 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,7 +19,6 @@ 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()
@ -27,7 +26,6 @@ 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)
@ -161,8 +159,6 @@ 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 {
@ -273,7 +269,7 @@ onMounted(() => onReload())
size="20"
t-tooltip="interface.load_all"
@click="onLoadAll" />
<div class="flex-item-expand" style="min-width: 10px" />
<div class="flex-item-expand" />
<icon-button
:button-class="['nav-pane-func-btn']"
:icon="Delete"

View File

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

View File

@ -94,8 +94,6 @@
"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",
@ -132,6 +130,8 @@
"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!",

View File

@ -88,8 +88,6 @@
"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",
@ -124,6 +122,8 @@
"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!",

View File

@ -94,8 +94,6 @@
"open_connection": "打开连接",
"copy_path": "复制路径",
"copy_key": "复制键名",
"save_value_succ": "已保存值",
"copy_succ": "已复制到剪切板",
"binary_key": "二进制键名",
"remove_key": "删除键",
"new_key": "添加新键",
@ -132,6 +130,8 @@
"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": "已重新载入",

View File

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

View File

@ -8,7 +8,6 @@ import {
ListConnection,
RenameGroup,
SaveConnection,
SaveLastDB,
SaveSortedConnection,
} from 'wailsjs/go/services/connectionService.js'
import { ConnectionType } from '@/consts/connection_type.js'
@ -334,20 +333,6 @@ 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

View File

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