Skip to content

Commit 7835cd2

Browse files
committed
fix: 修复若干bug并优化样式
1 parent 6cc44a6 commit 7835cd2

29 files changed

+331
-135
lines changed

.github/workflows/lint.yml

Lines changed: 20 additions & 41 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
13-
with:
14-
node-version: '14'
15-
cache: 'yarn'
16-
- run: yarn
17-
- run: yarn lint:strict
12+
- name: Checkout code
13+
uses: actions/checkout@v4
1814

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
15+
- name: Setup Node.js
16+
uses: actions/setup-node@v4
2517
with:
26-
node-version: '14'
18+
node-version: '18'
2719
cache: 'yarn'
28-
- run: yarn
29-
- run: yarn typecheck
3020

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
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: 3 additions & 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",
@@ -105,6 +106,8 @@
105106
"limit": "Word limit: 1-1000 characters",
106107
"contact_placeholder": "Contact information: WeChat/Phone number/Email",
107108
"submit": "Submit",
109+
"contact_info": "You can also contact me directly: ",
110+
"contact_info_desc": "[email protected]",
108111
"options": {
109112
"feedback": {
110113
"name": "Suggestions",

public/locales/en/periodical.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title": "HelloGitHub Monthly",
3-
"description": "Discover engaging and beginner-friendly open-source projects on GitHub, with the latest updates published on the 28th of each month. Spanning development tools, open-source books, tutorials, and enterprise-level projects, we aim to make you fall in love with open source.",
3+
"description": "Sharing interesting, beginner-friendly open-source projects from GitHub. Updated monthly on the 28th, covering developer tools, open-source books, tutorials, and enterprise-grade projects to help you fall in love with open source.",
44
"nav": "HelloGitHub Monthly",
5-
"p_text": "<strong>HelloGitHub Monthly</strong> shares interesting and beginner-friendly open source projects on GitHub. Published on the 28th of each month, it includes development tools, open source books, tutorials, and enterprise-level projects, helping you enjoying programming and fall in love with open source!",
5+
"p_text": "<strong>'HelloGitHub Monthly'</strong> has been carefully curating interesting, beginner-friendly open-source projects from GitHub every month since 2016, updated on the 28th. It covers developer tools, open-source books, tutorials, enterprise-grade projects, and more, enabling you to quickly discover the charm and spark your interest in open source.",
66
"read_button": "Read",
77
"submit_button": "Submit",
88
"detail_button": "Detail",
@@ -32,7 +32,7 @@
3232
"title": "HelloGitHub Monthly Vol.{{num}}",
3333
"nav": "Volume",
3434
"h2_text": "HelloGitHub Vol.{{num}}",
35-
"p_text": "<p>HelloGitHub shares interesting and beginner-friendly open source projects on GitHub, updated on the <strong>28th of each month</strong>. Here you will find fun and beginner-level open source projects, open source books, practical projects, and enterprise-level projects, allowing you to quickly appreciate the charm of open source and develop an interest in it.</p>",
35+
"p_text": "<p>HelloGitHub shares interesting, beginner-friendly open-source projects from GitHub, updated <strong>every month on the 28th</strong>. Discover fun beginner projects, open-source books, practical tutorials, and enterprise-grade projects, helping you quickly experience and become interested in the charm of open source.</p>",
3636
"catalog": "Catalog",
3737
"catalog2": "Catalog"
3838
}

public/locales/en/profile.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"featured": "Featured",
8989
"failed": "Failed",
9090
"review": "Under Review",
91-
"feedback": "Feedback"
91+
"feedback": "Feedback",
92+
"appeal": "Appeal"
9293
}
9394
}

public/locales/zh/common.json

