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(sync): refresh tunnel profiles after download

t8y22666ed1cd2af
diff --git a/apps/desktop/src/components/editor/EditorSettingsDialog.vue b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
index f1562fc78a..9cbe8d0748 100644
--- a/apps/desktop/src/components/editor/EditorSettingsDialog.vue
+++ b/apps/desktop/src/components/editor/EditorSettingsDialog.vue
@@ -104,6 +104,7 @@ import { APP_THEME_PALETTES, type AppThemeAppearance, type AppThemeMode, type Ap
import { editorSettingsDraftChanged, editorSettingsDraftFromSettings, editorSettingsPatchFromDraft, type EditorSettingsDraft } from "@/lib/settings/editorSettingsDraft";
import { useConnectionStore } from "@/stores/connectionStore";
import { useSavedSqlStore } from "@/stores/savedSqlStore";
+import { useTunnelProfileStore } from "@/stores/tunnelProfileStore";
import { currentLocale, setLocale, type Locale } from "@/i18n";
import { LOCALE_OPTIONS } from "@/lib/app/localeOptions";
import { DEFAULT_WEB_DAV_AUTO_UPLOAD_INTERVAL_MINUTES, DEFAULT_WEB_DAV_REMOTE_PATH, normalizedWebDavAutoUploadInterval, writeWebDavAutoUploadFields } from "@/lib/webdav/webdavAutoUploadConfig";
@@ -116,6 +117,7 @@ const { toast } = useToast();
const settingsStore = useSettingsStore();
const connectionStore = useConnectionStore();
const savedSqlStore = useSavedSqlStore();
+const tunnelProfileStore = useTunnelProfileStore();
const { isDark, themeMode, themePalette, setThemeMode, setThemePalette } = useTheme();
const appThemePaletteOptions = computed(
@@ -1583,6 +1585,9 @@ async function downloadSnippetSnapshot() {
await settingsStore.updateDesktopSettings(result.desktopSettings);
await connectionStore.initFromDisk();
await savedSqlStore.initFromStorage();
+ // Snapshot downloads replace backend-managed tunnel profiles, so refresh
+ // the already-loaded Pinia store instead of leaving the UI stale.
+ await tunnelProfileStore.refresh();
let message = t("settings.syncSnippetDownloadSuccess", { bytes: result.summary.bytes, id: result.summary.snippetId });
if (result.applySummary.encryptedSecretsPresent && !result.applySummary.secretsApplied) message += ` ${t("settings.syncSecretsSkipped")}`;
if (result.applySummary.secretsApplied) message += ` ${t("settings.syncSecretsApplied")}`;
@@ -1719,6 +1724,8 @@ async function downloadWebDavSnapshot() {
await settingsStore.updateDesktopSettings(result.desktopSettings);
await connectionStore.initFromDisk();
await savedSqlStore.initFromStorage();
+ // Keep the shared tunnel profile UI consistent with the downloaded snapshot.
+ await tunnelProfileStore.refresh();
const message = t("settings.syncDownloadSuccess", {
bytes: result.summary.bytes,
path: result.summary.remotePath,
diff --git a/packages/app-tests/syncTunnelProfiles.test.ts b/packages/app-tests/syncTunnelProfiles.test.ts
new file mode 100644
index 0000000000..7b50b26e0e
--- /dev/null
+++ b/packages/app-tests/syncTunnelProfiles.test.ts
@@ -0,0 +1,30 @@
+import { strict as assert } from "node:assert";
+import { readFileSync } from "node:fs";
+import { test } from "vitest";
+
+function functionBody(source: string, name: string): string {
+ const signature = `async function ${name}(`;
+ const signatureIndex = source.indexOf(signature);
+ assert.notEqual(signatureIndex, -1, `Could not find function ${name}`);
+ const bodyStart = source.indexOf("{", signatureIndex);
+ assert.notEqual(bodyStart, -1, `Could not find body for ${name}`);
+
+ let depth = 0;
+ for (let index = bodyStart; index < source.length; index += 1) {
+ if (source[index] === "{") depth += 1;
+ if (source[index] === "}") {
+ depth -= 1;
+ if (depth === 0) return source.slice(bodyStart + 1, index);
+ }
+ }
+ throw new Error(`Could not parse body for ${name}`);
+}
+
+test("sync downloads refresh shared tunnel profiles", () => {
+ const source = readFileSync("apps/desktop/src/components/editor/EditorSettingsDialog.vue", "utf8");
+
+ for (const functionName of ["downloadSnippetSnapshot", "downloadWebDavSnapshot"]) {
+ const body = functionBody(source, functionName);
+ assert.match(body, /await tunnelProfileStore\.refresh\(\)/, `${functionName} should refresh downloaded tunnel profiles`);
+ }
+});