Sửa lỗi tạo docker
This commit is contained in:
+39
-6
@@ -22,8 +22,6 @@ let sharedEmailsData = []; // [email]
|
||||
// Initialize when DOM is ready
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
try {
|
||||
console.log("--- Bắt đầu khởi tạo Frontend ---");
|
||||
|
||||
// 0. Kiểm tra tham số URL để truy cập trực tiếp
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
let urlSceneId = urlParams.get('sceneId');
|
||||
@@ -39,14 +37,15 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
fetchSystemSettings();
|
||||
|
||||
if (document.getElementById('map')) {
|
||||
console.log("1. Đang khởi tạo bản đồ Leaflet...");
|
||||
initMap();
|
||||
}
|
||||
|
||||
// Chạy tuần tự để tránh xung đột luồng xử lý
|
||||
checkAuthStatus(); // 2. Kiểm tra đăng nhập
|
||||
|
||||
// 3. Xử lý logic vào thẳng Scene hoặc khôi phục trang
|
||||
// 2.1. Kiểm tra xem server đã có Admin chưa (dành cho cài đặt mới)
|
||||
checkSystemInitialization();
|
||||
|
||||
if (urlSceneId) {
|
||||
console.log(`[Direct Access] Opening scene ${urlSceneId} from URL`);
|
||||
openScene(urlSceneId, urlToken ? 'shared' : null, urlToken);
|
||||
@@ -489,6 +488,42 @@ function checkAuthStatus() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kiểm tra trạng thái khởi tạo của hệ thống
|
||||
*/
|
||||
async function checkSystemInitialization() {
|
||||
const token = localStorage.getItem('jwt');
|
||||
if (token) return; // Nếu đã đăng nhập thì bỏ qua
|
||||
|
||||
try {
|
||||
const res = await fetch(`${API_BASE_URL}/auth/init-status`);
|
||||
const data = await res.json();
|
||||
|
||||
if (data && data.initialized === false) {
|
||||
showAdminSetupWizard();
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Không thể kiểm tra trạng thái khởi tạo hệ thống:", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Hiển thị giao diện thiết lập Admin tối cao
|
||||
*/
|
||||
function showAdminSetupWizard() {
|
||||
// Mở dropdown và chuyển sang tab đăng ký
|
||||
const dropdown = document.getElementById('user-dropdown');
|
||||
if (dropdown) dropdown.classList.add('show');
|
||||
|
||||
switchAuthMode('register');
|
||||
|
||||
// Tùy chỉnh giao diện cho chế độ thiết lập
|
||||
const regBtn = document.querySelector('#register-section .auth-submit-btn');
|
||||
if (regBtn) regBtn.innerText = 'Thiết lập Admin tối cao';
|
||||
|
||||
showNotification("Hệ thống mới: Vui lòng đăng ký tài khoản Admin đầu tiên để quản trị server.", "warning");
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles user login
|
||||
*/
|
||||
@@ -1008,8 +1043,6 @@ async function loadScenes(urlToken = null) {
|
||||
const tourName = (scene.tourId && typeof scene.tourId === 'object') ? scene.tourId.name : sceneName;
|
||||
const tourDescription = (scene.tourId && typeof scene.tourId === 'object') ? scene.tourId.description : scene.description;
|
||||
|
||||
console.log(`[Frontend] Đang thêm marker cho Tour: ${tourName} (Scene đại diện: ${sceneName})`);
|
||||
|
||||
const isProcessing = scene.status === 'processing';
|
||||
if (isProcessing) foundProcessing++;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user