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