Skip to content

Commit 2c8efea

Browse files
committed
feat(website): 优化网站的移动端适配,提升手机浏览体验
1 parent f24bb7c commit 2c8efea

File tree

4 files changed

+222
-2
lines changed

4 files changed

+222
-2
lines changed

office-website/src/components/Header/Header.module.css

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,93 @@
133133
.starCount {
134134
font-weight: 500;
135135
color: #2563eb;
136+
}
137+
138+
/* 移动端导航按钮 */
139+
.mobileNavToggle {
140+
display: none;
141+
flex-direction: column;
142+
justify-content: space-between;
143+
width: 30px;
144+
height: 21px;
145+
cursor: pointer;
146+
z-index: 200;
147+
}
148+
149+
.mobileNavToggle span {
150+
display: block;
151+
height: 3px;
152+
width: 100%;
153+
background-color: #2563eb;
154+
border-radius: 3px;
155+
transition: all 0.3s ease;
156+
}
157+
158+
/* 移动端适配 */
159+
@media (max-width: 768px) {
160+
.container {
161+
padding: 0 1rem;
162+
}
163+
164+
.nav {
165+
justify-content: space-between;
166+
}
167+
168+
.navLinks {
169+
position: fixed;
170+
top: 0;
171+
right: -100%;
172+
height: 100vh;
173+
width: 250px;
174+
background-color: rgba(255, 255, 255, 0.98);
175+
backdrop-filter: blur(10px);
176+
flex-direction: column;
177+
justify-content: center;
178+
align-items: center;
179+
gap: 2rem;
180+
transition: all 0.3s ease;
181+
box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
182+
z-index: 150;
183+
padding: 5rem 2rem;
184+
}
185+
186+
.navLinks.open {
187+
right: 0;
188+
}
189+
190+
.mobileNavToggle {
191+
display: flex;
192+
}
193+
194+
.mobileNavToggle.open span:nth-child(1) {
195+
transform: translateY(9px) rotate(45deg);
196+
}
197+
198+
.mobileNavToggle.open span:nth-child(2) {
199+
opacity: 0;
200+
}
201+
202+
.mobileNavToggle.open span:nth-child(3) {
203+
transform: translateY(-9px) rotate(-45deg);
204+
}
205+
206+
.githubBadge {
207+
margin-left: auto;
208+
padding: 0.4rem 0.75rem;
209+
font-size: 0.75rem;
210+
}
211+
212+
.githubBadge span:nth-child(2) {
213+
display: none; /* 隐藏"GitHub"文字 */
214+
}
215+
216+
.logo {
217+
font-size: 1.1rem;
218+
margin-right: 0;
219+
}
220+
221+
.logo img {
222+
width: 28px;
223+
height: 28px;
224+
}
136225
}