Lines changed: 3 additions & 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": "项目地址",
@@ -105,6 +106,8 @@
105106
"limit": "字数限制 1-1000 字符",
106107
"contact_placeholder": "联系方式:微信/手机号/邮箱",
107108
"submit": "提交",
109+
"contact_info": "您也可以直接联系我:",
110+
"contact_info_desc": "xueweihan(微信)",
108111
"options": {
109112
"feedback": { "name": "建议", "title": "建议改善" },
110113
"bug": { "title": "问题反馈" },

public/locales/zh/periodical.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"title": "HelloGitHub 月刊",
3-
"description": "分享 GitHub 上有趣的入门级开源项目,每月 28 日发布最新内容涵盖开发工具、开源书籍、教程及企业级的开源项目,让你爱上开源。",
3+
"description": "分享 GitHub 上有趣的入门级开源项目,每月 28 日发布最新内容涵盖开发工具、开源书籍、教程及企业级的开源项目,让你爱上开源。",
44
"nav": "HelloGitHub 月刊",
5-
"p_text": "<strong>「HelloGitHub 月刊」</strong>分享 GitHub 上有趣、入门级的开源项目,每月 28 号发布最新一期。内容包括开发利器、开源书籍、教程、企业级项目等,让你发现编程的乐趣、爱上开源!",
5+
"p_text": "<strong>「HelloGitHub 月刊」</strong>自 2016 年起,每月 28 号精选发布 GitHub 上有趣、入门级的开源项目。内容包括开发利器、开源书籍、教程、企业级项目等,帮助你快速发现开源的魅力,对开源产生兴趣。",
66
"read_button": "查看",
77
"submit_button": "推荐",
88
"detail_button": "详情",
@@ -32,7 +32,7 @@
3232
"title": "《HelloGitHub 月刊》第 {{num}} 期",
3333
"nav": "期数",
3434
"h2_text": "《HelloGitHub》第 {{num}} 期",
35-
"p_text": "<p>HelloGitHub 分享 GitHub 上有趣、入门级的开源项目,<strong>每月 28 号</strong>更新一期。这里有好玩和入门级的开源项目、开源书籍、实战项目、企业级项目,让你用极短的时间感受到开源的魅力,对开源产生兴趣。</p>",
35+
"p_text": "<p>HelloGitHub 分享 GitHub 上有趣、入门级的开源项目,<strong>每月 28 号</strong>更新一期。这里有好玩和入门级的开源项目、开源书籍、实战项目、企业级项目,帮助你快速发现开源的魅力,对开源产生兴趣。</p>",
3636
"catalog": "本期目录",
3737
"catalog2": "目录"
3838
}

public/locales/zh/profile.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"featured": "已推荐",
8989
"failed": "未通过",
9090
"review": "审核中",
91-
"feedback": "反馈"
91+
"feedback": "反馈",
92+
"appeal": "申诉"
9293
}
9394
}

src/components/dialog/Feedback.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import { useTranslation } from 'next-i18next';
22
import { useCallback, useEffect, useState } from 'react';
3-
import { IoIosArrowRoundForward } from 'react-icons/io';
3+
import {
4+
IoIosArrowRoundForward,
5+
IoMdInformationCircleOutline,
6+
} from 'react-icons/io';
47

58
import { useLoginContext } from '@/hooks/useLoginContext';
69

@@ -129,6 +132,22 @@ export function CreateFeedback({
129132
))}
130133
</div>
131134

