From cd7438e1952c4a04925ed8a3ebfc2ac8b6636dcd Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BCHKHG\\user" Date: Mon, 16 Dec 2024 22:44:09 +0900 Subject: [PATCH 1/6] 12-16 --- src/main.js | 133 +++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 120 insertions(+), 13 deletions(-) diff --git a/src/main.js b/src/main.js index 036c2a38..c2f57ee9 100644 --- a/src/main.js +++ b/src/main.js @@ -1,24 +1,24 @@ -const MainPage = () => ` +const MainPage = (isLoggedIn = false) => `

항해플러스

- + ${Navigation(isLoggedIn)}
-
- - -
- + ${ + isLoggedIn + ? ` +
+ + +
+ ` + : "" + } +
@@ -232,6 +232,24 @@ const ProfilePage = () => `
`; +const Navigation = (isLoggedIn) => ` + +`; document.body.innerHTML = ` ${MainPage()} @@ -239,3 +257,92 @@ document.body.innerHTML = ` ${LoginPage()} ${ErrorPage()} `; + +class Router { + constructor() { + this.routes = {}; + this.state = { + isLoggedIn: false, + }; + + window.addEventListener("popstate", this.handlePopState.bind(this)); + window.addEventListener("DOMContentLoaded", () => { + this.handleRoute(window.location.pathname); + }); + } + + addRoute(path, handler) { + this.routes[path] = handler; + } + + navigateTo(path) { + history.pushState(null, "", path); + this.handleRoute(path); + } + + handlePopState() { + this.handleRoute(window.location.pathname); + } + + handleRoute(path) { + const app = document.getElementById("app"); + const handler = this.routes[path] || this.routes["/404"]; + if (handler) { + app.innerHTML = handler(this.state); + } + } + + setLoggedIn(value) { + this.state.isLoggedIn = value; + this.handleRoute(window.location.pathname); + } +} + +const router = new Router(); + +router.addRoute("/", (state) => MainPage(state.isLoggedIn)); +router.addRoute("/login", (state) => + state.isLoggedIn ? router.navigateTo("/") : LoginPage(), +); +router.addRoute("/profile", (state) => + state.isLoggedIn ? ProfilePage() : router.navigateTo("/login"), +); +router.addRoute("/404", () => ErrorPage()); + +document.querySelector("nav").addEventListener("click", (e) => { + if (e.target.tagName === "A") { + e.preventDefault(); + router.navigateTo(e.target.pathname); + } +}); + +document.addEventListener("submit", (e) => { + if (e.target.matches("form")) { + e.preventDefault(); + const email = e.target.querySelector('input[type="text"]').value; + const password = e.target.querySelector('input[type="password"]').value; + + if (email && password) { + router.setLoggedIn(true); + router.navigateTo("/"); + } + } +}); + +document.addEventListener("click", (e) => { + // 기존 네비게이션 처리 + if (e.target.matches("a") && e.target.id !== "logout") { + e.preventDefault(); + const path = e.target.getAttribute("href"); + if (path !== "#") { + router.navigateTo(path); + } + } + + // 로그아웃 처리 + if (e.target.id === "logout") { + e.preventDefault(); + router.setLoggedIn(false); + router.navigateTo("/"); + } +}); From b9e3e0966be5ef7f1470d8029b4ffb71373e2a44 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BCHKHG\\user" Date: Fri, 20 Dec 2024 00:28:19 +0900 Subject: [PATCH 2/6] =?UTF-8?q?component=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DefaultLayout.js | 14 ++++ src/components/Footer.js | 7 ++ src/components/Header.js | 10 +++ src/components/Nav.js | 24 ++++++ src/{ => core}/main.js | 143 +++----------------------------- src/pages/ErrorPage.js | 17 ++++ src/pages/LoginPage.js | 25 ++++++ src/pages/MainPage.js | 87 +++++++++++++++++++ src/pages/ProfilePage.js | 70 ++++++++++++++++ src/utils/isLogin.js | 6 ++ 10 files changed, 272 insertions(+), 131 deletions(-) create mode 100644 src/components/DefaultLayout.js create mode 100644 src/components/Footer.js create mode 100644 src/components/Header.js create mode 100644 src/components/Nav.js rename src/{ => core}/main.js (72%) create mode 100644 src/pages/ErrorPage.js create mode 100644 src/pages/LoginPage.js create mode 100644 src/pages/MainPage.js create mode 100644 src/pages/ProfilePage.js create mode 100644 src/utils/isLogin.js diff --git a/src/components/DefaultLayout.js b/src/components/DefaultLayout.js new file mode 100644 index 00000000..5a4022fd --- /dev/null +++ b/src/components/DefaultLayout.js @@ -0,0 +1,14 @@ +import Header from "./Header"; +import Footer from "./Footer"; + +const DefaultLayout = (component) => { + return ` +
+ ${Header()} + ${component()} + ${Footer()} +
+ `; +}; + +export default DefaultLayout; diff --git a/src/components/Footer.js b/src/components/Footer.js new file mode 100644 index 00000000..134bf7a7 --- /dev/null +++ b/src/components/Footer.js @@ -0,0 +1,7 @@ +const Footer = () => ` +
+

© 2024 항해플러스. All rights reserved.

+
+`; + +export default Footer; diff --git a/src/components/Header.js b/src/components/Header.js new file mode 100644 index 00000000..2ee25d35 --- /dev/null +++ b/src/components/Header.js @@ -0,0 +1,10 @@ +import Nav from "./Nav"; + +const Header = () => ` +
+

항해플러스

+
+ ${Nav()} +`; + +export default Header; diff --git a/src/components/Nav.js b/src/components/Nav.js new file mode 100644 index 00000000..55c554d1 --- /dev/null +++ b/src/components/Nav.js @@ -0,0 +1,24 @@ +import isLogin from "../utils/isLogin"; + +const Nav = () => { + const activateStyle = "text-blue-600 font-bold"; + const deactivateStyle = "text-gray-600"; + const handleActivate = (x) => (x === path ? activateStyle : deactivateStyle); + const path = window.location.pathname; + + return ` + +`; +}; + +export default Nav; diff --git a/src/main.js b/src/core/main.js similarity index 72% rename from src/main.js rename to src/core/main.js index c2f57ee9..811f5b97 100644 --- a/src/main.js +++ b/src/core/main.js @@ -1,26 +1,22 @@ -const MainPage = (isLoggedIn = false) => ` +const MainPage = () => `

항해플러스

- - ${Navigation(isLoggedIn)} - +
- ${ - isLoggedIn - ? ` -
- - -
- ` - : "" - } - +
+ + +
-
프로필 @@ -36,7 +32,6 @@ const MainPage = (isLoggedIn = false) => `
-
프로필 @@ -52,7 +47,6 @@ const MainPage = (isLoggedIn = false) => `
-
프로필 @@ -68,7 +62,6 @@ const MainPage = (isLoggedIn = false) => `
-
프로필 @@ -84,7 +77,6 @@ const MainPage = (isLoggedIn = false) => `
-
프로필 @@ -102,7 +94,6 @@ const MainPage = (isLoggedIn = false) => `
-

© 2024 항해플러스. All rights reserved.

@@ -157,7 +148,6 @@ const ProfilePage = () => `

항해플러스

- -

@@ -224,7 +213,6 @@ const ProfilePage = () => `

-

© 2024 항해플러스. All rights reserved.

