Skip to content

Commit

Permalink
[fix] data & style of Open Source page
Browse files Browse the repository at this point in the history
  • Loading branch information
TechQuery committed Sep 1, 2024
1 parent cce1386 commit 14636ab
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 44 deletions.
11 changes: 6 additions & 5 deletions models/Base/File.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ export class AzureFileModel extends FileModel {

const { status, title, detail } = data as unknown as ErrorBaseData;

throw new HTTPError(
detail || title,
{ method, path: fullPath, headers, body },
{ status, statusText: title, headers: header, body: data },
);
throw new HTTPError(detail || title, {
status,
statusText: title,
headers: header,
body: data,
});
}

@toggle('uploading')
Expand Down
10 changes: 7 additions & 3 deletions models/Git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,13 @@ export class SourceRepositoryModel extends RepositoryModel {
.uniqueBy()
.slice((page - 1) * per_page, page * per_page);

const pageData = await Promise.all(
list.map(full_name => this.getOne(full_name, relation)),
);
const pageData: Awaited<ReturnType<RepositoryModel['getOne']>>[] = [];

for (const full_name of list) {
const item = await this.getOne(full_name, relation);

pageData.push(item);
}
return { pageData, totalCount: list.length };
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"echarts-jsx": "^0.5.4",
"idea-react": "^2.0.0-rc.2",
"jsonwebtoken": "^9.0.2",
"koajax": "^2.0.0",
"koajax": "^1.1.2",
"leaflet": "^1.9.4",
"leaflet.chinatmsproviders": "^3.0.6",
"mobx": "^6.13.1",
Expand Down
4 changes: 2 additions & 2 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ enableStaticRendering(isServer());
const { t } = i18n;

globalThis.addEventListener?.('unhandledrejection', ({ reason }) => {
const { message, response } = (reason || {}) as HTTPError<ErrorBaseData>;
const { message, body } = (reason || {}) as HTTPError<ErrorBaseData>;

const tips = response.body?.detail || message;
const tips = body?.detail || message;

if (tips) alert(tips);
});
Expand Down
3 changes: 1 addition & 2 deletions pages/api/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export function safeAPI(handler: NextAPI): NextAPI {
console.error(error);
return res.end(error);
}
const { message, response } = error;
let { status, body } = response;
let { message, status, body } = error;

res.status(status);
res.statusMessage = message;
Expand Down
22 changes: 14 additions & 8 deletions pages/open-source.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Contributor, GitRepository } from 'mobx-github';
import { observer } from 'mobx-react';
import { cache, compose, translator } from 'next-ssr-middleware';
import { FC } from 'react';
import { Container } from 'react-bootstrap';
import { Col, Container, Row } from 'react-bootstrap';

import { GitCard, SimpleRepository } from '../components/Git/Card';
import { PageHead } from '../components/layout/PageHead';
Expand Down Expand Up @@ -35,26 +35,32 @@ const OpenSourcePage: FC<OpenSourcePageProps> = observer(
({ repositories, contributors }) => (
<Container>
<PageHead title={t('open_source_code')} />
<h1 className="text-center">{t('open_source_code')}</h1>
<h1 className="my-5 text-center">{t('open_source_code')}</h1>

{SourceRepository.map((list, index) => (
{[...SourceRepository].reverse().map((list, index, { length }) => (
<section key={index}>
<h2>v{index + 1}</h2>
<h2 className="my-4">v{length - index}</h2>

<ul className="list-unstyled d-flex flex-wrap gap-3 justify-content-around align-items-center">
<Row as="ul" className="list-unstyled g-3">
{list.map(name => {
const repository = repositories.find(
({ full_name }) => full_name === name,
);
return (
<GitCard key={name} {...(repository as SimpleRepository)} />
<Col key={name}>
<GitCard
className="h-100"
{...(repository as SimpleRepository)}
renderController={() => <></>}
/>
</Col>
);
})}
</ul>
</Row>
</section>
))}

<h2>{t('team_members')}</h2>
<h2 className="my-4">{t('team_members')}</h2>
<TopUserList
value={contributors.map(
({ id, login, avatar_url, contributions }, index) => ({
Expand Down
25 changes: 2 additions & 23 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 comment on commit 14636ab

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for open-hackathon ready!

✅ Preview
https://open-hackathon-gdj88w6lv-techquerys-projects.vercel.app

Built with commit 14636ab.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.