-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: react-scan 설정 * feat: React-error-boundary 설정 * feat: react-query 설정 * feat: 존재하지 않는 방 에러 처리 * feat: 사이드바 앨범 리스트 query로 변경 * feat: 스트리밍 페이지 에러 핸들링 * fix: 마지막 노래 특정 부등호 수정 * style: 주석제거
- Loading branch information
1 parent
2b00fdb
commit 15d0841
Showing
16 changed files
with
300 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { Routes, Route } from 'react-router-dom'; | ||
import { MainPage } from '@/pages/MainPage'; | ||
import { StreamingPage } from '@/pages/StreamingPage'; | ||
import { AdminPage } from '@/pages/AdminPage'; | ||
import { AlbumPage } from '@/pages/AlbumPage'; | ||
import { AdminLoginPage } from '@/pages/AdminLoginPage'; | ||
import { ProtectedRoute } from '@/components/ProtectedRoute'; | ||
import { Outlet } from 'react-router-dom'; | ||
import { Sidebar } from './widgets/sidebar/ui/Sidebar'; | ||
import { GlobalBoundary } from './GlobalBoundary'; | ||
|
||
const MainLayout = () => ( | ||
<div className="flex flex-row"> | ||
<Sidebar /> | ||
<div className="flex-1"> | ||
<Outlet /> | ||
</div> | ||
</div> | ||
); | ||
|
||
export function App() { | ||
return ( | ||
<GlobalBoundary> | ||
<Routes> | ||
<Route element={<MainLayout />}> | ||
<Route index element={<MainPage />} /> | ||
<Route path="/streaming/:roomId" element={<StreamingPage />} /> | ||
<Route path="/album/:albumId" element={<AlbumPage />} /> | ||
</Route> | ||
|
||
<Route path="/admin/login" element={<AdminLoginPage />} /> | ||
<Route | ||
path="/admin" | ||
element={ | ||
<ProtectedRoute> | ||
<AdminPage /> | ||
</ProtectedRoute> | ||
} | ||
/> | ||
</Routes> | ||
</GlobalBoundary> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { ErrorBoundary, FallbackProps } from 'react-error-boundary'; | ||
import { Suspense } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
export const GlobalErrorFallback = ({ | ||
error, | ||
resetErrorBoundary, | ||
}: FallbackProps) => { | ||
const navigate = useNavigate(); | ||
const navigateToMain = () => { | ||
navigate('/'); | ||
resetErrorBoundary(); | ||
}; | ||
console.log('글로벌'); | ||
return ( | ||
<div> | ||
<h1>에러가 발생했습니다.</h1> | ||
<pre>{error.message}</pre> | ||
<button onClick={navigateToMain}>메인으로 이동</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export const GlobalBoundary = ({ children }: { children: React.ReactNode }) => { | ||
return ( | ||
<ErrorBoundary FallbackComponent={GlobalErrorFallback}> | ||
<Suspense fallback={<div>로딩중...</div>}>{children}</Suspense> | ||
</ErrorBoundary> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ErrorBoundary, FallbackProps } from 'react-error-boundary'; | ||
import { Suspense } from 'react'; | ||
import { QueryErrorResetBoundary } from '@tanstack/react-query'; | ||
import { Button } from './shared/ui'; | ||
|
||
export const NetworkFallback = ({ | ||
error, | ||
resetErrorBoundary, | ||
}: FallbackProps) => { | ||
console.log('네트워크'); | ||
const handleClickReset = () => { | ||
resetErrorBoundary(); | ||
}; | ||
return ( | ||
<div className="flex flex-col h-screen justify-center items-center w-full text-grayscale-100 gap-4"> | ||
<h1>이 에러엔 슬픈 전설이 있어</h1> | ||
<pre>{error.message}</pre> | ||
{/* <Button message={'메인으로 이동'} onClick={handleClickReset} /> */} | ||
</div> | ||
); | ||
}; | ||
|
||
export const NetworkBoundary = ({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) => { | ||
return ( | ||
<QueryErrorResetBoundary> | ||
{({ reset }) => ( | ||
<ErrorBoundary | ||
onReset={reset} | ||
FallbackComponent={NetworkFallback} | ||
onError={(error) => { | ||
if (error?.name === 'QueryError') { | ||
console.error('Query Error:', error); | ||
} | ||
}} | ||
> | ||
<Suspense | ||
fallback={<div className="text-grayscale-100">로딩중...</div>} | ||
> | ||
{children} | ||
</Suspense> | ||
</ErrorBoundary> | ||
)} | ||
</QueryErrorResetBoundary> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,29 @@ | ||
import { createRoot } from 'react-dom/client'; | ||
import './index.css'; | ||
import { Router } from '@/app/router'; | ||
import { App } from '@/App'; | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: 1, | ||
refetchOnWindowFocus: false, | ||
}, | ||
}, | ||
}); | ||
|
||
createRoot(document.getElementById('root')!).render( | ||
<> | ||
<Router /> | ||
<QueryClientProvider client={queryClient}> | ||
<BrowserRouter | ||
future={{ | ||
v7_relativeSplatPath: true, | ||
v7_startTransition: true, | ||
}} | ||
> | ||
<App /> | ||
</BrowserRouter> | ||
</QueryClientProvider> | ||
</>, | ||
); |
19 changes: 15 additions & 4 deletions
19
client/src/pages/StreamingErrorPage/ui/StreamingErrorPage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,18 @@ | ||
export function StreamingErrorPage() { | ||
import { useRouteError } from 'react-router-dom'; | ||
class APIError extends Error { | ||
statueCode: number; | ||
originalError: Error; | ||
|
||
constructor(statueCode: number, message: string, originalError?: Error) { | ||
super(message); | ||
this.name = 'APIError'; | ||
this.statueCode = statueCode; | ||
this.originalError = originalError || new Error(message); | ||
} | ||
} | ||
|
||
export function StreamingErrorPage({ message }: { message?: string }) { | ||
return ( | ||
<div className="flex flex-row h-screen text-grayscale-100 justify-center items-center"> | ||
방을 찾을 수 없을지도,,, | ||
</div> | ||
<div className="flex flex-row h-screen text-grayscale-100 justify-center items-center w-full"></div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.