135+
<div className='rounded-md bg-blue-50 p-3 dark:bg-blue-900/30'>
136+
<div className='flex'>
137+
<div className='flex-shrink-0'>
138+
<IoMdInformationCircleOutline className='h-5 w-5 text-blue-400' />
139+
</div>
140+
<div className='ml-2 flex-1 text-sm'>
141+
<p className='text-blue-700 dark:text-blue-300'>
142+
{t('feedback.contact_info')}
143+
<span className='font-medium'>
144+
{t('feedback.contact_info_desc')}
145+
</span>
146+
</p>
147+
</div>
148+
</div>
149+
</div>
150+
132151
<div>
133152
<textarea
134153
className='focus:ring-shadow-1 w-full rounded border-gray-200 p-3 text-sm focus:border-blue-500 focus:outline-none dark:border-gray-600 dark:bg-gray-800 dark:placeholder:text-gray-400'

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/home/Item.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface ItemProps {
1010
item: {
1111
item_id?: string;
1212
rid?: string;
13+
1314
author_avatar: string;
1415
is_hot?: boolean;
1516
is_featured?: boolean;
@@ -27,6 +28,7 @@ interface ItemProps {
2728
updated_at?: string;
2829
clicks_total?: number;
2930
stars?: number;
31+
full_name?: string;
3032
};
3133
i18n_lang: string;
3234
index?: number;
@@ -65,7 +67,9 @@ const RepositoryItem = ({
6567
} = item;
6668

6769
const isDefaultType = itemType === 'default';
68-
const href = isDefaultType ? `/repository/${item_id}` : `/repository/${rid}`;
70+
const href = isDefaultType
71+
? `/repository/${item.full_name || item_id}`
72+
: `/repository/${item.full_name || rid}`;
6973

7074
// 动态绑定类名
7175
const hoverClassName = `transform shadow-lg transition-transform ${

src/components/layout/Header.tsx

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { useEffect, useState } from 'react';
55
import { AiOutlineGithub } from 'react-icons/ai';
66

77
import { useLoginContext } from '@/hooks/useLoginContext';
8+
import { useSponsor } from '@/hooks/useSponsor';
89

910
import HeaderBtn from '@/components/buttons/HeaderBtn';
1011
import LanguageSwitcher from '@/components/buttons/LanguageSwitcher';
@@ -13,14 +14,10 @@ import ThemeSwitcher from '@/components/buttons/ThemeSwitcher';
1314
import { RepoModal } from '@/components/dialog/RepoModal';
1415
import AvatarWithDropdown from '@/components/dropdown/AvatarWithDropdown';
1516

16-
import { getHeaderAd } from '@/services/home';
17-
1817
import TopBanner from './TopBanner';
1918
import { LoginButton } from '../buttons/LoginButton';
2019
import SearchInput from '../search/SearchInput';
2120

22-
import { AdvertItem } from '@/types/home';
23-
2421
interface Props {
2522
hiddenAd: () => void;
2623
showAd: () => void;
@@ -31,34 +28,26 @@ const Header = ({ hiddenAd, showAd }: Props) => {
3128
const { isLogin } = useLoginContext();
3229
const [curPath, setCurPath] = useState('');
3330
const { t, i18n } = useTranslation('common');
34-
const [adData, setAdData] = useState<AdvertItem | null>(null);
3531
const [_, setHasHeaderAd] = useState(false);
32+
const { topAd } = useSponsor();
3633

3734
const handleCloseAd = () => {
3835
hiddenAd();
3936
setHasHeaderAd(false);
4037
};
4138

42-
const initHeaderAd = async () => {
43-
const res = await getHeaderAd();
44-
if (res.success) {
45-
if (res.data.length > 0) {
46-
if (localStorage.adClosed === res.data[0].aid) {
47-
setHasHeaderAd(false);
48-
} else {
49-
showAd();
50-
setHasHeaderAd(true);
51-
setAdData(res.data[0]);
52-
}
53-
} else {
39+
useEffect(() => {
40+
if (topAd) {
41+
if (localStorage.adClosed === topAd.aid) {
5442
setHasHeaderAd(false);
43+
} else {
44+
showAd();
45+
setHasHeaderAd(true);
5546
}
47+
} else {
48+
setHasHeaderAd(false);
5649
}
57-
};
58-
59-
useEffect(() => {
60-
initHeaderAd();
61-
}, []);
50+
}, [topAd, showAd]);
6251

6352
useEffect(() => {
6453
setCurPath(router.pathname);
@@ -79,10 +68,10 @@ const Header = ({ hiddenAd, showAd }: Props) => {
7968

8069
return (
8170
<div className='fixed z-10 w-full bg-white shadow-sm backdrop-blur dark:border dark:border-gray-50/[0.06] dark:bg-transparent'>
82-
{adData && (
71+
{topAd && (
8372
<TopBanner
8473
i18n_lang={i18n.language}
85-
data={adData}
74+
data={topAd}
8675
onClose={handleCloseAd}
8776
/>
8877
)}

src/components/periodical/item.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const PeriodItem: NextPage<PeriodicalItemProps> = ({ item, index }) => {
9191
</div>
9292
</div>
9393
<div className='flex h-14 flex-1 flex-row items-center justify-end pr-1'>
94-
<NoPrefetchLink href={`/repository/${item.rid}`}>
94+
<NoPrefetchLink href={`/repository/${item.full_name}`}>
9595
<Button
9696
variant='white-outline'
9797
className='font-normal text-gray-700'

0 commit comments

Comments
 (0)