Compare commits

..

3 Commits

Author SHA1 Message Date
Lykin cc696f9642 perf: clear key filter after switch database 2024-03-25 17:42:19 +08:00
Lykin adf9e4347f chore: update button description (#196) 2024-03-25 16:22:51 +08:00
Lykin 41d0dc6ffc perf: keys containing numbers are sorted by size first (#198) 2024-03-25 16:22:51 +08:00
11 changed files with 64 additions and 23 deletions

View File

@ -44,6 +44,7 @@ const browserStore = useBrowserStore()
const connectionStore = useConnectionStore()
const render = useRender()
const browserTreeRef = ref(null)
const filterInputRef = ref(null)
const loading = ref(false)
const fullyLoaded = ref(false)
const inCheckState = ref(false)
@ -207,6 +208,7 @@ const handleSelectDB = async (db) => {
loading.value = true
browserStore.setKeyFilter(props.server, {})
browserStore.closeDatabase(props.server, props.db)
filterInputRef.value?.reset()
await browserStore.openDatabase(props.server, db)
await nextTick()
await connectionStore.saveLastDB(props.server, db)
@ -291,6 +293,7 @@ watch(
<!-- top function bar -->
<div class="flex-box-h nav-pane-func" style="height: 36px">
<content-search-input
ref="filterInputRef"
:debounce-wait="1000"
:full-search-icon="Search"
small

View File

@ -456,7 +456,7 @@
"copy_log": "Copy Log",
"save_log": "Save Log",
"clean_log": "Clean Log",
"always_show_last": "Always Show Latest"
"always_show_last": "Auto Scroll to Latest"
},
"pubsub": {
"title": "Pub/Sub",
@ -469,6 +469,6 @@
"channel": "Channel",
"message": "Message",
"receive_message": "Received {total} messages",
"always_show_last": "Always Show Latest"
"always_show_last": "Auto Scroll to Latest"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "Copiar registro",
"save_log": "Guardar registro",
"clean_log": "Limpiar registro",
"always_show_last": "Siempre mostrar el último"
"always_show_last": "Desplazamiento automático al último"
},
"pubsub": {
"title": "Pub/Sub",
@ -469,6 +469,6 @@
"channel": "Canal",
"message": "Mensaje",
"receive_message": "Recibidos {total} mensajes",
"always_show_last": "Siempre mostrar el último"
"always_show_last": "Desplazamiento automático al último"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "Copier le journal",
"save_log": "Enregistrer le journal",
"clean_log": "Nettoyer le journal",
"always_show_last": "Toujours afficher les dernières"
"always_show_last": "Défilement automatique vers le dernier message"
},
"pubsub": {
"title": "Pub/Sub",
@ -469,6 +469,6 @@
"channel": "Canal",
"message": "Message",
"receive_message": "{total} messages reçus",
"always_show_last": "Toujours afficher les derniers"
"always_show_last": "Défilement automatique vers le dernier message"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "ログをコピー",
"save_log": "ログを保存",
"clean_log": "ログをクリア",
"always_show_last": "最新を常に表示"
"always_show_last": "最新に自動スクロール"
},
"pubsub": {
"title": "パブ/サブ",
@ -469,6 +469,6 @@
"channel": "チャンネル",
"message": "メッセージ",
"receive_message": "{total}件のメッセージを受信しました",
"always_show_last": "最新を常に表示"
"always_show_last": "最新に自動スクロール"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "로그 복사",
"save_log": "로그 저장",
"clean_log": "로그 지우기",
"always_show_last": "최신 항목 계속 표시"
"always_show_last": "최신 내용으로 자동 스크롤"
},
"pubsub": {
"title": "Pub/Sub",
@ -469,6 +469,6 @@
"channel": "채널",
"message": "메시지",
"receive_message": "{total}개의 메시지를 받았습니다",
"always_show_last": "최신 항목 계속 표시"
"always_show_last": "최신 내용으로 자동 스크롤"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "Copiar Log",
"save_log": "Salvar Log",
"clean_log": "Limpar Log",
"always_show_last": "Sempre Mostrar o Mais Recente"
"always_show_last": "Rolar automaticamente para o mais recente"
},
"pubsub": {
"title": "Pub/Sub",
@ -469,6 +469,6 @@
"channel": "Canal",
"message": "Mensagem",
"receive_message": "Recebidas {total} mensagens",
"always_show_last": "Sempre Mostrar o Mais Recente"
"always_show_last": "Rolar automaticamente para o mais recente"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "Копировать журнал",
"save_log": "Сохранить журнал",
"clean_log": "Очистить журнал",
"always_show_last": "Всегда показывать последние"
"always_show_last": "Автоматическая прокрутка к последнему"
},
"pubsub": {
"title": "Публикация/Подписка",
@ -469,6 +469,6 @@
"channel": "Канал",
"message": "Сообщение",
"receive_message": "Получено сообщений: {total}",
"always_show_last": "Всегда показывать последние"
"always_show_last": "Автоматическая прокрутка к последнему"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "复制日志",
"save_log": "保存日志",
"clean_log": "清空日志",
"always_show_last": "总是显示最新"
"always_show_last": "自动滚到最新"
},
"pubsub": {
"title": "发布订阅",
@ -469,6 +469,6 @@
"channel": "频道",
"message": "消息",
"receive_message": "已接收消息 {total} 条",
"always_show_last": "总是显示最新"
"always_show_last": "自动滚到最新"
}
}

View File

@ -456,7 +456,7 @@
"copy_log": "複製日誌",
"save_log": "儲存日誌",
"clean_log": "清空日誌",
"always_show_last": "總是顯示最新"
"always_show_last": "自動捲動到最新"
},
"pubsub": {
"title": "發佈訂閱",
@ -469,6 +469,6 @@
"channel": "頻道",
"message": "訊息",
"receive_message": "已接收訊息 {total} 條",
"always_show_last": "總是顯示最新"
"always_show_last": "自動捲動到最新"
}
}