@@ -232,24 +220,6 @@ const ProfilePage = () => `
`; -const Navigation = (isLoggedIn) => ` - -`; document.body.innerHTML = ` ${MainPage()} @@ -257,92 +227,3 @@ document.body.innerHTML = ` ${LoginPage()} ${ErrorPage()} `; - -class Router { - constructor() { - this.routes = {}; - this.state = { - isLoggedIn: false, - }; - - window.addEventListener("popstate", this.handlePopState.bind(this)); - window.addEventListener("DOMContentLoaded", () => { - this.handleRoute(window.location.pathname); - }); - } - - addRoute(path, handler) { - this.routes[path] = handler; - } - - navigateTo(path) { - history.pushState(null, "", path); - this.handleRoute(path); - } - - handlePopState() { - this.handleRoute(window.location.pathname); - } - - handleRoute(path) { - const app = document.getElementById("app"); - const handler = this.routes[path] || this.routes["/404"]; - if (handler) { - app.innerHTML = handler(this.state); - } - } - - setLoggedIn(value) { - this.state.isLoggedIn = value; - this.handleRoute(window.location.pathname); - } -} - -const router = new Router(); - -router.addRoute("/", (state) => MainPage(state.isLoggedIn)); -router.addRoute("/login", (state) => - state.isLoggedIn ? router.navigateTo("/") : LoginPage(), -); -router.addRoute("/profile", (state) => - state.isLoggedIn ? ProfilePage() : router.navigateTo("/login"), -); -router.addRoute("/404", () => ErrorPage()); - -document.querySelector("nav").addEventListener("click", (e) => { - if (e.target.tagName === "A") { - e.preventDefault(); - router.navigateTo(e.target.pathname); - } -}); - -document.addEventListener("submit", (e) => { - if (e.target.matches("form")) { - e.preventDefault(); - const email = e.target.querySelector('input[type="text"]').value; - const password = e.target.querySelector('input[type="password"]').value; - - if (email && password) { - router.setLoggedIn(true); - router.navigateTo("/"); - } - } -}); - -document.addEventListener("click", (e) => { - // 기존 네비게이션 처리 - if (e.target.matches("a") && e.target.id !== "logout") { - e.preventDefault(); - const path = e.target.getAttribute("href"); - if (path !== "#") { - router.navigateTo(path); - } - } - - // 로그아웃 처리 - if (e.target.id === "logout") { - e.preventDefault(); - router.setLoggedIn(false); - router.navigateTo("/"); - } -}); diff --git a/src/pages/ErrorPage.js b/src/pages/ErrorPage.js new file mode 100644 index 00000000..6182b3f3 --- /dev/null +++ b/src/pages/ErrorPage.js @@ -0,0 +1,17 @@ +const ErrorPage = () => ` +
+
+

항해플러스

+

404

+

페이지를 찾을 수 없습니다

+

+ 요청하신 페이지가 존재하지 않거나 이동되었을 수 있습니다. +

+ + 홈으로 돌아가기 + +
+
+`; + +export default ErrorPage; diff --git a/src/pages/LoginPage.js b/src/pages/LoginPage.js new file mode 100644 index 00000000..8dffeef5 --- /dev/null +++ b/src/pages/LoginPage.js @@ -0,0 +1,25 @@ +const LoginPage = () => ` +
+
+

항해플러스

+
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+`; + +export default LoginPage; diff --git a/src/pages/MainPage.js b/src/pages/MainPage.js new file mode 100644 index 00000000..2152edf8 --- /dev/null +++ b/src/pages/MainPage.js @@ -0,0 +1,87 @@ +const MainPage = () => ` +
+
+ + +
+
+
+
+ 프로필 +
+

홍길동

+

5분 전

+
+
+

오늘 날씨가 정말 좋네요. 다들 좋은 하루 보내세요!

+
+ + + +
+
+
+
+ 프로필 +
+

김철수

+

15분 전

+
+
+

새로운 프로젝트를 시작했어요. 열심히 코딩 중입니다!

+
+ + + +
+
+
+
+ 프로필 +
+

이영희

+

30분 전

+
+
+

오늘 점심 메뉴 추천 받습니다. 뭐가 좋을까요?

+
+ + + +
+
+
+
+ 프로필 +
+

박민수

+

1시간 전

+
+
+

주말에 등산 가실 분 계신가요? 함께 가요!

+
+ + + +
+
+
+
+ 프로필 +
+

정수연

+

2시간 전

+
+
+

새로 나온 영화 재미있대요. 같이 보러 갈 사람?

+
+ + + +
+
+
+
+`; + +export default MainPage; diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js new file mode 100644 index 00000000..e89fb971 --- /dev/null +++ b/src/pages/ProfilePage.js @@ -0,0 +1,70 @@ +const ProfilePage = () => ` +
+
+
+
+

항해플러스

+
+ +
+
+

+ 내 프로필 +

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+
+

© 2024 항해플러스. All rights reserved.

+
+
+
+
+`; + +export default ProfilePage; diff --git a/src/utils/isLogin.js b/src/utils/isLogin.js new file mode 100644 index 00000000..87341873 --- /dev/null +++ b/src/utils/isLogin.js @@ -0,0 +1,6 @@ +const isLogin = () => { + const user = localStorage.getItem("user"); + return user ? true : false; +}; + +export default isLogin; From 6df9b580e5da6fcb301de6cf13cbec48eff7300b Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BCHKHG\\user" Date: Fri, 20 Dec 2024 09:41:50 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=EB=9D=BC=EC=9A=B0=ED=84=B0=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84..?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/main.js | 229 ------------------------------- src/core/render.js | 13 ++ src/main.js | 45 ++++++ src/pages/ProfilePage.js | 57 ++++---- src/pages/handleChangeProfile.js | 11 ++ src/pages/handleLogin.js | 14 ++ src/pages/handleProfile.js | 10 ++ src/routes/hashRouter.js | 26 ++++ src/routes/hashRoutes.js | 12 ++ src/routes/router.js | 28 ++++ src/routes/routes.js | 0 11 files changed, 183 insertions(+), 262 deletions(-) delete mode 100644 src/core/main.js create mode 100644 src/core/render.js create mode 100644 src/main.js create mode 100644 src/pages/handleChangeProfile.js create mode 100644 src/pages/handleLogin.js create mode 100644 src/pages/handleProfile.js create mode 100644 src/routes/hashRouter.js create mode 100644 src/routes/hashRoutes.js create mode 100644 src/routes/router.js create mode 100644 src/routes/routes.js diff --git a/src/core/main.js b/src/core/main.js deleted file mode 100644 index 811f5b97..00000000 --- a/src/core/main.js +++ /dev/null @@ -1,229 +0,0 @@ -const MainPage = () => ` -
-
-
-

항해플러스

-
- -
-
- - -
-
-
-
- 프로필 -
-

홍길동

-

5분 전

-
-
-

오늘 날씨가 정말 좋네요. 다들 좋은 하루 보내세요!

-
- - - -
-
-
-
- 프로필 -
-

김철수

-

15분 전

-
-
-

새로운 프로젝트를 시작했어요. 열심히 코딩 중입니다!

-
- - - -
-
-
-
- 프로필 -
-

이영희

-

30분 전

-
-
-

오늘 점심 메뉴 추천 받습니다. 뭐가 좋을까요?

-
- - - -
-
-
-
- 프로필 -
-

박민수

-

1시간 전

-
-
-

주말에 등산 가실 분 계신가요? 함께 가요!

-
- - - -
-
-
-
- 프로필 -
-

정수연

-

2시간 전

-
-
-

새로 나온 영화 재미있대요. 같이 보러 갈 사람?

-
- - - -
-
-
-
-
-

© 2024 항해플러스. All rights reserved.

-
-
-
-`; - -const ErrorPage = () => ` -
-
-

항해플러스

-

404

-

페이지를 찾을 수 없습니다

-

- 요청하신 페이지가 존재하지 않거나 이동되었을 수 있습니다. -

- - 홈으로 돌아가기 - -
-
-`; - -const LoginPage = () => ` -
-
-

항해플러스

-
-
- -
-
- -
- -
- -
-
- -
-
-
-`; - -const ProfilePage = () => ` -
-
-
-
-

항해플러스

-
- -
-
-

- 내 프로필 -

-
-
- - -
-
- - -
-
- - -
- -
-
-
-
-

© 2024 항해플러스. All rights reserved.

-
-
-
-
-`; - -document.body.innerHTML = ` - ${MainPage()} - ${ProfilePage()} - ${LoginPage()} - ${ErrorPage()} -`; diff --git a/src/core/render.js b/src/core/render.js new file mode 100644 index 00000000..b74b12b7 --- /dev/null +++ b/src/core/render.js @@ -0,0 +1,13 @@ +const render = (component) => { + const root = document.getElementById("root"); + + root.innerHTML = ` +
+
+ ${component} +
+
+ `; +}; + +export default render; diff --git a/src/main.js b/src/main.js new file mode 100644 index 00000000..cd275bf7 --- /dev/null +++ b/src/main.js @@ -0,0 +1,45 @@ +import router from "./routes/router"; +import handleProfile from "./pages/handleProfile"; +import handleChangeProfile from "./pages/handleChangeProfile"; +import handleLogin from "./pages/handleLogin"; +import hashRouter from "./routes/hashRouter"; + +window.addEventListener("load", () => { + if (window.location.hash) { + hashRouter(); + } else { + router(); + } +}); + +window.addEventListener("popstate", () => router()); +window.addEventListener("hashchange", () => hashRouter()); + +document.addEventListener("click", (e) => { + if (e.target.tagName === "A") { + e.preventDefault(); + if (e.target.id === "logout") { + localStorage.removeItem("user"); + router("/login"); + } else { + const path = e.target.getAttribute("href"); + router(path); + handleProfile(); + } + } +}); + +document.addEventListener("submit", (e) => { + e.preventDefault(); + const form = e.target; + const formData = new FormData(form); + const data = Object.fromEntries(formData); + + if (form.id == "login-form") { + handleLogin(data); + } + if (form.id == "profile-form") { + handleChangeProfile(data); + } + handleProfile(); +}); diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index e89fb971..803fd773 100644 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -1,34 +1,30 @@ const ProfilePage = () => ` -
-
-
-
-

