Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

fix: history context menu view details unresponsive and delete missing confirmation

t8y21c0391760971
diff --git a/apps/desktop/src/components/editor/QueryHistory.vue b/apps/desktop/src/components/editor/QueryHistory.vue
index fee07a017e..a0995f4e48 100644
--- a/apps/desktop/src/components/editor/QueryHistory.vue
+++ b/apps/desktop/src/components/editor/QueryHistory.vue
@@ -9,7 +9,6 @@ import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
import { useHistoryStore } from "@/stores/historyStore";
import { useToast } from "@/composables/useToast";
-import { shouldClearHistory, shouldDeleteHistoryEntry } from "@/lib/historyActions";
import { resolveHistoryActivityKind } from "@/lib/historyActivityKind";
import { canRollbackHistoryEntry } from "@/lib/historyAiAnalysis";
import { HISTORY_ROW_HEIGHT, HISTORY_SCROLL_BUFFER, shouldVirtualizeHistory } from "@/lib/historyVirtualList";
@@ -34,6 +33,9 @@ const searchText = ref("");
const activeFilter = ref<HistoryFilter>("all");
const selectedEntry = ref<HistoryEntry | null>(null);
const isRollingBack = ref(false);
+const showDeleteConfirm = ref(false);
+const showClearConfirm = ref(false);
+const deleteTargetId = ref<string | null>(null);
const filters: HistoryFilter[] = ["all", "query", "data_change", "schema_change", "failed"];
@@ -70,17 +72,29 @@ async function copyText(text: string) {
}
function confirmDeleteEntry(id: string) {
- if (shouldDeleteHistoryEntry(() => window.confirm(t("history.confirmDelete")))) {
- store.remove(id);
+ deleteTargetId.value = id;
+ showDeleteConfirm.value = true;
+}
+
+function executeDelete() {
+ if (deleteTargetId.value) {
+ store.remove(deleteTargetId.value);
+ deleteTargetId.value = null;
}
+ showDeleteConfirm.value = false;
}
function confirmClearHistory() {
- if (shouldClearHistory(store.entries.length, () => window.confirm(t("history.confirmClear")))) {
- store.clear();
+ if (store.entries.length > 0) {
+ showClearConfirm.value = true;
}
}
+function executeClear() {
+ store.clear();
+ showClearConfirm.value = false;
+}
+
function formatTime(iso: string): string {
const d = new Date(iso);
const pad = (n: number) => String(n).padStart(2, "0");
@@ -172,7 +186,12 @@ async function rollback(entry: HistoryEntry) {
function getHistoryMenuItems(entry: HistoryEntry): ContextMenuItem[] {
return [
- { label: t("history.viewDetails"), action: () => (selectedEntry = entry) },
+ {
+ label: t("history.viewDetails"),
+ action: () => {
+ selectedEntry.value = entry;
+ },
+ },
{ label: t("history.restore"), action: () => restore(entry) },
{ label: t("history.analyzeWithAi"), action: () => emit("analyzeAi", entry), icon: Sparkles },
{ label: t("history.copy"), action: () => copyText(entry.sql) },
@@ -328,5 +347,31 @@ onMounted(() => store.load());
</DialogFooter>
</DialogContent>
</Dialog>
+
+ <Dialog v-model:open="showDeleteConfirm">
+ <DialogContent class="sm:max-w-[400px]">
+ <DialogHeader>
+ <DialogTitle>{{ t("history.delete") }}</DialogTitle>
+ </DialogHeader>
+ <p class="text-sm text-muted-foreground">{{ t("history.confirmDelete") }}</p>
+ <DialogFooter>
+ <Button variant="outline" @click="showDeleteConfirm = false">{{ t("dangerDialog.cancel") }}</Button>
+ <Button variant="destructive" @click="executeDelete">{{ t("dangerDialog.confirm") }}</Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
+ <Dialog v-model:open="showClearConfirm">
+ <DialogContent class="sm:max-w-[400px]">
+ <DialogHeader>
+ <DialogTitle>{{ t("history.clear") }}</DialogTitle>
+ </DialogHeader>
+ <p class="text-sm text-muted-foreground">{{ t("history.confirmClear") }}</p>
+ <DialogFooter>
+ <Button variant="outline" @click="showClearConfirm = false">{{ t("dangerDialog.cancel") }}</Button>
+ <Button variant="destructive" @click="executeClear">{{ t("dangerDialog.confirm") }}</Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
</div>
</template>
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index d187eb5871..8068a2c7d9 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -1133,6 +1133,7 @@ export default {
restore: "Restore to editor",
copy: "Copy SQL",
delete: "Delete",
+ clear: "Clear History",
viewDetails: "View details",
analyzeWithAi: "Analyze with AI",
aiAnalyzeNoConnection: "Cannot analyze this history entry because its connection no longer exists.",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 19458aee12..a3982e2554 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -1110,6 +1110,7 @@ export default {
restore: "恢复到编辑器",
copy: "复制 SQL",
delete: "删除",
+ clear: "清空历史",
viewDetails: "查看详情",
analyzeWithAi: "AI 分析",
aiAnalyzeNoConnection: "无法分析这条历史记录:对应连接已不存在。",