perf: optimize conflict connection name when duplicating
This commit is contained in:
parent
09264134ec
commit
74a6b9b0e1
|
@ -124,13 +124,29 @@ const useDialogStore = defineStore('dialog', {
|
||||||
|
|
||||||
async openDuplicateDialog(name) {
|
async openDuplicateDialog(name) {
|
||||||
const connStore = useConnectionStore()
|
const connStore = useConnectionStore()
|
||||||
const profile = await connStore.getConnectionProfile(name)
|
this.connParam = {}
|
||||||
if (profile != null) {
|
let profile
|
||||||
profile.name += '2'
|
let suffix = 1
|
||||||
this.connParam = profile
|
do {
|
||||||
} else {
|
let profileName = name
|
||||||
this.connParam = connStore.newDefaultConnection(name)
|
if (suffix > 1) {
|
||||||
|
profileName += suffix
|
||||||
}
|
}
|
||||||
|
profile = await connStore.getConnectionProfile(profileName)
|
||||||
|
if (profile != null) {
|
||||||
|
suffix += 1
|
||||||
|
if (profileName === name) {
|
||||||
|
this.connParam = profile
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.connParam = connStore.mergeConnectionProfile(
|
||||||
|
connStore.newDefaultConnection(profileName),
|
||||||
|
this.connParam,
|
||||||
|
)
|
||||||
|
this.connParam.name = profileName
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} while (true)
|
||||||
this.connType = ConnDialogType.NEW
|
this.connType = ConnDialogType.NEW
|
||||||
this.connDialogVisible = true
|
this.connDialogVisible = true
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue