Skip to content

Commit b3286b5

Browse files
author
521xueweihan
committed
fix: github action
1 parent 9787993 commit b3286b5

File tree

7 files changed

+125
-52
lines changed

7 files changed

+125
-52
lines changed

.github/workflows/lint.yml

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,31 @@
11
name: PR Source Code Check
22

33
on:
4-
- push
4+
push:
5+
pull_request:
56

67
jobs:
7-
lint:
8-
name: Run ESLint
8+
quality:
9+
name: Code Quality
910
runs-on: ubuntu-latest
1011
steps:
11-
- uses: actions/checkout@v2
12-
- uses: actions/setup-node@v2
12+
- name: Checkout code
13+
uses: actions/checkout@v4
14+
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
1317
with:
14-
node-version: '14'
18+
node-version: '18'
1519
cache: 'yarn'
16-
- run: yarn
17-
- run: yarn lint:strict
18-
19-
tsc:
20-
name: Run Type Check
21-
runs-on: ubuntu-latest
22-
steps:
23-
- uses: actions/checkout@v2
24-
- uses: actions/setup-node@v2
25-
with:
26-
node-version: '14'
27-
cache: 'yarn'
28-
- run: yarn
29-
- run: yarn typecheck
30-
31-
prettier:
32-
name: Run Prettier Check
33-
runs-on: ubuntu-latest
34-
steps:
35-
- uses: actions/checkout@v2
36-
- uses: actions/setup-node@v2
37-
with:
38-
node-version: '14'
39-
cache: 'yarn'
40-
- run: yarn
41-
- run: yarn format:check
42-
# test:
43-
# name: Run Test
44-
# runs-on: ubuntu-latest
45-
# steps:
46-
# - uses: actions/checkout@v2
47-
# - uses: actions/setup-node@v2
48-
# with:
49-
# node-version: '14'
50-
# cache: 'yarn'
51-
# - run: yarn
52-
# - run: yarn test
20+
21+
- name: Install dependencies
22+
run: yarn install --frozen-lockfile
23+
24+
- name: Lint check
25+
run: yarn lint:strict
26+
27+
- name: Type check
28+
run: yarn typecheck
29+
30+
- name: Format check
31+
run: yarn format:check

public/locales/en/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
},
6161
"submit_repo": {
6262
"text": "Submit",
63+
"view_repo": "Progress",
6364
"title": "Recommend or Submit an Project",
6465
"description": "Only approved projects will be displayed on the homepage",
6566
"url_placeholder": "Project URL",

public/locales/zh/common.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
},
6161
"submit_repo": {
6262
"text": "提交",
63+
"view_repo": "审核进度",
6364
"title": "推荐或自荐开源项目",
6465
"description": "通过审核的开源项目,才会在首页展示",
6566
"url_placeholder": "项目地址",

src/components/dialog/RepoModal.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useLoginContext } from '@/hooks/useLoginContext';
66

77
import Button from '@/components/buttons/Button';
88
import BasicDialog from '@/components/dialog/BasicDialog';
9+
import { CustomLink } from '@/components/links/CustomLink';
910
import Message from '@/components/message';
1011

1112
import { checkRepo, createRepo } from '@/services/repository';
@@ -18,6 +19,7 @@ interface CreateRepoProps {
1819
}
1920

