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。

feat(connection): let deep links skip the connection confirmation

javalover123b0e6bc82be1f
diff --git a/apps/desktop/src/components/connection/ConnectionDialog.vue b/apps/desktop/src/components/connection/ConnectionDialog.vue
index 6bd7926db3..f6e1aa63fc 100644
--- a/apps/desktop/src/components/connection/ConnectionDialog.vue
+++ b/apps/desktop/src/components/connection/ConnectionDialog.vue
@@ -98,7 +98,16 @@ import {
} from "@/lib/connection/timeoutLimits";
import { buildOracleTnsConnectionString, normalizeOracleTnsAdminPath, parseOracleTnsConnectionString } from "@/lib/connection/oracleTnsConnection";
import { applyConnectionDeepLinkUpdate, resolveConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLinkUpdate";
-import { connectionDeepLinkServiceHydrationValue, parseConnectionDeepLink, parseConnectionDeepLinkUpdate, parseServiceConnectionUrl, type ConnectionDeepLinkDraft, type ConnectionDeepLinkUpdate } from "@/lib/connection/connectionDeepLink";
+import {
+ connectionDeepLinkServiceHydrationValue,
+ parseConnectionDeepLink,
+ parseConnectionDeepLinkUpdate,
+ parseServiceConnectionUrl,
+ shouldAutoConfirmConnectionDeepLink,
+ shouldAutoConfirmConnectionPrefill,
+ type ConnectionDeepLinkDraft,
+ type ConnectionDeepLinkUpdate,
+} from "@/lib/connection/connectionDeepLink";
import { connectionUrlPlaceholder as getUrlPlaceholder } from "@/lib/connection/connectionPresentation";
import { parseGaussdbHosts, serializeGaussdbHosts, type GaussdbHostEntry } from "@/lib/connection/gaussdbHosts";
import { h2ConnectionModeForConfig, h2FileJdbcUrlWithPath, h2FilePathFromJdbcUrl, isH2SplitJdbcUrl, type H2ConnectionMode } from "@/lib/database/h2Connection";
@@ -3140,6 +3149,12 @@ function switchGbaseProfile(profile: GbaseProfile) {
let applyingConnectionUpdate = false;
let appliedConnectionUpdate: ConnectionDeepLinkUpdate | null = null;
+/**
+ * 免确认保存的去重键。必须早于下面这个 `immediate` watcher 声明——更新链接的
+ * 自动保存就在该 watcher 里触发,晚声明会命中 TDZ。
+ */
+const submittedAutoCreatePrefillKey = ref<string | null>(null);
+
function finishApplyingConnectionUpdate() {
void nextTick(() => {
applyingConnectionUpdate = false;
@@ -3331,7 +3346,10 @@ watch(
customDriverName.value = isCustomCompatibleProfile() ? config.driver_label || "" : "";
dialogStep.value = "config";
configTab.value = initialConfigTab();
- if (props.updatePrefill) finishApplyingConnectionUpdate();
+ if (props.updatePrefill) {
+ finishApplyingConnectionUpdate();
+ submitUpdateIfAutoConfirmed(props.updatePrefill);
+ }
// Form/profile watchers normalize derived fields in this flush. Capture
// the saved baseline afterwards so those initial changes are not treated
// as user edits that invalidate persisted database metadata.
@@ -6383,9 +6401,7 @@ function resetForm(options: { preservePickerState?: boolean } = {}) {
resetTestState();
}
-const submittedOneTimePrefillKey = ref<string | null>(null);
-
-function oneTimePrefillKey(draft: ConnectionDeepLinkDraft) {
+function prefillDraftKey(draft: ConnectionDeepLinkDraft) {
return JSON.stringify([
draft.name,
draft.dbType,
@@ -6406,11 +6422,31 @@ function oneTimePrefillKey(draft: ConnectionDeepLinkDraft) {
]);
}
-function submitOneTimePrefill(draft: ConnectionDeepLinkDraft) {
- if (!draft.oneTime) return;
- const key = oneTimePrefillKey(draft);
- if (submittedOneTimePrefillKey.value === key) return;
- submittedOneTimePrefillKey.value = key;
+/**
+ * 免确认保存连接深链。
+ *
+ * `one_time` 临时连接一直是自动提交的;设置项 `deepLinkConnectionConfirmMode`
+ * 打开对应形态后,新建(`create`)与带 `id` 的更新(`update`)链接也走同一条路径:
+ * 弹窗完成预填后立刻保存,用户不需要再点确认。
+ *
+ * 仍然复用弹窗自己的 `save()`,因此驱动安装、URL 解析、校验等逻辑与手动保存完全一致;
+ * 一旦校验失败,`save()` 返回 false 且弹窗保持打开,用户可以继续手动补全。
+ */
+function submitPrefillIfAutoConfirmed(draft: ConnectionDeepLinkDraft) {
+ if (!shouldAutoConfirmConnectionPrefill(draft, settingsStore.editorSettings.deepLinkConnectionConfirmMode)) return;
+ const key = prefillDraftKey(draft);
+ if (submittedAutoCreatePrefillKey.value === key) return;
+ submittedAutoCreatePrefillKey.value = key;
+ void nextTick(() => save());
+}
+
+/** 带 `id` 的更新链接:预填完成后按设置决定是否直接保存。 */
+function submitUpdateIfAutoConfirmed(update: ConnectionDeepLinkUpdate) {
+ if (!shouldAutoConfirmConnectionDeepLink("update", settingsStore.editorSettings.deepLinkConnectionConfirmMode)) return;
+ const key = `update:${update.connectionId}:${JSON.stringify(update.patch)}`;
+ if (submittedAutoCreatePrefillKey.value === key) return;
+ submittedAutoCreatePrefillKey.value = key;
+ // 让表单 watcher 先跑完一轮派生字段归一化,再按当前表单内容保存。
void nextTick(() => save());
}
@@ -6480,7 +6516,7 @@ function applyConnectionDraftToForm(draft: ConnectionDeepLinkDraft) {
function applyConnectionPrefill(draft: ConnectionDeepLinkDraft) {
resetForm();
applyConnectionDraftToForm(draft);
- submitOneTimePrefill(draft);
+ submitPrefillIfAutoConfirmed(draft);
}
watch(
@@ -6488,7 +6524,7 @@ watch(
(value) => {
if (!value) {
const draftId = editingId.value ? null : draftTestConnectionId.value;
- submittedOneTimePrefillKey.value = null;
+ submittedAutoCreatePrefillKey.value = null;
resetForm();
if (draftId) {
void api.disconnectDb(draftId).catch(() => undefined);
diff --git a/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts b/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
index fd6f8ac4be..78a7053b20 100644
--- a/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
+++ b/apps/desktop/src/components/connection/__tests__/ConnectionDialog.deepLinkEdit.spec.ts
@@ -29,7 +29,7 @@ const { store, settings, backend, actualStoreHolder } = vi.hoisted(() => ({
},
actualStoreHolder: { value: null as unknown },
settings: {
- editorSettings: { sidebarShowConnectionNotes: false, globalConnectTimeoutSecs: 10, globalQueryTimeoutSecs: 0, connectTimeoutInheritConnectionIds: [], queryTimeoutInheritConnectionIds: [] },
+ editorSettings: { sidebarShowConnectionNotes: false, globalConnectTimeoutSecs: 10, globalQueryTimeoutSecs: 0, connectTimeoutInheritConnectionIds: [], queryTimeoutInheritConnectionIds: [], deepLinkConnectionConfirmMode: "always" as "always" | "create" | "update" | "all" },
rememberedDatabaseForConnection: vi.fn(() => ""),
initEditorSettings: vi.fn().mockResolvedValue(undefined),
persistEditorSettings: vi.fn(),
@@ -236,6 +236,7 @@ beforeEach(() => {
actualStoreHolder.value = null;
visibleTab.value = "connection";
i18n.global.locale.value = "en";
+ settings.editorSettings.deepLinkConnectionConfirmMode = "always";
for (const fn of Object.values(backend)) fn.mockResolvedValue([]);
backend.listenAgentInstallProgress.mockResolvedValue(() => {});
store.updateConnection.mockResolvedValue(undefined);
@@ -768,4 +769,22 @@ describe("ConnectionDialog deep-link edit confirmation", () => {
}),
);
});
+
+ it("applies an id update link without waiting for confirmation when the mode allows updates", async () => {
+ // 「仅带 id 的更新链接」/「所有连接链接」两种模式下,带 id 的深链不再停在编辑弹窗。
+ settings.editorSettings.deepLinkConnectionConfirmMode = "update";
+
+ await mountDialog(savedConnection(), "dbx://connection/new?id=saved-production&host=new.example.test");
+ await settle();
+
+ expect(store.updateConnection).toHaveBeenCalledTimes(1);
+ expect(store.updateConnection).toHaveBeenCalledWith(expect.objectContaining({ id: "saved-production", host: "new.example.test" }));
+ });
+
+ it("keeps an id update link open for confirmation in the default mode", async () => {
+ await mountDialog(savedConnection(), "dbx://connection/new?id=saved-production&host=new.example.test");
+ await settle();
+
+ expect(store.updateConnection).not.toHaveBeenCalled();
+ });
});
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
index d846a20078..dab920594a 100644
--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue
+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
@@ -92,6 +92,7 @@ import {
type InterfaceLayout,
type DisconnectTabHandlingMode,
type DeleteConnectionTabHandlingMode,
+ type DeepLinkConnectionConfirmMode,
type DataTabReuseMode,
type DataGridFilterEditorView,
type DataGridToolbarLayout,
@@ -988,6 +989,7 @@ const editAutoReloadRestoredDataTabsOnOpen = ref(settingsStore.editorSettings.au
const editDisconnectTabHandlingMode = ref<DisconnectTabHandlingMode>(settingsStore.editorSettings.disconnectTabHandlingMode);
const editDeleteConnectionTabHandlingMode = ref<DeleteConnectionTabHandlingMode>(settingsStore.editorSettings.deleteConnectionTabHandlingMode);
const editRememberConnectionDatabaseOnDelete = ref(settingsStore.editorSettings.rememberConnectionDatabaseOnDelete);
+const editDeepLinkConnectionConfirmMode = ref<DeepLinkConnectionConfirmMode>(settingsStore.editorSettings.deepLinkConnectionConfirmMode);
// 「记住的连接名 → 数据库」是累积数据而非偏好设置,不进弹窗草稿;这里直接读写 store,
// 让清除操作立即生效,不受弹窗的保存/取消影响。
const rememberedConnectionDatabaseCount = computed(() => Object.keys(settingsStore.editorSettings.rememberedConnectionDatabases).length);
@@ -1095,6 +1097,18 @@ const deleteConnectionTabHandlingModeDescriptionKey = computed(() => {
return "deleteConnectionTabHandlingModeCloseTabsDescription";
});
+const deepLinkConnectionConfirmModeDescriptionKey = computed(() => {
+ switch (editDeepLinkConnectionConfirmMode.value) {
+ case "create":
+ return "deepLinkConnectionConfirmModeCreateDescription";
+ case "update":
+ return "deepLinkConnectionConfirmModeUpdateDescription";
+ case "all":
+ return "deepLinkConnectionConfirmModeAllDescription";
+ }
+
+ return "deepLinkConnectionConfirmModeAlwaysDescription";
+});
const normalizedEditTableColumnTemplateFields = computed(() => tableColumnTemplateRowsToSettings(editTableColumnTemplateRows.value));
const visibleTableColumnTemplateRows = computed(() =>
editTableColumnTemplateRows.value.filter((row) => {
@@ -1306,6 +1320,7 @@ function currentEditorSettingsDraft(): EditorSettingsDraft {
disconnectTabHandlingMode: editDisconnectTabHandlingMode.value,
deleteConnectionTabHandlingMode: editDeleteConnectionTabHandlingMode.value,
rememberConnectionDatabaseOnDelete: editRememberConnectionDatabaseOnDelete.value,
+ deepLinkConnectionConfirmMode: editDeepLinkConnectionConfirmMode.value,
dataTabReuseMode: editDataTabReuseMode.value,
openDataTabsNextToActive: editOpenDataTabsNextToActive.value,
prefillNewQueryWithSelect: editPrefillNewQueryWithSelect.value,
@@ -2010,6 +2025,7 @@ function syncEditorSettingsDraftFromStore() {
editDisconnectTabHandlingMode.value = settingsStore.editorSettings.disconnectTabHandlingMode;
editDeleteConnectionTabHandlingMode.value = settingsStore.editorSettings.deleteConnectionTabHandlingMode;
editRememberConnectionDatabaseOnDelete.value = settingsStore.editorSettings.rememberConnectionDatabaseOnDelete;
+ editDeepLinkConnectionConfirmMode.value = settingsStore.editorSettings.deepLinkConnectionConfirmMode;
editDataTabReuseMode.value = settingsStore.editorSettings.dataTabReuseMode;
editOpenDataTabsNextToActive.value = settingsStore.editorSettings.openDataTabsNextToActive;
editPrefillNewQueryWithSelect.value = settingsStore.editorSettings.prefillNewQueryWithSelect;
@@ -2182,6 +2198,7 @@ const editorSettingsDraftRefs: EditorSettingsDraftRefMap = {
disconnectTabHandlingMode: editDisconnectTabHandlingMode,
deleteConnectionTabHandlingMode: editDeleteConnectionTabHandlingMode,
rememberConnectionDatabaseOnDelete: editRememberConnectionDatabaseOnDelete,
+ deepLinkConnectionConfirmMode: editDeepLinkConnectionConfirmMode,
dataTabReuseMode: editDataTabReuseMode,
openDataTabsNextToActive: editOpenDataTabsNextToActive,
prefillNewQueryWithSelect: editPrefillNewQueryWithSelect,
@@ -2771,6 +2788,7 @@ function resetDefaultsForTab(tab: SettingsCategory) {
editDisconnectTabHandlingMode.value = DEFAULT_EDITOR_SETTINGS.disconnectTabHandlingMode;
editDeleteConnectionTabHandlingMode.value = DEFAULT_EDITOR_SETTINGS.deleteConnectionTabHandlingMode;
editRememberConnectionDatabaseOnDelete.value = DEFAULT_EDITOR_SETTINGS.rememberConnectionDatabaseOnDelete;
+ editDeepLinkConnectionConfirmMode.value = DEFAULT_EDITOR_SETTINGS.deepLinkConnectionConfirmMode;
editDataTabReuseMode.value = DEFAULT_EDITOR_SETTINGS.dataTabReuseMode;
editOpenDataTabsNextToActive.value = DEFAULT_EDITOR_SETTINGS.openDataTabsNextToActive;
editPrefillNewQueryWithSelect.value = DEFAULT_EDITOR_SETTINGS.prefillNewQueryWithSelect;
@@ -2995,6 +3013,7 @@ function resetAllDefaults() {
editDisconnectTabHandlingMode.value = DEFAULT_EDITOR_SETTINGS.disconnectTabHandlingMode;
editDeleteConnectionTabHandlingMode.value = DEFAULT_EDITOR_SETTINGS.deleteConnectionTabHandlingMode;
editRememberConnectionDatabaseOnDelete.value = DEFAULT_EDITOR_SETTINGS.rememberConnectionDatabaseOnDelete;
+ editDeepLinkConnectionConfirmMode.value = DEFAULT_EDITOR_SETTINGS.deepLinkConnectionConfirmMode;
editDataTabReuseMode.value = DEFAULT_EDITOR_SETTINGS.dataTabReuseMode;
editOpenDataTabsNextToActive.value = DEFAULT_EDITOR_SETTINGS.openDataTabsNextToActive;
editPrefillNewQueryWithSelect.value = DEFAULT_EDITOR_SETTINGS.prefillNewQueryWithSelect;
@@ -9404,6 +9423,28 @@ onUnmounted(() => {
</div>
<Switch id="remember-connection-database-on-delete" v-model="editRememberConnectionDatabaseOnDelete" />
</div>
+ <div class="settings-item space-y-2 rounded-md border bg-muted/20 px-3 py-2">
+ <div class="flex items-center gap-2">
+ <Label for="deeplink-connection-confirm-mode">{{ t("settings.deepLinkConnectionConfirmMode") }}</Label>
+ <HelpTooltip :label="t('settings.deepLinkConnectionConfirmMode')">
+ {{ t("settings.deepLinkConnectionConfirmModeDescription") }}
+ </HelpTooltip>
+ </div>
+ <Select :model-value="editDeepLinkConnectionConfirmMode" @update:model-value="(value) => (editDeepLinkConnectionConfirmMode = value as DeepLinkConnectionConfirmMode)">
+ <SelectTrigger id="deeplink-connection-confirm-mode" class="w-full">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ <SelectItem value="always">{{ t("settings.deepLinkConnectionConfirmModeAlways") }}</SelectItem>
+ <SelectItem value="create">{{ t("settings.deepLinkConnectionConfirmModeCreate") }}</SelectItem>
+ <SelectItem value="update">{{ t("settings.deepLinkConnectionConfirmModeUpdate") }}</SelectItem>
+ <SelectItem value="all">{{ t("settings.deepLinkConnectionConfirmModeAll") }}</SelectItem>
+ </SelectContent>
+ </Select>
+ <p class="text-xs text-muted-foreground">
+ {{ t(`settings.${deepLinkConnectionConfirmModeDescriptionKey}`) }}
+ </p>
+ </div>
<div class="settings-item space-y-2 rounded-md border bg-muted/20 px-3 py-2">
<div class="flex items-center gap-2">
<Label for="sidebar-object-info-mode">{{ t("settings.sidebarObjectInfoMode") }}</Label>
diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts
index 104162105b..57b490fe86 100644
--- a/apps/desktop/src/i18n/locales/en.ts
+++ b/apps/desktop/src/i18n/locales/en.ts
@@ -9883,6 +9883,16 @@ export default {
rememberConnectionDatabaseOnDelete: "Remember connection and database names",
rememberConnectionDatabaseOnDeleteDescription: "Remember a connection's name and database when it is deleted, and preselect them when a connection with the same name is created again.",
rememberConnectionDatabaseOnDeleteHint: "When enabled, creating a connection with the same name and database type prefills that database, and kept SQL tabs are rebound to the new connection automatically.",
+ deepLinkConnectionConfirmMode: "Confirmation for connections opened from links",
+ deepLinkConnectionConfirmModeDescription: "Choose which connection links save straight away instead of waiting for you to confirm them in the dialog.",
+ deepLinkConnectionConfirmModeAlways: "Always confirm",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Both new and updated connections wait for your confirmation in the dialog.",
+ deepLinkConnectionConfirmModeCreate: "Only new connections",
+ deepLinkConnectionConfirmModeCreateDescription: "New connections are created immediately; links carrying an id still wait for confirmation.",
+ deepLinkConnectionConfirmModeUpdate: "Only links with an id",
+ deepLinkConnectionConfirmModeUpdateDescription: "Links carrying an id update the saved connection immediately; new connections still wait for confirmation.",
+ deepLinkConnectionConfirmModeAll: "All connection links",
+ deepLinkConnectionConfirmModeAllDescription: "Both new and updated connections are saved without confirmation. If the prefilled parameters fail validation, the dialog stays open so you can finish it manually.",
rememberedConnectionDatabaseCount: "Remembered entries: {count}",
clearRememberedConnectionDatabases: "Clear remembered entries",
reuseDataTab: "Reuse data tab",
diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts
index dd13cbb5fc..52e29af921 100644
--- a/apps/desktop/src/i18n/locales/es.ts
+++ b/apps/desktop/src/i18n/locales/es.ts
@@ -8714,6 +8714,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "Recordar nombres de conexión y base de datos",
rememberConnectionDatabaseOnDeleteDescription: "Recuerda el nombre y la base de datos de una conexión al eliminarla, y los preselecciona al crear otra con el mismo nombre.",
rememberConnectionDatabaseOnDeleteHint: "Si se activa, al crear una conexión con el mismo nombre y tipo de base de datos se rellena esa base de datos y las pestañas SQL conservadas se vuelven a vincular automáticamente a la nueva conexión.",
+ deepLinkConnectionConfirmMode: "Confirmación de conexiones abiertas desde enlaces",
+ deepLinkConnectionConfirmModeDescription: "Elige qué enlaces de conexión se guardan directamente en lugar de esperar tu confirmación en el diálogo.",
+ deepLinkConnectionConfirmModeAlways: "Confirmar siempre",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Tanto las conexiones nuevas como las actualizadas esperan tu confirmación en el diálogo.",
+ deepLinkConnectionConfirmModeCreate: "Solo conexiones nuevas",
+ deepLinkConnectionConfirmModeCreateDescription: "Las conexiones nuevas se crean de inmediato; los enlaces con id siguen esperando confirmación.",
+ deepLinkConnectionConfirmModeUpdate: "Solo enlaces con id",
+ deepLinkConnectionConfirmModeUpdateDescription: "Los enlaces con id actualizan la conexión guardada de inmediato; las conexiones nuevas siguen esperando confirmación.",
+ deepLinkConnectionConfirmModeAll: "Todos los enlaces de conexión",
+ deepLinkConnectionConfirmModeAllDescription: "Las conexiones nuevas y las actualizadas se guardan sin confirmación. Si los parámetros precargados no son válidos, el diálogo permanece abierto para que los completes manualmente.",
rememberedConnectionDatabaseCount: "Entradas recordadas: {count}",
clearRememberedConnectionDatabases: "Borrar las entradas recordadas",
reuseDataTab: "Reutilizar pestaña de datos",
diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts
index 3121438de8..46c1ca98ef 100644
--- a/apps/desktop/src/i18n/locales/it.ts
+++ b/apps/desktop/src/i18n/locales/it.ts
@@ -8493,6 +8493,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "Ricorda i nomi di connessione e database",
rememberConnectionDatabaseOnDeleteDescription: "Ricorda il nome e il database di una connessione quando viene eliminata e li preseleziona quando ne viene creata una con lo stesso nome.",
rememberConnectionDatabaseOnDeleteHint: "Se attivo, creando una connessione con lo stesso nome e tipo di database il database viene precompilato e le schede SQL mantenute vengono ricollegate automaticamente alla nuova connessione.",
+ deepLinkConnectionConfirmMode: "Conferma delle connessioni aperte dai link",
+ deepLinkConnectionConfirmModeDescription: "Scegli quali link di connessione vengono salvati subito senza attendere la conferma nella finestra.",
+ deepLinkConnectionConfirmModeAlways: "Chiedi sempre conferma",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Sia le connessioni nuove sia quelle aggiornate attendono la conferma nella finestra.",
+ deepLinkConnectionConfirmModeCreate: "Solo nuove connessioni",
+ deepLinkConnectionConfirmModeCreateDescription: "Le nuove connessioni vengono create subito; i link con id attendono ancora la conferma.",
+ deepLinkConnectionConfirmModeUpdate: "Solo link con id",
+ deepLinkConnectionConfirmModeUpdateDescription: "I link con id aggiornano subito la connessione salvata; le nuove connessioni attendono ancora la conferma.",
+ deepLinkConnectionConfirmModeAll: "Tutti i link di connessione",
+ deepLinkConnectionConfirmModeAllDescription: "Le connessioni nuove e quelle aggiornate vengono salvate senza conferma. Se i parametri precompilati non sono validi, la finestra resta aperta per completarli manualmente.",
rememberedConnectionDatabaseCount: "Voci ricordate: {count}",
clearRememberedConnectionDatabases: "Cancella le voci ricordate",
reuseDataTab: "Riusa scheda dati",
diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts
index b5b2f006d0..bc89810b38 100644
--- a/apps/desktop/src/i18n/locales/ja.ts
+++ b/apps/desktop/src/i18n/locales/ja.ts
@@ -8505,6 +8505,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "接続名とデータベース名を記憶",
rememberConnectionDatabaseOnDeleteDescription: "接続を削除するときに名前とデータベースを記憶し、同名の接続を再度作成するときに自動で選択します。",
rememberConnectionDatabaseOnDeleteHint: "有効にすると、同名・同タイプの接続を作成したときにそのデータベースが自動入力され、保持された SQL タブも新しい接続に自動で再バインドされます。",
+ deepLinkConnectionConfirmMode: "リンクから開く接続の確認方法",
+ deepLinkConnectionConfirmModeDescription: "どの接続リンクを、ダイアログでの確認なしにそのまま保存するかを選びます。",
+ deepLinkConnectionConfirmModeAlways: "常に確認する",
+ deepLinkConnectionConfirmModeAlwaysDescription: "新規接続も更新リンクも、確認のためにダイアログを開きます。",
+ deepLinkConnectionConfirmModeCreate: "新規接続のみ",
+ deepLinkConnectionConfirmModeCreateDescription: "新規接続はすぐに作成し、id 付きの更新リンクは確認を待ちます。",
+ deepLinkConnectionConfirmModeUpdate: "id 付きリンクのみ",
+ deepLinkConnectionConfirmModeUpdateDescription: "id 付きのリンクは保存済みの接続をすぐ更新し、新規接続は確認を待ちます。",
+ deepLinkConnectionConfirmModeAll: "すべての接続リンク",
+ deepLinkConnectionConfirmModeAllDescription: "新規接続も更新リンクも確認なしで保存します。事前入力されたパラメーターが不正な場合はダイアログが開いたままになり、手動で補完できます。",
rememberedConnectionDatabaseCount: "記憶済みの項目: {count}",
clearRememberedConnectionDatabases: "記憶した項目を消去",
reuseDataTab: "データタブを再利用",
diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts
index 203f649bac..0f5390f124 100644
--- a/apps/desktop/src/i18n/locales/ko.ts
+++ b/apps/desktop/src/i18n/locales/ko.ts
@@ -8623,6 +8623,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "연결 이름과 데이터베이스 이름 기억",
rememberConnectionDatabaseOnDeleteDescription: "연결을 삭제할 때 이름과 데이터베이스를 기억하고, 같은 이름의 연결을 다시 만들 때 자동으로 선택합니다.",
rememberConnectionDatabaseOnDeleteHint: "활성화하면 같은 이름과 같은 유형의 연결을 만들 때 해당 데이터베이스가 자동으로 채워지고, 유지된 SQL 탭도 새 연결에 자동으로 다시 바인딩됩니다.",
+ deepLinkConnectionConfirmMode: "링크로 여는 연결의 확인 방식",
+ deepLinkConnectionConfirmModeDescription: "어떤 연결 링크를 대화 상자에서 확인하지 않고 바로 저장할지 선택합니다.",
+ deepLinkConnectionConfirmModeAlways: "항상 확인",
+ deepLinkConnectionConfirmModeAlwaysDescription: "새 연결과 업데이트 링크 모두 대화 상자에서 확인을 기다립니다.",
+ deepLinkConnectionConfirmModeCreate: "새 연결만",
+ deepLinkConnectionConfirmModeCreateDescription: "새 연결은 즉시 만들고, id가 있는 업데이트 링크는 확인을 기다립니다.",
+ deepLinkConnectionConfirmModeUpdate: "id가 있는 링크만",
+ deepLinkConnectionConfirmModeUpdateDescription: "id가 있는 링크는 저장된 연결을 즉시 업데이트하고, 새 연결은 확인을 기다립니다.",
+ deepLinkConnectionConfirmModeAll: "모든 연결 링크",
+ deepLinkConnectionConfirmModeAllDescription: "새 연결과 업데이트 링크를 확인 없이 저장합니다. 미리 채워진 매개변수가 유효하지 않으면 대화 상자가 열린 채로 남아 직접 마저 입력할 수 있습니다.",
rememberedConnectionDatabaseCount: "기억된 항목: {count}",
clearRememberedConnectionDatabases: "기억된 항목 지우기",
reuseDataTab: "데이터 탭 재사용",
diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts
index ce9b9a1715..3039478a76 100644
--- a/apps/desktop/src/i18n/locales/pt-BR.ts
+++ b/apps/desktop/src/i18n/locales/pt-BR.ts
@@ -8492,6 +8492,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "Lembrar nomes de conexão e banco de dados",
rememberConnectionDatabaseOnDeleteDescription: "Lembra o nome e o banco de dados de uma conexão ao excluí-la e os pré-seleciona ao criar outra com o mesmo nome.",
rememberConnectionDatabaseOnDeleteHint: "Quando ativado, criar uma conexão com o mesmo nome e tipo de banco de dados preenche esse banco de dados e as abas SQL mantidas são religadas automaticamente à nova conexão.",
+ deepLinkConnectionConfirmMode: "Confirmação de conexões abertas por links",
+ deepLinkConnectionConfirmModeDescription: "Escolha quais links de conexão são salvos imediatamente em vez de esperar sua confirmação na janela.",
+ deepLinkConnectionConfirmModeAlways: "Confirmar sempre",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Conexões novas e atualizadas aguardam sua confirmação na janela.",
+ deepLinkConnectionConfirmModeCreate: "Somente conexões novas",
+ deepLinkConnectionConfirmModeCreateDescription: "Conexões novas são criadas na hora; links com id continuam aguardando confirmação.",
+ deepLinkConnectionConfirmModeUpdate: "Somente links com id",
+ deepLinkConnectionConfirmModeUpdateDescription: "Links com id atualizam a conexão salva na hora; conexões novas continuam aguardando confirmação.",
+ deepLinkConnectionConfirmModeAll: "Todos os links de conexão",
+ deepLinkConnectionConfirmModeAllDescription: "Conexões novas e atualizadas são salvas sem confirmação. Se os parâmetros pré-preenchidos forem inválidos, a janela permanece aberta para você completar manualmente.",
rememberedConnectionDatabaseCount: "Entradas lembradas: {count}",
clearRememberedConnectionDatabases: "Limpar entradas lembradas",
reuseDataTab: "Reutilizar aba de dados",
diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts
index 631d77af1c..b10c68e676 100644
--- a/apps/desktop/src/i18n/locales/ru.ts
+++ b/apps/desktop/src/i18n/locales/ru.ts
@@ -11124,6 +11124,16 @@ export default withEnglishFallback({
linuxFloatingFrame: "Эффект прозрачности окна",
linuxFloatingFrameDescription: "Автоматически включает прозрачные границы на поддерживаемых рабочих столах. Если окно мерцает, эту функцию можно отключить; изменения вступят в силу после применения и перезапуска DBX. Настройки переменных среды имеют приоритет.",
shortcutExecuteAllSql: "Выполнить весь SQL",
+ deepLinkConnectionConfirmMode: "Способ подтверждения при открытии подключения по ссылке",
+ deepLinkConnectionConfirmModeDescription: "Выберите, какие ссылки подключения сохранять сразу, не дожидаясь подтверждения в диалоговом окне.",
+ deepLinkConnectionConfirmModeAlways: "Все требуют подтверждения",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Для новых подключений и ссылок обновления с id сначала открывается диалоговое окно с запросом подтверждения.",
+ deepLinkConnectionConfirmModeCreate: "Только новые подключения",
+ deepLinkConnectionConfirmModeCreateDescription: "Новые подключения создаются сразу; для ссылок обновления с id по-прежнему открывается диалоговое окно для подтверждения.",
+ deepLinkConnectionConfirmModeUpdate: "Только ссылки обновления с id",
+ deepLinkConnectionConfirmModeUpdateDescription: "Ссылки с id сразу обновляют сохранённое подключение; для новых подключений по-прежнему открывается диалоговое окно для подтверждения.",
+ deepLinkConnectionConfirmModeAll: "Все ссылки подключения",
+ deepLinkConnectionConfirmModeAllDescription: "Новые подключения и ссылки обновления с id сохраняются сразу, без подтверждения. Если предварительно заполненные параметры не проходят проверку, диалоговое окно останется открытым, и вы сможете дополнить их вручную.",
},
driverStore: {
jreDirRemoveFailed: "Не удалось удалить старый каталог JRE: {path} (исходная ошибка: {error})",
diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.ts
index 0fbd42f31b..3d2105a83d 100644
--- a/apps/desktop/src/i18n/locales/th.ts
+++ b/apps/desktop/src/i18n/locales/th.ts
@@ -11505,6 +11505,16 @@ export default withEnglishFallback({
linuxFloatingFrame: "เอฟเฟกต์ความโปร่งใสของหน้าต่าง",
linuxFloatingFrameDescription: "เปิดใช้ขอบโปร่งใสโดยอัตโนมัติบนเดสก์ท็อปที่รองรับ หากหน้าต่างกะพริบสามารถปิดได้ มีผลหลังนำไปใช้และรีสตาร์ท DBX การตั้งค่าตัวแปรสภาพแวดล้อมมีลำดับความสำคัญ",
shortcutExecuteAllSql: "เรียกใช้ SQL ทั้งหมด",
+ deepLinkConnectionConfirmMode: "วิธียืนยันเมื่อเปิดการเชื่อมต่อผ่านลิงก์",
+ deepLinkConnectionConfirmModeDescription: "เลือกว่าลิงก์การเชื่อมต่อใดจะบันทึกโดยตรงโดยไม่ต้องรอการยืนยันในป๊อปอัป",
+ deepLinkConnectionConfirmModeAlways: "ต้องยืนยันทั้งหมด",
+ deepLinkConnectionConfirmModeAlwaysDescription: "การเชื่อมต่อใหม่และลิงก์อัปเดตที่มี id จะเปิดป๊อปอัปเพื่อรอให้คุณยืนยันก่อน",
+ deepLinkConnectionConfirmModeCreate: "เฉพาะการเชื่อมต่อใหม่",
+ deepLinkConnectionConfirmModeCreateDescription: "การเชื่อมต่อใหม่จะถูกสร้างโดยตรง ส่วนลิงก์อัปเดตที่มี id ยังคงเปิดป๊อปอัปเพื่อรอการยืนยัน",
+ deepLinkConnectionConfirmModeUpdate: "เฉพาะลิงก์อัปเดตที่มี id",
+ deepLinkConnectionConfirmModeUpdateDescription: "ลิงก์ที่มี id จะอัปเดตการเชื่อมต่อที่บันทึกไว้โดยตรง ส่วนการเชื่อมต่อใหม่ยังคงเปิดป๊อปอัปเพื่อรอการยืนยัน",
+ deepLinkConnectionConfirmModeAll: "ลิงก์การเชื่อมต่อทั้งหมด",
+ deepLinkConnectionConfirmModeAllDescription: "การเชื่อมต่อใหม่และลิงก์อัปเดตที่มี id จะถูกบันทึกโดยตรงโดยไม่ต้องยืนยันอีก หากการตรวจสอบพารามิเตอร์ที่กรอกล่วงหน้าไม่ผ่าน ป๊อปอัปจะยังคงเปิดอยู่ และคุณสามารถกรอกข้อมูลให้ครบด้วยตนเองต่อไปได้",
},
driverStore: {
jreDirRemoveFailed: "ลบไดเรกทอรี JRE เก่าไม่สำเร็จ: {path} (ข้อผิดพลาดเดิม: {error})",
diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts
index d4ed01cf48..f0e7761a4f 100644
--- a/apps/desktop/src/i18n/locales/tr.ts
+++ b/apps/desktop/src/i18n/locales/tr.ts
@@ -7802,6 +7802,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "Bağlantı ve veritabanı adlarını hatırla",
rememberConnectionDatabaseOnDeleteDescription: "Bir bağlantı silindiğinde adını ve veritabanını hatırlar ve aynı adla yeni bir bağlantı oluşturulduğunda bunları önceden seçer.",
rememberConnectionDatabaseOnDeleteHint: "Etkinleştirildiğinde, aynı ad ve aynı veritabanı türüyle bir bağlantı oluşturmak o veritabanını önceden doldurur ve korunan SQL sekmeleri yeni bağlantıya otomatik olarak yeniden bağlanır.",
+ deepLinkConnectionConfirmMode: "Bağlantı linklerinden açılan bağlantılarda onay",
+ deepLinkConnectionConfirmModeDescription: "Hangi bağlantı linklerinin iletişim kutusunda onay beklenmeden doğrudan kaydedileceğini seçin.",
+ deepLinkConnectionConfirmModeAlways: "Her zaman onayla",
+ deepLinkConnectionConfirmModeAlwaysDescription: "Hem yeni hem güncellenen bağlantılar iletişim kutusunda onayınızı bekler.",
+ deepLinkConnectionConfirmModeCreate: "Yalnızca yeni bağlantılar",
+ deepLinkConnectionConfirmModeCreateDescription: "Yeni bağlantılar hemen oluşturulur; id içeren güncelleme linkleri onay bekler.",
+ deepLinkConnectionConfirmModeUpdate: "Yalnızca id içeren linkler",
+ deepLinkConnectionConfirmModeUpdateDescription: "id içeren linkler kayıtlı bağlantıyı hemen günceller; yeni bağlantılar onay bekler.",
+ deepLinkConnectionConfirmModeAll: "Tüm bağlantı linkleri",
+ deepLinkConnectionConfirmModeAllDescription: "Yeni ve güncellenen bağlantılar onay alınmadan kaydedilir. Önceden doldurulan parametreler geçersizse iletişim kutusu açık kalır ve elle tamamlayabilirsiniz.",
rememberedConnectionDatabaseCount: "Hatırlanan kayıt: {count}",
clearRememberedConnectionDatabases: "Hatırlanan kayıtları temizle",
reuseDataTab: "Veri sekmesini yeniden kullan",
diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts
index 52c89e6762..07101b18be 100644
--- a/apps/desktop/src/i18n/locales/zh-CN.ts
+++ b/apps/desktop/src/i18n/locales/zh-CN.ts
@@ -9850,6 +9850,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "记住连接名与数据库名",
rememberConnectionDatabaseOnDeleteDescription: "删除连接时记住它的名称与数据库,再次新建同名连接时自动选中。",
rememberConnectionDatabaseOnDeleteHint: "开启后,新建同名同类型连接会自动回填该数据库,保留下来的 SQL 页签也会自动重新绑定到新连接。",
+ deepLinkConnectionConfirmMode: "通过链接打开连接时的确认方式",
+ deepLinkConnectionConfirmModeDescription: "选择哪些连接链接直接保存,不再等待你在弹窗中确认。",
+ deepLinkConnectionConfirmModeAlways: "都需要确认",
+ deepLinkConnectionConfirmModeAlwaysDescription: "新建连接和带 id 的更新链接都会先打开弹窗等你确认。",
+ deepLinkConnectionConfirmModeCreate: "仅新建连接",
+ deepLinkConnectionConfirmModeCreateDescription: "新建连接直接创建;带 id 的更新链接仍会打开弹窗等确认。",
+ deepLinkConnectionConfirmModeUpdate: "仅带 id 的更新链接",
+ deepLinkConnectionConfirmModeUpdateDescription: "带 id 的链接直接更新已保存的连接;新建连接仍会打开弹窗等确认。",
+ deepLinkConnectionConfirmModeAll: "所有连接链接",
+ deepLinkConnectionConfirmModeAllDescription: "新建连接和带 id 的更新链接都直接保存,不再确认。若预填参数校验不通过,弹窗会保持打开,可继续手动补全。",
rememberedConnectionDatabaseCount: "已记住 {count} 条记录",
clearRememberedConnectionDatabases: "清除已记住的记录",
reuseDataTab: "复用数据标签页",
diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts
index ea47afa678..6735a1eede 100644
--- a/apps/desktop/src/i18n/locales/zh-TW.ts
+++ b/apps/desktop/src/i18n/locales/zh-TW.ts
@@ -7838,6 +7838,16 @@ export default withEnglishFallback({
rememberConnectionDatabaseOnDelete: "記住連線名稱與資料庫名稱",
rememberConnectionDatabaseOnDeleteDescription: "刪除連線時記住它的名稱與資料庫,再次建立同名連線時自動選取。",
rememberConnectionDatabaseOnDeleteHint: "開啟後,建立同名同類型連線會自動填入該資料庫,保留下來的 SQL 分頁也會自動重新綁定到新連線。",
+ deepLinkConnectionConfirmMode: "透過連結開啟連線時的確認方式",
+ deepLinkConnectionConfirmModeDescription: "選擇哪些連線連結直接儲存,不再等待你在對話框中確認。",
+ deepLinkConnectionConfirmModeAlways: "都需要確認",
+ deepLinkConnectionConfirmModeAlwaysDescription: "新建連線和帶 id 的更新連結都會先開啟對話框等你確認。",
+ deepLinkConnectionConfirmModeCreate: "僅新建連線",
+ deepLinkConnectionConfirmModeCreateDescription: "新建連線直接建立;帶 id 的更新連結仍會開啟對話框等確認。",
+ deepLinkConnectionConfirmModeUpdate: "僅帶 id 的更新連結",
+ deepLinkConnectionConfirmModeUpdateDescription: "帶 id 的連結直接更新已儲存的連線;新建連線仍會開啟對話框等確認。",
+ deepLinkConnectionConfirmModeAll: "所有連線連結",
+ deepLinkConnectionConfirmModeAllDescription: "新建連線和帶 id 的更新連結都直接儲存,不再確認。若預填參數驗證不通過,對話框會保持開啟,可繼續手動補全。",
rememberedConnectionDatabaseCount: "已記住 {count} 筆記錄",
clearRememberedConnectionDatabases: "清除已記住的記錄",
reuseDataTab: "重複使用資料分頁",
diff --git a/apps/desktop/src/lib/connection/__tests__/connectionDeepLinkAutoCreate.spec.ts b/apps/desktop/src/lib/connection/__tests__/connectionDeepLinkAutoCreate.spec.ts
new file mode 100644
index 0000000000..2798e8755e
--- /dev/null
+++ b/apps/desktop/src/lib/connection/__tests__/connectionDeepLinkAutoCreate.spec.ts
@@ -0,0 +1,37 @@
+import { describe, expect, it } from "vitest";
+import { shouldAutoConfirmConnectionDeepLink, shouldAutoConfirmConnectionPrefill } from "@/lib/connection/connectionDeepLink";
+
+describe("shouldAutoConfirmConnectionDeepLink", () => {
+ it("confirms both kinds by default", () => {
+ expect(shouldAutoConfirmConnectionDeepLink("create", "always")).toBe(false);
+ expect(shouldAutoConfirmConnectionDeepLink("update", "always")).toBe(false);
+ });
+
+ it("only skips confirmation for the kind the mode names", () => {
+ expect(shouldAutoConfirmConnectionDeepLink("create", "create")).toBe(true);
+ expect(shouldAutoConfirmConnectionDeepLink("update", "create")).toBe(false);
+ expect(shouldAutoConfirmConnectionDeepLink("create", "update")).toBe(false);
+ expect(shouldAutoConfirmConnectionDeepLink("update", "update")).toBe(true);
+ });
+
+ it("skips confirmation for every link in all mode", () => {
+ expect(shouldAutoConfirmConnectionDeepLink("create", "all")).toBe(true);
+ expect(shouldAutoConfirmConnectionDeepLink("update", "all")).toBe(true);
+ });
+});
+
+describe("shouldAutoConfirmConnectionPrefill", () => {
+ it("follows the create rule for regular new connections", () => {
+ expect(shouldAutoConfirmConnectionPrefill({}, "always")).toBe(false);
+ expect(shouldAutoConfirmConnectionPrefill({}, "create")).toBe(true);
+ expect(shouldAutoConfirmConnectionPrefill({}, "update")).toBe(false);
+ expect(shouldAutoConfirmConnectionPrefill({}, "all")).toBe(true);
+ });
+
+ it("always auto-submits one-time connections, regardless of the mode", () => {
+ // one_time 连接是临时预览,本来就不需要用户确认。
+ for (const mode of ["always", "create", "update", "all"] as const) {
+ expect(shouldAutoConfirmConnectionPrefill({ oneTime: true }, mode)).toBe(true);
+ }
+ });
+});
diff --git a/apps/desktop/src/lib/connection/connectionDeepLink.ts b/apps/desktop/src/lib/connection/connectionDeepLink.ts
index d9b78f9f07..80a996bc09 100644
--- a/apps/desktop/src/lib/connection/connectionDeepLink.ts
+++ b/apps/desktop/src/lib/connection/connectionDeepLink.ts
@@ -1,4 +1,5 @@
import type { DatabaseType } from "@/types/database";
+import type { DeepLinkConnectionConfirmMode } from "@/stores/settingsStore";
import { connectionProfileForScheme, parseConnectionUrl } from "@/lib/connection/connectionUrl";
export type ConnectionDeepLinkServiceConfig =
@@ -334,6 +335,32 @@ export function parseConnectionDeepLink(value: string): ConnectionDeepLinkDraft
};
}
+/**
+ * 连接深链免确认的两种形态:新建连接、以及带 `id` 的更新链接。
+ */
+export type ConnectionDeepLinkKind = "create" | "update";
+
+/**
+ * 当前设置下,该形态的连接深链是否可以跳过确认直接保存。
+ *
+ * 只对新建连接生效的老布尔开关已由 {@link DeepLinkConnectionConfirmMode} 取代:
+ * `create` 对应老的「开启」,`all` 额外覆盖带 `id` 的更新链接。
+ */
+export function shouldAutoConfirmConnectionDeepLink(kind: ConnectionDeepLinkKind, mode: DeepLinkConnectionConfirmMode): boolean {
+ if (mode === "all") return true;
+ return mode === kind;
+}
+
+/**
+ * 深链预填完成后是否应当跳过确认、直接创建连接。
+ *
+ * `one_time` 临时连接从来就是自动提交的;其余新建连接取决于设置项
+ * `deepLinkConnectionConfirmMode`(默认 `always`,保持「先在弹窗里确认」的老行为)。
+ */
+export function shouldAutoConfirmConnectionPrefill(draft: Pick<ConnectionDeepLinkDraft, "oneTime">, mode: DeepLinkConnectionConfirmMode): boolean {
+ return draft.oneTime === true || shouldAutoConfirmConnectionDeepLink("create", mode);
+}
+
export function parseServiceConnectionUrl(value: string): ConnectionDeepLinkDraft | null {
let url: URL;
try {
diff --git a/apps/desktop/src/lib/settings/editorSettingsDraft.ts b/apps/desktop/src/lib/settings/editorSettingsDraft.ts
index c99cad7fca..df7fbaa119 100644
--- a/apps/desktop/src/lib/settings/editorSettingsDraft.ts
+++ b/apps/desktop/src/lib/settings/editorSettingsDraft.ts
@@ -125,6 +125,7 @@ export const EDITOR_SETTINGS_DRAFT_KEYS = [
"disconnectTabHandlingMode",
"deleteConnectionTabHandlingMode",
"rememberConnectionDatabaseOnDelete",
+ "deepLinkConnectionConfirmMode",
"dataTabReuseMode",
"openDataTabsNextToActive",
"prefillNewQueryWithSelect",
diff --git a/apps/desktop/src/lib/settings/settingsSearch.ts b/apps/desktop/src/lib/settings/settingsSearch.ts
index 15e694f1de..10a8a85547 100644
--- a/apps/desktop/src/lib/settings/settingsSearch.ts
+++ b/apps/desktop/src/lib/settings/settingsSearch.ts
@@ -410,6 +410,14 @@ export const SETTINGS_SEARCH_DEFINITIONS: readonly SettingsSearchDefinition[] =
keywordKeys: ["settings.deleteConnectionTabHandlingModeCloseTabs", "settings.deleteConnectionTabHandlingModeKeepSqlTabs", "settings.deleteConnectionTabHandlingModeKeepPinnedSqlTabs", "settings.deleteConnectionTabHandlingModeKeepAllTabs"],
},
{ id: "navigation-remember-connection-database", category: "navigation", titleKey: "settings.rememberConnectionDatabaseOnDelete", descriptionKey: "settings.rememberConnectionDatabaseOnDeleteDescription", targetId: "navigation", keywordKeys: ["settings.rememberConnectionDatabaseOnDeleteHint"] },
+ {
+ id: "navigation-deeplink-connection-confirm-mode",
+ category: "navigation",
+ titleKey: "settings.deepLinkConnectionConfirmMode",
+ descriptionKey: "settings.deepLinkConnectionConfirmModeDescription",
+ targetId: "navigation",
+ keywordKeys: ["settings.deepLinkConnectionConfirmModeAlways", "settings.deepLinkConnectionConfirmModeCreate", "settings.deepLinkConnectionConfirmModeUpdate", "settings.deepLinkConnectionConfirmModeAll"],
+ },
{ id: "query-page-size", category: "data", titleKey: "settings.queryPageSize", descriptionKey: "settings.queryPageSizeDescription", targetId: "data" },
{ id: "data-page-size", category: "data", titleKey: "settings.tableOpenPageSize", descriptionKey: "settings.tableOpenPageSizeDescription", targetId: "data" },
{ id: "data-table-open-sort-mode", category: "data", titleKey: "settings.tableOpenSortMode", descriptionKey: "settings.tableOpenSortDescription", targetId: "data", keywordKeys: ["settings.tableSortUnchanged", "settings.tableSortDatabase", "settings.tableSortLocal"] },
diff --git a/apps/desktop/src/lib/settings/settingsTransfer.ts b/apps/desktop/src/lib/settings/settingsTransfer.ts
index b9eb61210f..6b34e1f33e 100644
--- a/apps/desktop/src/lib/settings/settingsTransfer.ts
+++ b/apps/desktop/src/lib/settings/settingsTransfer.ts
@@ -206,6 +206,7 @@ const SETTINGS_TRANSFER_CATEGORY_KEYS: Record<SettingsTransferCategoryId, readon
"disconnectTabHandlingMode",
"deleteConnectionTabHandlingMode",
"rememberConnectionDatabaseOnDelete",
+ "deepLinkConnectionConfirmMode",
"dataTabReuseMode",
"openDataTabsNextToActive",
"clickTableNavigationTarget",
diff --git a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
index 430ddcd883..e6d03dfabe 100644
--- a/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
+++ b/apps/desktop/src/stores/__tests__/settingsStore.spec.ts
@@ -590,6 +590,19 @@ describe("normalizeEditorSettings", () => {
expect(normalizeEditorSettings({ deleteConnectionTabHandlingMode: "keep-all" } as any).deleteConnectionTabHandlingMode).toBe("keep-all-tabs");
});
+ it("defaults DeepLink confirmation to always and maps the legacy boolean switch", () => {
+ // 默认都要确认:深链打开连接仍然要用户在弹窗里确认一次。
+ expect(normalizeEditorSettings({}).deepLinkConnectionConfirmMode).toBe("always");
+ for (const mode of ["always", "create", "update", "all"] as const) {
+ expect(normalizeEditorSettings({ deepLinkConnectionConfirmMode: mode }).deepLinkConnectionConfirmMode).toBe(mode);
+ }
+ // 上一版的布尔开关只覆盖新建连接,true 收敛成 create。
+ expect(normalizeEditorSettings({ deepLinkConnectionAutoCreate: true } as any).deepLinkConnectionConfirmMode).toBe("create");
+ expect(normalizeEditorSettings({ deepLinkConnectionAutoCreate: false } as any).deepLinkConnectionConfirmMode).toBe("always");
+ // 非法值一律回落默认值。
+ expect(normalizeEditorSettings({ deepLinkConnectionConfirmMode: "sometimes" } as any).deepLinkConnectionConfirmMode).toBe("always");
+ });
+
it("remembers connection databases by default and sanitizes the stored map", () => {
expect(normalizeEditorSettings({}).rememberConnectionDatabaseOnDelete).toBe(true);
expect(normalizeEditorSettings({ rememberConnectionDatabaseOnDelete: false }).rememberConnectionDatabaseOnDelete).toBe(false);
diff --git a/apps/desktop/src/stores/settingsStore.ts b/apps/desktop/src/stores/settingsStore.ts
index 3452ce11dc..67f41cf8af 100644
--- a/apps/desktop/src/stores/settingsStore.ts
+++ b/apps/desktop/src/stores/settingsStore.ts
@@ -868,6 +868,17 @@ export type DeleteConnectionTabHandlingMode = (typeof DELETE_CONNECTION_TAB_HAND
const CLICK_TABLE_NAVIGATION_TARGETS = ["data", "ddl"] as const;
export type ClickTableNavigationTarget = (typeof CLICK_TABLE_NAVIGATION_TARGETS)[number];
+/**
+ * 通过连接深链(`dbx://connection/new`)打开连接时,哪些情况跳过确认直接保存。
+ *
+ * - `always`:新建与更新都要在弹窗里确认(默认)
+ * - `create`:仅新建连接免确认;带 `id` 的更新链接仍要确认(更新会改动已保存的配置)
+ * - `update`:仅带 `id` 的更新链接免确认;新建仍要确认
+ * - `all`:所有连接深链都免确认
+ */
+const DEEP_LINK_CONNECTION_CONFIRM_MODES = ["always", "create", "update", "all"] as const;
+export type DeepLinkConnectionConfirmMode = (typeof DEEP_LINK_CONNECTION_CONFIRM_MODES)[number];
+
export interface CustomThemeColors {
keyword: string;
field: string;
@@ -1178,6 +1189,11 @@ export interface EditorSettings {
rememberConnectionDatabaseOnDelete: boolean;
/** 已记住的「连接名 → { 数据库名, 数据库类型 }」映射,用于新建同名连接时自动选中数据库。 */
rememberedConnectionDatabases: Record<string, RememberedConnectionDatabase>;
+ /**
+ * 通过连接深链(`dbx://connection/new`,含带 `id` 的更新链接)打开连接时,
+ * 哪些情况跳过确认直接保存。见 {@link DeepLinkConnectionConfirmMode}。
+ */
+ deepLinkConnectionConfirmMode: DeepLinkConnectionConfirmMode;
dataTabReuseMode: DataTabReuseMode;
openDataTabsNextToActive: boolean;
prefillNewQueryWithSelect: boolean;
@@ -1531,6 +1547,7 @@ export const DEFAULT_EDITOR_SETTINGS: EditorSettings = {
deleteConnectionTabHandlingMode: "close-tabs",
rememberConnectionDatabaseOnDelete: true,
rememberedConnectionDatabases: {},
+ deepLinkConnectionConfirmMode: "always",
dataTabReuseMode: DEFAULT_DATA_TAB_REUSE_MODE,
openDataTabsNextToActive: false,
prefillNewQueryWithSelect: true,
@@ -1798,6 +1815,24 @@ function normalizeDeleteConnectionTabHandlingMode(value: unknown): DeleteConnect
return DEFAULT_EDITOR_SETTINGS.deleteConnectionTabHandlingMode;
}
+/**
+ * 深链免确认模式。
+ *
+ * `legacyAutoCreate` 是上一版布尔开关 `deepLinkConnectionAutoCreate` 的值:
+ * 它只覆盖新建连接,所以 `true` 收敛成 `create`、`false` 收敛成 `always`。
+ */
+function normalizeDeepLinkConnectionConfirmMode(value: unknown, legacyAutoCreate?: unknown): DeepLinkConnectionConfirmMode {
+ if (DEEP_LINK_CONNECTION_CONFIRM_MODES.includes(value as DeepLinkConnectionConfirmMode)) {
+ return value as DeepLinkConnectionConfirmMode;
+ }
+ // 兼容早期试验值。
+ if (value === "never" || value === "none") return "always";
+ if (value === "create-only") return "create";
+ if (value === "update-only") return "update";
+ if (legacyAutoCreate === true) return "create";
+ return DEFAULT_EDITOR_SETTINGS.deepLinkConnectionConfirmMode;
+}
+
/** 记住的连接名 → 数据库映射:只保留合法条目,并限制条目数量避免无限增长。 */
const REMEMBERED_CONNECTION_DATABASES_LIMIT = 200;
@@ -2234,6 +2269,11 @@ export function normalizeEditorSettings(settings: Partial<EditorSettings>, exist
deleteConnectionTabHandlingMode: normalizeDeleteConnectionTabHandlingMode(settings.deleteConnectionTabHandlingMode),
rememberConnectionDatabaseOnDelete: typeof settings.rememberConnectionDatabaseOnDelete === "boolean" ? settings.rememberConnectionDatabaseOnDelete : DEFAULT_EDITOR_SETTINGS.rememberConnectionDatabaseOnDelete,
rememberedConnectionDatabases: normalizeRememberedConnectionDatabases(settings.rememberedConnectionDatabases),
+ deepLinkConnectionConfirmMode: normalizeDeepLinkConnectionConfirmMode(
+ settings.deepLinkConnectionConfirmMode,
+ // 上一版布尔开关,已从类型里移除,只在这里读一次做迁移。
+ (settings as { deepLinkConnectionAutoCreate?: unknown }).deepLinkConnectionAutoCreate,
+ ),
dataTabReuseMode: normalizeDataTabReuseMode(
settings.dataTabReuseMode,
(
@@ -3144,6 +3184,7 @@ export const useSettingsStore = defineStore("settings", () => {
if (partial.deleteConnectionTabHandlingMode !== undefined) editorSettings.value.deleteConnectionTabHandlingMode = normalizeDeleteConnectionTabHandlingMode(partial.deleteConnectionTabHandlingMode);
if (partial.rememberConnectionDatabaseOnDelete !== undefined) editorSettings.value.rememberConnectionDatabaseOnDelete = partial.rememberConnectionDatabaseOnDelete === true;
if (partial.rememberedConnectionDatabases !== undefined) editorSettings.value.rememberedConnectionDatabases = normalizeRememberedConnectionDatabases(partial.rememberedConnectionDatabases);
+ if (partial.deepLinkConnectionConfirmMode !== undefined) editorSettings.value.deepLinkConnectionConfirmMode = normalizeDeepLinkConnectionConfirmMode(partial.deepLinkConnectionConfirmMode);
if (partial.dataTabReuseMode !== undefined) editorSettings.value.dataTabReuseMode = normalizeDataTabReuseMode(partial.dataTabReuseMode);
if (partial.openDataTabsNextToActive !== undefined) editorSettings.value.openDataTabsNextToActive = partial.openDataTabsNextToActive === true;
if (partial.prefillNewQueryWithSelect !== undefined) editorSettings.value.prefillNewQueryWithSelect = partial.prefillNewQueryWithSelect;