Smart LAN routing for Navidrome sidebar link
This commit is contained in:
@@ -21,18 +21,18 @@
|
||||
}
|
||||
|
||||
const external = [
|
||||
{ label: "Navidrome", href: "https://music.jimmygan.com", icon: "music" },
|
||||
{ label: "Navidrome", port: 4533, remoteHref: "https://music.jimmygan.com", icon: "music" },
|
||||
{ label: "Immich", port: 2283, icon: "image" },
|
||||
{ label: "Jellyfin", port: 8096, icon: "play" },
|
||||
{ label: "Gitea Web", port: 3300, icon: "git" },
|
||||
{ label: "Speedtest", port: 8080, icon: "speedtest" },
|
||||
];
|
||||
|
||||
function extHref(port) {
|
||||
if (lanReachable && location.hostname !== LAN_IP) {
|
||||
return `http://${LAN_IP}:${port}`;
|
||||
}
|
||||
return `${location.protocol}//${location.hostname}:${port}`;
|
||||
function extHref(svc) {
|
||||
if (lanReachable && svc.port) return `http://${LAN_IP}:${svc.port}`;
|
||||
if (svc.remoteHref) return svc.remoteHref;
|
||||
if (svc.port) return `${location.protocol}//${location.hostname}:${svc.port}`;
|
||||
return svc.href;
|
||||
}
|
||||
|
||||
function navigate(id) {
|
||||
@@ -95,7 +95,7 @@
|
||||
<p class="text-[10px] font-semibold uppercase tracking-wider text-surface-400 px-3 mb-2">Services</p>
|
||||
{#each external as svc}
|
||||
<a
|
||||
href={svc.href || extHref(svc.port)}
|
||||
href={extHref(svc)}
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
class="w-full text-left px-3 py-2 rounded-lg text-[13px] font-medium flex items-center gap-2.5 mb-0.5 text-surface-500 hover:bg-surface-100 hover:text-surface-700 transition-all duration-150 {dark ? 'hover:bg-surface-700 hover:text-surface-200 text-surface-400' : ''}"
|
||||
|
||||
Reference in New Issue
Block a user