fix(redis): exclude empty commands from history navigation

- Empty commands show temporary error hint (1s) but not added to history
- Arrow key navigation skips empty command entries
- Add appendCommandOutput helper for transient feedback
This commit is contained in:
t8y2
2026-06-21 18:55:01 +08:00
parent dbc8668ced
commit fae644b888
@@ -428,6 +428,17 @@ function appendCommandHistory(entry: Omit<RedisCommandHistoryEntry, "id">) {
scrollCommandTerminalToEnd();
}
function appendCommandOutput(entry: Omit<RedisCommandHistoryEntry, "id">) {
// 显示输出但不记入历史(用于错误提示、空命令提示等)
const tempEntry = { id: ++commandHistoryId, ...entry };
commandHistory.value = [...commandHistory.value, tempEntry];
scrollCommandTerminalToEnd();
// 1秒后自动移除提示
setTimeout(() => {
commandHistory.value = commandHistory.value.filter((e) => e.id !== tempEntry.id);
}, 1000);
}
async function runRedisCommand(command: string) {
const prompt = commandPrompt.value;
commandRunning.value = true;
@@ -682,7 +693,8 @@ async function createRedisKey() {
async function executeCommand() {
const command = commandText.value.trim();
if (!command) {
appendCommandHistory({
// 空命令显示提示但不记入历史
appendCommandOutput({
prompt: commandPrompt.value,
command: "",
output: t("redis.commandEmpty"),