Xử lí lỗi critical: link chia sẻ truy cập trực tiếp vào quản lí hệ thống
This commit is contained in:
+3
-3
@@ -14,7 +14,7 @@
|
|||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" />
|
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.css" />
|
||||||
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css" />
|
<link rel="stylesheet" href="https://unpkg.com/leaflet.markercluster@1.4.1/dist/MarkerCluster.Default.css" />
|
||||||
<!-- Custom Style -->
|
<!-- Custom Style -->
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="/css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@@ -593,7 +593,7 @@
|
|||||||
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
<script src="https://unpkg.com/leaflet.markercluster@1.4.1/dist/leaflet.markercluster.js"></script>
|
||||||
|
|
||||||
<!-- Custom Scripts -->
|
<!-- Custom Scripts -->
|
||||||
<script src="js/viewer360.js"></script>
|
<script src="/js/viewer360.js"></script>
|
||||||
<script src="js/main_map.js"></script>
|
<script src="/js/main_map.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
|
|
||||||
// 0. Kiểm tra tham số URL để truy cập trực tiếp
|
// 0. Kiểm tra tham số URL để truy cập trực tiếp
|
||||||
const urlParams = new URLSearchParams(window.location.search);
|
const urlParams = new URLSearchParams(window.location.search);
|
||||||
const urlSceneId = urlParams.get('sceneId');
|
let urlSceneId = urlParams.get('sceneId');
|
||||||
const urlToken = urlParams.get('token');
|
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
|
// Ưu tiên nạp cấu hình hệ thống trước
|
||||||
fetchSystemSettings();
|
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)
|
// 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);
|
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, "/");
|
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ệ)
|
// 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);
|
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');
|
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)
|
// 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, "/");
|
window.history.replaceState({}, document.title, "/");
|
||||||
|
|||||||
Reference in New Issue
Block a user