Smart LAN routing for Navidrome sidebar link
This commit is contained in:
@@ -21,18 +21,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const external = [
|
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: "Immich", port: 2283, icon: "image" },
|
||||||
{ label: "Jellyfin", port: 8096, icon: "play" },
|
{ label: "Jellyfin", port: 8096, icon: "play" },
|
||||||
{ label: "Gitea Web", port: 3300, icon: "git" },
|
{ label: "Gitea Web", port: 3300, icon: "git" },
|
||||||
{ label: "Speedtest", port: 8080, icon: "speedtest" },
|
{ label: "Speedtest", port: 8080, icon: "speedtest" },
|
||||||
];
|
];
|
||||||
|
|
||||||
function extHref(port) {
|
function extHref(svc) {
|
||||||
if (lanReachable && location.hostname !== LAN_IP) {
|
if (lanReachable && svc.port) return `http://${LAN_IP}:${svc.port}`;
|
||||||
return `http://${LAN_IP}:${port}`;
|
if (svc.remoteHref) return svc.remoteHref;
|
||||||
}
|
if (svc.port) return `${location.protocol}//${location.hostname}:${svc.port}`;
|
||||||
return `${location.protocol}//${location.hostname}:${port}`;
|
return svc.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigate(id) {
|
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>
|
<p class="text-[10px] font-semibold uppercase tracking-wider text-surface-400 px-3 mb-2">Services</p>
|
||||||
{#each external as svc}
|
{#each external as svc}
|
||||||
<a
|
<a
|
||||||
href={svc.href || extHref(svc.port)}
|
href={extHref(svc)}
|
||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
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' : ''}"
|
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