Skip to content

Commit 778075e

Browse files
committed
✨ feat: page top loading
1 parent 10efcb4 commit 778075e

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@
104104
"nanoid": "^5.0.7",
105105
"next": "^14.2.13",
106106
"next-pwa": "^5.6.0",
107+
"nextjs-toploader": "^3.6.15",
107108
"numeral": "^2.0.6",
108109
"openai": "^4.63.0",
109110
"pino": "^9.4.0",

src/app/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Analytics } from '@vercel/analytics/react';
22
import { PropsWithChildren } from 'react';
33

4+
import NProgress from '@/components/NProgress';
45
import Layout from '@/layout';
56

67
import StyleRegistry from './StyleRegistry';
@@ -12,7 +13,10 @@ const RootLayout = ({ children }: PropsWithChildren) => {
1213
<html lang="cn" suppressHydrationWarning>
1314
<body>
1415
<StyleRegistry>
15-
<Layout>{children}</Layout>
16+
<Layout>
17+
<NProgress />
18+
{children}
19+
</Layout>
1620
</StyleRegistry>
1721
<Analytics />
1822
</body>

src/components/NProgress/index.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use client';
2+
3+
import { useTheme } from 'antd-style';
4+
import NextTopLoader from 'nextjs-toploader';
5+
import { memo } from 'react';
6+
7+
const NProgress = memo(() => {
8+
const theme = useTheme();
9+
return <NextTopLoader color={theme.colorText} height={2} shadow={false} showSpinner={false} />;
10+
});
11+
12+
export default NProgress;

0 commit comments

Comments
 (0)