Skip to content

Commit 7ea32e7

Browse files
committed
feat: 为主页部分实施延迟加载,并使用aria-labels增强按钮可访问性.
1 parent f622ae1 commit 7ea32e7

File tree

2 files changed

+35
-20
lines changed

2 files changed

+35
-20
lines changed

app/components/BlogArticles.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,14 @@ export function BlogArticles({ title = '我的文章', subtitle = '来自博客
166166
shape='circle'
167167
onClick={prevSlide}
168168
className='flex items-center justify-center border-indigo-300 text-indigo-600 hover:bg-indigo-50 hover:border-indigo-400 transition-colors'
169+
aria-label="Previous slide"
169170
/>
170171
<Button
171172
icon={<RightOutlined />}
172173
shape='circle'
173174
onClick={nextSlide}
174175
className='flex items-center justify-center border-indigo-300 text-indigo-600 hover:bg-indigo-50 hover:border-indigo-400 transition-colors'
176+
aria-label="Next slide"
175177
/>
176178
</div>
177179
</div>

app/components/PersonalHomepage.tsx

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
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";
33
import {
44
GithubOutlined,
55
MailOutlined,
66
MenuOutlined,
77
ReadOutlined,
88
CloseOutlined,
99
} 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 })));
1618
import type { Article } from "../types/article";
1719
import { config } from "../config";
1820

@@ -135,6 +137,7 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) {
135137
icon={<MenuOutlined />}
136138
onClick={() => setMobileMenuOpen(true)}
137139
className="flex items-center justify-center"
140+
aria-label="Open menu"
138141
/>
139142
</div>
140143

@@ -172,6 +175,7 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) {
172175
type="text"
173176
icon={<CloseOutlined />}
174177
onClick={() => setMobileMenuOpen(false)}
178+
aria-label="Close menu"
175179
/>
176180
</div>
177181

@@ -261,37 +265,46 @@ export function PersonalHomepage({ articles = [] }: PersonalHomepageProps) {
261265
shape="round"
262266
href={config.social.github}
263267
target="_blank"
268+
aria-label="GitHub"
264269
/>
265270
<Button
266271
size="large"
267272
icon={<MailOutlined />}
268273
className="border-gray-300 px-4 py-3 h-auto text-base rounded-full flex-1 sm:flex-none"
269274
shape="round"
270275
href={config.social.email}
276+
aria-label="Email"
271277
/>
272278
</div>
273279
</div>
274280
</div>
275281
</div>
276282
</section>
277283

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 />
280292

281-
{/* Project Showcase Section */}
282-
<ProjectShowcase />
293+
{/* Project Showcase Section */}
294+
<ProjectShowcase />
283295

284-
{/* Blog Articles Section */}
285-
<BlogArticles articles={articles} />
296+
{/* Blog Articles Section */}
297+
<BlogArticles articles={articles} />
286298

287-
{/* Note Showcase Section */}
288-
<NoteShowcase />
299+
{/* Note Showcase Section */}
300+
<NoteShowcase />
289301

290-
{/* About Section */}
291-
<About />
302+
{/* About Section */}
303+
<About />
292304

293-
{/* Footer */}
294-
<Footer />
305+
{/* Footer */}
306+
<Footer />
307+
</Suspense>
295308
</div>
296309
);
297310
}

0 commit comments

Comments
 (0)