View File

@ -1,4 +1,4 @@
import { isEmpty, remove, size, sortedIndexBy, sumBy } from 'lodash'
import { isEmpty, remove, size, sumBy } from 'lodash'
import { ConnectionType } from '@/consts/connection_type.js'
/**
@ -68,6 +68,46 @@ export class RedisNodeItem {
})
}
/**
* compare two items to determine the sort order
* @param {*} a
* @param {*} b
* @return {number}
*/
_sortingCompare(a, b) {
if (a.type !== b.type) {
return a.type - b.type
}
const isANum = isNaN(a.label)
const isBNum = isNaN(b.label)
if (!isANum && !isBNum) {
return parseInt(a.label, 10) - parseInt(b.label, 10)
} else if (!isANum) {
return -1
} else if (!isBNum) {
return 1
}
return a.label.localeCompare(b.label)
}
/**
* calculate insert sorted index
* @param {[]} arr
* @param {*} item
* @return {number}
*/
_sortedIndex(arr, item) {
for (let i = 0; i < arr.length; i++) {
const cmpResult = this._sortingCompare(arr[i], item)
if (cmpResult > 0) {
return i
} else if (cmpResult === 0) {
return i + 1
}
}
return arr.length
}
/**
* sort all node item's children and calculate keys count
* @param skipSort skip sorting children
@ -98,9 +138,7 @@ export class RedisNodeItem {
}
sortChildren() {
this.children.sort((a, b) => {
return a.key > b.key ? 1 : -1
})
this.children.sort(this._sortingCompare)
}
/**
@ -112,7 +150,7 @@ export class RedisNodeItem {
if (!!!sorted) {
this.children.push(child)
} else {
const idx = sortedIndexBy(this.children, child, 'key')
const idx = this._sortedIndex(this.children, child)
this.children.splice(idx, 0, child)
}
}