Skip to content
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

[FE] FIX: 라이트하우스 성능 개선 #1687 #1704

Merged
merged 16 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,34 @@
src="/src/Cabinet/components/Card/DisplayStyleCard/displayStyleInitializer.ts"
></script>
<meta charset="UTF-8" />
<meta
name="description"
content="여러분의 일상을 가볍게: 42서울 학생들을 위한 캐비닛 대여 서비스"
/>
<meta
name="keywords"
content="42, 42 Seoul, 42 서울, Cabi, 사물함, 사물함 대여, 동아리 사물함, 수요지식회"
/>

<link
rel="icon"
href="/src/Cabinet/assets/images/logo.ico"
type="image/x-icon"
/>
<link rel="shortcut icon" href="/src/Cabinet/assets/images/logo.png" />
<link rel="apple-touch-icon" href="/src/Cabinet/assets/images/logo.png" />
<link rel="manifest" href="/manifest.json" />
<link
rel="shortcut icon"
type="image/png"
href="/src/Cabinet/assets/images/logo.png"
/>

<!-- Apple Touch Icon -->
<link
rel="apple-touch-icon"
type="image/png"
href="/src/Cabinet/assets/images/logo.png"
/>

<!-- Apple Touch Icons with different sizes -->
<link
rel="apple-touch-icon"
sizes="192x192"
Expand All @@ -34,6 +54,8 @@
sizes="512x512"
href="/icons/icon-512x512.png"
/>

<link rel="manifest" href="/manifest.json" />
<meta
name="viewport"
content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
Expand All @@ -42,6 +64,8 @@
<meta property="og:type" content="website" />
<meta property="og:url" content="https://cabi.42seoul.io" />
<meta property="og:title" content="Cabi" />

<!-- Open Graph Image -->
<meta
property="og:image"
content="https://dev.cabi.42seoul.io/src/assets/images/desktopLogo.png"
Expand Down
Binary file added frontend/public/icons/icon-192x192.webp
Binary file not shown.
Binary file added frontend/public/icons/icon-256x256.webp
Binary file not shown.
Binary file added frontend/public/icons/icon-384x384.webp
Binary file not shown.
Binary file added frontend/public/icons/icon-512x512.webp
Binary file not shown.
2 changes: 2 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow : /
50 changes: 31 additions & 19 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,34 @@ import PageTracker from "@/api/analytics/PageTracker";
import * as Sentry from "@sentry/react";
import React, { Suspense, lazy } from "react";
import { BrowserRouter, Route, Routes } from "react-router-dom";
import AvailablePage from "@/Cabinet/pages/AvailablePage";
import ClubPage from "@/Cabinet/pages/ClubPage";
import CoinLogPage from "@/Cabinet/pages/CoinLogPage";
import HomePage from "@/Cabinet/pages/HomePage";
import InventoryPage from "@/Cabinet/pages/InventoryPage";
import ItemUsageLogPage from "@/Cabinet/pages/ItemUsageLogPage";
import Layout from "@/Cabinet/pages/Layout";
import LogPage from "@/Cabinet/pages/LogPage";
import LoginPage from "@/Cabinet/pages/LoginPage";
import MainPage from "@/Cabinet/pages/MainPage";
import PostLogin from "@/Cabinet/pages/PostLogin";
import ProfilePage from "@/Cabinet/pages/ProfilePage";
import StoreMainPage from "@/Cabinet/pages/StoreMainPage";
import AdminMainPage from "@/Cabinet/pages/admin/AdminMainPage";
import AdminSlackAlarmPage from "@/Cabinet/pages/admin/AdminSlackAlarmPage";
import AdminStorePage from "@/Cabinet/pages/admin/AdminStorePage";
import LoadingAnimation from "@/Cabinet/components/Common/LoadingAnimation";
import DetailPage from "@/Presentation/pages/DetailPage";
import PresentationHomePage from "@/Presentation/pages/HomePage";
import PresentationLayout from "@/Presentation/pages/Layout";
import PresentationLogPage from "@/Presentation/pages/LogPage";
import RegisterPage from "@/Presentation/pages/RegisterPage";
import AdminPresentationLayout from "@/Presentation/pages/admin/AdminLayout";

