refactor: 프로젝트 구조 최적화 및 컴포넌트 기반 모달 시스템 도입
주요 정리 내용: - 핵심 엔진 분리: state, excelHandler 등을 src/core/ 디렉토리로 격리 - 모달 컴포넌트화: index.html의 거대 HTML 구조를 각 모달 TS 파일로 내장 및 동적 주입 - index.html 최적화: 수백 줄의 중복 코드를 제거하여 슬림한 Shell 구조로 변환 - 전역 복구: 병합 과정에서 발생한 한글 인코딩 깨짐 전수 복구 및 빌드 오류 해결 - 경로 정합성: 파일 구조 변경에 따른 모든 import 경로 일괄 업데이트
This commit is contained in:
34
src/main.ts
34
src/main.ts
@@ -1,19 +1,21 @@
|
||||
import { state } from './state';
|
||||
import { state } from './core/state';
|
||||
import { renderSidebar } from './components/Sidebar';
|
||||
import { renderDashboard } from './views/DashboardView';
|
||||
import { renderTable } from './views/AssetTableView';
|
||||
import { downloadTemplate, exportToExcel, parseExcel } from './excelHandler';
|
||||
import { downloadTemplate, exportToExcel, parseExcel, HardwareAsset } from './core/excelHandler';
|
||||
import { initPcModal } from './components/Modal/PCModal';
|
||||
import { initHwModal, openHwModal } from './components/Modal/HWModal';
|
||||
import { initStorageModal } from './components/Modal/StorageModal';
|
||||
import { initSwModal } from './components/Modal/SWModal';
|
||||
import { initSwUserModal } from './components/Modal/SWUserModal';
|
||||
import { initDashboardDetailModal } from './components/Modal/DashboardDetailModal';
|
||||
import { createIcons, Download, Upload, FileSpreadsheet, Plus, X, LayoutDashboard, Monitor, Server, Database, Laptop, CalendarClock, Key, Cpu, Layers, Users, Paperclip, Edit2, History, RefreshCcw } from 'lucide';
|
||||
|
||||
// --- App Initialization ---
|
||||
function initApp() {
|
||||
const mainContent = document.getElementById('main-content')!;
|
||||
|
||||
if (!mainContent) return;
|
||||
|
||||
// 1. 초기 뷰 렌더링 (대시보드)
|
||||
renderDashboard(mainContent);
|
||||
|
||||
@@ -28,14 +30,17 @@ function initApp() {
|
||||
}
|
||||
// 상단 타이틀 업데이트
|
||||
const titleEl = document.getElementById('current-tab-title')!;
|
||||
titleEl.textContent = `${state.activeCategory === 'hw' ? '하드웨어' : '소프트웨어'} / ${state.activeSubTab}`;
|
||||
if (titleEl) {
|
||||
const catName = state.activeCategory === 'hw' ? '하드웨어' : '소프트웨어';
|
||||
titleEl.textContent = `${catName} / ${state.activeSubTab}`;
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 모달 초기화
|
||||
initPcModal();
|
||||
// 3. 모달 초기화 (HTML 주입 및 이벤트 바인딩)
|
||||
initPcModal(() => renderTable(mainContent), () => {});
|
||||
initHwModal();
|
||||
initStorageModal();
|
||||
initSwModal();
|
||||
initStorageModal(() => renderTable(mainContent), () => {});
|
||||
initSwModal(() => renderTable(mainContent), () => {});
|
||||
initSwUserModal(() => renderTable(mainContent), () => {});
|
||||
initDashboardDetailModal();
|
||||
|
||||
@@ -55,7 +60,7 @@ function initApp() {
|
||||
|
||||
document.getElementById('btn-add-asset')?.addEventListener('click', () => {
|
||||
if (state.activeSubTab === '서버' || state.activeSubTab === '전산비품' || state.activeSubTab === '스토리지') {
|
||||
const newAsset = {
|
||||
const newAsset: HardwareAsset = {
|
||||
id: Math.random().toString(36).substring(2, 9),
|
||||
type: state.activeSubTab,
|
||||
법인: '한맥',
|
||||
@@ -80,16 +85,5 @@ function initApp() {
|
||||
});
|
||||
}
|
||||
|
||||
function initDashboardDetailModal() {
|
||||
const modal = document.getElementById('dashboard-detail-modal')!;
|
||||
const closeBtn = document.getElementById('btn-close-dashboard-detail-modal')!;
|
||||
const cancelBtn = document.getElementById('btn-cancel-dashboard-detail-modal')!;
|
||||
|
||||
const closeModal = () => modal.classList.add('hidden');
|
||||
closeBtn.addEventListener('click', closeModal);
|
||||
cancelBtn.addEventListener('click', closeModal);
|
||||
modal.addEventListener('click', (e) => { if (e.target === modal) closeModal(); });
|
||||
}
|
||||
|
||||
// Start the app
|
||||
document.addEventListener('DOMContentLoaded', initApp);
|
||||
|
||||
Reference in New Issue
Block a user