항해플러스

-
- -
+

내 프로필

-
+
- - 사용자 이름 +
- + ` />
- + 자기소개입니다.
-
-
-

© 2024 항해플러스. All rights reserved.

-
-
-
-
+
`; export default ProfilePage; diff --git a/src/pages/handleChangeProfile.js b/src/pages/handleChangeProfile.js new file mode 100644 index 00000000..d5e79da6 --- /dev/null +++ b/src/pages/handleChangeProfile.js @@ -0,0 +1,11 @@ +const handleChangeProfile = (data) => { + const user = { + username: data.username ?? "", + email: data.email ?? "", + bio: data.bio ?? "", + }; + + localStorage.setItem("user", JSON.stringify(user)); +}; + +export default handleChangeProfile; diff --git a/src/pages/handleLogin.js b/src/pages/handleLogin.js new file mode 100644 index 00000000..c952bb4a --- /dev/null +++ b/src/pages/handleLogin.js @@ -0,0 +1,14 @@ +import router from "../routes/router"; + +const handleLogin = (data) => { + const user = { + username: data.username ?? "", + email: data.email ?? "", + bio: data.bio ?? "", + }; + + localStorage.setItem("user", JSON.stringify(user)); + router("/profile"); +}; + +export default handleLogin; diff --git a/src/pages/handleProfile.js b/src/pages/handleProfile.js new file mode 100644 index 00000000..cb37bedc --- /dev/null +++ b/src/pages/handleProfile.js @@ -0,0 +1,10 @@ +const handleProfile = () => { + if (window.location.pathname === "/profile" && localStorage.getItem("user")) { + const user = JSON.parse(localStorage.getItem("user")); + Object.entries(user).forEach(([key, value]) => { + document.getElementById(key).value = value; + }); + } +}; + +export default handleProfile; diff --git a/src/routes/hashRouter.js b/src/routes/hashRouter.js new file mode 100644 index 00000000..82fa111a --- /dev/null +++ b/src/routes/hashRouter.js @@ -0,0 +1,26 @@ +import render from "../core/render"; +import isLogin from "../utils/isLogin"; +import handleProfile from "../pages/handleProfile"; +import HASH_ROUTES from "./hashRoutes"; +import ErrorPage from "../pages/ErrorPage"; + +const hashRouter = (path) => { + path = path || window.location.hash; + + if (path === "#/profile") { + if (!isLogin()) { + path = "#/login"; + } + } + + if (path === "#/login" && isLogin()) { + path = "#/"; + } + + window.history.pushState({}, "", path); + const component = (HASH_ROUTES[path] || (() => ErrorPage()))(); + render(component); + handleProfile(); +}; + +export default hashRouter; diff --git a/src/routes/hashRoutes.js b/src/routes/hashRoutes.js new file mode 100644 index 00000000..de35ad2b --- /dev/null +++ b/src/routes/hashRoutes.js @@ -0,0 +1,12 @@ +import MainPage from "../pages/MainPage"; +import ProfilePage from "../pages/ProfilePage"; +import LoginPage from "../pages/LoginPage"; +import DefaultLayout from "../components/DefaultLayout"; + +const HASH_ROUTES = { + "#/": () => DefaultLayout(MainPage), + "#/profile": () => DefaultLayout(ProfilePage), + "#/login": () => LoginPage(), +}; + +export default HASH_ROUTES; diff --git a/src/routes/router.js b/src/routes/router.js new file mode 100644 index 00000000..28462589 --- /dev/null +++ b/src/routes/router.js @@ -0,0 +1,28 @@ +import render from "../core/render"; +import isLogin from "../utils/isLogin"; +import handleProfile from "../pages/handleProfile"; + +import ROUTES from "./routes"; +import ErrorPage from "../pages/ErrorPage"; + +const router = (path) => { + if (window.location.hash) return; + path = path || window.location.pathname; + + if (path === "/profile") { + if (!isLogin()) { + path = "/login"; + } + } + + if (path === "/login" && isLogin()) { + path = "/"; + } + + window.history.pushState({}, "", path); + const component = (ROUTES[path] || (() => ErrorPage()))(); + render(component); + handleProfile(); +}; + +export default router; diff --git a/src/routes/routes.js b/src/routes/routes.js new file mode 100644 index 00000000..e69de29b From b6198bf29360a4f12cc8762e4d19bf0e9d9a3846 Mon Sep 17 00:00:00 2001 From: Jonjour Date: Fri, 10 Jan 2025 13:10:38 +0900 Subject: [PATCH 4/6] =?UTF-8?q?SPA=20=EA=B8=B0=EB=B3=B8=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EC=99=84=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 252 +++++++++++++++++++-------------- package.json | 2 +- src/components/Footer.js | 5 + src/components/Header.js | 5 + src/components/Navigation.js | 18 +++ src/layouts/Layout.js | 14 ++ src/main.js | 262 +++-------------------------------- src/pages/HomePage.js | 97 +++++++++++++ src/pages/LoginPage.js | 23 +++ src/pages/NotFoundPage.js | 15 ++ src/pages/ProfilePage.js | 64 +++++++++ src/router.js | 77 ++++++++++ 12 files changed, 488 insertions(+), 346 deletions(-) create mode 100644 src/components/Footer.js create mode 100644 src/components/Header.js create mode 100644 src/components/Navigation.js create mode 100644 src/layouts/Layout.js create mode 100644 src/pages/HomePage.js create mode 100644 src/pages/LoginPage.js create mode 100644 src/pages/NotFoundPage.js create mode 100644 src/pages/ProfilePage.js create mode 100644 src/router.js diff --git a/package-lock.json b/package-lock.json index 8a563559..3ab4231b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "jsdom": "^25.0.1", "lint-staged": "^15.2.11", "prettier": "^3.4.2", - "vite": "^6.0.3", + "vite": "^6.0.7", "vitest": "^2.1.8" } }, @@ -153,13 +153,14 @@ } }, "node_modules/@esbuild/aix-ppc64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.0.tgz", - "integrity": "sha512-WtKdFM7ls47zkKHFVzMz8opM7LkcsIp9amDUBIAWirg70RM71WRSjdILPsY5Uv1D42ZpUfaPILDlfactHgsRkw==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.24.2.tgz", + "integrity": "sha512-thpVCb/rhxE/BnMLQ7GReQLLN8q9qbHmI55F4489/ByVg2aQaQ6kbcLb6FHkocZzQhxc4gx0sCk0tJkKBFzDhA==", "cpu": [ "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "aix" @@ -169,13 +170,14 @@ } }, "node_modules/@esbuild/android-arm": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.0.tgz", - "integrity": "sha512-arAtTPo76fJ/ICkXWetLCc9EwEHKaeya4vMrReVlEIUCAUncH7M4bhMQ+M9Vf+FFOZJdTNMXNBrWwW+OXWpSew==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.24.2.tgz", + "integrity": "sha512-tmwl4hJkCfNHwFB3nBa8z1Uy3ypZpxqxfTQOcHX+xRByyYgunVbZ9MzUUfb0RxaHIMnbHagwAxuTL+tnNM+1/Q==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -185,13 +187,14 @@ } }, "node_modules/@esbuild/android-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.0.tgz", - "integrity": "sha512-Vsm497xFM7tTIPYK9bNTYJyF/lsP590Qc1WxJdlB6ljCbdZKU9SY8i7+Iin4kyhV/KV5J2rOKsBQbB77Ab7L/w==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.24.2.tgz", + "integrity": "sha512-cNLgeqCqV8WxfcTIOeL4OAtSmL8JjcN6m09XIgro1Wi7cF4t/THaWEa7eL5CMoMBdjoHOTh/vwTO/o2TRXIyzg==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -201,13 +204,14 @@ } }, "node_modules/@esbuild/android-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.0.tgz", - "integrity": "sha512-t8GrvnFkiIY7pa7mMgJd7p8p8qqYIz1NYiAoKc75Zyv73L3DZW++oYMSHPRarcotTKuSs6m3hTOa5CKHaS02TQ==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.24.2.tgz", + "integrity": "sha512-B6Q0YQDqMx9D7rvIcsXfmJfvUYLoP722bgfBlO5cGvNVb5V/+Y7nhBE3mHV9OpxBf4eAS2S68KZztiPaWq4XYw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "android" @@ -217,13 +221,14 @@ } }, "node_modules/@esbuild/darwin-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.0.tgz", - "integrity": "sha512-CKyDpRbK1hXwv79soeTJNHb5EiG6ct3efd/FTPdzOWdbZZfGhpbcqIpiD0+vwmpu0wTIL97ZRPZu8vUt46nBSw==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.24.2.tgz", + "integrity": "sha512-kj3AnYWc+CekmZnS5IPu9D+HWtUI49hbnyqk0FLEJDbzCIQt7hg7ucF1SQAilhtYpIujfaHr6O0UHlzzSPdOeA==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -233,13 +238,14 @@ } }, "node_modules/@esbuild/darwin-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.0.tgz", - "integrity": "sha512-rgtz6flkVkh58od4PwTRqxbKH9cOjaXCMZgWD905JOzjFKW+7EiUObfd/Kav+A6Gyud6WZk9w+xu6QLytdi2OA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.24.2.tgz", + "integrity": "sha512-WeSrmwwHaPkNR5H3yYfowhZcbriGqooyu3zI/3GGpF8AyUdsrrP0X6KumITGA9WOyiJavnGZUwPGvxvwfWPHIA==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "darwin" @@ -249,13 +255,14 @@ } }, "node_modules/@esbuild/freebsd-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.0.tgz", - "integrity": "sha512-6Mtdq5nHggwfDNLAHkPlyLBpE5L6hwsuXZX8XNmHno9JuL2+bg2BX5tRkwjyfn6sKbxZTq68suOjgWqCicvPXA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.24.2.tgz", + "integrity": "sha512-UN8HXjtJ0k/Mj6a9+5u6+2eZ2ERD7Edt1Q9IZiB5UZAIdPnVKDoG7mdTVGhHJIeEml60JteamR3qhsr1r8gXvg==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "freebsd" @@ -265,13 +272,14 @@ } }, "node_modules/@esbuild/freebsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.0.tgz", - "integrity": "sha512-D3H+xh3/zphoX8ck4S2RxKR6gHlHDXXzOf6f/9dbFt/NRBDIE33+cVa49Kil4WUjxMGW0ZIYBYtaGCa2+OsQwQ==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.24.2.tgz", + "integrity": "sha512-TvW7wE/89PYW+IevEJXZ5sF6gJRDY/14hyIGFXdIucxCsbRmLUcjseQu1SyTko+2idmCw94TgyaEZi9HUSOe3Q==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "freebsd" @@ -281,13 +289,14 @@ } }, "node_modules/@esbuild/linux-arm": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.0.tgz", - "integrity": "sha512-gJKIi2IjRo5G6Glxb8d3DzYXlxdEj2NlkixPsqePSZMhLudqPhtZ4BUrpIuTjJYXxvF9njql+vRjB2oaC9XpBw==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.24.2.tgz", + "integrity": "sha512-n0WRM/gWIdU29J57hJyUdIsk0WarGd6To0s+Y+LwvlC55wt+GT/OgkwoXCXvIue1i1sSNWblHEig00GBWiJgfA==", "cpu": [ "arm" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -297,13 +306,14 @@ } }, "node_modules/@esbuild/linux-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.0.tgz", - "integrity": "sha512-TDijPXTOeE3eaMkRYpcy3LarIg13dS9wWHRdwYRnzlwlA370rNdZqbcp0WTyyV/k2zSxfko52+C7jU5F9Tfj1g==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.24.2.tgz", + "integrity": "sha512-7HnAD6074BW43YvvUmE/35Id9/NB7BeX5EoNkK9obndmZBUk8xmJJeU7DwmUeN7tkysslb2eSl6CTrYz6oEMQg==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -313,13 +323,14 @@ } }, "node_modules/@esbuild/linux-ia32": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.0.tgz", - "integrity": "sha512-K40ip1LAcA0byL05TbCQ4yJ4swvnbzHscRmUilrmP9Am7//0UjPreh4lpYzvThT2Quw66MhjG//20mrufm40mA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.24.2.tgz", + "integrity": "sha512-sfv0tGPQhcZOgTKO3oBE9xpHuUqguHvSo4jl+wjnKwFpapx+vUDcawbwPNuBIAYdRAvIDBfZVvXprIj3HA+Ugw==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -329,13 +340,14 @@ } }, "node_modules/@esbuild/linux-loong64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.0.tgz", - "integrity": "sha512-0mswrYP/9ai+CU0BzBfPMZ8RVm3RGAN/lmOMgW4aFUSOQBjA31UP8Mr6DDhWSuMwj7jaWOT0p0WoZ6jeHhrD7g==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.24.2.tgz", + "integrity": "sha512-CN9AZr8kEndGooS35ntToZLTQLHEjtVB5n7dl8ZcTZMonJ7CCfStrYhrzF97eAecqVbVJ7APOEe18RPI4KLhwQ==", "cpu": [ "loong64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -345,13 +357,14 @@ } }, "node_modules/@esbuild/linux-mips64el": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.0.tgz", - "integrity": "sha512-hIKvXm0/3w/5+RDtCJeXqMZGkI2s4oMUGj3/jM0QzhgIASWrGO5/RlzAzm5nNh/awHE0A19h/CvHQe6FaBNrRA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.24.2.tgz", + "integrity": "sha512-iMkk7qr/wl3exJATwkISxI7kTcmHKE+BlymIAbHO8xanq/TjHaaVThFF6ipWzPHryoFsesNQJPE/3wFJw4+huw==", "cpu": [ "mips64el" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -361,13 +374,14 @@ } }, "node_modules/@esbuild/linux-ppc64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.0.tgz", - "integrity": "sha512-HcZh5BNq0aC52UoocJxaKORfFODWXZxtBaaZNuN3PUX3MoDsChsZqopzi5UupRhPHSEHotoiptqikjN/B77mYQ==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.24.2.tgz", + "integrity": "sha512-shsVrgCZ57Vr2L8mm39kO5PPIb+843FStGt7sGGoqiiWYconSxwTiuswC1VJZLCjNiMLAMh34jg4VSEQb+iEbw==", "cpu": [ "ppc64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -377,13 +391,14 @@ } }, "node_modules/@esbuild/linux-riscv64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.0.tgz", - "integrity": "sha512-bEh7dMn/h3QxeR2KTy1DUszQjUrIHPZKyO6aN1X4BCnhfYhuQqedHaa5MxSQA/06j3GpiIlFGSsy1c7Gf9padw==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.24.2.tgz", + "integrity": "sha512-4eSFWnU9Hhd68fW16GD0TINewo1L6dRrB+oLNNbYyMUAeOD2yCK5KXGK1GH4qD/kT+bTEXjsyTCiJGHPZ3eM9Q==", "cpu": [ "riscv64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -393,13 +408,14 @@ } }, "node_modules/@esbuild/linux-s390x": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.0.tgz", - "integrity": "sha512-ZcQ6+qRkw1UcZGPyrCiHHkmBaj9SiCD8Oqd556HldP+QlpUIe2Wgn3ehQGVoPOvZvtHm8HPx+bH20c9pvbkX3g==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.24.2.tgz", + "integrity": "sha512-S0Bh0A53b0YHL2XEXC20bHLuGMOhFDO6GN4b3YjRLK//Ep3ql3erpNcPlEFed93hsQAjAQDNsvcK+hV90FubSw==", "cpu": [ "s390x" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -409,13 +425,14 @@ } }, "node_modules/@esbuild/linux-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.0.tgz", - "integrity": "sha512-vbutsFqQ+foy3wSSbmjBXXIJ6PL3scghJoM8zCL142cGaZKAdCZHyf+Bpu/MmX9zT9Q0zFBVKb36Ma5Fzfa8xA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.24.2.tgz", + "integrity": "sha512-8Qi4nQcCTbLnK9WoMjdC9NiTG6/E38RNICU6sUNqK0QFxCYgoARqVqxdFmWkdonVsvGqWhmm7MO0jyTqLqwj0Q==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "linux" @@ -424,14 +441,32 @@ "node": ">=18" } }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.24.2.tgz", + "integrity": "sha512-wuLK/VztRRpMt9zyHSazyCVdCXlpHkKm34WUyinD2lzK07FAHTq0KQvZZlXikNWkDGoT6x3TD51jKQ7gMVpopw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@esbuild/netbsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.0.tgz", - "integrity": "sha512-hjQ0R/ulkO8fCYFsG0FZoH+pWgTTDreqpqY7UnQntnaKv95uP5iW3+dChxnx7C3trQQU40S+OgWhUVwCjVFLvg==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.24.2.tgz", + "integrity": "sha512-VefFaQUc4FMmJuAxmIHgUmfNiLXY438XrL4GDNV1Y1H/RW3qow68xTwjZKfj/+Plp9NANmzbH5R40Meudu8mmw==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "netbsd" @@ -441,13 +476,14 @@ } }, "node_modules/@esbuild/openbsd-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.0.tgz", - "integrity": "sha512-MD9uzzkPQbYehwcN583yx3Tu5M8EIoTD+tUgKF982WYL9Pf5rKy9ltgD0eUgs8pvKnmizxjXZyLt0z6DC3rRXg==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.24.2.tgz", + "integrity": "sha512-YQbi46SBct6iKnszhSvdluqDmxCJA+Pu280Av9WICNwQmMxV7nLRHZfjQzwbPs3jeWnuAhE9Jy0NrnJ12Oz+0A==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "openbsd" @@ -457,13 +493,14 @@ } }, "node_modules/@esbuild/openbsd-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.0.tgz", - "integrity": "sha512-4ir0aY1NGUhIC1hdoCzr1+5b43mw99uNwVzhIq1OY3QcEwPDO3B7WNXBzaKY5Nsf1+N11i1eOfFcq+D/gOS15Q==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.24.2.tgz", + "integrity": "sha512-+iDS6zpNM6EnJyWv0bMGLWSWeXGN/HTaF/LXHXHwejGsVi+ooqDfMCCTerNFxEkM3wYVcExkeGXNqshc9iMaOA==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "openbsd" @@ -473,13 +510,14 @@ } }, "node_modules/@esbuild/sunos-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.0.tgz", - "integrity": "sha512-jVzdzsbM5xrotH+W5f1s+JtUy1UWgjU0Cf4wMvffTB8m6wP5/kx0KiaLHlbJO+dMgtxKV8RQ/JvtlFcdZ1zCPA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.24.2.tgz", + "integrity": "sha512-hTdsW27jcktEvpwNHJU4ZwWFGkz2zRJUz8pvddmXPtXDzVKTTINmlmga3ZzwcuMpUvLw7JkLy9QLKyGpD2Yxig==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "sunos" @@ -489,13 +527,14 @@ } }, "node_modules/@esbuild/win32-arm64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.0.tgz", - "integrity": "sha512-iKc8GAslzRpBytO2/aN3d2yb2z8XTVfNV0PjGlCxKo5SgWmNXx82I/Q3aG1tFfS+A2igVCY97TJ8tnYwpUWLCA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.24.2.tgz", + "integrity": "sha512-LihEQ2BBKVFLOC9ZItT9iFprsE9tqjDjnbulhHoFxYQtQfai7qfluVODIYxt1PgdoyQkz23+01rzwNwYfutxUQ==", "cpu": [ "arm64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -505,13 +544,14 @@ } }, "node_modules/@esbuild/win32-ia32": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.0.tgz", - "integrity": "sha512-vQW36KZolfIudCcTnaTpmLQ24Ha1RjygBo39/aLkM2kmjkWmZGEJ5Gn9l5/7tzXA42QGIoWbICfg6KLLkIw6yw==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.24.2.tgz", + "integrity": "sha512-q+iGUwfs8tncmFC9pcnD5IvRHAzmbwQ3GPS5/ceCyHdjXubwQWI12MKWSNSMYLJMq23/IUCvJMS76PDqXe1fxA==", "cpu": [ "ia32" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -521,13 +561,14 @@ } }, "node_modules/@esbuild/win32-x64": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.0.tgz", - "integrity": "sha512-7IAFPrjSQIJrGsK6flwg7NFmwBoSTyF3rl7If0hNUFQU4ilTsEPL6GuMuU9BfIWVVGuRnuIidkSMC+c0Otu8IA==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.24.2.tgz", + "integrity": "sha512-7VTgWzgMGvup6aSqDPLiW5zHaxYJGTO4OokMjIlrCtf+VpEL+cXKtCvg723iguPYI5oaUNdS+/V7OU2gvXVWEg==", "cpu": [ "x64" ], "dev": true, + "license": "MIT", "optional": true, "os": [ "win32" @@ -1647,11 +1688,12 @@ "dev": true }, "node_modules/esbuild": { - "version": "0.24.0", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.0.tgz", - "integrity": "sha512-FuLPevChGDshgSicjisSooU0cemp/sGXR841D5LHMB7mTVOmsEHcAxaH3irL53+8YDIeVNQEySh4DaYU/iuPqQ==", + "version": "0.24.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.24.2.tgz", + "integrity": "sha512-+9egpBW8I3CD5XPe0n6BfT5fxLzxrlDzqydF3aviG+9ni1lDC/OvMHcxqEFV0+LANZG5R1bFMWfUrjVsdwxJvA==", "dev": true, "hasInstallScript": true, + "license": "MIT", "bin": { "esbuild": "bin/esbuild" }, @@ -1659,30 +1701,31 @@ "node": ">=18" }, "optionalDependencies": { - "@esbuild/aix-ppc64": "0.24.0", - "@esbuild/android-arm": "0.24.0", - "@esbuild/android-arm64": "0.24.0", - "@esbuild/android-x64": "0.24.0", - "@esbuild/darwin-arm64": "0.24.0", - "@esbuild/darwin-x64": "0.24.0", - "@esbuild/freebsd-arm64": "0.24.0", - "@esbuild/freebsd-x64": "0.24.0", - "@esbuild/linux-arm": "0.24.0", - "@esbuild/linux-arm64": "0.24.0", - "@esbuild/linux-ia32": "0.24.0", - "@esbuild/linux-loong64": "0.24.0", - "@esbuild/linux-mips64el": "0.24.0", - "@esbuild/linux-ppc64": "0.24.0", - "@esbuild/linux-riscv64": "0.24.0", - "@esbuild/linux-s390x": "0.24.0", - "@esbuild/linux-x64": "0.24.0", - "@esbuild/netbsd-x64": "0.24.0", - "@esbuild/openbsd-arm64": "0.24.0", - "@esbuild/openbsd-x64": "0.24.0", - "@esbuild/sunos-x64": "0.24.0", - "@esbuild/win32-arm64": "0.24.0", - "@esbuild/win32-ia32": "0.24.0", - "@esbuild/win32-x64": "0.24.0" + "@esbuild/aix-ppc64": "0.24.2", + "@esbuild/android-arm": "0.24.2", + "@esbuild/android-arm64": "0.24.2", + "@esbuild/android-x64": "0.24.2", + "@esbuild/darwin-arm64": "0.24.2", + "@esbuild/darwin-x64": "0.24.2", + "@esbuild/freebsd-arm64": "0.24.2", + "@esbuild/freebsd-x64": "0.24.2", + "@esbuild/linux-arm": "0.24.2", + "@esbuild/linux-arm64": "0.24.2", + "@esbuild/linux-ia32": "0.24.2", + "@esbuild/linux-loong64": "0.24.2", + "@esbuild/linux-mips64el": "0.24.2", + "@esbuild/linux-ppc64": "0.24.2", + "@esbuild/linux-riscv64": "0.24.2", + "@esbuild/linux-s390x": "0.24.2", + "@esbuild/linux-x64": "0.24.2", + "@esbuild/netbsd-arm64": "0.24.2", + "@esbuild/netbsd-x64": "0.24.2", + "@esbuild/openbsd-arm64": "0.24.2", + "@esbuild/openbsd-x64": "0.24.2", + "@esbuild/sunos-x64": "0.24.2", + "@esbuild/win32-arm64": "0.24.2", + "@esbuild/win32-ia32": "0.24.2", + "@esbuild/win32-x64": "0.24.2" } }, "node_modules/escape-string-regexp": { @@ -3576,12 +3619,13 @@ } }, "node_modules/vite": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.3.tgz", - "integrity": "sha512-Cmuo5P0ENTN6HxLSo6IHsjCLn/81Vgrp81oaiFFMRa8gGDj5xEjIcEpf2ZymZtZR8oU0P2JX5WuUp/rlXcHkAw==", + "version": "6.0.7", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.0.7.tgz", + "integrity": "sha512-RDt8r/7qx9940f8FcOIAH9PTViRrghKaK2K1jY3RaAURrEUbm9Du1mJ72G+jlhtG3WwodnfzY8ORQZbBavZEAQ==", "dev": true, + "license": "MIT", "dependencies": { - "esbuild": "^0.24.0", + "esbuild": "^0.24.2", "postcss": "^8.4.49", "rollup": "^4.23.0" }, diff --git a/package.json b/package.json index e535bf69..71c76d58 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "jsdom": "^25.0.1", "lint-staged": "^15.2.11", "prettier": "^3.4.2", - "vite": "^6.0.3", + "vite": "^6.0.7", "vitest": "^2.1.8" } } diff --git a/src/components/Footer.js b/src/components/Footer.js new file mode 100644 index 00000000..62a3de1d --- /dev/null +++ b/src/components/Footer.js @@ -0,0 +1,5 @@ +export const Footer = () => ` +
+

© 2024 항해플러스. All rights reserved.

+
+`; diff --git a/src/components/Header.js b/src/components/Header.js new file mode 100644 index 00000000..d3b80d7b --- /dev/null +++ b/src/components/Header.js @@ -0,0 +1,5 @@ +export const Header = () => ` +
+

항해플러스

+
+`; diff --git a/src/components/Navigation.js b/src/components/Navigation.js new file mode 100644 index 00000000..cba2a4f3 --- /dev/null +++ b/src/components/Navigation.js @@ -0,0 +1,18 @@ +export const Navigation = (currentPath) => { + const isLoggedIn = !!localStorage.getItem("user"); + return ` + +`; +}; diff --git a/src/layouts/Layout.js b/src/layouts/Layout.js new file mode 100644 index 00000000..21bf9d8f --- /dev/null +++ b/src/layouts/Layout.js @@ -0,0 +1,14 @@ +import { Header } from "../components/Header.js"; +import { Navigation } from "../components/Navigation.js"; +import { Footer } from "../components/Footer.js"; + +export const Layout = (content, currentPath = "/") => ` +
+
+ ${Header()} + ${Navigation(currentPath)} + ${content} + ${Footer()} +
+
+`; diff --git a/src/main.js b/src/main.js index 036c2a38..2fe3136d 100644 --- a/src/main.js +++ b/src/main.js @@ -1,241 +1,21 @@ -const MainPage = () => ` -
-
-
-

항해플러스

-
- - - -
-
- - -
- -
- -
-
- 프로필 -
-

홍길동

-

5분 전

-
-
-

오늘 날씨가 정말 좋네요. 다들 좋은 하루 보내세요!

-
- - - -
-
- -
-
- 프로필 -
-

김철수

-

15분 전

-
-
-

새로운 프로젝트를 시작했어요. 열심히 코딩 중입니다!

-
- - - -
-
- -
-
- 프로필 -
-

이영희

-

30분 전

-
-
-

오늘 점심 메뉴 추천 받습니다. 뭐가 좋을까요?

-
- - - -
-
- -
-
- 프로필 -
-

박민수

-

1시간 전

-
-
-

주말에 등산 가실 분 계신가요? 함께 가요!

-
- - - -
-
- -
-
- 프로필 -
-

정수연

-

2시간 전

-
-
-

새로 나온 영화 재미있대요. 같이 보러 갈 사람?

-
- - - -
-
-
-
- -
-

© 2024 항해플러스. All rights reserved.

-
-
-
-`; - -const ErrorPage = () => ` -
-
-

항해플러스

-

404

-

페이지를 찾을 수 없습니다

-

- 요청하신 페이지가 존재하지 않거나 이동되었을 수 있습니다. -

- - 홈으로 돌아가기 - -
-
-`; - -const LoginPage = () => ` -
-
-

항해플러스

-
-
- -
-
- -
- -
- -
-
- -
-
-
-`; - -const ProfilePage = () => ` -
-
-
-
-

항해플러스

-
- - - -
-
-

- 내 프로필 -

-
-
- - -
-
- - -
-
- - -
- -
-
-
- -
-

© 2024 항해플러스. All rights reserved.

-
-
-
-
-`; - -document.body.innerHTML = ` - ${MainPage()} - ${ProfilePage()} - ${LoginPage()} - ${ErrorPage()} -`; +import { router } from "./router.js"; + +// 링크 클릭 이벤트 처리 +document.addEventListener("click", (e) => { + if (e.target.matches("a")) { + e.preventDefault(); + const href = e.target.getAttribute("href"); + if (href !== "#") { + window.history.pushState({}, "", href); + router(); + } + } +}); + +// 브라우저 뒤로가기/앞으로가기 처리 +window.addEventListener("popstate", router); + +// 초기 라우팅 처리 +window.addEventListener("DOMContentLoaded", () => { + router(); +}); diff --git a/src/pages/HomePage.js b/src/pages/HomePage.js new file mode 100644 index 00000000..1ccdbf99 --- /dev/null +++ b/src/pages/HomePage.js @@ -0,0 +1,97 @@ +import { Layout } from "../layouts/Layout.js"; + +export const HomePage = () => { + const content = ` +
+
+ + +
+ +
+ +
+
+ 프로필 +
+

