Skip to content

Commit 3916efd

Browse files
committed
隐藏外部链接显示,仅在点击【去试试】按钮时跳转
1 parent 06ae5ae commit 3916efd

File tree

2 files changed

+21
-39
lines changed

2 files changed

+21
-39
lines changed

src/components/ChallengeDetailPage/ChallengeActions.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,34 @@ const ChallengeActions: React.FC<ChallengeActionsProps> = ({ challenge, isMobile
2626
display: 'flex',
2727
justifyContent: 'center',
2828
width: '100%',
29-
marginTop: '8px'
29+
marginTop: '8px',
30+
flexDirection: 'column',
31+
gap: '12px'
3032
}}>
33+
{challenge.externalLink && (
34+
<Button
35+
type="primary"
36+
onClick={() => window.open(challenge.externalLink, '_blank')}
37+
size="middle"
38+
style={{
39+
width: '100%',
40+
maxWidth: '400px',
41+
alignSelf: 'center'
42+
}}
43+
>
44+
{t('challenge.detail.startChallenge')}
45+
</Button>
46+
)}
47+
3148
<Button
32-
type="primary"
49+
type="default"
3350
icon={<HomeOutlined />}
3451
onClick={() => navigate('/challenges')}
3552
size="middle"
3653
style={{
3754
width: '100%',
38-
maxWidth: '400px'
55+
maxWidth: '400px',
56+
alignSelf: 'center'
3957
}}
4058
>
4159
{t('challenge.actions.backToList')}

src/components/ChallengeDetailPage/ChallengeMetadata.tsx

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -72,25 +72,6 @@ const ChallengeMetadata: React.FC<ChallengeMetadataProps> = ({ challenge, isMobi
7272
{formatDateTime(challenge.updateTime)}
7373
</Text>
7474
</Descriptions.Item>
75-
76-
{challenge.externalLink && (
77-
<Descriptions.Item
78-
label={t('challenge.detail.originalLink')}
79-
span={1}
80-
>
81-
<a
82-
href={challenge.externalLink}
83-
target="_blank"
84-
rel="noopener noreferrer"
85-
style={{
86-
wordBreak: 'break-all',
87-
fontSize: '12px'
88-
}}
89-
>
90-
{challenge.externalLink}
91-
</a>
92-
</Descriptions.Item>
93-
)}
9475
</Descriptions>
9576
);
9677
}
@@ -128,23 +109,6 @@ const ChallengeMetadata: React.FC<ChallengeMetadataProps> = ({ challenge, isMobi
128109
<Text type="secondary">{t('challenge.detail.updated')}:</Text>
129110
<Text style={{ marginLeft: '8px' }}>{formatDateTime(challenge.updateTime)}</Text>
130111
</div>
131-
132-
{challenge.externalLink && (
133-
<div style={{ width: '100%' }}>
134-
<Text type="secondary">{t('challenge.detail.originalLink')}:</Text>
135-
<a
136-
href={challenge.externalLink}
137-
target="_blank"
138-
rel="noopener noreferrer"
139-
style={{
140-
marginLeft: '8px',
141-
wordBreak: 'break-all'
142-
}}
143-
>
144-
{challenge.externalLink}
145-
</a>
146-
</div>
147-
)}
148112
</div>
149113
);
150114
};

0 commit comments

Comments
 (0)