-
Notifications
You must be signed in to change notification settings - Fork 3
[#123] feat(os): 부팅 화면 및 윈도우 시작음 기능 추가 #153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,40 @@ | ||
| import { useState } from "react"; | ||
| import { Routes, Route, Navigate } from "react-router"; | ||
|
|
||
| import AuthInitializer from "@/hooks/AuthListener"; | ||
| import AuthLayout from "@/layouts/AuthLayout"; | ||
| import SignInPage from "@/pages/auth/sign-in/SignInPage"; | ||
| import SignUpPage from "@/pages/auth/sign-up/SignUpPage"; | ||
| import BootScreen from "@/pages/os/BootScreen"; | ||
| import OsMain from "@/pages/os/OsMain"; | ||
| import ProtectedRoute from "@/router/ProtectedRoute"; | ||
| import PublicRoute from "@/router/PublicRoute"; | ||
|
|
||
| export default function App() { | ||
| const [isBooting, setIsBooting] = useState(false); | ||
| const USE_ENTER_MODE = true; | ||
|
||
|
|
||
| return ( | ||
| <> | ||
| <AuthInitializer /> | ||
| <Routes> | ||
| <Route element={<PublicRoute />}> | ||
| <Route element={<AuthLayout />}> | ||
| <Route path="/signin" element={<SignInPage />} /> | ||
| <Route path="/signup" element={<SignUpPage />} /> | ||
| {!isBooting ? ( | ||
| <BootScreen onComplete={() => setIsBooting(true)} useEnterMode={USE_ENTER_MODE} /> | ||
| ) : ( | ||
| <Routes> | ||
| <Route element={<PublicRoute />}> | ||
| <Route element={<AuthLayout />}> | ||
| <Route path="/signin" element={<SignInPage />} /> | ||
| <Route path="/signup" element={<SignUpPage />} /> | ||
| </Route> | ||
| </Route> | ||
|
|
||
| <Route element={<ProtectedRoute />}> | ||
| <Route path="/" element={<OsMain />} /> | ||
| </Route> | ||
| </Route> | ||
| <Route element={<ProtectedRoute />}> | ||
| <Route path="/" element={<OsMain />} /> | ||
| </Route> | ||
| <Route path="*" element={<Navigate to="/" replace />} /> | ||
| </Routes> | ||
|
|
||
| <Route path="*" element={<Navigate to="/" replace />} /> | ||
| </Routes> | ||
| )} | ||
| </> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { useEffect } from "react"; | ||
|
|
||
| import Bios from "@/assets/os/bios.png"; | ||
| import StartupSound from "@/assets/sounds/windows95-startup-sound.mp3"; | ||
|
|
||
| interface BootScreenProps { | ||
| onComplete: () => void; | ||
| useEnterMode: boolean; | ||
| } | ||
|
|
||
| export default function BootScreen({ onComplete, useEnterMode }: BootScreenProps) { | ||
| useEffect(() => { | ||
| if (!useEnterMode) return; | ||
|
|
||
| const handleKeyDown = async (event: KeyboardEvent) => { | ||
| if (event.key === "Enter") { | ||
| onComplete(); | ||
|
|
||
| try { | ||
| const audio = new Audio(StartupSound); | ||
| audio.volume = 0.1; | ||
| await audio.play(); | ||
| } catch (error) { | ||
| console.error("오디오 에러:", error); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| window.addEventListener("keydown", handleKeyDown); | ||
|
|
||
| return () => window.removeEventListener("keydown", handleKeyDown); | ||
| }, [useEnterMode, onComplete]); | ||
|
|
||
| useEffect(() => { | ||
| if (useEnterMode) return; | ||
|
|
||
| const timer = setTimeout(() => { | ||
| onComplete(); | ||
| }, 2000); | ||
|
|
||
| return () => clearTimeout(timer); | ||
| }, [useEnterMode, onComplete]); | ||
|
|
||
| return ( | ||
| <div className="fixed inset-0 flex items-center justify-center bg-black p-4"> | ||
| <div className="flex h-full w-full flex-col items-center justify-center gap-6"> | ||
| <img src={Bios} alt="바이오스 화면" className="max-h-[90vh] w-auto object-contain" /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,11 +3,7 @@ import { Navigate, Outlet } from "react-router"; | |||||||||||||
| import { useAuthUser } from "@/hooks/useAuthUser"; | ||||||||||||||
|
|
||||||||||||||
| export default function ProtectedRoute() { | ||||||||||||||
| const { isLoggedIn, isLoading } = useAuthUser(); | ||||||||||||||
|
|
||||||||||||||
| if (isLoading) { | ||||||||||||||
| return <div>Loading...</div>; | ||||||||||||||
| } | ||||||||||||||
| const { isLoggedIn } = useAuthUser(); | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+6
to
7
|
||||||||||||||
| const { isLoggedIn } = useAuthUser(); | |
| const { isLoggedIn, isLoading } = useAuthUser(); | |
| if (isLoading) { | |
| return <div>Loading...</div>; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,11 +3,7 @@ import { Navigate, Outlet } from "react-router"; | |||||||||||||
| import { useAuthUser } from "@/hooks/useAuthUser"; | ||||||||||||||
|
|
||||||||||||||
| export default function PublicRoute() { | ||||||||||||||
| const { isLoggedIn, isLoading } = useAuthUser(); | ||||||||||||||
|
|
||||||||||||||
| if (isLoading) { | ||||||||||||||
| return <div>Loading...</div>; | ||||||||||||||
| } | ||||||||||||||
| const { isLoggedIn } = useAuthUser(); | ||||||||||||||
|
|
||||||||||||||
|
Comment on lines
+6
to
7
|
||||||||||||||
| const { isLoggedIn } = useAuthUser(); | |
| const { isLoggedIn, isLoading } = useAuthUser(); | |
| if (isLoading) { | |
| return <div>Loading...</div>; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
USE_ENTER_MODEconstant is hard-coded astruewithout clear documentation of what it controls or why this value was chosen.Recommendation: Consider one of the following:
REQUIRE_MANUAL_BOOTorUSE_BIOS_MANUAL_MODE