홍길동

+

5분 전

+
+
+

오늘 날씨가 정말 좋네요. 다들 좋은 하루 보내세요!

+
+ + + +
+
+ +
+
+ 프로필 +
+

김철수

+

15분 전

+
+
+

새로운 프로젝트를 시작했어요. 열심히 코딩 중입니다!

+
+ + + +
+
+ +
+
+ 프로필 +
+

이영희

+

30분 전

+
+
+

오늘 점심 메뉴 추천 받습니다. 뭐가 좋을까요?

+
+ + + +
+
+ +
+
+ 프로필 +
+

박민수

+

1시간 전

+
+
+

주말에 등산 가실 분 계신가요? 함께 가요!

+
+ + + +
+
+ +
+
+ 프로필 +
+

정수연

+

2시간 전

+
+
+

새로 나온 영화 재미있대요. 같이 보러 갈 사람?

+
+ + + +
+
+
+
+`; + + return Layout(content, "/"); +}; diff --git a/src/pages/LoginPage.js b/src/pages/LoginPage.js new file mode 100644 index 00000000..9f099a68 --- /dev/null +++ b/src/pages/LoginPage.js @@ -0,0 +1,23 @@ +export const LoginPage = () => ` +
+
+

항해플러스

+
+
+ +
+
+ +
+ +
+ +
+
+ +
+
+
+`; diff --git a/src/pages/NotFoundPage.js b/src/pages/NotFoundPage.js new file mode 100644 index 00000000..e379658b --- /dev/null +++ b/src/pages/NotFoundPage.js @@ -0,0 +1,15 @@ +export const NotFoundPage = () => ` +
+
+

