fix hostname

This commit is contained in:
Siyuan 2025-10-10 13:39:33 +00:00
parent 579345e5b4
commit fe074b2253
4 changed files with 4 additions and 1 deletions

View File

@ -10,6 +10,7 @@ import (
// InterfaceState represents the current state of a network interface // InterfaceState represents the current state of a network interface
type InterfaceState struct { type InterfaceState struct {
InterfaceName string `json:"interface_name"` InterfaceName string `json:"interface_name"`
Hostname string `json:"hostname"`
MACAddress string `json:"mac_address"` MACAddress string `json:"mac_address"`
Up bool `json:"up"` Up bool `json:"up"`
Online bool `json:"online"` Online bool `json:"online"`

View File

@ -78,6 +78,7 @@ func (nm *NetworkManager) AddInterface(iface string, config *types.NetworkConfig
// Set up callbacks // Set up callbacks
im.SetOnStateChange(func(state types.InterfaceState) { im.SetOnStateChange(func(state types.InterfaceState) {
if nm.onInterfaceStateChange != nil { if nm.onInterfaceStateChange != nil {
state.Hostname = nm.Hostname()
nm.onInterfaceStateChange(iface, state) nm.onInterfaceStateChange(iface, state)
} }
}) })

View File

@ -720,6 +720,7 @@ export interface NetworkState {
ipv6_link_local?: string; ipv6_link_local?: string;
ipv6_gateway?: string; ipv6_gateway?: string;
dhcp_lease?: DhcpLease; dhcp_lease?: DhcpLease;
hostname?: string;
setNetworkState: (state: NetworkState) => void; setNetworkState: (state: NetworkState) => void;
setDhcpLease: (lease: NetworkState["dhcp_lease"]) => void; setDhcpLease: (lease: NetworkState["dhcp_lease"]) => void;

View File

@ -253,7 +253,7 @@ export default function SettingsNetworkRoute() {
<SettingsItem title="Hostname" description="Set the device hostname"> <SettingsItem title="Hostname" description="Set the device hostname">
<InputField <InputField
size="SM" size="SM"
placeholder="jetkvm" placeholder={networkState?.hostname || "jetkvm"}
{...register("hostname")} {...register("hostname")}
error={formState.errors.hostname?.message} error={formState.errors.hostname?.message}
/> />