fix: 代理表单字段保存时自动去除前后空格

前后端同时处理,防止因意外空格导致代理连接失败
This commit is contained in:
shaw
2025-12-19 10:39:30 +08:00
parent 32e58115cc
commit 2e59998c51
2 changed files with 38 additions and 27 deletions

View File

@@ -647,10 +647,10 @@ const parseProxyUrl = (line: string): {
return {
protocol: protocol.toLowerCase() as ProxyProtocol,
host,
host: host.trim(),
port: portNum,
username: username || '',
password: password || ''
username: username?.trim() || '',
password: password?.trim() || ''
}
}
@@ -714,9 +714,12 @@ const handleCreateProxy = async () => {
submitting.value = true
try {
await adminAPI.proxies.create({
...createForm,
username: createForm.username || null,
password: createForm.password || null
name: createForm.name.trim(),
protocol: createForm.protocol,
host: createForm.host.trim(),
port: createForm.port,
username: createForm.username.trim() || null,
password: createForm.password.trim() || null
})
appStore.showSuccess(t('admin.proxies.proxyCreated'))
closeCreateModal()
@@ -752,17 +755,18 @@ const handleUpdateProxy = async () => {
submitting.value = true
try {
const updateData: any = {
name: editForm.name,
name: editForm.name.trim(),
protocol: editForm.protocol,
host: editForm.host,
host: editForm.host.trim(),
port: editForm.port,
username: editForm.username || null,
username: editForm.username.trim() || null,
status: editForm.status
}
// Only include password if it was changed
if (editForm.password) {
updateData.password = editForm.password
const trimmedPassword = editForm.password.trim()
if (trimmedPassword) {
updateData.password = trimmedPassword
}
await adminAPI.proxies.update(editingProxy.value.id, updateData)