feat(desktop/setup): improve addresses display

This commit is contained in:
Elian Doran
2026-03-25 23:45:47 +02:00
parent 8eb45e2814
commit de57a39df6
3 changed files with 19 additions and 3 deletions

View File

@@ -311,15 +311,20 @@ body.setup {
}
.ip-addresses {
min-width: 200px;
min-width: 250px;
user-select: text;
display: flex;
flex-direction: column;
font-family: var(--monospace-font-family);
font-size: 0.9em;
.tn-card-body {
overflow: auto;
padding-bottom: 0.5em;
> :first-child {
font-weight: bold;
}
}
}
}

View File

@@ -378,7 +378,7 @@ function SyncFromDesktop({ setState }: { setState: (state: State) => void }) {
{networkAddresses.length > 0 && (
<Card heading={t("setup.your-ip-addresses")} className="ip-addresses">
{networkAddresses.map((addr) => (
<CardSection key={addr}>{addr}</CardSection>
<CardSection key={addr}>{`${location.protocol}//${addr}:${location.port}`}</CardSection>
))}
</Card>
)}
@@ -484,7 +484,18 @@ function getNetworkAddresses(): string[] {
}
}
// Sort by likelihood of being the local network address.
addresses.sort((a, b) => networkScore(a) - networkScore(b));
return addresses;
}
function networkScore(addr: string): number {
if (addr.startsWith("192.168.")) return 0;
if (addr.startsWith("10.")) return 1;
if (/^172\.(1[6-9]|2\d|3[01])\./.test(addr)) return 2;
if (addr.includes(":")) return 4; // IPv6
return 3;
}
main();

View File

@@ -2280,6 +2280,6 @@
"wrong-password": "Incorrect password. Please try again.",
"language": "Language",
"continue": "Continue",
"your-ip-addresses": "Your IP addresses"
"your-ip-addresses": "Addresses for this device"
}
}