Address accessibility issue
The screen was not visible. This commit addresses an accessibility issue.
This commit is contained in:
45
src/App.tsx
45
src/App.tsx
@@ -18,22 +18,51 @@ import NotFound from "./pages/NotFound";
|
||||
import Login from "./pages/Login";
|
||||
import Register from "./pages/Register";
|
||||
import ForgotPassword from "./pages/ForgotPassword";
|
||||
import { initSyncSettings } from "./utils/syncUtils";
|
||||
|
||||
// 전역 오류 처리
|
||||
const handleError = (error: any) => {
|
||||
console.error("앱 오류 발생:", error);
|
||||
};
|
||||
|
||||
// 오류 발생 시 전역 핸들러에 연결
|
||||
window.addEventListener('error', (event) => {
|
||||
handleError(event.error);
|
||||
});
|
||||
|
||||
window.addEventListener('unhandledrejection', (event) => {
|
||||
handleError(event.reason);
|
||||
});
|
||||
|
||||
const queryClient = new QueryClient({
|
||||
defaultOptions: {
|
||||
queries: {
|
||||
retry: 1,
|
||||
refetchOnWindowFocus: false,
|
||||
// 오류 처리 추가
|
||||
onError: (error) => {
|
||||
console.error("쿼리 오류:", error);
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
// 오류 처리 추가
|
||||
onError: (error) => {
|
||||
console.error("뮤테이션 오류:", error);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const App = () => {
|
||||
const [isLoaded, setIsLoaded] = useState(false);
|
||||
const [initError, setInitError] = useState<Error | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
// 애플리케이션 초기화 및 로딩 상태 관리
|
||||
try {
|
||||
// 동기화 설정 초기화
|
||||
initSyncSettings();
|
||||
|
||||
// 기본 예산 데이터 초기화
|
||||
if (!localStorage.getItem('budgetData')) {
|
||||
const defaultBudgetData = {
|
||||
@@ -74,6 +103,7 @@ const App = () => {
|
||||
setIsLoaded(true);
|
||||
} catch (error) {
|
||||
console.error('앱 초기화 중 오류 발생:', error);
|
||||
setInitError(error instanceof Error ? error : new Error('앱 초기화 중 알 수 없는 오류가 발생했습니다'));
|
||||
// 오류가 발생해도 앱 로딩
|
||||
setIsLoaded(true);
|
||||
}
|
||||
@@ -88,6 +118,21 @@ const App = () => {
|
||||
</div>;
|
||||
}
|
||||
|
||||
if (initError) {
|
||||
return <div className="flex items-center justify-center h-screen">
|
||||
<div className="text-center max-w-md p-6 neuro-card">
|
||||
<h2 className="text-xl font-bold text-red-500 mb-4">앱 로드 오류</h2>
|
||||
<p className="text-gray-600 mb-4">{initError.message}</p>
|
||||
<button
|
||||
onClick={() => window.location.reload()}
|
||||
className="neuro-button"
|
||||
>
|
||||
다시 시도
|
||||
</button>
|
||||
</div>
|
||||
</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<TooltipProvider>
|
||||
|
||||
Reference in New Issue
Block a user