항해플러스

+

404

+

페이지를 찾을 수 없습니다

+

+ 요청하신 페이지가 존재하지 않거나 이동되었을 수 있습니다. +

+ + 홈으로 돌아가기 + +
+
+ `; diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js new file mode 100644 index 00000000..bf0c1613 --- /dev/null +++ b/src/pages/ProfilePage.js @@ -0,0 +1,64 @@ +import { Layout } from "../layouts/Layout.js"; + +export const ProfilePage = () => { + const user = JSON.parse(localStorage.getItem("user") || "{}"); + const { username = "", email = "", bio = "" } = user; + + const content = ` + +
+
+

+ 내 프로필 +

+
+
+ + +
+
+ + +
+
+ + +
+ +
+
+
+ `; + return Layout(content, "/profile"); +}; diff --git a/src/router.js b/src/router.js new file mode 100644 index 00000000..3c968dc2 --- /dev/null +++ b/src/router.js @@ -0,0 +1,77 @@ +// src/router.js +import { HomePage } from "./pages/HomePage.js"; +import { ProfilePage } from "./pages/ProfilePage.js"; +import { LoginPage } from "./pages/LoginPage.js"; +import { NotFoundPage } from "./pages/NotFoundPage.js"; + +export const routes = { + "/": HomePage, + "/profile": ProfilePage, + "/login": LoginPage, + "/404": NotFoundPage, +}; + +const handlers = { + login: (event) => { + event.preventDefault(); + const username = document.getElementById("username").value; + localStorage.setItem( + "user", + JSON.stringify({ username, email: "", bio: "" }), + ); + navigate("/profile"); + }, + + profile: (event) => { + event.preventDefault(); + const user = JSON.parse(localStorage.getItem("user") || "{}"); + const updatedUser = { + ...user, + username: document.getElementById("username").value, + email: document.getElementById("email").value, + bio: document.getElementById("bio").value, + }; + localStorage.setItem("user", JSON.stringify(updatedUser)); + router(); + }, +}; + +const navigate = (path) => { + window.history.pushState({}, "", path); + router(); +}; + +export const handleLogout = (e) => { + e.preventDefault(); + localStorage.removeItem("user"); + navigate("/login"); +}; + +export const router = () => { + const path = window.location.pathname; + const isAuthenticated = !!localStorage.getItem("user"); + + if (path === "/profile" && !isAuthenticated) { + navigate("/login"); + return; + } + + const page = routes[path] || routes["/404"]; + document.getElementById("root").innerHTML = page(); + + // 이벤트 핸들러 연결 + const forms = { + "login-form": handlers.login, + "profile-form": handlers.profile, + logout: handleLogout, + }; + + Object.entries(forms).forEach(([id, handler]) => { + const element = document.getElementById(id); + if (element) { + element instanceof HTMLFormElement + ? element.addEventListener("submit", handler) + : element.addEventListener("click", handler); + } + }); +}; From 649fac64b668f14057c5f80ed6322223557ea0a0 Mon Sep 17 00:00:00 2001 From: Jonjour Date: Fri, 10 Jan 2025 14:02:04 +0900 Subject: [PATCH 5/6] =?UTF-8?q?=EA=B8=B0=EB=B3=B8=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EB=A8=B8=EC=A7=80=20=ED=9B=84=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/DefaultLayout.js | 14 ----- src/components/Footer.js | 5 +- src/components/Header.js | 4 +- src/components/Nav.js | 24 --------- src/core/render.js | 13 ----- src/layouts/Layout.js | 1 - src/pages/ErrorPage.js | 17 ------- src/pages/HomePage.js | 8 --- src/pages/LoginPage.js | 4 +- src/pages/MainPage.js | 87 -------------------------------- src/pages/ProfilePage.js | 6 +-- src/pages/handleChangeProfile.js | 11 ---- src/pages/handleLogin.js | 14 ----- src/pages/handleProfile.js | 10 ---- src/router.js | 11 ---- src/routes/hashRouter.js | 26 ---------- src/routes/hashRoutes.js | 12 ----- src/routes/router.js | 28 ---------- src/routes/routes.js | 0 src/utils/isLogin.js | 6 --- 20 files changed, 4 insertions(+), 297 deletions(-) delete mode 100644 src/components/DefaultLayout.js delete mode 100644 src/components/Nav.js delete mode 100644 src/core/render.js delete mode 100644 src/pages/ErrorPage.js delete mode 100644 src/pages/MainPage.js delete mode 100644 src/pages/handleChangeProfile.js delete mode 100644 src/pages/handleLogin.js delete mode 100644 src/pages/handleProfile.js delete mode 100644 src/routes/hashRouter.js delete mode 100644 src/routes/hashRoutes.js delete mode 100644 src/routes/router.js delete mode 100644 src/routes/routes.js delete mode 100644 src/utils/isLogin.js diff --git a/src/components/DefaultLayout.js b/src/components/DefaultLayout.js deleted file mode 100644 index 5a4022fd..00000000 --- a/src/components/DefaultLayout.js +++ /dev/null @@ -1,14 +0,0 @@ -import Header from "./Header"; -import Footer from "./Footer"; - -const DefaultLayout = (component) => { - return ` -
- ${Header()} - ${component()} - ${Footer()} -
- `; -}; - -export default DefaultLayout; diff --git a/src/components/Footer.js b/src/components/Footer.js index 724ce202..7d1ff566 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -1,8 +1,5 @@ - -const Footer = () => ` +export const Footer = () => `

© 2024 항해플러스. All rights reserved.

`; - -export default Footer; diff --git a/src/components/Header.js b/src/components/Header.js index 4ab381c0..d3b80d7b 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,7 +1,5 @@ -const Header = () => ` +export const Header = () => `

