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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
feat(sql-files): add keyboard navigation and configurable opening (#13076)
二丫讲梵163a4e5030af
diff --git a/apps/desktop/src/components/layout/SqlFilePanel.vue b/apps/desktop/src/components/layout/SqlFilePanel.vueindex 59d5242967..d4bee8f752 100644--- a/apps/desktop/src/components/layout/SqlFilePanel.vue+++ b/apps/desktop/src/components/layout/SqlFilePanel.vue@@ -1,5 +1,5 @@<script setup lang="ts">-import { ref, computed, nextTick, onMounted, watch } from "vue";+import { ref, computed, nextTick, onMounted, watch, useId } from "vue";import { useI18n } from "vue-i18n";import { FolderOpen, FolderClosed, FileCode, FolderPlus, ChevronRight, ChevronDown, X, Trash2, RefreshCw, FolderSearch, Copy, Play, ChevronsUpDown, ChevronsDownUp, Settings, FilePlus, Pencil, Search, ArrowDownAZ, ArrowUpAZ } from "@lucide/vue";import { Button } from "@/components/ui/button";@@ -23,7 +23,8 @@ import * as api from "@/lib/backend/api";import type { SqlFileEntry } from "@/lib/backend/api";import { getSqlFileFilter, getSqlFileFolderPaths, saveSqlFileFilter, saveSqlFileFolderPaths, notifySqlFileFoldersChanged } from "@/lib/sqlFile/sqlFileFolders";import { filterAndSortSqlFileEntries, getSqlFileSortOrder, saveSqlFileSortOrder, type SqlFileSortOrder } from "@/lib/sql/sqlFileTreeFilter";-import { orderedListRangeAnchorIndex, orderedListSelectionIntent, type OrderedListSelectionItem } from "@/lib/selection/orderedListSelection";+import { orderedListSelectionIntent, type OrderedListSelectionItem } from "@/lib/selection/orderedListSelection";+import { getSqlFileOpenMode, saveSqlFileOpenMode, type SqlFileOpenMode } from "@/lib/sqlFile/sqlFileInteraction";const emit = defineEmits<{close: [];@@ -52,6 +53,10 @@ const currentFilePath = computed(() => {});const filterSettingsOpen = ref(false);const fileFilterDraft = ref(getSqlFileFilter());+const openMode = ref<SqlFileOpenMode>(getSqlFileOpenMode());+const openModeDraft = ref<SqlFileOpenMode>(openMode.value);+const treeId = useId();+let lastClickedKey: string | null = null;const fileFilterRegexExample = "(?i)[.](sql|ddl|sh|py)$";const searchText = ref("");@@ -94,9 +99,9 @@ const showRenameFolderDialog = ref(false);const showDeleteDialog = ref(false);const showDeleteFolderDialog = ref(false);-const selectedPaths = ref<Set<string>>(new Set());-const activePath = ref<string | null>(null);-const selectionAnchorIndex = ref<number | null>(null);+const selectedKeys = ref<Set<string>>(new Set());+const activeKey = ref<string | null>(null);+const selectionAnchorKey = ref<string | null>(null);function findFileAncestors(entries: SqlFileEntry[], path: string): string[] | null {for (const entry of entries) {@@ -125,7 +130,7 @@ async function locateActiveFile() {const target = activeFileTarget.value;if (!target) return;if (searchText.value) {- const isVisibleNow = visibleItems.value.some((item) => item.type === "file" && normalizeExternalSqlPath(item.id) === target.path);+ const isVisibleNow = visibleItems.value.some((item) => item.folder === target.folder && item.type === "file" && normalizeExternalSqlPath(item.path) === target.path);if (!isVisibleNow) {searchText.value = "";await nextTick();@@ -133,25 +138,45 @@ async function locateActiveFile() {}target.folder.collapsed = false;target.folder.expanded = new Set([...target.folder.expanded, ...target.ancestors]);- const itemIndex = visibleItems.value.findIndex((item) => item.type === "file" && normalizeExternalSqlPath(item.id) === target.path);+ const itemIndex = visibleItems.value.findIndex((item) => item.folder === target.folder && item.type === "file" && normalizeExternalSqlPath(item.path) === target.path);const item = visibleItems.value[itemIndex];if (!item) return;- selectedPaths.value = new Set();- activePath.value = item.id;- selectionAnchorIndex.value = itemIndex;+ selectedKeys.value = new Set();+ activeKey.value = item.id;+ selectionAnchorKey.value = item.id;await nextTick();- const row = Array.from(fileTree.value?.querySelectorAll<HTMLElement>("[data-sql-file-path]") ?? []).find((row) => normalizeExternalSqlPath(row.dataset.sqlFilePath!) === target.path);+ const row = document.getElementById(`${treeId}-row-${activeItemIndex.value}`);row?.scrollIntoView({ block: "center", inline: "nearest" });}function clearSelection() {- selectedPaths.value = new Set();- activePath.value = null;- selectionAnchorIndex.value = null;+ selectedKeys.value = new Set();+ activeKey.value = null;+ selectionAnchorKey.value = null;}-function isPathHighlighted(path: string) {- return activePath.value === path || selectedPaths.value.has(path);+type NodeKind = "folderHeader" | "dir" | "file";++function nodeKey(rootPath: string, kind: NodeKind, path: string): string {+ // A path may appear under multiple opened roots, or as both a root and a child.+ return JSON.stringify([normalizeExternalSqlPath(rootPath), kind, normalizeExternalSqlPath(path)]);+}++function isPathHighlighted(rootPath: string, kind: NodeKind, path: string) {+ const key = nodeKey(rootPath, kind, path);+ return activeKey.value === key || selectedKeys.value.has(key);+}++function remapSelectionPaths(mapPath: (path: string) => string | null) {+ const remapKey = (key: string): string | null => {+ const [rootPath, kind, path] = JSON.parse(key) as [string, NodeKind, string];+ const root = mapPath(rootPath);+ const mapped = mapPath(path);+ return root !== null && mapped !== null ? nodeKey(root, kind, mapped) : null;+ };+ selectedKeys.value = new Set([...selectedKeys.value].map(remapKey).filter((key): key is string => key !== null));+ activeKey.value = activeKey.value ? remapKey(activeKey.value) : null;+ selectionAnchorKey.value = selectionAnchorKey.value ? remapKey(selectionAnchorKey.value) : null;}function loadSavedFolders(): string[] {@@ -254,8 +279,7 @@ async function loadFolderEntries(folderPath: string): Promise<string | null> {if (displayPath && stillPresent.has(displayPath)) nextExpanded.add(displayPath);}folders.value[target].expanded = nextExpanded;- selectedPaths.value = new Set([...selectedPaths.value].map((path) => displayPaths.get(normalizeExternalSqlPath(path)) ?? path));- if (activePath.value) activePath.value = displayPaths.get(normalizeExternalSqlPath(activePath.value)) ?? activePath.value;+ // Selection keys already normalize both root and entry paths.}} catch (e: any) {const message = e?.message || String(e);@@ -291,6 +315,10 @@ async function refreshAll() {async function saveFileFilter() {const previousFilter = getSqlFileFilter();+ if (fileFilterDraft.value.trim() === previousFilter) {+ commitInteractionSettings();+ return;+ }saveSqlFileFilter(fileFilterDraft.value);const errors = await Promise.all(folders.value.map((f) => loadFolderEntries(f.path)));// An unparsable pattern must not survive in localStorage: it would fail@@ -302,11 +330,17 @@ async function saveFileFilter() {toast(t("sqlFileTree.filterInvalid", { message: invalidFilter }), 5000);return;}- filterSettingsOpen.value = false;+ commitInteractionSettings();notifySqlFileFoldersChanged();toast(t("sqlFileTree.refreshed"), 1500);}+function commitInteractionSettings() {+ openMode.value = openModeDraft.value;+ saveSqlFileOpenMode(openMode.value);+ filterSettingsOpen.value = false;+}+async function reloadFolderAfterMutation(folderPath: string) {await loadFolderEntries(folderPath);notifySqlFileFoldersChanged();@@ -500,46 +534,143 @@ function flatTree(entries: SqlFileEntry[], expanded: Set<string>): TreeEntry[] {return result;}-const visibleItems = computed<OrderedListSelectionItem[]>(() => {- const items: OrderedListSelectionItem[] = [];+type VisibleItem = OrderedListSelectionItem & { type: NodeKind; path: string; folder: FolderState; entry?: SqlFileEntry };+const visibleItems = computed<VisibleItem[]>(() => {+ const items: VisibleItem[] = [];for (const folder of folders.value) {- items.push({ type: "folderHeader", id: folder.path });- if (!isFolderContentVisible(folder)) continue;+ items.push({ type: "folderHeader", id: nodeKey(folder.path, "folderHeader", folder.path), path: folder.path, folder });+ if (folder.loading || !isFolderContentVisible(folder)) continue;for (const { entry } of flatTree(getProcessedEntries(folder.path), getEffectiveExpanded(folder))) {- items.push({ type: entry.is_dir ? "dir" : "file", id: entry.path });+ const type = entry.is_dir ? "dir" : "file";+ items.push({ type, id: nodeKey(folder.path, type, entry.path), path: entry.path, folder, entry });}}return items;});+const visibleRowIds = computed(() => {+ const ids = new Map<FolderState, Map<string, string>>();+ visibleItems.value.forEach((item, index) => {+ let folderIds = ids.get(item.folder);+ if (!folderIds) {+ folderIds = new Map();+ ids.set(item.folder, folderIds);+ }+ folderIds.set(item.path, `${treeId}-row-${index}`);+ });+ return ids;+});++const activeItemIndex = computed(() => visibleItems.value.findIndex((item) => item.id === activeKey.value));++function focusTree() {+ fileTree.value?.focus({ preventScroll: true });+}++function restoreTreeFocus(event: Event) {+ event.preventDefault();+ focusTree();+}++async function scrollActiveRow() {+ await nextTick();+ document.getElementById(`${treeId}-row-${activeItemIndex.value}`)?.scrollIntoView({ block: "nearest" });+}++// Preserve identity across sorting; replace hidden or removed selection only once+// all roots have finished loading, so refresh does not discard the active file.+watch(visibleItems, (items, previous) => {+ if (folders.value.some((folder) => folder.loading)) return;+ const ids = new Set(items.map((item) => item.id));+ selectedKeys.value = new Set([...selectedKeys.value].filter((key) => ids.has(key)));+ if (activeKey.value && !ids.has(activeKey.value)) {+ const oldIndex = previous.findIndex((item) => item.id === activeKey.value);+ activeKey.value = items[Math.min(Math.max(oldIndex, 0), items.length - 1)]?.id ?? null;+ }+ // Resolve the anchor by identity: callers may have already selected a node+ // in the new list before this watcher runs (for example, Locate Current File).+ if (selectionAnchorKey.value && !ids.has(selectionAnchorKey.value)) {+ selectionAnchorKey.value = activeKey.value;+ }+ if (document.activeElement === fileTree.value) void scrollActiveRow();+});++function activateItem(item: VisibleItem) {+ if (item.folder.loading) return;+ if (item.type === "folderHeader") toggleFolderCollapse(item.folder);+ else if (item.type === "dir") toggleExpand(item.folder, item.path);+ else void openFile(item.path);+}++function handleTreeKeydown(event: KeyboardEvent) {+ if (event.target !== fileTree.value || event.isComposing || event.ctrlKey || event.metaKey || event.altKey || event.shiftKey) return;+ if (contextTarget.value || filterSettingsOpen.value || showCreateDialog.value || showCreateFolderDialog.value || showRenameDialog.value || showRenameFolderDialog.value || showDeleteDialog.value || showDeleteFolderDialog.value) return;+ const items = visibleItems.value;+ if (!items.length) return;+ const index = activeItemIndex.value;+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {+ const nextIndex = index < 0 ? (event.key === "ArrowDown" ? 0 : items.length - 1) : Math.max(0, Math.min(items.length - 1, index + (event.key === "ArrowDown" ? 1 : -1)));+ activeKey.value = items[nextIndex].id;+ selectedKeys.value = new Set();+ selectionAnchorKey.value = items[nextIndex].id;+ void scrollActiveRow();+ } else if (event.key === "Enter" || event.key === " " || event.key === "F2") {+ const item = items[index];+ if (!item || [...selectedKeys.value].some((key) => key !== item.id)) return;+ if (event.key === "F2") {+ if (!item.entry || item.folder.loading) return;+ if (!event.repeat) {+ if (item.type === "dir") openRenameFolderDialog({ kind: "dir", folderPath: item.folder.path, entry: item.entry });+ else openRenameDialog({ kind: "file", folderPath: item.folder.path, entry: item.entry });+ }+ } else if (!event.repeat) activateItem(item);+ } else return;+ event.preventDefault();+ event.stopPropagation();+}++function handlePathDoubleClick(rootPath: string, path: string, type: NodeKind, event: MouseEvent) {+ event.stopPropagation();+ if ((event.target as HTMLElement | null)?.closest("button, input, select, textarea, [contenteditable='true']")) return;+ if (openMode.value !== "double" || orderedListSelectionIntent(event) !== "single" || event.altKey) return;+ const key = nodeKey(rootPath, type, path);+ const item = visibleItems.value.find((item) => item.id === key);+ if (item) activateItem(item);+}+function selectedRangeAnchorIndex() {- const activeItem = activePath.value ? (visibleItems.value.find((item) => item.id === activePath.value) ?? null) : null;- return orderedListRangeAnchorIndex(visibleItems.value, selectionAnchorIndex.value, activeItem);+ const anchorIndex = visibleItems.value.findIndex((item) => item.id === selectionAnchorKey.value);+ if (anchorIndex >= 0) return anchorIndex;+ return activeItemIndex.value >= 0 ? activeItemIndex.value : null;}function selectRangeTo(currentIndex: number) {const anchorIndex = selectedRangeAnchorIndex();if (anchorIndex === null) {const current = visibleItems.value[currentIndex];- selectedPaths.value = new Set(current ? [current.id] : []);- selectionAnchorIndex.value = currentIndex;+ selectedKeys.value = new Set(current ? [current.id] : []);+ selectionAnchorKey.value = current?.id ?? null;return;}const start = Math.min(anchorIndex, currentIndex);const end = Math.max(anchorIndex, currentIndex);- const next = new Set(selectedPaths.value);+ const next = new Set(selectedKeys.value);for (let i = start; i <= end; i++) {const item = visibleItems.value[i];if (item) next.add(item.id);}- selectedPaths.value = next;+ selectedKeys.value = next;}-function handlePathClick(path: string, type: OrderedListSelectionItem["type"], event: MouseEvent, activate: () => void) {- const currentIndex = visibleItems.value.findIndex((item) => item.id === path && item.type === type);+function handlePathClick(rootPath: string, path: string, type: NodeKind, event: MouseEvent) {+ const key = nodeKey(rootPath, type, path);+ const currentIndex = visibleItems.value.findIndex((item) => item.id === key);if (currentIndex < 0) return;+ focusTree();+ const repeatedClick = event.detail > 1 && lastClickedKey === key;+ lastClickedKey = key;const selectionIntent = orderedListSelectionIntent(event);if (selectionIntent === "range") {event.preventDefault();@@ -550,18 +681,18 @@ function handlePathClick(path: string, type: OrderedListSelectionItem["type"], eif (selectionIntent === "toggle") {event.preventDefault();event.stopPropagation();- const next = new Set(selectedPaths.value);- if (next.has(path)) next.delete(path);- else next.add(path);- selectedPaths.value = next;- selectionAnchorIndex.value = currentIndex;+ const next = new Set(selectedKeys.value);+ if (next.has(key)) next.delete(key);+ else next.add(key);+ selectedKeys.value = next;+ selectionAnchorKey.value = key;return;}- selectedPaths.value = new Set();- activePath.value = path;- selectionAnchorIndex.value = currentIndex;- activate();+ selectedKeys.value = new Set();+ activeKey.value = key;+ selectionAnchorKey.value = key;+ if (openMode.value === "single" && !repeatedClick) activateItem(visibleItems.value[currentIndex]);}function handlePanelClick(event: MouseEvent) {@@ -605,9 +736,7 @@ function updateFolderPaths(previousPath: string, nextPath?: string) {folder.expanded = mapSet(folder.expanded);return true;});- selectedPaths.value = mapSet(selectedPaths.value);- activePath.value = activePath.value ? mapPath(activePath.value) : null;- selectionAnchorIndex.value = null;+ remapSelectionPaths(mapPath);saveFolders();}@@ -636,13 +765,10 @@ async function createSqlFolder() {folder.collapsed = false;folder.expanded = new Set([...folder.expanded, target.directoryPath, path]);}- activePath.value = path;- selectedPaths.value = new Set();- selectionAnchorIndex.value = null;- await nextTick();- Array.from(fileTree.value?.querySelectorAll<HTMLElement>("[data-sql-file-path]") ?? [])- .find((row) => row.dataset.sqlFilePath === path)- ?.scrollIntoView({ block: "nearest" });+ activeKey.value = nodeKey(target.rootPath, "dir", path);+ selectedKeys.value = new Set();+ selectionAnchorKey.value = activeKey.value;+ await scrollActiveRow();toast(t("sqlFileTree.folderCreated"), 1500);} catch (e: any) {toast(t("sqlFileTree.createFolderFailed", { message: translateBackendError(t, e) }), 5000);@@ -706,6 +832,7 @@ async function renameSqlFile() {// successful rename appear to fail for files too large for the editor.queryStore.relocateExternalSqlFilePath(target.entry.path, nextPath);moveExternalSqlFileTarget(target.entry.path, nextPath);+ remapSelectionPaths((path) => (normalizeExternalSqlPath(path) === normalizeExternalSqlPath(target.entry.path) ? nextPath : path));showRenameDialog.value = false;await reloadFolderAfterMutation(target.folderPath);toast(t("sqlFileTree.fileRenamed"), 1500);@@ -911,13 +1038,14 @@ function clearContextTarget() {<LightTooltip :text="t('sqlFileTree.locateActiveFile')" side="bottom" :delay="0" :close-delay="0" nowrap><SidebarLocateButton class="disabled:pointer-events-none disabled:opacity-50" :label="t('sqlFileTree.locateActiveFile')" :disabled="!currentFilePath || locatingFile || folders.some((folder) => folder.loading)" @locate="locateCurrentFile" /></LightTooltip>- <LightTooltip :text="t('sqlFileTree.filterSettings')" side="bottom" :delay="0" :close-delay="0" nowrap>+ <LightTooltip :text="t('sqlFileTree.panelSettings')" side="bottom" :delay="0" :close-delay="0" nowrap><Buttonvariant="ghost"size="icon"class="h-5 w-5"@click="fileFilterDraft = getSqlFileFilter();+ openModeDraft = openMode;filterSettingsOpen = true;">@@ -961,7 +1089,13 @@ function clearContextTarget() {<template #default="{ onContextMenu }"><divref="fileTree"- class="flex-1 overflow-y-auto"+ class="flex-1 overflow-y-auto focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring"+ tabindex="0"+ role="tree"+ :aria-label="t('sqlFileTree.title')"+ aria-multiselectable="true"+ :aria-activedescendant="activeItemIndex >= 0 ? `${treeId}-row-${activeItemIndex}` : undefined"+ @keydown="handleTreeKeydown"@click="handlePanelClick"@contextmenu.capture="contextTarget = { kind: 'panel' }"@contextmenu.prevent="@@ -980,15 +1114,21 @@ function clearContextTarget() {<divdata-sql-file-row="true"class="flex cursor-default items-center gap-1 px-2 py-1.5 text-[11px] font-medium text-muted-foreground bg-[color-mix(in_oklab,var(--muted)_10%,var(--background))] sticky top-0 select-none"- :class="isPathHighlighted(folder.path) ? 'bg-accent text-accent-foreground' : 'hover:bg-[color-mix(in_oklab,var(--accent)_40%,var(--background))]'"- @click.stop="handlePathClick(folder.path, 'folderHeader', $event, () => toggleFolderCollapse(folder))"+ :class="isPathHighlighted(folder.path, 'folderHeader', folder.path) ? 'bg-accent text-accent-foreground' : 'hover:bg-[color-mix(in_oklab,var(--accent)_40%,var(--background))]'"+ role="treeitem"+ :id="visibleRowIds.get(folder)?.get(folder.path)"+ :aria-level="1"+ :aria-selected="isPathHighlighted(folder.path, 'folderHeader', folder.path)"+ :aria-expanded="isFolderContentVisible(folder)"+ @click.stop="handlePathClick(folder.path, folder.path, 'folderHeader', $event)"+ @dblclick.stop="handlePathDoubleClick(folder.path, folder.path, 'folderHeader', $event)"@contextmenu.capture="contextTarget = { kind: 'folderHeader', folderPath: folder.path };- activePath = folder.path;+ activeKey = nodeKey(folder.path, 'folderHeader', folder.path);"@contextmenu.prevent="contextTarget = { kind: 'folderHeader', folderPath: folder.path };- activePath = folder.path;+ activeKey = nodeKey(folder.path, 'folderHeader', folder.path);onContextMenu($event);">@@ -1039,18 +1179,24 @@ function clearContextTarget() {v-for="{ entry, depth } in flatTree(getProcessedEntries(folder.path), getEffectiveExpanded(folder))":key="entry.path":data-sql-file-path="entry.path"- :aria-current="activePath === entry.path ? 'true' : undefined"+ :aria-current="activeKey === nodeKey(folder.path, entry.is_dir ? 'dir' : 'file', entry.path) ? 'true' : undefined"class="flex cursor-default select-none items-center gap-1 px-2 py-1 text-sm"- :class="[entry.is_dir ? 'rounded-sm' : 'rounded-none', isPathHighlighted(entry.path) ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/40']"+ :class="[entry.is_dir ? 'rounded-sm' : 'rounded-none', isPathHighlighted(folder.path, entry.is_dir ? 'dir' : 'file', entry.path) ? 'bg-accent text-accent-foreground' : 'hover:bg-accent/40']":style="{ paddingLeft: depth * 16 + 8 + 'px' }"- @click.stop="handlePathClick(entry.path, entry.is_dir ? 'dir' : 'file', $event, () => (entry.is_dir ? toggleExpand(folder, entry.path) : openFile(entry.path)))"+ role="treeitem"+ :id="visibleRowIds.get(folder)?.get(entry.path)"+ :aria-level="depth + 2"+ :aria-selected="isPathHighlighted(folder.path, entry.is_dir ? 'dir' : 'file', entry.path)"+ :aria-expanded="entry.is_dir ? getEffectiveExpanded(folder).has(entry.path) : undefined"+ @click.stop="handlePathClick(folder.path, entry.path, entry.is_dir ? 'dir' : 'file', $event)"+ @dblclick.stop="handlePathDoubleClick(folder.path, entry.path, entry.is_dir ? 'dir' : 'file', $event)"@contextmenu.capture="contextTarget = entry.is_dir ? { kind: 'dir', folderPath: folder.path, entry } : { kind: 'file', folderPath: folder.path, entry };- activePath = entry.path;+ activeKey = nodeKey(folder.path, entry.is_dir ? 'dir' : 'file', entry.path);"@contextmenu.prevent="contextTarget = entry.is_dir ? { kind: 'dir', folderPath: folder.path, entry } : { kind: 'file', folderPath: folder.path, entry };- activePath = entry.path;+ activeKey = nodeKey(folder.path, entry.is_dir ? 'dir' : 'file', entry.path);onContextMenu($event);">@@ -1111,9 +1257,15 @@ function clearContextTarget() {<Dialog v-model:open="filterSettingsOpen"><DialogContent class="sm:max-w-md"><DialogHeader>- <DialogTitle>{{ t("sqlFileTree.filterSettings") }}</DialogTitle>+ <DialogTitle>{{ t("sqlFileTree.panelSettings") }}</DialogTitle></DialogHeader><div class="grid gap-2 py-2">+ <Label for="sql-file-open-mode">{{ t("sqlFileTree.openMode") }}</Label>+ <select id="sql-file-open-mode" v-model="openModeDraft" class="h-8 rounded-md border border-input bg-background px-2 text-sm">+ <option value="single">{{ t("sqlFileTree.openModeSingle") }}</option>+ <option value="double">{{ t("sqlFileTree.openModeDouble") }}</option>+ </select>+ <p class="text-xs text-muted-foreground">{{ t("sqlFileTree.keyboardHelp") }}</p><Label for="sql-file-filter">{{ t("sqlFileTree.fileFilter") }}</Label><Input id="sql-file-filter" v-model="fileFilterDraft" :placeholder="t('sqlFileTree.fileFilterPlaceholder')" @keydown.enter="saveFileFilter" /><p class="text-xs text-muted-foreground">{{ t("sqlFileTree.fileFilterHint", { regex: fileFilterRegexExample }) }}</p>@@ -1161,7 +1313,7 @@ function clearContextTarget() {</Dialog><Dialog :open="showRenameDialog" @update:open="(open) => (showRenameDialog = open)">- <DialogContent class="sm:max-w-[380px]">+ <DialogContent class="sm:max-w-[380px]" @close-auto-focus="restoreTreeFocus"><DialogHeader><DialogTitle>{{ t("sqlFileTree.renameFile") }}</DialogTitle><DialogDescription>{{ t("sqlFileTree.renameFileDescription") }}</DialogDescription>@@ -1182,7 +1334,7 @@ function clearContextTarget() {}">- <DialogContent class="sm:max-w-[380px]">+ <DialogContent class="sm:max-w-[380px]" @close-auto-focus="restoreTreeFocus"><DialogHeader><DialogTitle>{{ t("sqlFileTree.renameFolder") }}</DialogTitle><DialogDescription>{{ t("sqlFileTree.renameFolderDescription") }}</DialogDescription>diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 0458123e04..b9d1a72c9d 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -6937,6 +6937,11 @@ export default withEnglishFallback({deleteFailed: "SQL faylını silmək mümkün olmadı: {message}",expandAll: "Hamısını genişləndir",collapseAll: "Hamısını yığ",+ panelSettings: "SQL faylı parametrləri",+ openMode: "Açılma üsulu",+ openModeSingle: "Bir kliklə aç",+ openModeDouble: "İki kliklə aç",+ keyboardHelp: "Fayl ağacı fokusda olduqda seçim üçün ↑ / ↓, açmaq və ya genişləndirmək üçün Enter / Boşluq, faylın və ya alt qovluğun adını dəyişmək üçün F2 istifadə edin.",filterSettings: "Fayl süzgəci",fileFilter: "Fayl adının süzgəci",fileFilterPlaceholder: "Fayl adının süzgəci",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 0691c7b4ce..f5eebe01b4 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -8482,6 +8482,11 @@ export default {deleteFailed: "Failed to delete SQL file: {message}",expandAll: "Expand all",collapseAll: "Collapse all",+ panelSettings: "SQL File Settings",+ openMode: "Open behavior",+ openModeSingle: "Single-click to open",+ openModeDouble: "Double-click to open",+ keyboardHelp: "With the file tree focused, use ↑ / ↓ to select, Enter / Space to open or expand, and F2 to rename a file or subfolder.",filterSettings: "File Filter",fileFilter: "File name filter",fileFilterPlaceholder: "File name filter",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 4e924db92b..c5c08dd874 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -10502,6 +10502,11 @@ export default withEnglishFallback({deleteFailed: "No se pudo eliminar el archivo SQL: {message}",expandAll: "Expandir todo",collapseAll: "Contraer todo",+ panelSettings: "Configuración de archivos SQL",+ openMode: "Modo de apertura",+ openModeSingle: "Abrir con un clic",+ openModeDouble: "Abrir con doble clic",+ keyboardHelp: "Con el foco en el árbol de archivos, usa ↑ / ↓ para seleccionar, Intro / Espacio para abrir o expandir y F2 para renombrar un archivo o subcarpeta.",filterSettings: "Filtro de archivos",fileFilter: "Filtro de nombre de archivo",fileFilterPlaceholder: "Filtro de nombre de archivo",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 88e8b3743e..84dfb2f85c 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -7636,6 +7636,11 @@ export default withEnglishFallback({deleteFailed: "Gagal menghapus file SQL: {message}",expandAll: "Perluas semua",collapseAll: "Ciutkan semua",+ panelSettings: "Pengaturan File SQL",+ openMode: "Cara membuka",+ openModeSingle: "Buka dengan sekali klik",+ openModeDouble: "Buka dengan klik ganda",+ keyboardHelp: "Saat pohon file mendapat fokus, gunakan ↑ / ↓ untuk memilih, Enter / Spasi untuk membuka atau memperluas, dan F2 untuk mengganti nama file atau subfolder.",filterSettings: "Filter File",fileFilter: "Filter nama file",fileFilterPlaceholder: "Filter nama file",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 75d7f5f69d..471290f586 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -10250,6 +10250,11 @@ export default withEnglishFallback({deleteFailed: "Impossibile eliminare il file SQL: {message}",expandAll: "Espandi tutto",collapseAll: "Comprimi tutto",+ panelSettings: "Impostazioni dei file SQL",+ openMode: "Modalità di apertura",+ openModeSingle: "Apri con un clic",+ openModeDouble: "Apri con doppio clic",+ keyboardHelp: "Con il focus sull’albero dei file, usa ↑ / ↓ per selezionare, Invio / Spazio per aprire o espandere e F2 per rinominare un file o una sottocartella.",filterSettings: "Filtro file",fileFilter: "Filtro nome file",fileFilterPlaceholder: "Filtro nome file",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 408e8169b6..4767a3ba0a 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -10286,6 +10286,11 @@ export default withEnglishFallback({deleteFailed: "SQLファイルを削除できませんでした: {message}",expandAll: "すべて展開",collapseAll: "すべて折りたたむ",+ panelSettings: "SQL ファイル設定",+ openMode: "開き方",+ openModeSingle: "シングルクリックで開く",+ openModeDouble: "ダブルクリックで開く",+ keyboardHelp: "ファイルツリーにフォーカスがある場合、↑ / ↓ で選択、Enter / スペースで開く・展開、F2 でファイルまたはサブフォルダーの名前を変更できます。",filterSettings: "ファイルフィルター",fileFilter: "ファイル名フィルター",fileFilterPlaceholder: "ファイル名フィルター",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex e2dfb2393a..07100b4053 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -7281,6 +7281,11 @@ export default withEnglishFallback({deleteFailed: "SQL 파일을 삭제하지 못했습니다: {message}",expandAll: "모두 펼치기",collapseAll: "모두 접기",+ panelSettings: "SQL 파일 설정",+ openMode: "열기 방식",+ openModeSingle: "한 번 클릭하여 열기",+ openModeDouble: "두 번 클릭하여 열기",+ keyboardHelp: "파일 트리에 포커스가 있을 때 ↑ / ↓로 선택하고, Enter / Space로 열거나 펼치고, F2로 파일 또는 하위 폴더의 이름을 변경합니다.",filterSettings: "파일 필터",fileFilter: "파일 이름 필터",fileFilterPlaceholder: "파일 이름 필터",diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.tsindex 76511b886c..907aec0602 100644--- a/apps/desktop/src/i18n/locales/pl.ts+++ b/apps/desktop/src/i18n/locales/pl.ts@@ -7670,6 +7670,11 @@ export default withEnglishFallback({deleteFailed: "Nie udało się usunąć pliku SQL: {message}",expandAll: "Rozwiń wszystko",collapseAll: "Zwiń wszystko",+ panelSettings: "Ustawienia plików SQL",+ openMode: "Sposób otwierania",+ openModeSingle: "Otwieraj pojedynczym kliknięciem",+ openModeDouble: "Otwieraj podwójnym kliknięciem",+ keyboardHelp: "Gdy drzewo plików ma fokus, użyj ↑ / ↓, aby wybrać element, Enter / Spacji, aby otworzyć lub rozwinąć, oraz F2, aby zmienić nazwę pliku lub podfolderu.",filterSettings: "Filtr plików",fileFilter: "Filtr nazw plików",fileFilterPlaceholder: "Filtr nazw plików",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 470666ba60..46e25b7cbf 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -10246,6 +10246,11 @@ export default withEnglishFallback({deleteFailed: "Falha ao excluir o arquivo SQL: {message}",expandAll: "Expandir todos",collapseAll: "Recolher todos",+ panelSettings: "Configurações de arquivos SQL",+ openMode: "Modo de abertura",+ openModeSingle: "Abrir com um clique",+ openModeDouble: "Abrir com clique duplo",+ keyboardHelp: "Com o foco na árvore de arquivos, use ↑ / ↓ para selecionar, Enter / Espaço para abrir ou expandir e F2 para renomear um arquivo ou subpasta.",filterSettings: "Filtro de arquivos",fileFilter: "Filtro de nome de arquivo",fileFilterPlaceholder: "Filtro de nome de arquivo",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 03c9b3da66..d21837c405 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -8728,6 +8728,11 @@ export default withEnglishFallback({deleteFailed: "Не удалось удалить SQL-файл: {message}",expandAll: "Развернуть всё",collapseAll: "Свернуть всё",+ panelSettings: "Настройки SQL-файлов",+ openMode: "Способ открытия",+ openModeSingle: "Открывать одним щелчком",+ openModeDouble: "Открывать двойным щелчком",+ keyboardHelp: "Когда дерево файлов в фокусе, используйте ↑ / ↓ для выбора, Enter / Пробел для открытия или разворачивания и F2 для переименования файла или вложенной папки.",filterSettings: "Фильтр файлов",fileFilter: "Фильтр по имени файла",fileFilterPlaceholder: "Фильтр по имени файла",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex 34dff75207..d9e0f06ec0 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -9125,6 +9125,11 @@ export default withEnglishFallback({deleteFailed: "ลบไฟล์ SQL ไม่สำเร็จ: {message}",expandAll: "ขยายทั้งหมด",collapseAll: "ยุบทั้งหมด",+ panelSettings: "การตั้งค่าไฟล์ SQL",+ openMode: "วิธีเปิด",+ openModeSingle: "คลิกครั้งเดียวเพื่อเปิด",+ openModeDouble: "ดับเบิลคลิกเพื่อเปิด",+ keyboardHelp: "เมื่อโฟกัสอยู่ที่แผนผังไฟล์ ใช้ ↑ / ↓ เพื่อเลือก Enter / Space เพื่อเปิดหรือขยาย และ F2 เพื่อเปลี่ยนชื่อไฟล์หรือโฟลเดอร์ย่อย",filterSettings: "ตัวกรองไฟล์",fileFilter: "ตัวกรองชื่อไฟล์",fileFilterPlaceholder: "ตัวกรองชื่อไฟล์",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 82966a45ae..daaec6c786 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -6817,6 +6817,11 @@ export default withEnglishFallback({deleteFailed: "SQL dosyası silinemedi: {message}",expandAll: "Tümünü genişlet",collapseAll: "Tümünü daralt",+ panelSettings: "SQL Dosyası Ayarları",+ openMode: "Açma biçimi",+ openModeSingle: "Tek tıklamayla aç",+ openModeDouble: "Çift tıklamayla aç",+ keyboardHelp: "Dosya ağacı odaktayken seçmek için ↑ / ↓, açmak veya genişletmek için Enter / Boşluk, dosya veya alt klasörü yeniden adlandırmak için F2 kullanın.",filterSettings: "Dosya Filtresi",fileFilter: "Dosya adı filtresi",fileFilterPlaceholder: "Dosya adı filtresi",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex dd2b87ed0d..e2cad0f468 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -8450,6 +8450,11 @@ export default withEnglishFallback({deleteFailed: "删除 SQL 文件失败: {message}",expandAll: "全部展开",collapseAll: "全部折叠",+ panelSettings: "SQL 文件设置",+ openMode: "打开方式",+ openModeSingle: "单击打开",+ openModeDouble: "双击打开",+ keyboardHelp: "聚焦文件树后,↑ / ↓ 选择,Enter / 空格打开或展开,F2 重命名文件或子文件夹。",filterSettings: "文件过滤",fileFilter: "文件名过滤规则",fileFilterPlaceholder: "文件名过滤规则",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 777350590c..3809678ac4 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -10256,6 +10256,11 @@ export default withEnglishFallback({deleteFailed: "刪除 SQL 檔案失敗: {message}",expandAll: "全部展開",collapseAll: "全部摺疊",+ panelSettings: "SQL 檔案設定",+ openMode: "開啟方式",+ openModeSingle: "按一下開啟",+ openModeDouble: "按兩下開啟",+ keyboardHelp: "焦點位於檔案樹時,↑ / ↓ 選取,Enter / 空白鍵開啟或展開,F2 重新命名檔案或子資料夾。",filterSettings: "檔案篩選",fileFilter: "檔案名稱篩選規則",fileFilterPlaceholder: "檔案名稱篩選規則",diff --git a/apps/desktop/src/lib/sqlFile/sqlFileInteraction.ts b/apps/desktop/src/lib/sqlFile/sqlFileInteraction.tsnew file mode 100644index 0000000000..ec877c3694--- /dev/null+++ b/apps/desktop/src/lib/sqlFile/sqlFileInteraction.ts@@ -0,0 +1,12 @@+import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/backend/safeStorage";++export type SqlFileOpenMode = "single" | "double";+const OPEN_MODE_STORAGE_KEY = "dbx-sql-file-open-mode";++export function getSqlFileOpenMode(): SqlFileOpenMode {+ return safeLocalStorageGet(OPEN_MODE_STORAGE_KEY) === "double" ? "double" : "single";+}++export function saveSqlFileOpenMode(mode: SqlFileOpenMode): void {+ safeLocalStorageSet(OPEN_MODE_STORAGE_KEY, mode === "double" ? "double" : "single");+}