feat(connection): auto-generate name when left empty

Allow saving connections without a name by generating one in the format
`{DbType}_{random4chars}` (e.g. Neo4j_a3f2). Update placeholder text
to inform users about auto-generation.
This commit is contained in:
t8y2
2026-05-15 20:20:44 +08:00
parent f031fe85ae
commit 793c244d40
5 changed files with 83 additions and 4 deletions
@@ -515,8 +515,17 @@ async function testConnection() {
}
}
function generateConnectionName(): string {
const label = selectedProfile().label;
const rand = Math.random().toString(36).slice(2, 6);
return `${label}_${rand}`;
}
function connectionConfigForSubmit(id: string): ConnectionConfig {
const config: ConnectionConfig = { ...form.value, id };
if (!config.name?.trim()) {
config.name = generateConnectionName();
}
const sshTimeout = Number(config.ssh_connect_timeout_secs);
config.ssh_connect_timeout_secs = Number.isFinite(sshTimeout) && sshTimeout > 0 ? sshTimeout : 5;
const proxyPort = Number(config.proxy_port);
@@ -1431,7 +1440,6 @@ function openExternalUrl(url: string) {
@click="save"
:disabled="
isSaving ||
!form.name ||
(!form.host &&
!(mongoUseUrl && form.connection_string) &&
!(form.db_type === 'jdbc' && form.connection_string))
+1 -1
View File
@@ -93,7 +93,7 @@ export default {
connection: {
title: "New Connection",
name: "Name",
namePlaceholder: "My Database",
namePlaceholder: "Connection name, auto-generated if empty",
type: "Type",
host: "Host",
filePath: "File Path",
+1 -1
View File
@@ -93,7 +93,7 @@ export default {
connection: {
title: "Nueva conexión",
name: "Nombre",
namePlaceholder: "Mi base de datos",
namePlaceholder: "Nombre de conexión, se genera automáticamente si está vacío",
type: "Tipo",
host: "Host",
filePath: "Ruta del archivo",
+1 -1
View File
@@ -92,7 +92,7 @@ export default {
connection: {
title: "新建连接",
name: "名称",
namePlaceholder: "我的数据库",
namePlaceholder: "连接名称,留空则自动生成",
type: "类型",
host: "主机",
filePath: "文件路径",