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, "/");