항해플러스

`; - -export default Header; \ No newline at end of file diff --git a/src/components/Nav.js b/src/components/Nav.js deleted file mode 100644 index 55c554d1..00000000 --- a/src/components/Nav.js +++ /dev/null @@ -1,24 +0,0 @@ -import isLogin from "../utils/isLogin"; - -const Nav = () => { - const activateStyle = "text-blue-600 font-bold"; - const deactivateStyle = "text-gray-600"; - const handleActivate = (x) => (x === path ? activateStyle : deactivateStyle); - const path = window.location.pathname; - - return ` - -`; -}; - -export default Nav; diff --git a/src/core/render.js b/src/core/render.js deleted file mode 100644 index b74b12b7..00000000 --- a/src/core/render.js +++ /dev/null @@ -1,13 +0,0 @@ -const render = (component) => { - const root = document.getElementById("root"); - - root.innerHTML = ` -
-
- ${component} -
-
- `; -}; - -export default render; diff --git a/src/layouts/Layout.js b/src/layouts/Layout.js index 21bf9d8f..210a98fc 100644 --- a/src/layouts/Layout.js +++ b/src/layouts/Layout.js @@ -1,7 +1,6 @@ import { Header } from "../components/Header.js"; import { Navigation } from "../components/Navigation.js"; import { Footer } from "../components/Footer.js"; - export const Layout = (content, currentPath = "/") => `
diff --git a/src/pages/ErrorPage.js b/src/pages/ErrorPage.js deleted file mode 100644 index 6182b3f3..00000000 --- a/src/pages/ErrorPage.js +++ /dev/null @@ -1,17 +0,0 @@ -const ErrorPage = () => ` -
-
-

항해플러스

-

404

-

페이지를 찾을 수 없습니다

-

- 요청하신 페이지가 존재하지 않거나 이동되었을 수 있습니다. -

- - 홈으로 돌아가기 - -
-
-`; - -export default ErrorPage; diff --git a/src/pages/HomePage.js b/src/pages/HomePage.js index 1ccdbf99..d1dc8cce 100644 --- a/src/pages/HomePage.js +++ b/src/pages/HomePage.js @@ -1,5 +1,4 @@ import { Layout } from "../layouts/Layout.js"; - export const HomePage = () => { const content = `
@@ -7,9 +6,7 @@ export const HomePage = () => {
-
-
프로필 @@ -25,7 +22,6 @@ export const HomePage = () => {
-
프로필 @@ -41,7 +37,6 @@ export const HomePage = () => {
-
프로필 @@ -57,7 +52,6 @@ export const HomePage = () => {
-
프로필 @@ -73,7 +67,6 @@ export const HomePage = () => {
-
프로필 @@ -92,6 +85,5 @@ export const HomePage = () => {
`; - return Layout(content, "/"); }; diff --git a/src/pages/LoginPage.js b/src/pages/LoginPage.js index f7a0cb73..9f099a68 100644 --- a/src/pages/LoginPage.js +++ b/src/pages/LoginPage.js @@ -1,4 +1,4 @@ -const LoginPage = () => ` +export const LoginPage = () => `

