Skip to content

Commit 76d5cf3

Browse files
committed
perf: claim
1 parent ffb2b09 commit 76d5cf3

File tree

7 files changed

+87
-61
lines changed

7 files changed

+87
-61
lines changed

public/locales/en/profile.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@
8585
},
8686
"repo": {
8787
"empty": "No projects",
88-
"featured": "Featured",
89-
"failed": "Failed",
90-
"review": "Under Review",
9188
"feedback": "Feedback",
92-
"appeal": "Appeal"
89+
"appeal": "Appeal",
90+
"category_all": "All",
91+
"category_reject": "Rejected",
92+
"category_pending": "Pending",
93+
"category_pass": "Passed",
94+
"category_featured": "Featured",
95+
"category_claimed": "Claimed"
9396
}
9497
}

public/locales/zh/profile.json

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,13 @@
8585
},
8686
"repo": {
8787
"empty": "暂无项目",
88-
"featured": "已推荐",
89-
"failed": "未通过",
90-
"review": "审核中",
9188
"feedback": "反馈",
92-
"appeal": "申诉"
89+
"appeal": "申诉",
90+
"category_all": "全部",
91+
"category_reject": "未通过",
92+
"category_pending": "审核中",
93+
"category_pass": "已展示",
94+
"category_featured": "已推荐",
95+
"category_claimed": "已认领"
9396
}
9497
}

