[修正]修正了当dhcp启用时保存的bug
This commit is contained in:
@@ -157,26 +157,29 @@ class ManageNetwork extends SettingsPage
|
||||
// 获取用户输入的网络配置
|
||||
$ipAddress = $this->form->getState()['ip'] ?? '';
|
||||
$gateway = $this->form->getState()['gateway'] ?? '';
|
||||
$dhcpEnabled = $this->form->getState()['dhcp_enabled'];
|
||||
if ($dhcpEnabled !== 'true'){
|
||||
if (!filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
Notification::make()
|
||||
->title('无效的 IP 地址格式')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return; // 返回,不执行保存操作
|
||||
}
|
||||
|
||||
// 验证网关地址格式
|
||||
if (!filter_var($gateway, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
Notification::make()
|
||||
->title('无效的网关地址格式')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return; // 返回,不执行保存操作
|
||||
}
|
||||
}
|
||||
// 验证 IP 地址格式
|
||||
if (!filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
Notification::make()
|
||||
->title('无效的 IP 地址格式')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return; // 返回,不执行保存操作
|
||||
}
|
||||
|
||||
// 验证网关地址格式
|
||||
if (!filter_var($gateway, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
|
||||
Notification::make()
|
||||
->title('无效的网关地址格式')
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return; // 返回,不执行保存操作
|
||||
}
|
||||
|
||||
// 调用父类的保存方法以持久化设置
|
||||
parent::save();
|
||||
@@ -197,8 +200,6 @@ class ManageNetwork extends SettingsPage
|
||||
$ipAddress = $this->form->getState()['ip'] ?? '';
|
||||
$mask = $this->form->getState()['mask'] ?? '';
|
||||
$gateway = $this->form->getState()['gateway'] ?? '';
|
||||
// $dns1 = $this->form->getState()['dns_server_1'] ?? '';
|
||||
// $dns2 = $this->form->getState()['dns_server_2'] ?? '';
|
||||
|
||||
$dnsServers = $this->form->getState()['dns_servers'] ?? [];
|
||||
$dnsString = implode(',', $dnsServers); // 合并 DNS 地址为字符串
|
||||
|
||||
Reference in New Issue
Block a user