From 4fbd4d7d5b92f93cc34558c4876c9bf19b4989b2 Mon Sep 17 00:00:00 2001 From: locphamtran Date: Wed, 10 Jun 2026 07:32:55 +0700 Subject: [PATCH] =?UTF-8?q?X=E1=BB=AD=20l=C3=AD=20l=E1=BB=97i=20critical:?= =?UTF-8?q?=20link=20chia=20s=E1=BA=BB=20truy=20c=E1=BA=ADp=20tr=E1=BB=B1c?= =?UTF-8?q?=20ti=E1=BA=BFp=20v=C3=A0o=20qu=E1=BA=A3n=20l=C3=AD=20h?= =?UTF-8?q?=E1=BB=87=20th=E1=BB=91ng?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/index.html | 6 +++--- frontend/js/main_map.js | 12 +++++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/frontend/index.html b/frontend/index.html index 6f8c49f..96755c0 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -14,7 +14,7 @@ - + @@ -593,7 +593,7 @@ - - + + diff --git a/frontend/js/main_map.js b/frontend/js/main_map.js index 66a245f..5f4e896 100644 --- a/frontend/js/main_map.js +++ b/frontend/js/main_map.js @@ -25,9 +25,15 @@ document.addEventListener('DOMContentLoaded', () => { // 0. Kiểm tra tham số URL để truy cập trực tiếp const urlParams = new URLSearchParams(window.location.search); - const urlSceneId = urlParams.get('sceneId'); + let urlSceneId = urlParams.get('sceneId'); const urlToken = urlParams.get('token'); + // Hỗ trợ lấy Scene ID từ pathname (trường hợp truy cập qua /api/share/:id) + if (!urlSceneId && window.location.pathname.includes('/api/share/')) { + const pathParts = window.location.pathname.split('/').filter(Boolean); + urlSceneId = pathParts.pop(); // Lấy phần tử ID cuối cùng trong URL + } + // Ưu tiên nạp cấu hình hệ thống trước fetchSystemSettings(); @@ -1132,7 +1138,7 @@ async function openScene(sceneId, privacy, shareToken, force = false, initialPit // Sau khi mở thành công từ URL trực tiếp, xóa tham số để làm sạch thanh địa chỉ (URL chuyên nghiệp) const urlParams = new URLSearchParams(window.location.search); - if (urlParams.has('sceneId')) { + if (urlParams.has('sceneId') || window.location.pathname.includes('/api/share/')) { window.history.replaceState({}, document.title, "/"); } @@ -1145,7 +1151,7 @@ async function openScene(sceneId, privacy, shareToken, force = false, initialPit // Kiểm tra nếu đang truy cập qua link trực tiếp (URL có sceneId) mà gặp lỗi (do xóa token hoặc token không hợp lệ) const urlParams = new URLSearchParams(window.location.search); - if (urlParams.has('sceneId')) { + if (urlParams.has('sceneId') || window.location.pathname.includes('/api/share/')) { showNotification("Bạn không có quyền truy cập hoặc liên kết chia sẻ đã hết hạn. Quay về bản đồ công cộng.", 'error'); // Xóa toàn bộ tham số URL và tải lại trang để làm mới trạng thái (về trang chủ dành cho khách) window.history.replaceState({}, document.title, "/");