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(structure): add default value quick-pick presets to table designer
t8y230cf9a4e9299
diff --git a/apps/desktop/src/components/structure/TableStructureEditor.vue b/apps/desktop/src/components/structure/TableStructureEditor.vueindex 106fdd2de7..ae0c93e150 100644--- a/apps/desktop/src/components/structure/TableStructureEditor.vue+++ b/apps/desktop/src/components/structure/TableStructureEditor.vue@@ -7,7 +7,7 @@ import { Input } from "@/components/ui/input";import { Badge } from "@/components/ui/badge";import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";import { AlertTriangle, Check, ChevronDown, ChevronUp, Copy, Database, Info, KeyRound, Loader2, Maximize2, Plus, RefreshCw, Save, SlidersHorizontal, Trash2, X } from "@lucide/vue";-import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";+import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";import { SearchableSelect } from "@/components/ui/searchable-select";@@ -301,6 +301,68 @@ const indexTypesByDb: Record<string, string[]> = {};const indexTypeOptions = computed(() => (structureCapabilities.value.indexType ? (indexTypesByDb[structureDialect.value] ?? []) : []));+interface DefaultValuePreset {+ label: string;+ value: string;+}++const defaultValuePresets = computed((): DefaultValuePreset[] => {+ const universal: DefaultValuePreset[] = [+ { label: "''", value: "''" },+ { label: "NULL", value: "NULL" },+ { label: "0", value: "0" },+ { label: "1", value: "1" },+ ];++ const dialectPresets: Record<string, DefaultValuePreset[]> = {+ mysql: [+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "CURRENT_DATE", value: "CURRENT_DATE" },+ { label: "CURRENT_TIME", value: "CURRENT_TIME" },+ ],+ postgres: [+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "CURRENT_DATE", value: "CURRENT_DATE" },+ { label: "now()", value: "now()" },+ { label: "gen_random_uuid()", value: "gen_random_uuid()" },+ ],+ sqlite: [+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "CURRENT_DATE", value: "CURRENT_DATE" },+ { label: "CURRENT_TIME", value: "CURRENT_TIME" },+ ],+ duckdb: [+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "CURRENT_DATE", value: "CURRENT_DATE" },+ ],+ sqlserver: [+ { label: "GETDATE()", value: "GETDATE()" },+ { label: "GETUTCDATE()", value: "GETUTCDATE()" },+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "NEWID()", value: "NEWID()" },+ ],+ oracle: [+ { label: "SYSDATE", value: "SYSDATE" },+ { label: "SYSTIMESTAMP", value: "SYSTIMESTAMP" },+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ ],+ h2: [+ { label: "CURRENT_TIMESTAMP", value: "CURRENT_TIMESTAMP" },+ { label: "CURRENT_DATE", value: "CURRENT_DATE" },+ ],+ clickhouse: [+ { label: "now()", value: "now()" },+ { label: "today()", value: "today()" },+ ],+ informix: [+ { label: "CURRENT", value: "CURRENT" },+ { label: "TODAY", value: "TODAY" },+ ],+ };++ return [...universal, ...(dialectPresets[structureDialect.value] ?? [])];+});+function isPostgresIdentityType(dbType: string | undefined): boolean {return dbType === "postgres" || dbType === "gaussdb" || dbType === "kwdb" || dbType === "opengauss" || dbType === "highgo" || dbType === "vastbase" || dbType === "kingbase";}@@ -1035,7 +1097,21 @@ watch(activeTab, (tab) => {/></td><td v-if="columnEditorControls.defaultValue" :class="structureCellClass">- <Input v-model="column.defaultValue" :class="structureMonoControlClass" :disabled="isColumnDefaultDisabled(column)" />+ <div class="flex min-w-0 items-center gap-1">+ <Input v-model="column.defaultValue" :class="[structureMonoControlClass, 'flex-1']" :disabled="isColumnDefaultDisabled(column)" />+ <DropdownMenu>+ <DropdownMenuTrigger as-child>+ <Button variant="ghost" size="icon" :class="[structureIconButtonClass, 'shrink-0']" :disabled="isColumnDefaultDisabled(column)" :aria-label="t('structureEditor.defaultValuePresets')" :title="t('structureEditor.defaultValuePresets')">+ <ChevronDown :class="structureIconClass" />+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end" class="max-h-56 min-w-36 overflow-y-auto">+ <DropdownMenuItem v-for="preset in defaultValuePresets" :key="preset.value" @click="column.defaultValue = preset.value">+ <code class="font-mono text-[length:var(--structure-font-size)]">{{ preset.label }}</code>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </div></td><td v-if="columnEditorControls.comment" :class="structureCellClass"><div class="flex min-w-0 items-center gap-1">diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 8fb0c94907..e371fbea30 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -1349,6 +1349,7 @@ export default {nullable: "Nullable",primaryKey: "Primary Key",defaultValue: "Default",+ defaultValuePresets: "Default value presets",comment: "Comment",editComment: "Edit comment",commentPlaceholder: "Enter column comment...",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex cf4b3a08b1..9673647179 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -1120,6 +1120,7 @@ export default {nullable: "Admite nulos",primaryKey: "Clave primaria",defaultValue: "Valor por defecto",+ defaultValuePresets: "Valores predeterminados preestablecidos",comment: "Comentario",editComment: "Editar comentario",commentPlaceholder: "Ingresar comentario de columna...",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex 472958b592..2c4cf72107 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -1236,6 +1236,7 @@ export default {nullable: "Nullabile",primaryKey: "Chiave Primaria",defaultValue: "Valore Predefinito",+ defaultValuePresets: "Preimpostazioni valore predefinito",comment: "Commento",editComment: "Modifica commento",commentPlaceholder: "Inserisci commento colonna...",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 4ce0e2c9ff..f7f9745dd5 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -1337,6 +1337,7 @@ export default {nullable: "NULL許容",primaryKey: "主キー",defaultValue: "デフォルト",+ defaultValuePresets: "デフォルト値プリセット",comment: "コメント",editComment: "コメントを編集",commentPlaceholder: "列コメントを入力...",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 069dbe3172..37b898c914 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -1238,6 +1238,7 @@ export default {nullable: "Permite nulo",primaryKey: "Chave primária",defaultValue: "Padrão",+ defaultValuePresets: "Predefinições de valor padrão",comment: "Comentário",editComment: "Editar comentário",commentPlaceholder: "Insira o comentário da coluna...",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex d87b4c7710..44cb55cbb1 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -1348,6 +1348,7 @@ export default {nullable: "可为空",primaryKey: "主键",defaultValue: "默认值",+ defaultValuePresets: "默认值预设",comment: "注释",editComment: "编辑注释",commentPlaceholder: "输入字段注释...",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex 487153cd6c..c9708ce517 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -1217,6 +1217,7 @@ export default {nullable: "可為空",primaryKey: "主鍵",defaultValue: "預設值",+ defaultValuePresets: "預設值預設",comment: "註解",editComment: "編輯註解",commentPlaceholder: "輸入欄位註解……",