feat: support multiple desktop windows

This commit is contained in:
t8y2 committed 2026-06-05 20:45:00 +08:00
1 parent 28e8a77fa3
commit 642fa39bb8
26 files changed
+522 -436

No files matched your search

+22 -2
View File
@@ -27,6 +27,7 @@ import { useNavigationTargets } from "@/composables/useNavigationTargets";
import { useDataGridActions } from "@/composables/useDataGridActions";
import { useTauriEvents } from "@/composables/useTauriEvents";
import { useVisibilityChange } from "@/composables/useVisibilityChange";
import { installWindowDragRegions } from "@/composables/useWindowDragRegion";
import "@/i18n";
import { translateBackendError } from "@/i18n/backend-errors";
import * as api from "@/lib/api";
@@ -46,6 +47,7 @@ import {
isFocusSearchShortcut,
isModRShortcut,
isNewQueryShortcut,
isNewWindowShortcut,
isObjectSourceSaveShortcutTarget,
isResetZoomShortcut,
isRefreshDataShortcut,
@@ -59,6 +61,8 @@ import { classifyAiSqlExecution } from "@/lib/aiSqlExecutionPolicy";
import { buildHistoryAiAnalysisPrompt } from "@/lib/historyAiAnalysis";
import { countAvailableAgentDriverUpdates, type AgentDriverUpdateBadgeState } from "@/lib/agentDriverUpdateBadge";
import { safeLocalStorageGet, safeLocalStorageSet } from "@/lib/safeStorage";
import { openDesktopWindow } from "@/lib/desktopWindows";
import { subscribeTableMutations } from "@/lib/tableMutationBroadcast";
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
@@ -103,6 +107,8 @@ const { setupFileDrop } = useFileDrop();
const isDesktop = isTauriRuntime();
const UPDATE_CHECK_INTERVAL_MS = 60 * 60 * 1000;
let updateCheckTimer: ReturnType<typeof setInterval> | undefined;
let unsubscribeTableMutations: (() => void) | undefined;
let uninstallWindowDragRegions: (() => void) | undefined;
const needsAuth = ref(!isDesktop);
const authenticated = ref(isDesktop);
const setupRequired = ref(false);
@@ -760,6 +766,12 @@ function handleKeydown(e: KeyboardEvent) {
contentAreaRef.value?.refreshData();
return;
}
if (isNewWindowShortcut(e)) {
e.preventDefault();
e.stopPropagation();
void openDesktopWindow();
return;
}
if (isNewQueryShortcut(e, shortcuts)) {
e.preventDefault();
e.stopPropagation();
@@ -888,7 +900,11 @@ onMounted(async () => {
});
applyTheme();
void applyUiScale(settingsStore.editorSettings.uiScale);
window.addEventListener("keydown", handleKeydown);
window.addEventListener("keydown", handleKeydown, true);
uninstallWindowDragRegions = installWindowDragRegions();
unsubscribeTableMutations = subscribeTableMutations((message) => {
queryStore.markTableTabsStale(message);
});
window.addEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
if (isDesktop) {
document.addEventListener("contextmenu", handleContextMenu);
@@ -944,7 +960,11 @@ onUnmounted(() => {
if (updateCheckTimer) {
clearInterval(updateCheckTimer);
}
window.removeEventListener("keydown", handleKeydown);
window.removeEventListener("keydown", handleKeydown, true);
uninstallWindowDragRegions?.();
uninstallWindowDragRegions = undefined;
unsubscribeTableMutations?.();
unsubscribeTableMutations = undefined;
window.removeEventListener("dbx-open-driver-store", openDriverStoreFromEvent);
document.removeEventListener("contextmenu", handleContextMenu);
});