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() {

View File

@@ -173,10 +173,25 @@ button {
.dark-btn {
height: 34px;
padding: 0 14px;
border: 1px solid var(--line);
border: 1px solid rgba(142, 162, 189, 0.38);
border-radius: 8px;
background: var(--panel-2);
background: linear-gradient(180deg, rgba(23, 34, 51, 0.96), rgba(11, 17, 27, 0.96));
color: var(--text);
box-shadow:
inset 0 1px 0 rgba(232, 240, 251, 0.06),
0 0 0 1px rgba(7, 10, 15, 0.3);
}
.top-actions .dark-btn {
border-color: rgba(82, 124, 184, 0.72);
color: #eaf2ff;
background: linear-gradient(180deg, rgba(28, 42, 62, 0.98), rgba(13, 21, 33, 0.98));
}
.top-actions #viewerHomeBtn {
border-color: rgba(25, 212, 194, 0.66);
color: #c8fff7;
background: linear-gradient(180deg, rgba(17, 61, 70, 0.92), rgba(9, 30, 42, 0.98));
}
.primary-btn,
@@ -205,10 +220,15 @@ button {
.dark-btn:hover,
.filter-grid button:hover {
border-color: var(--line-strong);
border-color: rgba(52, 118, 246, 0.82);
background: #172233;
}
.top-actions #viewerHomeBtn:hover {
border-color: var(--cyan);
background: rgba(25, 212, 194, 0.14);
}
.layout {
height: calc(100vh - 66px);
display: grid;