feat(远程备份): 添加连接测试功能并优化协议切换逻辑

前端添加连接测试功能,使用 getFieldsValue 获取完整表单值并打印日志
后端实现 /remote/test 接口,支持协议自动推断和连接测试
优化协议切换时的表单重置逻辑,清空相关字段并设置默认路径
This commit is contained in:
zhang1106
2026-03-23 10:40:26 +08:00
parent a5da9c04c9
commit 66807b1660
2 changed files with 71 additions and 3 deletions
+18 -3
View File
@@ -293,8 +293,10 @@ const RemoteBackupSettings = () => {
try {
setTesting(true);
setTestStatus('testing');
const values = await form.validateFields();
await form.validateFields();
const values = form.getFieldsValue(true);
console.log('[TestConnection] getFieldsValue(true):', JSON.stringify(values));
const response = await api.post('/backup/remote/test', values);
if (response?.success) {
@@ -832,7 +834,20 @@ const RemoteBackupSettings = () => {
placeholder="选择协议类型"
size="large"
onChange={() => {
form.setFieldsValue({});
form.setFieldsValue({
host: undefined,
port: undefined,
username: undefined,
password: undefined,
secure: undefined,
privateKey: undefined,
passphrase: undefined,
share: undefined,
domain: undefined,
url: undefined,
authType: undefined,
rootPath: '/',
});
setTestStatus(null);
}}
>