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:
@@ -28,10 +28,11 @@ function getApiBaseUrl() {
|
||||
// API 설정
|
||||
const API_URL = getApiBaseUrl();
|
||||
|
||||
export const API = API_URL;
|
||||
export const API_BASE_URL = API_URL;
|
||||
// 전역 변수로 설정
|
||||
window.API = API_URL;
|
||||
window.API_BASE_URL = API_URL;
|
||||
|
||||
export function ensureAuthenticated() {
|
||||
function ensureAuthenticated() {
|
||||
const token = localStorage.getItem('token');
|
||||
if (!token || token === 'undefined') {
|
||||
alert('로그인이 필요합니다');
|
||||
@@ -51,7 +52,7 @@ export function getAuthHeaders() {
|
||||
}
|
||||
|
||||
// 🔧 개선된 API 호출 함수 (에러 처리 강화)
|
||||
export async function apiCall(url, options = {}) {
|
||||
async function apiCall(url, options = {}) {
|
||||
const defaultOptions = {
|
||||
headers: getAuthHeaders()
|
||||
};
|
||||
@@ -137,6 +138,12 @@ export async function testApiConnection() {
|
||||
}
|
||||
}
|
||||
|
||||
// 전역 함수로 설정
|
||||
window.ensureAuthenticated = ensureAuthenticated;
|
||||
window.getAuthHeaders = getAuthHeaders;
|
||||
window.apiCall = apiCall;
|
||||
window.testApiConnection = testApiConnection;
|
||||
|
||||
// 개발 모드에서 자동 테스트
|
||||
if (window.location.hostname === 'localhost' || window.location.hostname.startsWith('192.168.')) {
|
||||
setTimeout(() => {
|
||||
|
||||
Reference in New Issue
Block a user