Skip to content

Commit 325c9b4

Browse files
committed
feat: add videos
1 parent 023f479 commit 325c9b4

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

public/locales/en/repository.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"content": {
6060
"desc_tab": "Description",
6161
"code_tab": "Code",
62+
"video_tab": "Video",
6263
"volume_label": "Included in:",
6364
"volume": "Vol.{{volume}}",
6465
"tag_label": "Tags:"

public/locales/zh/repository.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"content": {
6060
"desc_tab": "介绍",
6161
"code_tab": "代码",
62+
"video_tab": "视频",
6263
"volume_label": "收录于:",
6364
"volume": "第 {{volume}} 期",
6465
"tag_label": "标签:"

src/components/respository/Tabs.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,23 @@ const Tabs = ({ repo, t, i18n_lang }: RepositoryProps) => {
8383
<MDRender>{repo.code}</MDRender>
8484
</div>
8585
);
86+
} else if (selectTab === 'video') {
87+
return (
88+
<div className='w-full p-2'>
89+
{repo.video_url && (
90+
<div className='aspect-video w-full overflow-hidden rounded-lg border border-gray-200 dark:border-gray-700'>
91+
<iframe
92+
src={`${repo.video_url}${
93+
repo.video_url.includes('?') ? '&' : '?'
94+
}autoplay=0`}
95+
className='h-full w-full'
96+
allowFullScreen
97+
title={`${repo.name} video player`}
98+
/>
99+
</div>
100+
)}
101+
</div>
102+
);
86103
}
87104
};
88105

@@ -103,6 +120,14 @@ const Tabs = ({ repo, t, i18n_lang }: RepositoryProps) => {
103120
{t('content.code_tab')}
104121
</span>
105122
)}
123+
{repo.video_url && (
124+
<span
125+
className={tabClassName('video')}
126+
onClick={() => setSelectTab('video')}
127+
>
128+
{t('content.video_tab')}
129+
</span>
130+
)}
106131
</nav>
107132
{tabContent()}
108133
</>

src/types/repository.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ export interface Repository extends RepoType {
3737
license_lid: string;
3838
license_spdx_id: string;
3939

40+
// 新增视频URL字段
41+
video_url: string | null;
42+
4043
star_history: StarHistory;
4144

4245
release_tag: string | null;

0 commit comments

Comments
 (0)