office-website/src/components/Header/index.tsx

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,19 @@ interface HeaderProps {
1414
const Header: React.FC<HeaderProps> = ({ activeSection }): JSX.Element => {
1515
const { t } = useTranslation();
1616
const [star, setStar] = useState<number | null>(null);
17+
const [isMenuOpen, setIsMenuOpen] = useState(false);
18+
19+
// 当菜单打开时禁止页面滚动
20+
useEffect(() => {
21+
if (isMenuOpen) {
22+
document.body.style.overflow = 'hidden';
23+
} else {
24+
document.body.style.overflow = 'auto';
25+
}
26+
return () => {
27+
document.body.style.overflow = 'auto';
28+
};
29+
}, [isMenuOpen]);
1730

1831
useEffect(() => {
1932
const now = Date.now();
@@ -34,6 +47,11 @@ const Header: React.FC<HeaderProps> = ({ activeSection }): JSX.Element => {
3447
}
3548
}, []);
3649

50+
// 关闭菜单的处理函数
51+
const handleNavLinkClick = () => {
52+
setIsMenuOpen(false);
53+
};
54+
3755
return (
3856
<header className={`${styles.header} ${activeSection === 'scrolled' ? styles.scrolled : ''}`}>
3957
<div className={`container ${styles.container}`}>
@@ -42,28 +60,32 @@ const Header: React.FC<HeaderProps> = ({ activeSection }): JSX.Element => {
4260
<img src="logo.png" alt="AST Explorer Helper" />
4361
{t('title')}
4462
</a>
45-
<div className={styles.navLinks}>
63+
<div className={`${styles.navLinks} ${isMenuOpen ? styles.open : ''}`}>
4664
<a
4765
href="#home"
4866
className={`${styles.navLink} ${activeSection === 'home' ? styles.active : ''}`}
67+
onClick={handleNavLinkClick}
4968
>
5069
{t('nav.home')}
5170
</a>
5271
<a
5372
href="#features"
5473
className={`${styles.navLink} ${activeSection === 'features' ? styles.active : ''}`}
74+
onClick={handleNavLinkClick}
5575
>
5676
{t('nav.features')}
5777
</a>
5878
<a
5979
href="#install"
6080
className={`${styles.navLink} ${activeSection === 'install' ? styles.active : ''}`}
81+
onClick={handleNavLinkClick}
6182
>
6283
{t('nav.install')}
6384
</a>
6485
<a
6586
href="#community"
6687
className={`${styles.navLink} ${activeSection === 'community' ? styles.active : ''}`}
88+
onClick={handleNavLinkClick}
6789
>
6890
{t('nav.community')}
6991
</a>
@@ -96,6 +118,14 @@ const Header: React.FC<HeaderProps> = ({ activeSection }): JSX.Element => {
96118
<span>{star !== null ? star : '--'}</span>
97119
</a>
98120
<LanguageSwitcher />
121+
<div
122+
className={`${styles.mobileNavToggle} ${isMenuOpen ? styles.open : ''}`}
123+
onClick={() => setIsMenuOpen(!isMenuOpen)}
124+
>
125+
<span></span>
126+
<span></span>
127+
<span></span>
128+
</div>
99129
</nav>
100130
</div>
101131
</header>

office-website/src/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
66
<title>AST Explorer Helper - Make AST analysis simpler</title>
77
<meta name="description" content="AST Explorer Helper is a simple and practical browser plugin used to enhance the user experience of the AST Explorer website.">
88
<link rel="icon" href="/favicon.ico" />

office-website/src/pages/Home/Home.module.css

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,11 @@
487487
.ctaButtons {
488488
flex-direction: column;
489489
gap: var(--space-3);
490+
width: 100%;
491+
}
492+
493+
.ctaButtons a {
494+
width: 100%;
490495
}
491496

492497
.featureGrid {
@@ -496,6 +501,102 @@
496501
.step {
497502
padding: var(--space-4);
498503
}
504+
505+
:global(.btn) {
506+
width: 100%;
507+
padding: 0.75rem 1.5rem;
508+
}
509+
510+
.featureItem {
511+
padding: var(--space-4);
512+
}
513+
514+
.featureHeader {
515+
flex-direction: column;
516+
align-items: flex-start;
517+
text-align: left;
518+
}
519+
520+
.featureIcon {
521+
margin-bottom: var(--space-3);
522+
margin-right: 0;
523+
}
524+
525+
.reasons {
526+
grid-template-columns: 1fr;
527+
gap: var(--space-4);
528+
margin-top: var(--space-6);
529+
padding: 0 var(--space-3);
530+
}
531+
532+
.reason {
533+
padding: var(--space-4);
534+
}
535+
536+
.communityGrid {
537+
grid-template-columns: 1fr;
538+
gap: var(--space-4);
539+
padding: 0 var(--space-3);
540+
}
541+
542+
.communityItem {
543+
padding: var(--space-4);
544+
}
545+
546+
.qrcode {
547+
width: 180px;
548+
height: 180px;
549+
}
550+
551+
.hero {
552+
min-height: auto;
553+
padding-top: calc(var(--header-height) + var(--space-6));
554+
padding-bottom: var(--space-6);
555+
}
556+
557+
.heroContent {
558+
padding: 0 var(--space-3);
559+
}
560+
561+
.title {
562+
font-size: clamp(2rem, 8vw, 3rem);
563+
}
564+
565+
.subtitle {
566+
font-size: clamp(1rem, 4vw, 1.25rem);
567+
}
568+
}
569+
570+
@media (max-width: 480px) {
571+
.featureDemoWrapper {
572+
margin-top: 10px;
573+
}
574+
575+
.step p, .step ol, .step ul, .browserOptions, .installMethods {
576+
margin-left: 0;
577+
}
578+
579+
.stepTitle {
580+
flex-direction: column;
581+
align-items: flex-start;
582+
}
583+
584+
.stepNumber {
585+
margin-bottom: var(--space-2);
586+
}
587+
588+
.installSteps::before {
589+
display: none;
590+
}
591+
592+
.contributorItem {
593+
padding: var(--space-3);
594+
}
595+
596+
.contributorAvatar {
597+
width: 80px;
598+
height: 80px;
599+
}
499600
}
500601

501602
/* 为什么使用部分 */

0 commit comments

Comments
 (0)