항해플러스

@@ -21,5 +21,3 @@ const LoginPage = () => `
`; - -export default LoginPage; diff --git a/src/pages/MainPage.js b/src/pages/MainPage.js deleted file mode 100644 index 2152edf8..00000000 --- a/src/pages/MainPage.js +++ /dev/null @@ -1,87 +0,0 @@ -const MainPage = () => ` -
-
- - -
-
-
-
- 프로필 -
-

홍길동

-

5분 전

-
-
-

오늘 날씨가 정말 좋네요. 다들 좋은 하루 보내세요!

-
- - - -
-
-
-
- 프로필 -
-

김철수

-

15분 전

-
-
-

새로운 프로젝트를 시작했어요. 열심히 코딩 중입니다!

-
- - - -
-
-
-
- 프로필 -
-

이영희

-

30분 전

-
-
-

오늘 점심 메뉴 추천 받습니다. 뭐가 좋을까요?

-
- - - -
-
-
-
- 프로필 -
-

박민수

-

1시간 전

-
-
-

주말에 등산 가실 분 계신가요? 함께 가요!

-
- - - -
-
-
-
- 프로필 -
-

정수연

-

2시간 전

-
-
-

새로 나온 영화 재미있대요. 같이 보러 갈 사람?

-
- - - -
-
-
-
-`; - -export default MainPage; diff --git a/src/pages/ProfilePage.js b/src/pages/ProfilePage.js index 3f0eec70..12de98b5 100644 --- a/src/pages/ProfilePage.js +++ b/src/pages/ProfilePage.js @@ -1,9 +1,7 @@ import { Layout } from "../layouts/Layout.js"; - -const ProfilePage = () => { +export const ProfilePage = () => { const user = JSON.parse(localStorage.getItem("user") || "{}"); const { username = "", email = "", bio = "" } = user; - const content = `
@@ -62,5 +60,3 @@ const ProfilePage = () => { `; return Layout(content, "/profile"); }; - -export default ProfilePage; diff --git a/src/pages/handleChangeProfile.js b/src/pages/handleChangeProfile.js deleted file mode 100644 index d5e79da6..00000000 --- a/src/pages/handleChangeProfile.js +++ /dev/null @@ -1,11 +0,0 @@ -const handleChangeProfile = (data) => { - const user = { - username: data.username ?? "", - email: data.email ?? "", - bio: data.bio ?? "", - }; - - localStorage.setItem("user", JSON.stringify(user)); -}; - -export default handleChangeProfile; diff --git a/src/pages/handleLogin.js b/src/pages/handleLogin.js deleted file mode 100644 index c952bb4a..00000000 --- a/src/pages/handleLogin.js +++ /dev/null @@ -1,14 +0,0 @@ -import router from "../routes/router"; - -const handleLogin = (data) => { - const user = { - username: data.username ?? "", - email: data.email ?? "", - bio: data.bio ?? "", - }; - - localStorage.setItem("user", JSON.stringify(user)); - router("/profile"); -}; - -export default handleLogin; diff --git a/src/pages/handleProfile.js b/src/pages/handleProfile.js deleted file mode 100644 index cb37bedc..00000000 --- a/src/pages/handleProfile.js +++ /dev/null @@ -1,10 +0,0 @@ -const handleProfile = () => { - if (window.location.pathname === "/profile" && localStorage.getItem("user")) { - const user = JSON.parse(localStorage.getItem("user")); - Object.entries(user).forEach(([key, value]) => { - document.getElementById(key).value = value; - }); - } -}; - -export default handleProfile; diff --git a/src/router.js b/src/router.js index 3c968dc2..255f5ad1 100644 --- a/src/router.js +++ b/src/router.js @@ -1,16 +1,13 @@ -// src/router.js import { HomePage } from "./pages/HomePage.js"; import { ProfilePage } from "./pages/ProfilePage.js"; import { LoginPage } from "./pages/LoginPage.js"; import { NotFoundPage } from "./pages/NotFoundPage.js"; - export const routes = { "/": HomePage, "/profile": ProfilePage, "/login": LoginPage, "/404": NotFoundPage, }; - const handlers = { login: (event) => { event.preventDefault(); @@ -21,7 +18,6 @@ const handlers = { ); navigate("/profile"); }, - profile: (event) => { event.preventDefault(); const user = JSON.parse(localStorage.getItem("user") || "{}"); @@ -35,37 +31,30 @@ const handlers = { router(); }, }; - const navigate = (path) => { window.history.pushState({}, "", path); router(); }; - export const handleLogout = (e) => { e.preventDefault(); localStorage.removeItem("user"); navigate("/login"); }; - export const router = () => { const path = window.location.pathname; const isAuthenticated = !!localStorage.getItem("user"); - if (path === "/profile" && !isAuthenticated) { navigate("/login"); return; } - const page = routes[path] || routes["/404"]; document.getElementById("root").innerHTML = page(); - // 이벤트 핸들러 연결 const forms = { "login-form": handlers.login, "profile-form": handlers.profile, logout: handleLogout, }; - Object.entries(forms).forEach(([id, handler]) => { const element = document.getElementById(id); if (element) { diff --git a/src/routes/hashRouter.js b/src/routes/hashRouter.js deleted file mode 100644 index 82fa111a..00000000 --- a/src/routes/hashRouter.js +++ /dev/null @@ -1,26 +0,0 @@ -import render from "../core/render"; -import isLogin from "../utils/isLogin"; -import handleProfile from "../pages/handleProfile"; -import HASH_ROUTES from "./hashRoutes"; -import ErrorPage from "../pages/ErrorPage"; - -const hashRouter = (path) => { - path = path || window.location.hash; - - if (path === "#/profile") { - if (!isLogin()) { - path = "#/login"; - } - } - - if (path === "#/login" && isLogin()) { - path = "#/"; - } - - window.history.pushState({}, "", path); - const component = (HASH_ROUTES[path] || (() => ErrorPage()))(); - render(component); - handleProfile(); -}; - -export default hashRouter; diff --git a/src/routes/hashRoutes.js b/src/routes/hashRoutes.js deleted file mode 100644 index de35ad2b..00000000 --- a/src/routes/hashRoutes.js +++ /dev/null @@ -1,12 +0,0 @@ -import MainPage from "../pages/MainPage"; -import ProfilePage from "../pages/ProfilePage"; -import LoginPage from "../pages/LoginPage"; -import DefaultLayout from "../components/DefaultLayout"; - -const HASH_ROUTES = { - "#/": () => DefaultLayout(MainPage), - "#/profile": () => DefaultLayout(ProfilePage), - "#/login": () => LoginPage(), -}; - -export default HASH_ROUTES; diff --git a/src/routes/router.js b/src/routes/router.js deleted file mode 100644 index 28462589..00000000 --- a/src/routes/router.js +++ /dev/null @@ -1,28 +0,0 @@ -import render from "../core/render"; -import isLogin from "../utils/isLogin"; -import handleProfile from "../pages/handleProfile"; - -import ROUTES from "./routes"; -import ErrorPage from "../pages/ErrorPage"; - -const router = (path) => { - if (window.location.hash) return; - path = path || window.location.pathname; - - if (path === "/profile") { - if (!isLogin()) { - path = "/login"; - } - } - - if (path === "/login" && isLogin()) { - path = "/"; - } - - window.history.pushState({}, "", path); - const component = (ROUTES[path] || (() => ErrorPage()))(); - render(component); - handleProfile(); -}; - -export default router; diff --git a/src/routes/routes.js b/src/routes/routes.js deleted file mode 100644 index e69de29b..00000000 diff --git a/src/utils/isLogin.js b/src/utils/isLogin.js deleted file mode 100644 index 87341873..00000000 --- a/src/utils/isLogin.js +++ /dev/null @@ -1,6 +0,0 @@ -const isLogin = () => { - const user = localStorage.getItem("user"); - return user ? true : false; -}; - -export default isLogin; From 069f4344c1e53d308e83dc97adfac903c85ff85f Mon Sep 17 00:00:00 2001 From: Jonjour Date: Fri, 10 Jan 2025 17:48:18 +0900 Subject: [PATCH 6/6] =?UTF-8?q?SPA=20=EC=8B=AC=ED=99=94=EA=B8=B0=EB=8A=A5?= =?UTF-8?q?=20=EA=B0=9C=EB=B0=9C=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Navigation.js | 10 ++-- src/config/routes.js | 11 +++++ src/handlers/formHandlers.js | 32 +++++++++++++ src/pages/ProfilePage.js | 2 + src/router.js | 93 +++++++++++++----------------------- src/utils/auth.js | 24 ++++++++++ src/utils/eventBinding.js | 17 +++++++ 7 files changed, 126 insertions(+), 63 deletions(-) create mode 100644 src/config/routes.js create mode 100644 src/handlers/formHandlers.js create mode 100644 src/utils/auth.js create mode 100644 src/utils/eventBinding.js diff --git a/src/components/Navigation.js b/src/components/Navigation.js index cba2a4f3..c03e885c 100644 --- a/src/components/Navigation.js +++ b/src/components/Navigation.js @@ -1,15 +1,17 @@ +import { auth } from "../utils/auth.js"; + export const Navigation = (currentPath) => { - const isLoggedIn = !!localStorage.getItem("user"); + const isLoggedIn = auth.isAuthenticated(); return `