Thay đổi ARCHITEC.md cập nhật các thông tin để chuẩn bị refactor lại dự án
This commit is contained in:
+24
-10
@@ -690,6 +690,11 @@ function openCreateSceneModal(lat, lng) {
|
||||
document.getElementById('modal-lat').value = lat.toFixed(6);
|
||||
document.getElementById('modal-lng').value = lng.toFixed(6);
|
||||
|
||||
// [FIX] Đảm bảo xóa tourId cũ khi tạo từ Map để Scene này trở thành Tour Gốc (Root)
|
||||
const tourIdInput = document.getElementById('modal-tour-id');
|
||||
if (tourIdInput) tourIdInput.value = '';
|
||||
localStorage.removeItem('activeTourId');
|
||||
|
||||
const lang = systemSettings.language || 'vi';
|
||||
const modalTitle = document.getElementById('create-scene-modal-title');
|
||||
if (modalTitle) modalTitle.innerText = lang === 'vi' ? "Tạo 3D scene mới" : "Create New 3D Scene";
|
||||
@@ -1099,9 +1104,10 @@ async function openScene(sceneId, privacy, shareToken, force = false, initialPit
|
||||
const scene = await sceneRes.json();
|
||||
const hotspots = await hotspotsRes.json();
|
||||
|
||||
// [TOUR ID] Cập nhật tourId hiện tại vào localStorage để các cảnh con kế thừa đúng
|
||||
const currentTourId = scene.tourId?._id || scene.tourId || scene._id;
|
||||
localStorage.setItem('activeTourId', currentTourId);
|
||||
// [TOUR ID] Luôn cập nhật activeTourId theo Scene hiện tại để đảm bảo các cảnh con/hotspot mới
|
||||
// được gán đúng vào Tour gốc của cảnh đang xem, tránh sử dụng ID cũ/lỗi từ phiên trước.
|
||||
const openedSceneTourId = scene.tourId?._id || scene.tourId || scene._id;
|
||||
localStorage.setItem('activeTourId', openedSceneTourId);
|
||||
|
||||
if (!sceneRes.ok) throw new Error(scene.message || 'Failed to fetch scene details');
|
||||
|
||||
@@ -1162,6 +1168,7 @@ async function openScene(sceneId, privacy, shareToken, force = false, initialPit
|
||||
localStorage.removeItem('activeSceneId');
|
||||
localStorage.removeItem('activeScenePrivacy');
|
||||
localStorage.removeItem('activeSceneToken');
|
||||
localStorage.removeItem('activeTourId');
|
||||
localStorage.removeItem('activeTourId');
|
||||
|
||||
// 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ệ)
|
||||
@@ -1243,19 +1250,22 @@ window.handleHotspotCreation = async function(pitch, yaw, existingHotspot = null
|
||||
const activeTourId = localStorage.getItem('activeTourId');
|
||||
const targetTourId = targetScene?.tourId?._id || targetScene?.tourId;
|
||||
|
||||
const existingNotice = document.getElementById('hs-existing-notice');
|
||||
let crossLinkNotice = document.getElementById('hs-crosslink-notice');
|
||||
if (!crossLinkNotice) {
|
||||
crossLinkNotice = document.createElement('div');
|
||||
crossLinkNotice.id = 'hs-crosslink-notice';
|
||||
crossLinkNotice.style = 'font-size: 11px; margin-top: 5px; color: #ffc107; display: none;';
|
||||
crossLinkNotice.style = 'font-size: 11px; margin-top: 4px; color: #ffc107; font-weight: bold; display: none;';
|
||||
select.parentNode.appendChild(crossLinkNotice);
|
||||
}
|
||||
|
||||
if (targetTourId && activeTourId && targetTourId !== activeTourId) {
|
||||
crossLinkNotice.innerText = "ℹ️ Cảnh này thuộc Tour khác. Liên kết sẽ được tạo dưới dạng liên kết chéo.";
|
||||
crossLinkNotice.innerText = "⚠️ Chú ý: Cảnh này thuộc về một Tour khác (Liên kết chéo).";
|
||||
crossLinkNotice.style.display = 'block';
|
||||
if (existingNotice) existingNotice.style.opacity = '0.6';
|
||||
} else {
|
||||
crossLinkNotice.style.display = 'none';
|
||||
if (existingNotice) existingNotice.style.opacity = '1';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1265,6 +1275,8 @@ window.handleHotspotCreation = async function(pitch, yaw, existingHotspot = null
|
||||
document.getElementById('hs-desc').value = existingHotspot.description || '';
|
||||
if (existingHotspot.target_scene_id) {
|
||||
select.value = existingHotspot.target_scene_id;
|
||||
// Kích hoạt logic hiển thị thông báo ngay khi mở modal nếu đang sửa
|
||||
if (typeof select.onchange === 'function') select.onchange();
|
||||
}
|
||||
}
|
||||
} catch (e) { console.error("Lỗi nạp danh sách scene:", e); }
|
||||
@@ -1303,7 +1315,9 @@ window.handleHotspotCreation = async function(pitch, yaw, existingHotspot = null
|
||||
sceneData.append('title', formData.get('title'));
|
||||
sceneData.append('lat', lat); // FormData sẽ convert sang string, Backend cần ép kiểu lại
|
||||
sceneData.append('lng', lng);
|
||||
sceneData.append('privacy', 'public');
|
||||
// [FIX] Kế thừa quyền riêng tư của scene hiện tại thay vì fix cứng public
|
||||
const currentPrivacy = localStorage.getItem('activeScenePrivacy') || 'private';
|
||||
sceneData.append('privacy', currentPrivacy);
|
||||
|
||||
// [FIX] Kế thừa tourId từ cảnh cha khi tạo cảnh mới qua hotspot upload
|
||||
const activeTourId = localStorage.getItem('activeTourId');
|
||||
@@ -2061,10 +2075,10 @@ window.openEditMetadataModal = function(scene, isChildArg = null) {
|
||||
sharedUsersData = scene.sharedWith || [];
|
||||
sharedEmailsData = scene.sharedEmails || [];
|
||||
|
||||
// [TOUR ID] Cập nhật activeTourId ngay khi mở modal sửa để đảm bảo
|
||||
// các thao tác tạo cảnh con sau đó (nếu có) luôn mang ID của Tour này.
|
||||
const currentTourId = scene.tourId?._id || scene.tourId || scene._id;
|
||||
localStorage.setItem('activeTourId', currentTourId);
|
||||
// [TOUR ID] Cập nhật activeTourId khi mở modal sửa.
|
||||
// Điều này đảm bảo ngữ cảnh tạo cảnh con mới (nếu có) luôn thuộc về Tour của cảnh đang sửa.
|
||||
const editingSceneTourId = scene.tourId?._id || scene.tourId || scene._id;
|
||||
localStorage.setItem('activeTourId', editingSceneTourId);
|
||||
|
||||
document.getElementById('edit-modal-scene-id').value = scene._id;
|
||||
document.getElementById('edit-modal-title').value = scene.name || scene.title || '';
|
||||
|
||||
Reference in New Issue
Block a user