src/components/respository/Info.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
467467
<div className='flex-row items-center md:flex'>
468468
<span>{t('info.opensource')}</span>
469469
<span className='mx-0.5 md:mx-1.5'></span>
470-
<NoPrefetchLink href={`/license/${repo.license_lid}`}>
470+
<NoPrefetchLink href={`/license/${repo.license_spdx_id}`}>
471471
<span className='inline-flex max-w-[65px] cursor-pointer overflow-hidden text-ellipsis whitespace-nowrap text-blue-500 md:max-w-full'>
472472
{repo.license}
473473
</span>
@@ -478,7 +478,9 @@ const Info = ({ repo, t, i18n_lang }: RepositoryProps) => {
478478
</div>
479479
<div className='flex flex-row gap-x-1 text-sm md:gap-x-4'>
480480
{!repo.is_claimed && (
481-
<NoPrefetchLink href={`/badge?rid=${repo.rid}`}>
481+
<NoPrefetchLink
482+
href={`/badge?rid=${repo.rid}&full_name=${repo.full_name}`}
483+
>
482484
<div className='flex cursor-pointer items-center justify-center text-blue-500 hover:text-current active:text-gray-400 md:hover:text-blue-600'>
483485
<BsPersonCheck className='mr-1' size={16} />
484486
{t('info.claim')}

src/components/user/RepoList.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import Loading from '../loading/Loading';
88

99
import { UserTabProps } from '@/types/user';
1010

11-
const categoryItems = [
12-
{ name: '不限', value: 0 },
13-
{ name: '未通过', value: -1 },
14-
{ name: '待审核', value: 1 },
15-
{ name: '已通过', value: 2 },
16-
];
17-
1811
const RepoList = ({ uid, t }: UserTabProps) => {
1912
const [state, setState] = useState(0);
2013
const { data, setPage } = useRepoHistory(uid, state);
14+
const categoryItems = [
15+
{ name: t('repo.category_all'), value: 0 },
16+
{ name: t('repo.category_reject'), value: -1 },
17+
{ name: t('repo.category_pending'), value: 1 },
18+
{ name: t('repo.category_pass'), value: 2 },
19+
{ name: t('repo.category_claimed'), value: 3 },
20+
];
2121

2222
const selectState = (e: any) => {
2323
setState(e.target.value);

src/components/user/RepoRecord.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ const RepoStatus = ({ item, t, showStatus }: RepoStatusProps) => {
5151
)}
5252
>
5353
<span className='mr-1 h-1.5 w-1.5 rounded-full bg-red-500' />
54-
<span>{t('repo.failed')}</span>
54+
<span>{t('repo.category_reject')}</span>
5555
<span className='mx-1.5 text-gray-300 dark:text-gray-600'>|</span>
5656
<span className='opacity-85'>{t('repo.appeal')}</span>
5757
</div>
@@ -67,7 +67,7 @@ const RepoStatus = ({ item, t, showStatus }: RepoStatusProps) => {
6767
)}
6868
>
6969
<span className='mr-1 h-1.5 w-1.5 rounded-full bg-yellow-500' />
70-
<span>{t('repo.review')}</span>
70+
<span>{t('repo.category_pending')}</span>
7171
<span className='mx-1.5 text-gray-300 dark:text-gray-600'>|</span>
7272
<span className='opacity-85'>{t('repo.feedback')}</span>
7373
</div>
@@ -87,7 +87,9 @@ const RepoStatus = ({ item, t, showStatus }: RepoStatusProps) => {
8787
>
8888
<span className='mr-1 h-1.5 w-1.5 rounded-full bg-green-500' />
8989
<span>
90-
{item.is_featured ? t('repo.featured') : t('comment.show')}
90+
{item.is_featured
91+
? t('repo.category_featured')
92+
: t('repo.category_pass')}
9193
</span>
9294
</div>
9395
<Divider />

src/pages/badge/index.tsx

Lines changed: 56 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useRouter } from 'next/router';
55
import { Trans, useTranslation } from 'next-i18next';
66
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
77
import { useEffect, useState } from 'react';
8+
import { FaGithub } from 'react-icons/fa';
89

910
import { useLoginContext } from '@/hooks/useLoginContext';
1011

@@ -20,7 +21,7 @@ import { API_HOST, API_ROOT_PATH } from '@/utils/api';
2021

2122
const EmbedPage: NextPage = () => {
2223
const router = useRouter();
23-
const { rid } = router.query;
24+
const { rid, full_name } = router.query;
2425
const { t } = useTranslation('claim');
2526

2627
const [url, setUrl] = useState('');
@@ -31,6 +32,7 @@ const EmbedPage: NextPage = () => {
3132
const [isLoading, setIsLoading] = useState(false); // 状态:是否在提交中
3233
const [theme, setTheme] = useState<string>('neutral');
3334
const [svgFile, setSVGFile] = useState<string>('');
35+
const [fullName, setFullName] = useState('');
3436

3537
const generateBadge = () => {
3638
if (!repoID) return;
@@ -45,11 +47,12 @@ const EmbedPage: NextPage = () => {
4547

4648
useEffect(() => {
4749
if (rid) setRepoID(rid as string);
48-
}, [rid]);
50+
if (full_name) setFullName(full_name as string);
51+
}, [rid, full_name]);
4952

5053
useEffect(() => {
5154
if (repoID) generateBadge();
52-
}, [repoID, userInfo]);
55+
}, [userInfo, repoID]);
5356

5457
const themeClassName = (themeName: string) =>
5558
classNames('px-2 py-1 text-xs', {
@@ -76,6 +79,7 @@ const EmbedPage: NextPage = () => {
7679
return Message.error(t('submit.check_fail4'));
7780
case 3:
7881
setRepoID(info_res.data.rid);
82+
setFullName(info_res.data.full_name);
7983
break;
8084
case 4:
8185
return Message.error(t('submit.check_fail5'));
@@ -86,7 +90,7 @@ const EmbedPage: NextPage = () => {
8690

8791
const handleCopy = () => {
8892
if (!isLogin) return login();
89-
const pageURL = `https://hellogithub.com/repository/${repoID}`;
93+
const pageURL = `https://hellogithub.com/repository/${fullName}`;
9094
const text =
9195
theme === 'small'
9296
? `<a href="${pageURL}" target="_blank"><img src="${svgFile}" alt="Featured|HelloGitHub" /></a>`
@@ -174,49 +178,60 @@ const EmbedPage: NextPage = () => {
174178
{t('generate.title')}
175179
</h3>
176180
{repoID ? (
177-
<div className='flex flex-col rounded-lg bg-gray-100 dark:bg-gray-700'>
178-
<div className='flex rounded-t-lg bg-gray-200 dark:bg-slate-900'>
179-
<div className='p-2'>
180-
<div className='flex cursor-pointer rounded-full bg-gray-50 dark:bg-gray-600'>
181-
<div
182-
className={themeClassName('neutral')}
183-
onClick={() => handleTheme('neutral')}
184-
>
185-
{t('badge_theme_neutral')}
186-
</div>
187-
<div
188-
className={themeClassName('dark')}
189-
onClick={() => handleTheme('dark')}
190-
>
191-
{t('badge_theme_dark')}
181+
<>
182+
<div className='flex flex-col rounded-lg bg-gray-100 dark:bg-gray-700'>
183+
<div className='flex rounded-t-lg bg-gray-200 dark:bg-slate-900'>
184+
<div className='p-2'>
185+
<div className='flex cursor-pointer rounded-full bg-gray-50 dark:bg-gray-600'>
186+
<div
187+
className={themeClassName('neutral')}
188+
onClick={() => handleTheme('neutral')}
189+
>
190+
{t('badge_theme_neutral')}
191+
</div>
192+
<div
193+
className={themeClassName('dark')}
194+
onClick={() => handleTheme('dark')}
195+
>
196+
{t('badge_theme_dark')}
197+
</div>
198+
<div
199+
className={themeClassName('small')}
200+
onClick={() => handleTheme('small')}
201+
>
202+
{t('badge_theme_small')}
203+
</div>
192204
</div>
193-
<div
194-
className={themeClassName('small')}
195-
onClick={() => handleTheme('small')}
205+
</div>
206+
<div className='shrink grow' />
207+
<div className='p-1.5'>
208+
<Button
209+
onClick={handleCopy}
210+
className='cursor-pointer rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 dark:bg-gray-600'
196211
>
197-
{t('badge_theme_small')}
198-
</div>
212+
{t('copy.text')}
213+
</Button>
199214
</div>
200215
</div>
201-
<div className='shrink grow' />
202-
<div className='p-1.5'>
203-
<Button
204-
onClick={handleCopy}
205-
className='cursor-pointer rounded-md bg-gray-50 px-2 py-1 text-xs font-medium text-gray-600 dark:bg-gray-600'
206-
>
207-
{t('copy.text')}
208-
</Button>
209-
</div>
210-
</div>
211216

212-
<div className='my-8 flex justify-center'>
213-
{svgFile ? (
214-
<img className='w-max-full' src={svgFile} />
215-
) : (
216-
<Loading />
217-
)}
217+
<div className='my-8 flex justify-center'>
218+
{svgFile ? (
219+
<img className='w-max-full' src={svgFile} />
220+
) : (
221+
<Loading />
222+
)}
223+
</div>
218224
</div>
219-
</div>
225+
{fullName && (
226+
<div
227+
className='mx-auto mt-1 mb-4 flex max-w-full select-text items-center justify-center gap-1 overflow-hidden truncate whitespace-nowrap text-center text-xs font-normal not-italic leading-tight text-gray-400 dark:text-gray-500 md:max-w-xl md:text-sm'
228+
title={fullName}
229+
>
230+
<FaGithub className='inline-block text-base' />
231+
{fullName}
232+
</div>
233+
)}
234+
</>
220235
) : (
221236
<div className='flex items-center space-x-4 rounded-lg bg-gray-100 p-4 dark:bg-gray-700'>
222237
<input

src/types/repository.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface Repository extends RepoType {
3535
online: string | null;
3636
other_url: string | null;
3737
license_lid: string;
38+
license_spdx_id: string;
3839

3940
star_history: StarHistory;
4041

0 commit comments

Comments
 (0)