fix: C 端设备局域网地址为空时默认 192.168.1.1
网关常不返回设备 lan_ip,H5 点后台管理时提示设备未开机;为空时回落到设备默认网关地址。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -801,6 +801,15 @@ func packageStatusName(status int) string {
|
||||
}
|
||||
}
|
||||
|
||||
// clientDeviceLANIP 网关未返回局域网网关地址(空或仅空白)时使用设备默认网关地址,保证 C 端可进入设备后台。
|
||||
func clientDeviceLANIP(lanIP *string) *string {
|
||||
if lanIP != nil && strings.TrimSpace(*lanIP) != "" {
|
||||
return lanIP
|
||||
}
|
||||
defaultIP := constants.DefaultDeviceLANIP
|
||||
return &defaultIP
|
||||
}
|
||||
|
||||
// mapDeviceGatewayInfoToClientInfo 将 B 端 DeviceGatewayInfo 映射为 C 端 DeviceRealtimeInfo
|
||||
// B 端和 C 端结构独立,通过映射函数转换(per D-08)
|
||||
func mapDeviceGatewayInfoToClientInfo(g *dto.DeviceGatewayInfo) *dto.DeviceRealtimeInfo {
|
||||
@@ -844,7 +853,7 @@ func mapDeviceGatewayInfoToClientInfo(g *dto.DeviceGatewayInfo) *dto.DeviceRealt
|
||||
info.WifiPassword = g.WifiPassword
|
||||
info.IPAddress = g.IPAddress
|
||||
info.WANIP = g.WANIP
|
||||
info.LANIP = g.LANIP
|
||||
info.LANIP = clientDeviceLANIP(g.LANIP)
|
||||
info.MACAddress = g.MACAddress
|
||||
info.DailyUsage = g.DailyUsage
|
||||
info.DLStats = g.DLStats
|
||||
|
||||
Reference in New Issue
Block a user