const NotFoundPage = lazy(() => import("@/Cabinet/pages/NotFoundPage"));
const LoginFailurePage = lazy(() => import("@/Cabinet/pages/LoginFailurePage"));
const NotFoundPage = lazy(() => import("@/Cabinet/pages/NotFoundPage"));
const AvailablePage = lazy(() => import("@/Cabinet/pages/AvailablePage"));
const ClubPage = lazy(() => import("@/Cabinet/pages/ClubPage"));
const CoinLogPage = lazy(() => import("@/Cabinet/pages/CoinLogPage"));
const InventoryPage = lazy(() => import("@/Cabinet/pages/InventoryPage"));
const ItemUsageLogPage = lazy(() => import("@/Cabinet/pages/ItemUsageLogPage"));
const LogPage = lazy(() => import("@/Cabinet/pages/LogPage"));
const MainPage = lazy(() => import("@/Cabinet/pages/MainPage"));
const ProfilePage = lazy(() => import("@/Cabinet/pages/ProfilePage"));
const StoreMainPage = lazy(() => import("@/Cabinet/pages/StoreMainPage"));

// NOTE : 수요지식회
const PresentationHomePage = lazy(
() => import("@/Presentation/pages/HomePage")
);
const PresentationLayout = lazy(() => import("@/Presentation/pages/Layout"));
const DetailPage = lazy(() => import("@/Presentation/pages/DetailPage"));
const PresentationLogPage = lazy(() => import("@/Presentation/pages/LogPage"));
const RegisterPage = lazy(() => import("@/Presentation/pages/RegisterPage"));

