Skip to content

Commit e61e39c

Browse files
committed
feat(i18n): 优化i18n实现逻辑,调整index.ts及首页相关样式和逻辑
1 parent fd705ef commit e61e39c

File tree

3 files changed

+89
-18
lines changed

3 files changed

+89
-18
lines changed

office-website/src/i18n/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ const zhTranslation = {
9494
description: "完全开源,社区驱动,持续改进"
9595
}
9696
},
97+
contributors: {
98+
title: "贡献者与感谢",
99+
description: "感谢以下用户帮助我们不断完善产品:",
100+
list: [
101+
{
102+
name: "mazp99",
103+
profile: "https://github.com/mazp99"
104+
}
105+
]
106+
},
97107
install: {
98108
title: "安装指南",
99109
step1: {
@@ -250,6 +260,16 @@ const enTranslation = {
250260
description: "Support quick copying of node content with right-click menu while preserving original formatting"
251261
}
252262
},
263+
contributors: {
264+
title: "Contributors & Thanks",
265+
description: "Thanks to the following users for reporting issues and suggesting improvements, helping us to continuously enhance our product:",
266+
list: [
267+
{
268+
name: "mazp99",
269+
profile: "https://github.com/mazp99"
270+
}
271+
]
272+
},
253273
whyUse: {
254274
title: "Why Use AST Explorer Helper?",
255275
efficiency: {

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -752,31 +752,52 @@
752752
text-align: center;
753753
border: 1px solid var(--border-color);
754754
transition: all 0.3s ease;
755-
width: 280px;
755+
width: 180px;
756+
display: flex;
757+
flex-direction: column;
758+
align-items: center;
759+
text-decoration: none;
760+
color: inherit;
756761
}
757762

758763
.contributorItem:hover {
759764
transform: translateY(-4px);
760765
box-shadow: var(--shadow-hover);
761766
border-color: var(--primary);
767+
background-color: var(--bg-lighter);
762768
}
763769

764-
.contributorItem h3 {
765-
color: var(--text-primary);
766-
font-size: 1.4rem;
767-
font-weight: 600;
770+
.contributorAvatar {
771+
width: 100px;
772+
height: 100px;
773+
border-radius: 50%;
774+
overflow: hidden;
768775
margin-bottom: var(--space-3);
776+
border: 2px solid var(--border-color);
777+
transition: all 0.3s ease;
769778
}
770779

771-
.contributorItem h3 a {
780+
.contributorAvatar img {
781+
width: 100%;
782+
height: 100%;
783+
object-fit: cover;
784+
}
785+
786+
.contributorItem:hover .contributorAvatar {
787+
border-color: var(--primary);
788+
transform: scale(1.05);
789+
}
790+
791+
.contributorItem h3 {
772792
color: var(--primary);
773-
text-decoration: none;
793+
font-size: 1.2rem;
794+
font-weight: 600;
795+
margin: 0;
774796
transition: color 0.2s ease;
775797
}
776798

777-
.contributorItem h3 a:hover {
799+
.contributorItem:hover h3 {
778800
color: var(--primary-dark);
779-
text-decoration: underline;
780801
}
781802

782803
.contributorItem p {

office-website/src/pages/Home/index.tsx

Lines changed: 39 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -195,16 +195,46 @@ const Home: React.FC = () => {
195195
<h2 className="text-center">{t('contributors.title')}</h2>
196196
<p className="text-center">{t('contributors.description')}</p>
197197
<div className={styles.contributorsGrid}>
198-
{(t('contributors.list', { returnObjects: true }) as Array<{name: string; profile: string; contribution: string}>).map((contributor, index) => (
199-
<div className={styles.contributorItem} key={index}>
200-
<h3>
201-
<a href={contributor.profile} target="_blank" rel="noopener noreferrer">
202-
{contributor.name}
198+
{(() => {
199+
const contributorsList = t('contributors.list', { returnObjects: true });
200+
// 检查是否为数组且至少有一个元素
201+
if (Array.isArray(contributorsList) && contributorsList.length > 0) {
202+
return contributorsList.map((contributor, index) => (
203+
<a
204+
href={contributor.profile}
205+
target="_blank"
206+
rel="noopener noreferrer"
207+
className={styles.contributorItem}
208+
key={index}
209+
>
210+
<div className={styles.contributorAvatar}>
211+
<img
212+
src={`https://github.com/${contributor.name}.png`}
213+
alt={`${contributor.name}'s avatar`}
214+
/>
215+
</div>
216+
<h3>{contributor.name}</h3>
203217
</a>
204-
</h3>
205-
<p>{contributor.contribution}</p>
206-
</div>
207-
))}
218+
));
219+
}
220+
// 默认显示一个固定的贡献者项(备用方案)
221+
return (
222+
<a
223+
href="https://github.com/mazp99"
224+
target="_blank"
225+
rel="noopener noreferrer"
226+
className={styles.contributorItem}
227+
>
228+
<div className={styles.contributorAvatar}>
229+
<img
230+
src="https://github.com/mazp99.png"
231+
alt="mazp99's avatar"
232+
/>
233+
</div>
234+
<h3>mazp99</h3>
235+
</a>
236+
);
237+
})()}
208238
</div>
209239
</div>
210240
</section>

0 commit comments

Comments
 (0)