import React, { useState } from 'react';
import {
ThemeProvider,
CssBaseline,
Box,
AppBar,
Toolbar,
Typography,
Button,
Container,
IconButton,
Tooltip,
Chip,
Menu,
MenuItem,
ListItemIcon,
ListItemText,
Divider,
Badge,
} from '@mui/material';
import {
Dashboard as DashboardIcon,
ShowChart,
CloudDownload,
Schedule,
Settings as SettingsIcon,
Analytics,
LightMode,
DarkMode,
Login as LoginIcon,
Logout as LogoutIcon,
AccountCircle,
Person,
Rule as RuleIcon,
AccountBalance as SimulationIcon,
TrendingUp as TrendingUpIcon,
Fullscreen,
FullscreenExit,
Notifications as NotificationsIcon,
ListAlt as OrderbookIcon,
FormatListBulleted as AlertListIcon,
AutoAwesome as AutoTradingIcon,
GridView as MultiChartIcon,
ClearAll as ClearAllIcon,
CompareArrows as CompareIcon,
} from '@mui/icons-material';
import { useAppTheme } from './contexts/ThemeContext';
import { useIndicatorPopup } from './contexts/IndicatorPopupContext';
import { useAuth } from './contexts/AuthContext';
import { useAlertNotification } from './contexts/AlertNotificationContext';
import { useNavigation } from './contexts/NavigationContext';
import { useIsMobile } from './hooks/useIsMobile';
import { MobileAppShell } from './components/MobileAppShell';
import DashboardPage from './pages/DashboardPage';
import PatternSearchPage from './pages/PatternSearchPage';
import RisingStocksPage from './pages/RisingStocksPage';
import StrategyTreeBuilderPage from './pages/StrategyTreeBuilderPage';
import SimulationPage from './pages/SimulationPage';
import DataCollectionPage from './pages/DataCollectionPage';
import SchedulerPage from './pages/SchedulerPage';
import SettingsPage from './pages/SettingsPage';
import CandlestickTestPage from './pages/CandlestickTestPage';
import CandlestickTestPage3 from './pages/CandlestickTestPage3';
import AlertPage from './pages/AlertPage';
import NotificationListPage from './pages/NotificationListPage';
import OrderbookPage from './pages/OrderbookPage';
import AutoTradingPage from './pages/AutoTradingPage';
import MultiChartPage from './pages/MultiChartPage';
import MultiChartPage2 from './pages/MultiChartPage2';
import AlertListPage from './pages/AlertListPage';
import ChartValidationPage from './pages/admin/ChartValidationPage';
import LoginDialog from './components/LoginDialog';
import SignUpDialog from './components/SignUpDialog';
import IndicatorConfigPanel from './components/IndicatorConfigPanel';
import IndicatorPopupWindow from './components/IndicatorPopupWindow';
import AlertSnackbar from './components/alert/AlertSnackbar';
interface MenuItemType {
shortText: string;
fullText: string;
icon: React.ReactNode;
page: string;
}
const menuItems: MenuItemType[] = [
{ shortText: '대시보드', fullText: '대시보드', icon: , page: 'dashboard' },
{ shortText: '멀티차트', fullText: '멀티차트', icon: , page: 'multi-chart' },
{ shortText: '멀티2', fullText: '멀티차트2', icon: , page: 'multi-chart-2' },
{ shortText: '추세', fullText: '상승종목 추세분석', icon: , page: 'rising-stocks' },
{ shortText: '패턴', fullText: '패턴검색', icon: , page: 'pattern-search' },
{ shortText: '투자', fullText: '모의투자', icon: , page: 'simulation' },
{ shortText: '전략', fullText: '전략설정', icon: , page: 'strategy-tree' },
{ shortText: '분석', fullText: '투자분석', icon: , page: 'candlestick-test' },
{ shortText: '분석3', fullText: '투자분석3 (프론트엔드 지표)', icon: , page: 'candlestick-test-3' },
{ shortText: '알림', fullText: '알림 설정', icon: , page: 'alerts' },
{ shortText: '알림목록', fullText: '알림목록', icon: , page: 'alert-list' },
{ shortText: '호가', fullText: '실시간 호가', icon: , page: 'orderbook' },
{ shortText: '자동매매', fullText: '자동매매', icon: , page: 'auto-trading' },
{ shortText: '검증', fullText: '차트 비교검증', icon: , page: 'chart-validation' },
{ shortText: '데이터', fullText: '데이터 수집', icon: , page: 'data-collection' },
{ shortText: '스케쥴', fullText: '스케쥴러', icon: , page: 'scheduler' },
{ shortText: '설정', fullText: '설정', icon: , page: 'settings' },
];
function MainContent() {
const isMobile = useIsMobile();
const { currentPage, navigateToPage } = useNavigation();
const { themeMode, setThemeMode, theme } = useAppTheme();
const { isAuthenticated, user, logout } = useAuth();
const { isPopupOpen, closePopup, chartData, chartMargin } = useIndicatorPopup();
const { unreadCount, notifications, dismissAllNotifications } = useAlertNotification();
// 로그인/회원가입 다이얼로그 상태
const [loginDialogOpen, setLoginDialogOpen] = useState(false);
const [signUpDialogOpen, setSignUpDialogOpen] = useState(false);
// 사용자 메뉴 상태
const [userMenuAnchor, setUserMenuAnchor] = useState(null);
// 전체화면 상태
const [isFullscreen, setIsFullscreen] = useState(false);
const handleUserMenuOpen = (event: React.MouseEvent) => {
setUserMenuAnchor(event.currentTarget);
};
const handleUserMenuClose = () => {
setUserMenuAnchor(null);
};
const handleLogout = () => {
logout();
handleUserMenuClose();
};
const renderPage = () => {
// 투자분석/투자분석3: 상태 유지를 위해 항상 마운트하되 css display로 노출 여부 제어
if (currentPage === 'candlestick-test') return null;
if (currentPage === 'candlestick-test-3') return null;
switch (currentPage) {
case 'dashboard':
return ;
case 'multi-chart':
return ;
case 'multi-chart-2':
return ;
case 'rising-stocks':
return ;
case 'pattern-search':
return ;
case 'simulation':
return ;
case 'strategy-tree':
return ;
case 'data-collection':
return ;
case 'scheduler':
return ;
case 'alerts':
return ;
case 'alert-list':
return ;
case 'notifications':
return ;
case 'orderbook':
return ;
case 'auto-trading':
return ;
case 'chart-validation':
return ;
case 'settings':
return ;
default:
return ;
}
};
const handleThemeToggle = () => {
setThemeMode(themeMode === 'dark' ? 'light' : 'dark');
};
// 전체화면 토글 함수
const handleFullscreenToggle = () => {
if (!document.fullscreenElement) {
// 전체화면으로 전환
document.documentElement.requestFullscreen().catch((err) => {
console.error('전체화면 전환 실패:', err);
});
} else {
// 전체화면 해제
if (document.exitFullscreen) {
document.exitFullscreen();
}
}
};
// 전체화면 상태 변경 감지
React.useEffect(() => {
const handleFullscreenChange = () => {
setIsFullscreen(!!document.fullscreenElement);
};
document.addEventListener('fullscreenchange', handleFullscreenChange);
return () => {
document.removeEventListener('fullscreenchange', handleFullscreenChange);
};
}, []);
// 다크 모드 AppBar 스타일
const darkAppBarStyle = {
background: 'linear-gradient(90deg, #0a0a0f 0%, #12121a 50%, #1a1a2e 100%)',
borderBottom: '1px solid rgba(100, 149, 237, 0.2)',
boxShadow: '0 2px 10px rgba(0, 0, 0, 0.3)',
};
// 라이트 모드 AppBar 스타일
const lightAppBarStyle = {
background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
boxShadow: '0 2px 10px rgba(0, 0, 0, 0.15)',
};
// 모바일 접속 시 모바일 앱 UI (전체 화면 모바일 최적화)
if (isMobile) {
return (
);
}
// 데스크톱: 기존 레이아웃 유지
return (
{/* Top Navigation Bar */}
theme.zIndex.drawer + 100,
}}
>
{/* Logo & Title */}
Golden Analysis
{/*
투자전략 성능 분석 시스템
*/}
{/* Navigation Menu */}
{menuItems.map((item) => (
navigateToPage(item.page)}
sx={{
color: themeMode === 'dark'
? (currentPage === item.page ? 'primary.main' : 'text.secondary')
: (currentPage === item.page ? '#ffffff' : 'rgba(255, 255, 255, 0.7)'),
backgroundColor: currentPage === item.page
? (themeMode === 'dark' ? 'rgba(100, 149, 237, 0.15)' : 'rgba(255, 255, 255, 0.2)')
: 'transparent',
borderBottom: currentPage === item.page ? '2px solid' : '2px solid transparent',
borderBottomColor: currentPage === item.page
? (themeMode === 'dark' ? 'primary.main' : '#ffffff')
: 'transparent',
borderRadius: 0,
'&:hover': {
backgroundColor: themeMode === 'dark' ? 'rgba(100, 149, 237, 0.1)' : 'rgba(255, 255, 255, 0.15)',
color: themeMode === 'dark' ? 'primary.light' : '#ffffff',
},
transition: 'all 0.2s ease-in-out',
}}
>
{item.page === 'alerts' && unreadCount > 0 ? (
{item.icon}
) : (
item.icon
)}
))}
{/* Theme Toggle Button */}
{themeMode === 'dark' ? : }
{/* Fullscreen Toggle Button */}
{isFullscreen ? : }
{/* 알림팝업 전체 닫기 버튼 */}
{/* 로그인/사용자 버튼 */}
{isAuthenticated ? (
<>
}
label={user?.name || user?.username || '사용자'}
onClick={handleUserMenuOpen}
sx={{
ml: 2,
backgroundColor: themeMode === 'dark' ? 'rgba(100, 149, 237, 0.2)' : 'rgba(255, 255, 255, 0.2)',
color: themeMode === 'dark' ? 'primary.main' : '#ffffff',
cursor: 'pointer',
'&:hover': {
backgroundColor: themeMode === 'dark' ? 'rgba(100, 149, 237, 0.3)' : 'rgba(255, 255, 255, 0.3)',
},
}}
/>
>
) : (
}
onClick={() => setLoginDialogOpen(true)}
sx={{
ml: 2,
borderColor: themeMode === 'dark' ? 'primary.main' : '#ffffff',
color: themeMode === 'dark' ? 'primary.main' : '#ffffff',
'&:hover': {
borderColor: themeMode === 'dark' ? 'primary.light' : '#ffffff',
backgroundColor: themeMode === 'dark' ? 'rgba(100, 149, 237, 0.1)' : 'rgba(255, 255, 255, 0.15)',
},
}}
>
로그인
)}
{/* Version */}
v1.1.0
{/* Main Content - Full Width */}
{/* 상태 유지가 필요한 투자분석 화면 */}
{/* 투자분석3 (프론트엔드 지표 계산 버전) — 상태 유지 */}
{renderPage()}
{/* 로그인 다이얼로그 */}
setLoginDialogOpen(false)}
onSwitchToSignUp={() => {
setLoginDialogOpen(false);
setSignUpDialogOpen(true);
}}
/>
{/* 회원가입 다이얼로그 */}
setSignUpDialogOpen(false)}
onSwitchToLogin={() => {
setSignUpDialogOpen(false);
setLoginDialogOpen(true);
}}
/>
{/* 지표 설정 패널 (우측 하단 FAB) */}
{/* 보조지표 팝업 윈도우 */}
{/* 알림 스낵바 (모든 화면에서 표시) */}
);
}
function App() {
// Context providers are now in AppRouter.tsx
return ;
}
export default App;