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

성능 최적화 (2) #218

Merged
merged 12 commits into from
Nov 15, 2024
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<link rel="preconnect" href="https://www.sinitto.life" />
<link rel="preconnect" href="https://sinitto.site" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link
rel="apple-touch-icon"
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
"@babel/preset-env": "^7.25.4",
"@babel/preset-react": "^7.25.9",
"@babel/preset-typescript": "7.24.7",
"@prerenderer/renderer-puppeteer": "^1.2.4",
"@prerenderer/rollup-plugin": "^0.3.12",
"@testing-library/jest-dom": "6.4.8",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/jest": "29.5.12",
Expand Down
995 changes: 977 additions & 18 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/app/routes/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './protected-route';
export * from './lazy-loading';
116 changes: 0 additions & 116 deletions src/app/routes/components/lazy-loading/LazyLoading.ts

This file was deleted.

22 changes: 0 additions & 22 deletions src/app/routes/components/lazy-loading/index.ts

This file was deleted.

141 changes: 117 additions & 24 deletions src/app/routes/router.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,126 @@
import { Suspense } from 'react';
import { lazy, Suspense } from 'react';
import { createBrowserRouter, RouterProvider } from 'react-router-dom';

import {
ProtectedRoute,
GuardMainPage,
RegisterPage,
GuardMyPage,
ServiceHistoryPage,
GuardReportPage,
SinittoReviewPage,
ServiceManualPage,
SeniorRegisterPage,
GuideLinePage,
HelloCallApplyPage,
SinittoMainPage,
SinittoMyPage,
HelloCallListPage,
HelloCallServicePage,
HelloCallReportPage,
CallBackListPage,
CallBackDetailPage,
SinittoGuideLinePage,
SinittoServiceHistoryPage,
HelloCallDetailPage,
} from './components';
import { ProtectedRoute } from './components';
import { RouterPath } from './path';
import { OnboardPage, RedirectPage, DummyRedirectPage } from '@/pages';
import { Layout, LoadingView } from '@/shared/components';

export const RegisterPage = lazy(
() => import('@/pages/common/register/ui/RegisterPage')
);
export const GuardMainPage = lazy(() =>
import('@/pages/guard/guard-main/ui/GuardMainPage').then((module) => ({
default: module.GuardMainPage,
}))
);

export const ServiceHistoryPage = lazy(() =>
import('@/pages/guard/service-history/ui/ServiceHistoryPage').then(
(module) => ({
default: module.ServiceHistoryPage,
})
)
);

export const GuardMyPage = lazy(() =>
import('@/pages/guard/mypage/ui/GuardMyPage').then((module) => ({
default: module.GuardMyPage,
}))
);

export const GuardReportPage = lazy(
() => import('@/pages/guard/hello-call-report/ui/GuardReportPage')
);

export const SinittoReviewPage = lazy(() =>
import('@/pages/guard/review/ui/SinittoReviewPage').then((module) => ({
default: module.SinittoReviewPage,
}))
);

export const ServiceManualPage = lazy(
() => import('@/pages/common/service-manual/ui/ServiceManualPage')
);

export const SeniorRegisterPage = lazy(
() => import('@/pages/guard/register/ui/SeniorRegisterPage')
);

export const GuideLinePage = lazy(() =>
import('@/pages/guard/guide-line/ui/GuideLinePage').then((module) => ({
default: module.GuideLinePage,
}))
);

export const HelloCallApplyPage = lazy(() =>
import('@/pages/guard/hello-call-apply/ui/HelloCallApplyPage').then(
(module) => ({
default: module.HelloCallApplyPage,
})
)
);

export const SinittoMainPage = lazy(() =>
import('@/pages/sinitto/sinitto-main/ui/SinittoMainPage').then((module) => ({
default: module.SinittoMainPage,
}))
);

export const SinittoMyPage = lazy(() =>
import('@/pages/sinitto/mypage/ui/SinittoMyPage').then((module) => ({
default: module.SinittoMyPage,
}))
);

export const HelloCallListPage = lazy(
() => import('@/pages/sinitto/hello-call-list/ui/HelloCallListPage')
);

export const HelloCallServicePage = lazy(
() => import('@/pages/sinitto/hello-call-service/ui/HelloCallServicePage')
);

export const HelloCallReportPage = lazy(
() => import('@/pages/sinitto/hello-call-report/ui/HelloCallReportPage')
);

export const CallBackListPage = lazy(
() => import('@/pages/sinitto/call-back/list/ui/CallBackListPage')
);

export const CallBackDetailPage = lazy(() =>
import('@/pages/sinitto/call-back/detail/ui/CallBackDetailPage').then(
(module) => ({
default: module.CallBackDetailPage,
})
)
);

export const SinittoGuideLinePage = lazy(() =>
import('@/pages/sinitto/guide-line/ui/SinittoGuideLinePage').then(
(module) => ({
default: module.SinittoGuideLinePage,
})
)
);

export const SinittoServiceHistoryPage = lazy(() =>
import('@/pages/sinitto/service-history/ui/SinittoServiceHistoryPage').then(
(module) => ({
default: module.SinittoServiceHistoryPage,
})
)
);

export const HelloCallDetailPage = lazy(() =>
import('@/pages/sinitto/hello-call-detail/ui/HelloCallDetailPage').then(
(module) => ({
default: module.HelloCallDetailPage,
})
)
);

export const router = createBrowserRouter([
{
path: RouterPath.ROOT,
Expand Down
7 changes: 7 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from 'react';

declare namespace React {
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
fetchPriority?: 'high' | 'low' | 'auto';
}
}
Binary file removed src/pages/assets/shared/hello-call.png
Binary file not shown.
Binary file added src/pages/assets/shared/hello-call.webp
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link } from 'react-router-dom';

import { RouterPath } from '@/app/routes';
import { IconArrow } from '@/pages/assets';
import HelloCallImg from '@/pages/assets/shared/hello-call.png';
import HelloCallImg from '@/pages/assets/shared/hello-call.webp';
import { Button, Flex, Image, Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const ServiceTotal = ({
<ContentsBox>
<TitleText>서비스 총 이용 횟수</TitleText>
<Flex alignItems='center' justifyContent='center' gap={2} mb={3}>
<Text as='b'>매주</Text>
<Text as='b'>매 회차</Text>
<HighlightText>{serviceTime}분</HighlightText>
<Text as='b' mx='0.5'>
Expand Down
12 changes: 7 additions & 5 deletions src/pages/sinitto/hello-call-list/ui/HelloCallListPage.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { CallRequest } from '../components';
import { lazy } from 'react';

import {
useInfiniteScroll,
useErrorHandling,
useNavigateToDetail,
useGetServiceList,
} from '../hooks';
import { LoadingView } from '@/shared/components';
import { Flex, Text } from '@chakra-ui/react';
import { Text } from '@chakra-ui/react';
import styled from '@emotion/styled';

const CallRequest = lazy(
() => import('../components/call-request/CallRequest')
);

const HelloCallListPage = () => {
const { data, isError, isLoading, hasNextPage, fetchNextPage, error } =
useGetServiceList(10);
Expand All @@ -29,9 +34,6 @@ const HelloCallListPage = () => {

return (
<HelloCallListLayout>
<Flex w='100%' justifyContent='end'>
<Text>새로고침</Text>
</Flex>
{allContent.map((item, index) => {
const isLastElement = index === allContent.length - 1;
return (
Expand Down
Loading