Compare commits

..

No commits in common. "e6b28c9edc4c7de7fd175959bb6febb1fdbce03b" and "44df1d5800c928ab7941377f6a5b5ed15c3ee8d7" have entirely different histories.

33 changed files with 2951 additions and 3067 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,7 @@ func containsBinary(str string) bool {
//}
rs := []rune(str)
for _, r := range rs {
if !unicode.IsPrint(r) && r != '\n' {
if !unicode.IsPrint(r) {
return true
}
}

View File

@ -9,6 +9,7 @@ import ConnectionPane from './components/sidebar/ConnectionPane.vue'
import ContentServerPane from './components/content/ContentServerPane.vue'
import useTabStore from './stores/tab.js'
import usePreferencesStore from './stores/preferences.js'
import useConnectionStore from './stores/connections.js'
import ContentLogPane from './components/content/ContentLogPane.vue'
import ContentValueTab from '@/components/content/ContentValueTab.vue'
import ToolbarControlWidget from '@/components/common/ToolbarControlWidget.vue'
@ -31,6 +32,7 @@ const data = reactive({
const tabStore = useTabStore()
const prefStore = usePreferencesStore()
const connectionStore = useConnectionStore()
const logPaneRef = ref(null)
const exThemeVars = computed(() => {
return extraTheme(prefStore.isDark)

View File

@ -2,16 +2,16 @@
import { computed, h, nextTick, reactive, ref } from 'vue'
import IconButton from '@/components/common/IconButton.vue'
import Refresh from '@/components/icons/Refresh.vue'
import useConnectionStore from 'stores/connections.js'
import { map, size, split, uniqBy } from 'lodash'
import { useI18n } from 'vue-i18n'
import Delete from '@/components/icons/Delete.vue'
import dayjs from 'dayjs'
import { useThemeVars } from 'naive-ui'
import useBrowserStore from 'stores/browser.js'
const themeVars = useThemeVars()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const i18n = useI18n()
const data = reactive({
loading: false,
@ -36,7 +36,7 @@ const tableRef = ref(null)
const loadHistory = () => {
data.loading = true
browserStore
connectionStore
.getCmdHistory()
.then((list) => {
data.history = list || []
@ -50,7 +50,7 @@ const loadHistory = () => {
const cleanHistory = async () => {
$dialog.warning(i18n.t('log.confirm_clean_log'), () => {
data.loading = true
browserStore
connectionStore
.cleanCmdHistory()
.then((success) => {
if (success) {

View File

@ -8,7 +8,6 @@ import { useThemeVars } from 'naive-ui'
import useConnectionStore from 'stores/connections.js'
import { extraTheme } from '@/utils/extra_theme.js'
import usePreferencesStore from 'stores/preferences.js'
import useBrowserStore from 'stores/browser.js'
/**
* Value content tab on head
@ -18,14 +17,13 @@ const themeVars = useThemeVars()
const i18n = useI18n()
const tabStore = useTabStore()
const connectionStore = useConnectionStore()
const browserStore = useBrowserStore()
const prefStore = usePreferencesStore()
const onCloseTab = (tabIndex) => {
const tab = get(tabStore.tabs, tabIndex)
if (tab != null) {
$dialog.warning(i18n.t('dialogue.close_confirm', { name: tab.name }), () => {
browserStore.closeConnection(tab.name)
connectionStore.closeConnection(tab.name)
})
}
}

View File

@ -4,13 +4,13 @@ import { computed, onMounted, onUnmounted, ref } from 'vue'
import IconButton from '@/components/common/IconButton.vue'
import Filter from '@/components/icons/Filter.vue'
import Refresh from '@/components/icons/Refresh.vue'
import useBrowserStore from 'stores/browser.js'
import useConnectionStore from 'stores/connections.js'
const props = defineProps({
server: String,
})
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const serverInfo = ref({})
const autoRefresh = ref(false)
const loading = ref(false) // loading status for refresh
@ -27,9 +27,9 @@ const refreshInfo = async (force) => {
} else {
autoLoading.value = true
}
if (!isEmpty(props.server) && browserStore.isConnected(props.server)) {
if (!isEmpty(props.server) && connectionStore.isConnected(props.server)) {
try {
serverInfo.value = await browserStore.getServerInfo(props.server)
serverInfo.value = await connectionStore.getServerInfo(props.server)
} finally {
loading.value = false
autoLoading.value = false

View File

@ -1,15 +1,15 @@
<script setup>
import { h, onMounted, onUnmounted, reactive, ref } from 'vue'
import Refresh from '@/components/icons/Refresh.vue'
import useConnectionStore from 'stores/connections.js'
import { debounce, isEmpty, map, size, split } from 'lodash'
import { useI18n } from 'vue-i18n'
import dayjs from 'dayjs'
import { useThemeVars } from 'naive-ui'
import useBrowserStore from 'stores/browser.js'
const themeVars = useThemeVars()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const i18n = useI18n()
const props = defineProps({
server: {
@ -35,7 +35,7 @@ const tableRef = ref(null)
const _loadSlowLog = () => {
data.loading = true
browserStore
connectionStore
.getSlowLog(props.server, props.db, data.listLimit)
.then((list) => {
data.list = list || []
@ -180,10 +180,10 @@ const onListLimitChanged = (limit) => {
},
},
]"
@update:sorter="({ order }) => (data.sortOrder = order)"
:data="data.list"
class="flex-item-expand"
flex-height
@update:sorter="({ order }) => (data.sortOrder = order)" />
flex-height />
</div>
</n-card>
</template>

View File

@ -8,12 +8,12 @@ import Timer from '@/components/icons/Timer.vue'
import RedisTypeTag from '@/components/common/RedisTypeTag.vue'
import { useI18n } from 'vue-i18n'
import IconButton from '@/components/common/IconButton.vue'
import useConnectionStore from 'stores/connections.js'
import Copy from '@/components/icons/Copy.vue'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
import { computed } from 'vue'
import { isEmpty, padStart } from 'lodash'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const props = defineProps({
server: String,
@ -45,7 +45,7 @@ const props = defineProps({
})
const dialogStore = useDialog()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const i18n = useI18n()
const binaryKey = computed(() => {
@ -78,7 +78,7 @@ const ttlString = computed(() => {
})
const onReloadKey = () => {
browserStore.loadKeyValue(props.server, props.db, keyName.value, props.viewAs, props.decode)
connectionStore.loadKeyValue(props.server, props.db, keyName.value, props.viewAs, props.decode)
}
const onCopyKey = () => {
@ -103,7 +103,7 @@ const onRenameKey = () => {
const onDeleteKey = () => {
$dialog.warning(i18n.t('dialogue.remove_tip', { name: props.keyPath }), () => {
browserStore.deleteKey(props.server, props.db, keyName.value).then((success) => {
connectionStore.deleteKey(props.server, props.db, keyName.value).then((success) => {
if (success) {
$message.success(i18n.t('dialogue.delete_key_succ', { key: props.keyPath }))
}

View File

@ -7,10 +7,10 @@ import { NButton, NCode, NIcon, NInput, useThemeVars } from 'naive-ui'
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
import useDialogStore from 'stores/dialog.js'
import useConnectionStore from 'stores/connections.js'
import { isEmpty } from 'lodash'
import bytes from 'bytes'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -60,7 +60,7 @@ const filterOption = [
]
const filterType = ref(1)
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const dialogStore = useDialogStore()
const keyType = redisTypes.HASH
const currentEditRow = ref({
@ -142,14 +142,14 @@ const actionColumn = {
},
onDelete: async () => {
try {
const { success, msg } = await browserStore.removeHashField(
const { success, msg } = await connectionStore.removeHashField(
props.name,
props.db,
keyName.value,
row.key,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.key }))
// update display value
// if (!isEmpty(removed)) {
@ -166,7 +166,7 @@ const actionColumn = {
},
onSave: async () => {
try {
const { success, msg } = await browserStore.setHash(
const { success, msg } = await connectionStore.setHash(
props.name,
props.db,
keyName.value,
@ -175,7 +175,7 @@ const actionColumn = {
currentEditRow.value.value,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.save_value_succ'))
// update display value
// if (!isEmpty(updated)) {

View File

@ -8,9 +8,9 @@ import { isEmpty, size } from 'lodash'
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
import useDialogStore from 'stores/dialog.js'
import useConnectionStore from 'stores/connections.js'
import bytes from 'bytes'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -48,7 +48,7 @@ const keyName = computed(() => {
return !isEmpty(props.keyCode) ? props.keyCode : props.keyPath
})
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const dialogStore = useDialogStore()
const keyType = redisTypes.LIST
const currentEditRow = ref({
@ -99,14 +99,14 @@ const actionColumn = {
},
onDelete: async () => {
try {
const { success, msg } = await browserStore.removeListItem(
const { success, msg } = await connectionStore.removeListItem(
props.name,
props.db,
keyName.value,
row.no - 1,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.delete_key_succ', { key: '#' + row.no }))
// update display value
// if (!isEmpty(removed)) {
@ -121,7 +121,7 @@ const actionColumn = {
},
onSave: async () => {
try {
const { success, msg } = await browserStore.updateListItem(
const { success, msg } = await connectionStore.updateListItem(
props.name,
props.db,
keyName.value,
@ -129,7 +129,7 @@ const actionColumn = {
currentEditRow.value.value,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.save_value_succ'))
// update display value
// if (!isEmpty(updated)) {

View File

@ -8,9 +8,9 @@ import { isEmpty, size } from 'lodash'
import useDialogStore from 'stores/dialog.js'
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
import useConnectionStore from 'stores/connections.js'
import bytes from 'bytes'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -48,7 +48,7 @@ const keyName = computed(() => {
return !isEmpty(props.keyCode) ? props.keyCode : props.keyPath
})
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const dialogStore = useDialogStore()
const keyType = redisTypes.SET
const currentEditRow = ref({
@ -100,14 +100,14 @@ const actionColumn = {
},
onDelete: async () => {
try {
const { success, msg } = await browserStore.removeSetItem(
const { success, msg } = await connectionStore.removeSetItem(
props.name,
props.db,
keyName.value,
row.value,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.value }))
// update display value
// props.value.splice(row.no - 1, 1)
@ -120,7 +120,7 @@ const actionColumn = {
},
onSave: async () => {
try {
const { success, msg } = await browserStore.updateSetItem(
const { success, msg } = await connectionStore.updateSetItem(
props.name,
props.db,
keyName.value,
@ -128,7 +128,7 @@ const actionColumn = {
currentEditRow.value.value,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.save_value_succ'))
// update display value
// props.value[row.no - 1] = currentEditRow.value.value

View File

@ -7,10 +7,10 @@ import { NButton, NCode, NIcon, NInput, useThemeVars } from 'naive-ui'
import { types, types as redisTypes } from '@/consts/support_redis_type.js'
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
import useDialogStore from 'stores/dialog.js'
import useConnectionStore from 'stores/connections.js'
import { includes, isEmpty, keys, some, values } from 'lodash'
import bytes from 'bytes'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -60,7 +60,7 @@ const filterOption = [
]
const filterType = ref(1)
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const dialogStore = useDialogStore()
const keyType = redisTypes.STREAM
const idColumn = reactive({
@ -108,14 +108,14 @@ const actionColumn = {
readonly: true,
onDelete: async () => {
try {
const { success, msg } = await browserStore.removeStreamValues(
const { success, msg } = await connectionStore.removeStreamValues(
props.name,
props.db,
keyName.value,
row.id,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.id }))
// update display value
// if (!isEmpty(removed)) {

View File

@ -10,12 +10,12 @@ import Close from '@/components/icons/Close.vue'
import { types as redisTypes } from '@/consts/support_redis_type.js'
import { ClipboardSetText } from 'wailsjs/runtime/runtime.js'
import { isEmpty, toLower } from 'lodash'
import useConnectionStore from 'stores/connections.js'
import DropdownSelector from '@/components/content_value/DropdownSelector.vue'
import Code from '@/components/icons/Code.vue'
import Conversion from '@/components/icons/Conversion.vue'
import EditFile from '@/components/icons/EditFile.vue'
import bytes from 'bytes'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -74,11 +74,11 @@ const viewLanguage = computed(() => {
})
const onViewTypeUpdate = (viewType) => {
browserStore.loadKeyValue(props.name, props.db, keyName.value, viewType, props.decode)
connectionStore.loadKeyValue(props.name, props.db, keyName.value, viewType, props.decode)
}
const onDecodeTypeUpdate = (decodeType) => {
browserStore.loadKeyValue(props.name, props.db, keyName.value, props.viewAs, decodeType)
connectionStore.loadKeyValue(props.name, props.db, keyName.value, props.viewAs, decodeType)
}
/**
@ -110,12 +110,12 @@ const onCancelEdit = () => {
/**
* Save value
*/
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const saving = ref(false)
const onSaveValue = async () => {
saving.value = true
try {
const { success, msg } = await browserStore.setKey(
const { success, msg } = await connectionStore.setKey(
props.name,
props.db,
keyName.value,
@ -126,7 +126,7 @@ const onSaveValue = async () => {
props.decode,
)
if (success) {
await browserStore.loadKeyValue(props.name, props.db, keyName.value)
await connectionStore.loadKeyValue(props.name, props.db, keyName.value)
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)

View File

@ -8,10 +8,10 @@ import ContentValueSet from '@/components/content_value/ContentValueSet.vue'
import ContentValueZset from '@/components/content_value/ContentValueZSet.vue'
import ContentValueStream from '@/components/content_value/ContentValueStream.vue'
import { useThemeVars } from 'naive-ui'
import useBrowserStore from 'stores/browser.js'
import useConnectionStore from 'stores/connections.js'
const themeVars = useThemeVars()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const props = defineProps({
blank: Boolean,
@ -54,7 +54,7 @@ const valueComponents = {
* @returns {Promise<null>}
*/
const onReloadKey = async () => {
await browserStore.loadKeyValue(props.name, props.db, props.key, props.viewAs)
await connectionStore.loadKeyValue(props.name, props.db, props.key, props.viewAs)
}
</script>

View File

@ -8,9 +8,9 @@ import { types, types as redisTypes } from '@/consts/support_redis_type.js'
import EditableTableColumn from '@/components/common/EditableTableColumn.vue'
import { isEmpty } from 'lodash'
import useDialogStore from 'stores/dialog.js'
import useConnectionStore from 'stores/connections.js'
import bytes from 'bytes'
import { decodeTypes, formatTypes } from '@/consts/value_view_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const themeVars = useThemeVars()
@ -60,7 +60,7 @@ const filterOption = [
]
const filterType = ref(1)
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const dialogStore = useDialogStore()
const keyType = redisTypes.ZSET
const currentEditRow = ref({
@ -171,14 +171,14 @@ const actionColumn = {
},
onDelete: async () => {
try {
const { success, msg } = await browserStore.removeZSetItem(
const { success, msg } = await connectionStore.removeZSetItem(
props.name,
props.db,
keyName.value,
row.value,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.delete_key_succ', { key: row.value }))
} else {
$message.error(msg)
@ -194,7 +194,7 @@ const actionColumn = {
$message.error(i18n.t('dialogue.spec_field_required', { key: i18n.t('common.value') }))
return
}
const { success, msg } = await browserStore.updateZSetItem(
const { success, msg } = await connectionStore.updateZSetItem(
props.name,
props.db,
keyName.value,
@ -203,7 +203,7 @@ const actionColumn = {
currentEditRow.value.score,
)
if (success) {
browserStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
connectionStore.loadKeyValue(props.name, props.db, keyName.value).then((r) => {})
$message.success(i18n.t('dialogue.save_value_succ'))
} else {
$message.error(msg)

View File

@ -8,9 +8,9 @@ import { useI18n } from 'vue-i18n'
import AddListValue from '@/components/new_value/AddListValue.vue'
import AddHashValue from '@/components/new_value/AddHashValue.vue'
import AddZSetValue from '@/components/new_value/AddZSetValue.vue'
import useConnectionStore from 'stores/connections.js'
import NewStreamValue from '@/components/new_value/NewStreamValue.vue'
import { isEmpty, size, slice } from 'lodash'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const newForm = reactive({
@ -78,7 +78,7 @@ watch(
},
)
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const onAdd = async () => {
try {
const { server, db, key, keyCode, type } = newForm
@ -92,14 +92,14 @@ const onAdd = async () => {
{
let data
if (newForm.opType === 1) {
data = await browserStore.prependListItem(server, db, keyName, value)
data = await connectionStore.prependListItem(server, db, keyName, value)
} else {
data = await browserStore.appendListItem(server, db, keyName, value)
data = await connectionStore.appendListItem(server, db, keyName, value)
}
const { success, msg } = data
if (success) {
if (newForm.reload) {
browserStore.loadKeyValue(server, db, keyName).then(() => {})
connectionStore.loadKeyValue(server, db, keyName).then(() => {})
}
$message.success(i18n.t('dialogue.handle_succ'))
} else {
@ -110,10 +110,16 @@ const onAdd = async () => {
case types.HASH:
{
const { success, msg } = await browserStore.addHashField(server, db, keyName, newForm.opType, value)
const { success, msg } = await connectionStore.addHashField(
server,
db,
keyName,
newForm.opType,
value,
)
if (success) {
if (newForm.reload) {
browserStore.loadKeyValue(server, db, keyName).then(() => {})
connectionStore.loadKeyValue(server, db, keyName).then(() => {})
}
$message.success(i18n.t('dialogue.handle_succ'))
} else {
@ -124,10 +130,10 @@ const onAdd = async () => {
case types.SET:
{
const { success, msg } = await browserStore.addSetItem(server, db, keyName, value)
const { success, msg } = await connectionStore.addSetItem(server, db, keyName, value)
if (success) {
if (newForm.reload) {
browserStore.loadKeyValue(server, db, keyName).then(() => {})
connectionStore.loadKeyValue(server, db, keyName).then(() => {})
}
$message.success(i18n.t('dialogue.handle_succ'))
} else {
@ -138,10 +144,16 @@ const onAdd = async () => {
case types.ZSET:
{
const { success, msg } = await browserStore.addZSetItem(server, db, keyName, newForm.opType, value)
const { success, msg } = await connectionStore.addZSetItem(
server,
db,
keyName,
newForm.opType,
value,
)
if (success) {
if (newForm.reload) {
browserStore.loadKeyValue(server, db, keyName).then(() => {})
connectionStore.loadKeyValue(server, db, keyName).then(() => {})
}
$message.success(i18n.t('dialogue.handle_succ'))
} else {
@ -153,7 +165,7 @@ const onAdd = async () => {
case types.STREAM:
{
if (size(value) > 2) {
const { success, msg } = await browserStore.addStreamValue(
const { success, msg } = await connectionStore.addStreamValue(
server,
db,
keyName,
@ -162,7 +174,7 @@ const onAdd = async () => {
)
if (success) {
if (newForm.reload) {
browserStore.loadKeyValue(server, db, keyName).then(() => {})
connectionStore.loadKeyValue(server, db, keyName).then(() => {})
}
$message.success(i18n.t('dialogue.handle_succ'))
} else {

View File

@ -9,7 +9,6 @@ import useConnectionStore from 'stores/connections.js'
import FileOpenInput from '@/components/common/FileOpenInput.vue'
import { KeyViewType } from '@/consts/key_view_type.js'
import { useThemeVars } from 'naive-ui'
import useBrowserStore from 'stores/browser.js'
/**
* Dialog for new or edit connection
@ -18,7 +17,6 @@ import useBrowserStore from 'stores/browser.js'
const themeVars = useThemeVars()
const dialogStore = useDialog()
const connectionStore = useConnectionStore()
const browserStore = useBrowserStore()
const i18n = useI18n()
const editName = ref('')
@ -47,7 +45,7 @@ const closingConnection = computed(() => {
if (isEmpty(editName.value)) {
return false
}
return browserStore.isConnected(editName.value)
return connectionStore.isConnected(editName.value)
})
const groupOptions = computed(() => {

View File

@ -2,8 +2,8 @@
import { reactive, watch } from 'vue'
import useDialog from 'stores/dialog'
import { useI18n } from 'vue-i18n'
import useConnectionStore from 'stores/connections.js'
import { isEmpty, size } from 'lodash'
import useBrowserStore from 'stores/browser.js'
const deleteForm = reactive({
server: '',
@ -16,7 +16,7 @@ const deleteForm = reactive({
})
const dialogStore = useDialog()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
watch(
() => dialogStore.deleteKeyDialogVisible,
(visible) => {
@ -36,7 +36,7 @@ watch(
const scanAffectedKey = async () => {
try {
deleteForm.loadingAffected = true
const { keys = [] } = await browserStore.scanKeys(deleteForm.server, deleteForm.db, deleteForm.key)
const { keys = [] } = await connectionStore.scanKeys(deleteForm.server, deleteForm.db, deleteForm.key)
deleteForm.affectedKeys = keys || []
deleteForm.showAffected = true
} finally {
@ -53,7 +53,7 @@ const i18n = useI18n()
const onConfirmDelete = async () => {
try {
const { server, db, key, async } = deleteForm
const success = await browserStore.deleteKeyPrefix(server, db, key, async)
const success = await connectionStore.deleteKeyPrefix(server, db, key, async)
if (success) {
$message.success(i18n.t('dialogue.handle_succ'))
}

View File

@ -2,7 +2,7 @@
import { reactive, watch } from 'vue'
import useDialog from 'stores/dialog'
import { useI18n } from 'vue-i18n'
import useBrowserStore from 'stores/browser.js'
import useConnectionStore from 'stores/connections.js'
const flushForm = reactive({
server: '',
@ -13,7 +13,7 @@ const flushForm = reactive({
})
const dialogStore = useDialog()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
watch(
() => dialogStore.flushDBDialogVisible,
(visible) => {
@ -31,7 +31,7 @@ const i18n = useI18n()
const onConfirmFlush = async () => {
try {
const { server, db, async } = flushForm
const success = await browserStore.flushDatabase(server, db, async)
const success = await connectionStore.flushDatabase(server, db, async)
if (success) {
$message.success(i18n.t('dialogue.handle_succ'))
}

View File

@ -2,8 +2,8 @@
import { computed, reactive, ref, watch } from 'vue'
import useDialog from 'stores/dialog'
import { useI18n } from 'vue-i18n'
import useConnectionStore from 'stores/connections.js'
import { types } from '@/consts/support_redis_type.js'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const filterForm = reactive({
@ -39,11 +39,11 @@ watch(
},
)
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const onConfirm = () => {
const { server, db, type, pattern } = filterForm
browserStore.setKeyFilter(server, db, pattern, type)
browserStore.reopenDatabase(server, db)
connectionStore.setKeyFilter(server, db, pattern, type)
connectionStore.reopenDatabase(server, db)
}
const onClose = () => {

View File

@ -10,10 +10,10 @@ import NewListValue from '@/components/new_value/NewListValue.vue'
import NewZSetValue from '@/components/new_value/NewZSetValue.vue'
import NewSetValue from '@/components/new_value/NewSetValue.vue'
import { useI18n } from 'vue-i18n'
import useConnectionStore from 'stores/connections.js'
import { NSpace } from 'naive-ui'
import useTabStore from 'stores/tab.js'
import NewStreamValue from '@/components/new_value/NewStreamValue.vue'
import useBrowserStore from 'stores/browser.js'
const i18n = useI18n()
const newForm = reactive({
@ -33,7 +33,7 @@ const formRules = computed(() => {
}
})
const dbOptions = computed(() =>
map(keys(browserStore.databases[newForm.server]), (key) => ({
map(keys(connectionStore.databases[newForm.server]), (key) => ({
label: key,
value: parseInt(key),
})),
@ -101,7 +101,7 @@ const renderTypeLabel = (option) => {
)
}
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const tabStore = useTabStore()
const onAdd = async () => {
await newFormRef.value?.validate().catch((err) => {
@ -117,7 +117,7 @@ const onAdd = async () => {
if (value == null) {
value = defaultValue[type]
}
const { success, msg, nodeKey } = await browserStore.setKey(
const { success, msg, nodeKey } = await connectionStore.setKey(
server,
db,
key,
@ -130,7 +130,7 @@ const onAdd = async () => {
if (success) {
// select current key
tabStore.setSelectedKeys(server, nodeKey)
browserStore.loadKeyValue(server, db, key).then(() => {})
connectionStore.loadKeyValue(server, db, key).then(() => {})
} else if (!isEmpty(msg)) {
$message.error(msg)
}

View File

@ -2,7 +2,7 @@
import { reactive, watch } from 'vue'
import useDialog from 'stores/dialog'
import { useI18n } from 'vue-i18n'
import useBrowserStore from 'stores/browser.js'
import useConnectionStore from 'stores/connections.js'
const renameForm = reactive({
server: '',
@ -12,7 +12,7 @@ const renameForm = reactive({
})
const dialogStore = useDialog()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
watch(
() => dialogStore.renameDialogVisible,
(visible) => {
@ -30,9 +30,9 @@ const i18n = useI18n()
const onRename = async () => {
try {
const { server, db, key, newKey } = renameForm
const { success, msg } = await browserStore.renameKey(server, db, key, newKey)
const { success, msg } = await connectionStore.renameKey(server, db, key, newKey)
if (success) {
await browserStore.loadKeyValue(server, db, newKey)
await connectionStore.loadKeyValue(server, db, newKey)
$message.success(i18n.t('dialogue.handle_succ'))
} else {
$message.error(msg)

View File

@ -2,9 +2,9 @@
import { reactive, watch } from 'vue'
import useDialog from 'stores/dialog'
import useTabStore from 'stores/tab.js'
import useConnectionStore from 'stores/connections.js'
import Binary from '@/components/icons/Binary.vue'
import { isEmpty } from 'lodash'
import useBrowserStore from 'stores/browser.js'
const ttlForm = reactive({
server: '',
@ -15,7 +15,7 @@ const ttlForm = reactive({
})
const dialogStore = useDialog()
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const tabStore = useTabStore()
watch(
@ -51,7 +51,7 @@ const onConfirm = async () => {
return
}
const key = isEmpty(ttlForm.keyCode) ? ttlForm.key : ttlForm.keyCode
const success = await browserStore.setTTL(tab.name, tab.db, key, ttlForm.ttl)
const success = await connectionStore.setTTL(tab.name, tab.db, key, ttlForm.ttl)
if (success) {
tabStore.updateTTL({
server: ttlForm.server,

View File

@ -8,6 +8,7 @@ import { get } from 'lodash'
import Refresh from '@/components/icons/Refresh.vue'
import useDialogStore from 'stores/dialog.js'
import { useI18n } from 'vue-i18n'
import useConnectionStore from 'stores/connections.js'
import { types } from '@/consts/support_redis_type.js'
import Search from '@/components/icons/Search.vue'
import Unlink from '@/components/icons/Unlink.vue'
@ -23,6 +24,7 @@ const onInfo = () => {
}
const i18n = useI18n()
const connectionStore = useConnectionStore()
const onDisconnect = () => {
browserTreeRef.value?.handleSelectContextMenu('server_close')
}
@ -53,7 +55,7 @@ const filterTypeOptions = computed(() => {
// const viewType = ref(0)
// const onSwitchView = (selectView) => {
// const { server } = tabStore.currentTab
// browserStore.switchKeyView(server, selectView)
// connectionStore.switchKeyView(server, selectView)
// }
</script>

View File

@ -25,7 +25,6 @@ import IconButton from '@/components/common/IconButton.vue'
import { parseHexColor } from '@/utils/rgb.js'
import LoadList from '@/components/icons/LoadList.vue'
import LoadAll from '@/components/icons/LoadAll.vue'
import useBrowserStore from 'stores/browser.js'
const props = defineProps({
server: String,
@ -38,7 +37,6 @@ const loading = ref(false)
const loadingConnections = ref(false)
const expandedKeys = ref([props.server])
const connectionStore = useConnectionStore()
const browserStore = useBrowserStore()
const tabStore = useTabStore()
const dialogStore = useDialogStore()
@ -55,7 +53,7 @@ const selectedKeys = computed(() => {
})
const data = computed(() => {
const dbs = get(browserStore.databases, props.server, [])
const dbs = get(connectionStore.databases, props.server, [])
return dbs
})
@ -231,7 +229,7 @@ const handleSelectContextMenu = (key) => {
if (selectedKey == null) {
return
}
const node = browserStore.getNode(selectedKey)
const node = connectionStore.getNode(selectedKey)
const { db = 0, key: nodeKey, redisKey: rk = '', redisKeyCode: rkc, label } = node || {}
const redisKey = rkc || rk
const redisKeyName = !!rkc ? label : redisKey
@ -243,23 +241,23 @@ const handleSelectContextMenu = (key) => {
case 'server_reload':
expandedKeys.value = [props.server]
tabStore.setSelectedKeys(props.server)
browserStore.openConnection(props.server, true).then(() => {
connectionStore.openConnection(props.server, true).then(() => {
$message.success(i18n.t('dialogue.reload_succ'))
})
break
case 'server_close':
browserStore.closeConnection(props.server)
connectionStore.closeConnection(props.server)
break
case 'db_open':
nextTick().then(() => expandKey(nodeKey))
break
case 'db_reload':
resetExpandKey(props.server, db)
browserStore.reopenDatabase(props.server, db)
connectionStore.reopenDatabase(props.server, db)
break
case 'db_close':
resetExpandKey(props.server, db, true)
browserStore.closeDatabase(props.server, db)
connectionStore.closeDatabase(props.server, db)
break
case 'db_flush':
dialogStore.openFlushDBDialog(props.server, db)
@ -269,21 +267,21 @@ const handleSelectContextMenu = (key) => {
dialogStore.openNewKeyDialog(redisKey, props.server, db)
break
case 'db_filter':
const { match: pattern, type } = browserStore.getKeyFilter(props.server, db)
const { match: pattern, type } = connectionStore.getKeyFilter(props.server, db)
dialogStore.openKeyFilterDialog(props.server, db, pattern, type)
break
// case 'key_reload':
// browserStore.loadKeys(props.server, db, redisKey)
// connectionStore.loadKeys(props.server, db, redisKey)
// break
case 'value_reload':
browserStore.loadKeyValue(props.server, db, redisKey)
connectionStore.loadKeyValue(props.server, db, redisKey)
break
case 'key_remove':
dialogStore.openDeleteKeyDialog(props.server, db, isEmpty(redisKey) ? '*' : redisKey + ':*')
break
case 'value_remove':
$dialog.warning(i18n.t('dialogue.remove_tip', { name: redisKeyName }), () => {
browserStore.deleteKey(props.server, db, redisKey).then((success) => {
connectionStore.deleteKey(props.server, db, redisKey).then((success) => {
if (success) {
$message.success(i18n.t('dialogue.delete_key_succ', { key: redisKeyName }))
}
@ -305,7 +303,7 @@ const handleSelectContextMenu = (key) => {
case 'db_loadmore':
if (node != null && !!!node.loading && !!!node.fullLoaded) {
node.loading = true
browserStore
connectionStore
.loadMoreKeys(props.server, db)
.then((end) => {
// fully loaded
@ -322,7 +320,7 @@ const handleSelectContextMenu = (key) => {
case 'db_loadall':
if (node != null && !!!node.loading) {
node.loading = true
browserStore
connectionStore
.loadAllKeys(props.server, db)
.catch((e) => {
$message.error(e.message)
@ -378,14 +376,14 @@ const onUpdateSelectedKeys = (keys, options) => {
const { key, db } = node
const redisKey = node.redisKeyCode || node.redisKey
if (!includes(selectedKeys.value, key)) {
browserStore.loadKeyValue(props.server, db, redisKey)
connectionStore.loadKeyValue(props.server, db, redisKey)
}
return
}
}
}
// default is load blank key to display server status
browserStore.loadKeyValue(props.server, 0)
connectionStore.loadKeyValue(props.server, 0)
} finally {
tabStore.setSelectedKeys(props.server, keys)
}
@ -436,7 +434,7 @@ const renderLabel = ({ option }) => {
return h('b', {}, { default: () => option.label })
case ConnectionType.RedisDB:
const { name: server, db, opened = false } = option
let { match: matchPattern, type: typeFilter } = browserStore.getKeyFilter(server, db)
let { match: matchPattern, type: typeFilter } = connectionStore.getKeyFilter(server, db)
const items = []
if (opened) {
items.push(`${option.label} (${option.keys || 0}/${Math.max(option.maxKeys || 0, option.keys || 0)})`)
@ -459,8 +457,8 @@ const renderLabel = ({ option }) => {
},
onClose: () => {
// remove type filter
browserStore.setKeyFilter(server, db, matchPattern)
browserStore.reopenDatabase(server, db)
connectionStore.setKeyFilter(server, db, matchPattern)
connectionStore.reopenDatabase(server, db)
},
},
{ default: () => typeFilter },
@ -478,8 +476,8 @@ const renderLabel = ({ option }) => {
size: 'small',
onClose: () => {
// remove key match pattern
browserStore.setKeyFilter(server, db, '*', typeFilter)
browserStore.reopenDatabase(server, db)
connectionStore.setKeyFilter(server, db, '*', typeFilter)
connectionStore.reopenDatabase(server, db)
},
},
{ default: () => matchPattern },
@ -654,7 +652,7 @@ const onLoadTree = async (node) => {
case ConnectionType.RedisDB:
loading.value = true
try {
await browserStore.openDatabase(props.server, node.db)
await connectionStore.openDatabase(props.server, node.db)
} catch (e) {
$message.error(e.message)
node.isLeaf = undefined

View File

@ -6,10 +6,12 @@ import AddLink from '@/components/icons/AddLink.vue'
import IconButton from '@/components/common/IconButton.vue'
import Filter from '@/components/icons/Filter.vue'
import ConnectionTree from './ConnectionTree.vue'
import useConnectionStore from 'stores/connections.js'
import { ref } from 'vue'
const themeVars = useThemeVars()
const dialogStore = useDialogStore()
const connectionStore = useConnectionStore()
const filterPattern = ref('')
</script>

View File

@ -19,13 +19,11 @@ import Edit from '@/components/icons/Edit.vue'
import { hexGammaCorrection, parseHexColor, toHexColor } from '@/utils/rgb.js'
import IconButton from '@/components/common/IconButton.vue'
import usePreferencesStore from 'stores/preferences.js'
import useBrowserStore from 'stores/browser.js'
const themeVars = useThemeVars()
const i18n = useI18n()
const connectingServer = ref('')
const connectionStore = useConnectionStore()
const browserStore = useBrowserStore()
const tabStore = useTabStore()
const prefStore = usePreferencesStore()
const dialogStore = useDialogStore()
@ -68,7 +66,7 @@ const menuOptions = {
},
],
[ConnectionType.Server]: ({ name }) => {
const connected = browserStore.isConnected(name)
const connected = connectionStore.isConnected(name)
if (connected) {
return [
{
@ -194,7 +192,7 @@ const renderPrefix = ({ option }) => {
},
)
case ConnectionType.Server:
const connected = browserStore.isConnected(option.name)
const connected = connectionStore.isConnected(option.name)
const color = getServerMarkColor(option.name)
const icon = option.cluster === true ? Cluster : Server
return h(
@ -267,7 +265,7 @@ const renderSuffix = ({ option }) => {
if (includes(selectedKeys.value, option.key)) {
switch (option.type) {
case ConnectionType.Server:
const connected = browserStore.isConnected(option.name)
const connected = connectionStore.isConnected(option.name)
return renderIconMenu(getServerMenu(connected))
case ConnectionType.Group:
return renderIconMenu(getGroupMenu())
@ -292,8 +290,8 @@ const onUpdateSelectedKeys = (keys, option) => {
const openConnection = async (name) => {
try {
connectingServer.value = name
if (!browserStore.isConnected(name)) {
await browserStore.openConnection(name)
if (!connectionStore.isConnected(name)) {
await connectionStore.openConnection(name)
}
// check if connection already canceled before finish open
if (!isEmpty(connectingServer.value)) {
@ -390,9 +388,9 @@ const handleSelectContextMenu = (key) => {
break
case 'server_edit':
// ask for close relevant connections before edit
if (browserStore.isConnected(name)) {
if (connectionStore.isConnected(name)) {
$dialog.warning(i18n.t('dialogue.edit_close_confirm'), () => {
browserStore.closeConnection(name)
connectionStore.closeConnection(name)
dialogStore.openEditDialog(name)
})
} else {
@ -406,7 +404,7 @@ const handleSelectContextMenu = (key) => {
removeConnection(name)
break
case 'server_close':
browserStore.closeConnection(name).then((closed) => {
connectionStore.closeConnection(name).then((closed) => {
if (closed) {
$message.success(i18n.t('dialogue.handle_succ'))
}
@ -477,7 +475,7 @@ const handleDrop = ({ node, dragNode, dropPosition }) => {
const onCancelOpen = () => {
if (!isEmpty(connectingServer.value)) {
browserStore.closeConnection(connectingServer.value)
connectionStore.closeConnection(connectingServer.value)
connectingServer.value = ''
}
}

View File

@ -9,10 +9,10 @@ import Config from '@/components/icons/Config.vue'
import useDialogStore from 'stores/dialog.js'
import Github from '@/components/icons/Github.vue'
import { BrowserOpenURL } from 'wailsjs/runtime/runtime.js'
import useConnectionStore from 'stores/connections.js'
import usePreferencesStore from 'stores/preferences.js'
import Record from '@/components/icons/Record.vue'
import { extraTheme } from '@/utils/extra_theme.js'
import useBrowserStore from 'stores/browser.js'
const themeVars = useThemeVars()
@ -34,7 +34,7 @@ const renderIcon = (icon) => {
return () => h(NIcon, null, { default: () => h(icon, { strokeWidth: 3 }) })
}
const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const i18n = useI18n()
const menuOptions = computed(() => {
return [
@ -42,7 +42,7 @@ const menuOptions = computed(() => {
label: i18n.t('ribbon.browser'),
key: 'browser',
icon: renderIcon(Database),
show: browserStore.anyConnectionOpened,
show: connectionStore.anyConnectionOpened,
},
{
label: i18n.t('ribbon.server'),

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -12,7 +12,6 @@ export const themeOverrides = {
primaryColorSuppl: '#FF6B6B',
borderRadius: '4px',
borderRadiusSmall: '3px',
heightMedium: '32px',
lineHeight: 1.5,
scrollbarWidth: '8px',
tabColor: '#FFFFFF',

View File

@ -29,7 +29,6 @@ func main() {
// Create an instance of the app structure
sysSvc := services.System()
connSvc := services.Connection()
browserSvc := services.Browser()
cliSvc := services.Cli()
prefSvc := services.Preferences()
prefSvc.SetAppVersion(version)
@ -60,7 +59,6 @@ func main() {
OnStartup: func(ctx context.Context) {
sysSvc.Start(ctx)
connSvc.Start(ctx)
browserSvc.Start(ctx)
cliSvc.Start(ctx)
services.GA().SetSecretKey(gaMeasurementID, gaSecretKey)
@ -70,13 +68,12 @@ func main() {
runtime2.WindowShow(ctx)
},
OnShutdown: func(ctx context.Context) {
browserSvc.Stop()
connSvc.Stop()
cliSvc.CloseAll()
},
Bind: []interface{}{
sysSvc,
connSvc,
browserSvc,
cliSvc,
prefSvc,
},