feat(远程备份): 添加连接测试功能并优化协议切换逻辑
前端添加连接测试功能,使用 getFieldsValue 获取完整表单值并打印日志 后端实现 /remote/test 接口,支持协议自动推断和连接测试 优化协议切换时的表单重置逻辑,清空相关字段并设置默认路径
This commit is contained in:
@@ -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);
|
||||
}}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user