2026-01-09 18:11:21 +09:00
|
|
|
import { useEffect } from 'react';
|
2026-01-23 20:47:05 +09:00
|
|
|
import { BrowserRouter, useLocation } from 'react-router-dom';
|
2025-12-31 21:51:23 +09:00
|
|
|
import { BrowserView, MobileView } from 'react-device-detect';
|
|
|
|
|
|
2026-01-07 10:10:12 +09:00
|
|
|
// 공통 컴포넌트
|
2026-01-23 10:29:30 +09:00
|
|
|
import { ScrollToTop } from '@/components/common';
|
2026-01-07 10:10:12 +09:00
|
|
|
|
2026-01-23 13:34:28 +09:00
|
|
|
// 라우트
|
|
|
|
|
import { PCPublicRoutes, PCAdminRoutes, MobileRoutes } from '@/routes';
|
2026-01-23 10:29:30 +09:00
|
|
|
|
2026-01-23 20:47:05 +09:00
|
|
|
// 스토어
|
|
|
|
|
import { useAuthStore } from '@/stores';
|
|
|
|
|
|
2026-01-23 10:29:30 +09:00
|
|
|
/**
|
|
|
|
|
* PC 환경에서 body에 클래스 추가하는 래퍼
|
|
|
|
|
*/
|
2026-01-09 18:11:21 +09:00
|
|
|
function PCWrapper({ children }) {
|
2026-01-23 10:29:30 +09:00
|
|
|
useEffect(() => {
|
|
|
|
|
document.body.classList.add('is-pc');
|
|
|
|
|
return () => document.body.classList.remove('is-pc');
|
|
|
|
|
}, []);
|
|
|
|
|
return children;
|
2026-01-09 18:11:21 +09:00
|
|
|
}
|
|
|
|
|
|
2026-01-23 20:47:05 +09:00
|
|
|
/**
|
|
|
|
|
* PC 라우트 - admin 경로일 때만 AdminRoutes 렌더링
|
|
|
|
|
*/
|
|
|
|
|
function PCRoutes() {
|
|
|
|
|
const location = useLocation();
|
|
|
|
|
const isAdminPath = location.pathname.startsWith('/admin');
|
|
|
|
|
const { _hasHydrated } = useAuthStore();
|
|
|
|
|
|
|
|
|
|
// admin 경로에서 hydration 완료 전까지 빈 화면
|
|
|
|
|
if (isAdminPath && !_hasHydrated) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<PCWrapper>
|
|
|
|
|
{isAdminPath ? <PCAdminRoutes /> : <PCPublicRoutes />}
|
|
|
|
|
</PCWrapper>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-23 10:29:30 +09:00
|
|
|
/**
|
|
|
|
|
* 프로미스나인 팬사이트 메인 앱
|
|
|
|
|
* react-device-detect를 사용한 PC/Mobile 분리
|
|
|
|
|
*/
|
2025-12-31 21:51:23 +09:00
|
|
|
function App() {
|
2026-01-23 10:29:30 +09:00
|
|
|
return (
|
|
|
|
|
<BrowserRouter future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
|
|
|
|
|
<ScrollToTop />
|
|
|
|
|
|
|
|
|
|
{/* PC 뷰 */}
|
|
|
|
|
<BrowserView>
|
2026-01-23 20:47:05 +09:00
|
|
|
<PCRoutes />
|
2026-01-23 10:29:30 +09:00
|
|
|
</BrowserView>
|
|
|
|
|
|
|
|
|
|
{/* Mobile 뷰 */}
|
|
|
|
|
<MobileView>
|
2026-01-23 13:34:28 +09:00
|
|
|
<MobileRoutes />
|
2026-01-23 10:29:30 +09:00
|
|
|
</MobileView>
|
|
|
|
|
</BrowserRouter>
|
|
|
|
|
);
|
2025-12-31 21:51:23 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default App;
|