fix: JavaScript 모듈 문법 오류 수정 - 브라우저 호환성 개선
🐛 문제 해결: - SyntaxError: Unexpected token '{'. import call expects one or two arguments - SyntaxError: Unexpected keyword 'export' - ES6 모듈 문법이 브라우저에서 제대로 로드되지 않는 문제 🔧 수정 내용: - modern-dashboard.js: ES6 import/export → 브라우저 호환 스크립트 - api-config.js: export 문법 → window 전역 변수 설정 - group-leader.html: type="module" 제거, 일반 스크립트 로딩 ✅ 브라우저 호환성: - window.API, window.apiCall 전역 변수 사용 - window.getAuthHeaders, window.ensureAuthenticated 함수 제공 - 모든 함수를 window 객체에 등록하여 전역 접근 가능 🚀 개선 효과: - 모든 브라우저에서 JavaScript 오류 없이 로딩 - 모던 대시보드 기능 정상 작동 - API 호출 및 인증 시스템 안정화 테스트: http://localhost:20000/pages/dashboard/group-leader.html
This commit is contained in:
@@ -1,7 +1,17 @@
|
||||
// ✅ modern-dashboard.js - 모던 대시보드 JavaScript
|
||||
|
||||
import { apiCall, API } from './api-config.js';
|
||||
import { getAuthData } from './auth.js';
|
||||
// API 설정 및 함수들은 api-config.js에서 로드됨
|
||||
// window.API, window.apiCall, window.getAuthHeaders 사용
|
||||
|
||||
// 인증 관련 함수들
|
||||
function getAuthData() {
|
||||
const token = localStorage.getItem('token');
|
||||
const user = localStorage.getItem('user');
|
||||
return {
|
||||
token,
|
||||
user: user ? JSON.parse(user) : null
|
||||
};
|
||||
}
|
||||
|
||||
// 전역 변수
|
||||
let currentUser = null;
|
||||
@@ -182,7 +192,7 @@ async function loadDashboardData() {
|
||||
async function loadWorkers() {
|
||||
try {
|
||||
console.log('👥 작업자 데이터 로딩...');
|
||||
const response = await apiCall(`${API}/workers`);
|
||||
const response = await window.apiCall(`${window.API}/workers`);
|
||||
workersData = Array.isArray(response) ? response : (response.data || []);
|
||||
console.log(`✅ 작업자 ${workersData.length}명 로드 완료`);
|
||||
return workersData;
|
||||
@@ -196,7 +206,7 @@ async function loadWorkers() {
|
||||
async function loadWorkData(date) {
|
||||
try {
|
||||
console.log(`📋 ${date} 작업 데이터 로딩...`);
|
||||
const response = await apiCall(`${API}/daily-work-reports?date=${date}&view_all=true`);
|
||||
const response = await window.apiCall(`${window.API}/daily-work-reports?date=${date}&view_all=true`);
|
||||
workData = Array.isArray(response) ? response : (response.data || []);
|
||||
console.log(`✅ 작업 데이터 ${workData.length}건 로드 완료`);
|
||||
return workData;
|
||||
@@ -509,11 +519,5 @@ function showToast(message, type = 'info', duration = 3000) {
|
||||
// ========== 전역 함수 (HTML에서 호출) ========== //
|
||||
window.loadDashboardData = loadDashboardData;
|
||||
window.showToast = showToast;
|
||||
|
||||
// ========== 내보내기 ========== //
|
||||
export {
|
||||
loadDashboardData,
|
||||
showToast,
|
||||
updateSummaryCards,
|
||||
displayWorkers
|
||||
};
|
||||
window.updateSummaryCards = updateSummaryCards;
|
||||
window.displayWorkers = displayWorkers;
|
||||
|
||||
Reference in New Issue
Block a user