// NOTE : admin
const AdminLayout = lazy(() => import("@/Cabinet/pages/admin/AdminLayout"));
const AdminLoginPage = lazy(
() => import("@/Cabinet/pages/admin/AdminLoginPage")
Expand All @@ -38,6 +40,16 @@ const AdminLoginFailurePage = lazy(
() => import("@/Cabinet/pages/admin/AdminLoginFailurePage")
);
const AdminHomePage = lazy(() => import("@/Cabinet/pages/admin/AdminHomePage"));
const AdminMainPage = lazy(() => import("@/Cabinet/pages/admin/AdminMainPage"));
const AdminSlackAlarmPage = lazy(
() => import("@/Cabinet/pages/admin/AdminSlackAlarmPage")
);
const AdminStorePage = lazy(
() => import("@/Cabinet/pages/admin/AdminStorePage")
);
const AdminPresentationLayout = lazy(
() => import("@/Presentation/pages/admin/AdminLayout")
);

function App(): React.ReactElement {
const SentryRoutes = Sentry.withSentryReactRouterV6Routing(Routes);
Expand Down
15 changes: 7 additions & 8 deletions frontend/src/Cabinet/assets/images/storeCoin.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added frontend/src/Cabinet/assets/images/webp/logo.webp
Binary file not shown.
Binary file not shown.
22 changes: 20 additions & 2 deletions frontend/src/Cabinet/components/Announce/AnnounceTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,27 @@ const AnnounceTemplate = (props: Itext) => {
<TitleStyled>{title}</TitleStyled>
<CabiImgStyled>
{type === "ERROR" ? (
<img src="/src/Cabinet/assets/images/sadCcabiWhite.png"></img>
<picture>
<source
type="image/webp"
srcSet="/src/Cabinet/assets/images/webp/sadCcabiWhite.webp"
/>
<img
src="/src/Cabinet/assets/images/sadCcabiWhite.png"
alt="sad cabi"
/>
</picture>
) : (
<img src="/src/Cabinet/assets/images/happyCcabiWhite.png"></img>
<picture>
<source
type="image/webp"
srcSet="/src/Cabinet/assets/images/webp/happyCcabiWhite.webp"
/>
<img
src="/src/Cabinet/assets/images/happyCcabiWhite.png"
alt="happy cabi"
/>
</picture>
)}
</CabiImgStyled>
<SubTitleStyled>{subTitle}</SubTitleStyled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import styled from "styled-components";
const EmptySection = ({ message }: { message: string }): JSX.Element => {
return (
<EmptySectionStyled>
<CabiImageStyled
{/* <CabiImageStyled
src="/src/Cabinet/assets/images/happyCcabi.png"
alt="happy cabi"
/>
/> */}
<picture>
<source
type="image/webp"
srcSet="/src/Cabinet/assets/images/webp/happyCcabi.webp"
/>
<CabiImageStyled
src="/src/Cabinet/assets/images/happyCcabi.png"
alt="happy cabi"
/>
</picture>
<ContentStyled>{message}</ContentStyled>
</EmptySectionStyled>
);
Expand Down
54 changes: 6 additions & 48 deletions frontend/src/Cabinet/components/TopNav/TopNav.container.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import React, { SetStateAction, useEffect, useState } from "react";
import React, { useEffect, useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { useRecoilState, useRecoilValue, useSetRecoilState } from "recoil";
import {
buildingsFloorState,
currentBuildingNameState,
myCabinetInfoState,
} from "@/Cabinet/recoil/atoms";
import { useRecoilState, useRecoilValue } from "recoil";
import { currentBuildingNameState } from "@/Cabinet/recoil/atoms";
import { buildingsState } from "@/Cabinet/recoil/selectors";
import TopNav from "@/Cabinet/components/TopNav/TopNav";
import { MyCabinetInfoResponseDto } from "@/Cabinet/types/dto/cabinet.dto";
import {
axiosBuildingFloor,
axiosMyLentInfo,
} from "@/Cabinet/api/axios/axios.custom";
import { staticColNumData } from "@/Cabinet/assets/data/sectionColNumData";
import useMenu from "@/Cabinet/hooks/useMenu";

const TopNavContainer: React.FC<{
setIsLoading: React.Dispatch<SetStateAction<boolean>>;
}> = (props) => {
const TopNavContainer: React.FC = () => {
const [buildingClicked, setBuildingClicked] = useState(false);
const [currentBuildingName, setCurrentBuildingName] = useRecoilState(
currentBuildingNameState
);
const setMyLentInfo =
useSetRecoilState<MyCabinetInfoResponseDto>(myCabinetInfoState);
const setBuildingsFloor = useSetRecoilState(buildingsFloorState);
const buildingsList = useRecoilValue<Array<string>>(buildingsState);
const { setIsLoading } = props;
const { toggleLeftNav } = useMenu();
const navigator = useNavigate();
const isLocation = useLocation();
Expand All @@ -35,42 +21,14 @@ const TopNavContainer: React.FC<{
toggleLeftNav();
};

useEffect(() => {
function setTimeoutPromise(delay: number) {
return new Promise((resolve) => setTimeout(resolve, delay));
}
const getBuildingsData = async () => {
try {
await setTimeoutPromise(500);
const buildingsFloorData = await axiosBuildingFloor();
setBuildingsFloor([...buildingsFloorData.data]);
} catch (error) {
console.log(error);
}
};
async function getMyLentInfo() {
try {
const { data: myLentInfo } = await axiosMyLentInfo();

setMyLentInfo(myLentInfo);
} catch (error) {
console.error(error);
}
}

Promise.all([getBuildingsData(), getMyLentInfo()]).then(() =>
setIsLoading(false)
);
}, []);

useEffect(() => {
if (buildingsList.length === 0) return;
setCurrentBuildingName(buildingsList[0]);
}, [buildingsList]);

useEffect(() => {
if (currentBuildingName === undefined) return;
else if (currentBuildingName === "새롬관") {
else if (currentBuildingName === staticColNumData[0].building) {
navigator(isLocation);
}
}, [currentBuildingName]);
Expand Down
Loading
Loading