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
fix(structure): load editor on open
t8y25b3b69f7fbb8
diff --git a/apps/desktop/src/components/structure/TableStructureEditorDialog.vue b/apps/desktop/src/components/structure/TableStructureEditorDialog.vueindex 017a0f0a88..f128c08e1f 100644--- a/apps/desktop/src/components/structure/TableStructureEditorDialog.vue+++ b/apps/desktop/src/components/structure/TableStructureEditorDialog.vue@@ -39,7 +39,12 @@ import {type EditableStructureIndex,} from "@/lib/tableStructureEditorSql";import { getTableStructureCapabilities } from "@/lib/tableStructureCapabilities";-import { createColumnDrafts, createIndexDrafts, toColumnNames } from "@/lib/tableStructureEditorState";+import {+ buildStructureTargetLabel,+ createColumnDrafts,+ createIndexDrafts,+ toColumnNames,+} from "@/lib/tableStructureEditorState";import type { ForeignKeyInfo, TriggerInfo } from "@/types/database";import * as api from "@/lib/api";@@ -116,11 +121,14 @@ const indexColLabels = computed(() => [const targetSchema = computed(() => props.prefillSchema || props.prefillDatabase || "");const isCreateMode = computed(() => !props.prefillTable);const newTableName = ref("");-const targetLabel = computed(() => {- const parts = [connection.value?.name, props.prefillDatabase, props.prefillSchema];- if (!isCreateMode.value) parts.push(props.prefillTable);- return parts.filter(Boolean).join(" / ");-});+const targetLabel = computed(() =>+ buildStructureTargetLabel(+ connection.value?.name,+ props.prefillDatabase,+ props.prefillSchema,+ isCreateMode.value ? undefined : props.prefillTable,+ ),+);const changeSql = computed(() => {if (isCreateMode.value) {@@ -331,12 +339,16 @@ async function applyChanges() {}}-watch(open, (value) => {- if (value) {- resetState();- void loadStructure();- }-});+watch(+ open,+ (value) => {+ if (value) {+ resetState();+ void loadStructure();+ }+ },+ { immediate: true },+);</script><template>diff --git a/apps/desktop/src/lib/tableStructureEditorState.ts b/apps/desktop/src/lib/tableStructureEditorState.tsindex 8419abaa37..717e63c8ce 100644--- a/apps/desktop/src/lib/tableStructureEditorState.ts+++ b/apps/desktop/src/lib/tableStructureEditorState.ts@@ -34,3 +34,15 @@ export function createIndexDrafts(indexes: IndexInfo[]): EditableStructureIndex[export function toColumnNames(columns: string[]): string {return columns.join(", ");}++export function buildStructureTargetLabel(+ connectionName: string | undefined,+ database: string | undefined,+ schema: string | undefined,+ tableName: string | undefined,+): string {+ const parts = [connectionName, database];+ if (schema && schema !== database) parts.push(schema);+ if (tableName) parts.push(tableName);+ return parts.filter(Boolean).join(" / ");+}diff --git a/packages/app-tests/tableStructureEditorPresentation.test.ts b/packages/app-tests/tableStructureEditorPresentation.test.tsindex 37ff83a1e2..227449f53d 100644--- a/packages/app-tests/tableStructureEditorPresentation.test.ts+++ b/packages/app-tests/tableStructureEditorPresentation.test.ts@@ -18,6 +18,10 @@ test("structure editor keeps columns when optional metadata fails", () => {assert.match(source, /api\s*\n\s*\.listTriggers[\s\S]*\.catch\(\(\) => \[\]\)/);});+test("structure editor loads immediately when mounted open", () => {+ assert.match(source, /watch\(\s*open,[\s\S]*\{\s*immediate:\s*true\s*\},?\s*\)/);+});+test("structure editor gates controls through table structure capabilities", () => {assert.match(source, /getTableStructureCapabilities/);assert.match(source, /const structureCapabilities = computed/);diff --git a/packages/app-tests/tableStructureEditorState.test.ts b/packages/app-tests/tableStructureEditorState.test.tsindex ef9388e6d1..5cac0133d9 100644--- a/packages/app-tests/tableStructureEditorState.test.ts+++ b/packages/app-tests/tableStructureEditorState.test.ts@@ -1,6 +1,7 @@import assert from "node:assert/strict";import test from "node:test";import {+ buildStructureTargetLabel,createColumnDrafts,createIndexDrafts,toColumnNames,@@ -102,3 +103,14 @@ test("creates editable index drafts and splits pasted column lists", () => {]);assert.equal(toColumnNames(["id", "name"]), "id, name");});++test("structure editor target label omits duplicate database and schema", () => {+ assert.equal(+ buildStructureTargetLabel("online-clickhouse", "testdb", "testdb", "users"),+ "online-clickhouse / testdb / users",+ );+ assert.equal(+ buildStructureTargetLabel("online-postgres", "app", "public", "users"),+ "online-postgres / app / public / users",+ );+});