Fix viewer link host resolution

This commit is contained in:
Codex
2026-05-28 09:37:02 +08:00
parent 5aabb300f2
commit 160790d38d
2 changed files with 38 additions and 5 deletions

View File

@@ -240,9 +240,22 @@ function markNode(id, state, strong, meta) {
node.querySelector("em").textContent = meta;
}
function viewerBaseUrl() {
try {
const url = new URL(app.viewerUrl || `${location.protocol}//${location.hostname}:8107`, location.href);
if (["127.0.0.1", "localhost", "0.0.0.0"].includes(url.hostname) && !["127.0.0.1", "localhost"].includes(location.hostname)) {
url.hostname = location.hostname;
}
url.protocol = location.protocol;
return url.toString().replace(/\/$/, "");
} catch (_) {
return `${location.protocol}//${location.hostname}:8107`;
}
}
function dicomViewerUrl(row = app.active) {
if (!row?.pacs_ct_number) return "";
return `${app.viewerUrl.replace(/\/$/, "")}/?ct_number=${encodeURIComponent(row.pacs_ct_number)}`;
return `${viewerBaseUrl()}/?ct_number=${encodeURIComponent(row.pacs_ct_number)}`;
}
function updateOpenDicomButton() {
@@ -539,7 +552,7 @@ function openDicomViewer() {
}
function openViewerHome() {
window.open(app.viewerUrl.replace(/\/$/, ""), "_blank", "noopener");
window.open(viewerBaseUrl(), "_blank", "noopener");
}
function wire() {