[修正]修正了当dhcp启用时保存的bug

This commit is contained in:
makotocc0107
2024-10-09 13:37:34 +08:00
committed by Coding
parent d422735062
commit f8dbe17c6a

View File

@@ -157,8 +157,8 @@ class ManageNetwork extends SettingsPage
// 获取用户输入的网络配置
$ipAddress = $this->form->getState()['ip'] ?? '';
$gateway = $this->form->getState()['gateway'] ?? '';
// 验证 IP 地址格式
$dhcpEnabled = $this->form->getState()['dhcp_enabled'];
if ($dhcpEnabled !== 'true'){
if (!filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
Notification::make()
->title('无效的 IP 地址格式')
@@ -177,6 +177,9 @@ class ManageNetwork extends SettingsPage
return; // 返回,不执行保存操作
}
}
// 验证 IP 地址格式
// 调用父类的保存方法以持久化设置
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 地址为字符串