2021
export function CreateRepo({ response, t }: CreateRepoProps) {
22+
const { userInfo } = useLoginContext();
2123
const [loading, setLoading] = useState<boolean>(false);
2224
const [paramReady, setParamReady] = useState<boolean>(true);
2325

@@ -189,12 +191,19 @@ export function CreateRepo({ response, t }: CreateRepoProps) {
189191
onChange={onSummaryChange}
190192
onBlur={onSummaryBlur}
191193
></textarea>
192-
<div className='mt-2 text-left text-xs text-gray-400'>
193-
{summaryMessage ? (
194-
<span className='text-red-600'>{summaryMessage}</span>
195-
) : (
196-
t('submit_repo.summary_tip')
197-
)}
194+
<div className='mt-2 flex items-center justify-between text-left text-xs text-gray-400'>
195+
<div>
196+
{summaryMessage ? (
197+
<span className='text-red-600'>{summaryMessage}</span>
198+
) : (
199+
t('submit_repo.summary_tip')
200+
)}
201+
</div>
202+
<CustomLink className='inline' href={`/user/${userInfo?.uid}/repo`}>
203+
<span className='cursor-pointer text-blue-500 hover:text-blue-600'>
204+
{t('submit_repo.view_repo')}
205+
</span>
206+
</CustomLink>
198207
</div>
199208
</div>
200209

src/components/user/RepoRecord.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ const RepoData = ({ data, setPage, showStatus }: RepoDataProps) => {
191191

192192
return (
193193
<>
194-
<div className='space-y-2'>
194+
<div className='space-y-1'>
195195
{data.data.map((item, index) => (
196196
<RepoListItem
197197
key={item.repo.rid}

src/pages/repository/[rid]/index.tsx

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import { GetServerSideProps, NextPage } from 'next';
2+
import { useTranslation } from 'next-i18next';
3+
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
4+
5+
import RepoDetailNavbar from '@/components/navbar/RepoNavbar';
6+
import CommentContainer from '@/components/respository/CommentContainer';
7+
import Info from '@/components/respository/Info';
8+
import Tabs from '@/components/respository/Tabs';
9+
import Seo from '@/components/Seo';
10+
11+
import { getDetail } from '@/services/repository';
12+
import { getClientIP } from '@/utils/util';
13+
14+
import { Repository } from '@/types/repository';
15+
16+
interface Props {
17+
repo: Repository;
18+
}
19+
20+
const RepositoryPage: NextPage<Props> = ({ repo }) => {
21+
const { t, i18n } = useTranslation('repository');
22+
23+
const getLocalizedField = (field: any, fallback: any) =>
24+
i18n.language === 'en' ? field ?? fallback : fallback;
25+
26+
return (
27+
<>
28+
<Seo
29+
title={`${repo.full_name}: ${getLocalizedField(
30+
repo.title_en,
31+
repo.title
32+
)}`}
33+
description={getLocalizedField(repo.summary_en, repo.summary)}
34+
image={repo.image_url ? repo.image_url : repo.author_avatar}
35+
/>
36+
<RepoDetailNavbar
37+
avatar={repo.share_user.avatar}
38+
uid={repo.share_user.uid}
39+
t={t}
40+
/>
41+
<div className='mt-2 bg-white px-2 pb-3 pt-2 dark:bg-gray-800 md:rounded-lg'>
42+
<Info repo={repo} t={t} i18n_lang={i18n.language} />
43+
<Tabs repo={repo} t={t} i18n_lang={i18n.language} />
44+
</div>
45+
<CommentContainer
46+
className='mt-2 bg-white dark:bg-gray-800 md:rounded-lg'
47+
belong='repository'
48+
belongId={repo.rid}
49+
t={t}
50+
i18n_lang={i18n.language}
51+
/>
52+
<div className='h-8 lg:h-36' />
53+
</>
54+
);
55+
};
56+
57+
export const getServerSideProps: GetServerSideProps = async ({
58+
req,
59+
query,
60+
locale,
61+
}) => {
62+
const ip = getClientIP(req);
63+
console.log(query);
64+
const rid = query?.rid as string;
65+
const data = await getDetail(ip, rid);
66+
if (data.success) {
67+
return {
68+
props: {
69+
...(await serverSideTranslations(locale as string, [
70+
'common',
71+
'repository',
72+
])),
73+
repo: data.data,
74+
},
75+
};
76+
} else {
77+
return {
78+
notFound: true,
79+
};
80+
}
81+
};
82+
83+
export default RepositoryPage;

src/services/repository.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ import {
1919

2020
export const getDetail = async (
2121
ip: string,
22-
identifier: string
22+
rid: string
2323
): Promise<RepositorySuccessData> => {
2424
const req: RequestInit = {};
2525
req.headers = { 'x-real-ip': ip, 'x-forwarded-for': ip };
2626
const result = await fetcher<RepositorySuccessData>(
27-
makeUrl(`/repository/detail/${identifier}`),
27+
makeUrl(`/repository/detail/${rid}`),
2828
req
2929
);
3030
return result;

0 commit comments

Comments
 (0)