|
1 | | -import { useState, useRef, useEffect } from "react"; |
2 | | -import { Avatar, Button, Drawer } from "antd"; |
| 1 | +import { useState, useRef, useEffect, Suspense, lazy } from "react"; |
| 2 | +import { Avatar, Button, Drawer, Spin } from "antd"; |
3 | 3 | import { |
4 | 4 | GithubOutlined, |
5 | 5 | MailOutlined, |
6 | 6 | MenuOutlined, |
7 | 7 | ReadOutlined, |
8 | 8 | CloseOutlined, |
9 | 9 | } from "@ant-design/icons"; |
10 | | -import { Recommended } from "./Recommended"; |
11 | | -import { BlogArticles } from "./BlogArticles"; |
12 | | -import { NoteShowcase } from "./NoteShowcase"; |
13 | | -import { About } from "./About"; |
14 | | -import { ProjectShowcase } from "./ProjectShowcase"; |
15 | | -import { Footer } from "./Footer"; |
| 10 | + |
| 11 | +// Lazy load components |
| 12 | +const Recommended = lazy(() => import("./Recommended").then(module => ({ default: module.Recommended }))); |
| 13 | +const BlogArticles = lazy(() => import("./BlogArticles").then(module => ({ default: module.BlogArticles }))); |
| 14 | +const NoteShowcase = lazy(() => import("./NoteShowcase").then(module => ({ default: module.NoteShowcase }))); |
| 15 | +const About = lazy(() => import("./About").then(module => ({ default: module.About }))); |
| 16 | +const ProjectShowcase = lazy(() => import("./ProjectShowcase").then(module => ({ default: module.ProjectShowcase }))); |
| 17 | +const Footer = lazy(() => import("./Footer").then(module => ({ default: module.Footer }))); |
16 | 18 | import type { Article } from "../types/article"; |
17 | 19 | import { config } from "../config"; |
18 | 20 |
|
@@ -135,6 +137,7 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) { |
135 | 137 | icon={<MenuOutlined />} |
136 | 138 | onClick={() => setMobileMenuOpen(true)} |
137 | 139 | className="flex items-center justify-center" |
| 140 | + aria-label="Open menu" |
138 | 141 | /> |
139 | 142 | </div> |
140 | 143 |
|
@@ -172,6 +175,7 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) { |
172 | 175 | type="text" |
173 | 176 | icon={<CloseOutlined />} |
174 | 177 | onClick={() => setMobileMenuOpen(false)} |
| 178 | + aria-label="Close menu" |
175 | 179 | /> |
176 | 180 | </div> |
177 | 181 |
|
@@ -261,37 +265,46 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) { |
261 | 265 | shape="round" |
262 | 266 | href={config.social.github} |
263 | 267 | target="_blank" |
| 268 | + aria-label="GitHub" |
264 | 269 | /> |
265 | 270 | <Button |
266 | 271 | size="large" |
267 | 272 | icon={<MailOutlined />} |
268 | 273 | className="border-gray-300 px-4 py-3 h-auto text-base rounded-full flex-1 sm:flex-none" |
269 | 274 | shape="round" |
270 | 275 | href={config.social.email} |
| 276 | + aria-label="Email" |
271 | 277 | /> |
272 | 278 | </div> |
273 | 279 | </div> |
274 | 280 | </div> |
275 | 281 | </div> |
276 | 282 | </section> |
277 | 283 |
|
278 | | - {/* Recommended Products Section */} |
279 | | - <Recommended /> |
| 284 | + {/* Lazy Loaded Sections */} |
| 285 | + <Suspense fallback={ |
| 286 | + <div className="flex justify-center items-center py-20"> |
| 287 | + <Spin size="large" /> |
| 288 | + </div> |
| 289 | + }> |
| 290 | + {/* Recommended Products Section */} |
| 291 | + <Recommended /> |
280 | 292 |
|
281 | | - {/* Project Showcase Section */} |
282 | | - <ProjectShowcase /> |
| 293 | + {/* Project Showcase Section */} |
| 294 | + <ProjectShowcase /> |
283 | 295 |
|
284 | | - {/* Blog Articles Section */} |
285 | | - <BlogArticles articles={articles} /> |
| 296 | + {/* Blog Articles Section */} |
| 297 | + <BlogArticles articles={articles} /> |
286 | 298 |
|
287 | | - {/* Note Showcase Section */} |
288 | | - <NoteShowcase /> |
| 299 | + {/* Note Showcase Section */} |
| 300 | + <NoteShowcase /> |
289 | 301 |
|
290 | | - {/* About Section */} |
291 | | - <About /> |
| 302 | + {/* About Section */} |
| 303 | + <About /> |
292 | 304 |
|
293 | | - {/* Footer */} |
294 | | - <Footer /> |
| 305 | + {/* Footer */} |
| 306 | + <Footer /> |
| 307 | + </Suspense> |
295 | 308 | </div> |
296 | 309 | ); |
297 | 310 | } |
0 commit comments