Skip to content

Commit e7ecc64

Browse files
committed
Merge remote-tracking branch 'origin/main' into seo
2 parents afa1675 + b27f03c commit e7ecc64

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4053
-2473
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ NEXT_PUBLIC_SITE_SUMMARY = 全行业信息化转型专家
33
NEXT_PUBLIC_LOGO = /idea2app.svg
44

55
NEXT_PUBLIC_CACHE_HOST = https://cache.idea2.app
6+
CACHE_REPOSITORY = idea2app/OWS-cache
67

78
NEXT_PUBLIC_SENTRY_DSN = https://03e5d951172f411a04c1bab44022e22b@o4506471366852608.ingest.sentry.io/4506484563705856
89
SENTRY_ORG = idea2app

.npmrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
public-hoist-pattern[] = *import-in-the-middle*
2+
public-hoist-pattern[] = *require-in-the-middle*
13
auto-install-peers = false

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,20 +68,20 @@ You can check out [the Next.js GitHub repository][27] - your feedback and contri
6868

6969
| name | file | description |
7070
| :----------------------: | :----------: | :---------------------: |
71-
| `CRAWLER_TOKEN` | `.env.local` | Web hooks authorization |
72-
| `SENTRY_AUTH_TOKEN` | `.env.local` | [Official document][28] |
73-
| `SENTRY_ORG` | `.env` | [Official document][29] |
74-
| `SENTRY_PROJECT` | `.env` | [Official document][29] |
75-
| `NEXT_PUBLIC_SENTRY_DSN` | `.env` | [Official document][30] |
76-
| `GITHUB_TOKEN` | `.env.local` | [Official document][31] |
77-
| `LARK_APP_ID` | `.env.local` | [Official document][32] |
78-
| `LARK_APP_SECRET` | `.env.local` | [Official document][32] |
71+
| `JWT_SECRET` | `.env.local` | [API authorization][28] |
72+
| `SENTRY_AUTH_TOKEN` | `.env.local` | [Official document][29] |
73+
| `SENTRY_ORG` | `.env` | [Official document][30] |
74+
| `SENTRY_PROJECT` | `.env` | [Official document][30] |
75+
| `NEXT_PUBLIC_SENTRY_DSN` | `.env` | [Official document][31] |
76+
| `GITHUB_TOKEN` | `.env.local` | [Official document][32] |
77+
| `LARK_APP_ID` | `.env.local` | [Official document][33] |
78+
| `LARK_APP_SECRET` | `.env.local` | [Official document][33] |
7979

8080
### Vercel
8181

8282
The easiest way to deploy your Next.js app is to use the [Vercel Platform][13] from the creators of Next.js.
8383

84-
Check out our [Next.js deployment documentation][33] for more details.
84+
Check out our [Next.js deployment documentation][34] for more details.
8585

8686
### Docker
8787

@@ -110,16 +110,17 @@ pnpm container
110110
[18]: https://github.com/new?template_name=idea2app.github.io&template_owner=idea2app
111111
[19]: https://github.com/idea2app/idea2app.github.io/blob/34a68d5c3a21665c5971edff5aa7c208647d1566/.github/workflows/main.yml#L9-L11
112112
[20]: https://github.com/idea2app/idea2app.github.io/settings/secrets/actions
113-
[21]: https://github.com/kaiyuanshe/kaiyuanshe.github.io/blob/bb4675a56bf1d6b207231313da5ed0af7cf0ebd6/.github/workflows/pull-request.yml#L32-L56
113+
[21]: https://github.com/idea2app/Lark-Next-Bootstrap-ts/blob/363e023e5dd472c8ea53ec96eac25ec5122e667b/.github/workflows/Lark-notification.yml#L39
114114
[22]: https://github.com/idea2app/idea2app.github.io/issues/new/choose
115115
[23]: https://github.com/idea2app/idea2app.github.io/projects
116116
[24]: https://nextjs.org/docs/api-routes/introduction
117117
[25]: https://nextjs.org/docs
118118
[26]: https://nextjs.org/learn
119119
[27]: https://github.com/vercel/next.js/
120-
[28]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-configuration-files-for-source-map-upload
121-
[29]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-environment-variables
122-
[30]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files
123-
[31]: https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api#authenticating-with-a-personal-access-token
124-
[32]: https://open.larksuite.com/document/server-docs/getting-started/api-access-token/app-access-token-development-guide#95c7f5f5
125-
[33]: https://nextjs.org/docs/deployment
120+
[28]: https://github.com/auth0/node-jsonwebtoken?tab=readme-ov-file#jwtsignpayload-secretorprivatekey-options-callback
121+
[29]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-configuration-files-for-source-map-upload
122+
[30]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#use-environment-variables
123+
[31]: https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/#create-initialization-config-files
124+
[32]: https://docs.github.com/en/rest/authentication/authenticating-to-the-rest-api#authenticating-with-a-personal-access-token
125+
[33]: https://open.larksuite.com/document/server-docs/getting-started/api-access-token/app-access-token-development-guide#95c7f5f5
126+
[34]: https://nextjs.org/docs/deployment

components/Client/Partner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Tooltip } from '@mui/material';
22
import { FC, ReactNode } from 'react';
33

4+
import { fileURLOf } from '../../models/Base';
45
import { Client } from '../../models/Client';
5-
import { fileURLOf } from '../../pages/api/Lark/file/[id]';
66
import { LarkImage } from '../LarkImage';
77

88
export interface PartnerProps extends Client {
@@ -41,7 +41,7 @@ export const LogoWithLink: FC<Omit<PartnerOverviewProps, 'tooltip'>> = ({
4141
address,
4242
logo,
4343
logoDark,
44-
className
44+
className,
4545
}) => (
4646
<a
4747
key={name}

components/Git/Card.tsx

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { Button, Chip } from '@mui/material';
22
import { GitRepository } from 'mobx-github';
33
import { observer } from 'mobx-react';
44
import Link from 'next/link';
5-
import { FC } from 'react';
5+
import { FC, useContext } from 'react';
66

7-
import { i18n } from '../../models/Translation';
7+
import { I18nContext } from '../../models/Translation';
88

99
export interface GitCardProps
1010
extends Pick<GitRepository, 'full_name' | 'html_url' | 'languages'>,
@@ -13,39 +13,43 @@ export interface GitCardProps
1313
}
1414

1515
export const GitCard: FC<GitCardProps> = observer(
16-
({ className = '', full_name, html_url, topics = [], description, homepage }) => (
17-
<li
18-
className={`${className} grid grid-cols-1 grid-rows-10 gap-2 rounded-2xl border p-4 elevation-1 hover:elevation-8 dark:border-0`}
19-
>
20-
<h2 className="row-span-2 text-lg">
21-
<a target="_blank" href={html_url} rel="noreferrer">
22-
{full_name}
23-
</a>
24-
</h2>
16+
({ className = '', full_name, html_url, topics = [], description, homepage }) => {
17+
const { t } = useContext(I18nContext);
2518

26-
<nav className="row-span-3 flex flex-row flex-wrap gap-2">
27-
{topics.map(topic => (
28-
<Chip
29-
key={topic}
30-
size="small"
31-
component="a"
32-
target="_blank"
33-
href={`https://github.com/topics/${topic}`}
34-
label={topic}
35-
/>
36-
))}
37-
</nav>
19+
return (
20+
<li
21+
className={`${className} elevation-1 hover:elevation-8 grid grid-cols-1 grid-rows-10 gap-2 rounded-2xl border p-4 dark:border-0`}
22+
>
23+
<h2 className="row-span-2 text-lg">
24+
<a target="_blank" href={html_url} rel="noreferrer">
25+
{full_name}
26+
</a>
27+
</h2>
3828

39-
<p className="row-span-3 text-sm">{description}</p>
29+
<nav className="row-span-3 flex flex-row flex-wrap gap-2">
30+
{topics.map(topic => (
31+
<Chip
32+
key={topic}
33+
size="small"
34+
component="a"
35+
target="_blank"
36+
href={`https://github.com/topics/${topic}`}
37+
label={topic}
38+
/>
39+
))}
40+
</nav>
4041

41-
<Button
42-
className="row-span-2 place-self-center"
43-
component={Link}
44-
target="_blank"
45-
href={homepage ?? html_url}
46-
>
47-
{i18n.t('home_page')}
48-
</Button>
49-
</li>
50-
),
42+
<p className="row-span-3 text-sm">{description}</p>
43+
44+
<Button
45+
className="row-span-2 place-self-center"
46+
component={Link}
47+
target="_blank"
48+
href={homepage ?? html_url}
49+
>
50+
{t('home_page')}
51+
</Button>
52+
</li>
53+
);
54+
},
5155
);

components/Git/Issue/Card.tsx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { Avatar, Card, CardContent, CardProps, Chip } from '@mui/material';
2+
import { marked } from 'marked';
3+
import { Issue } from 'mobx-github';
4+
import { FC } from 'react';
5+
6+
import { SymbolIcon } from '../../Icon';
7+
8+
export type IssueCardProps = Issue & Omit<CardProps, 'id'>;
9+
10+
export const IssueCard: FC<IssueCardProps> = ({
11+
id,
12+
repository_url,
13+
number,
14+
title,
15+
labels,
16+
body,
17+
html_url,
18+
user,
19+
comments,
20+
created_at,
21+
...props
22+
}) => (
23+
<Card {...props}>
24+
<CardContent className="flex h-full flex-col justify-between gap-2">
25+
<h2 className="text-2xl">
26+
<a
27+
href={html_url}
28+
target="_blank"
29+
rel="noreferrer"
30+
style={{ textDecoration: 'none', color: 'inherit' }}
31+
>
32+
{repository_url.split('/').slice(-2).join('/')}#{number}
33+
<br />
34+
{title}
35+
</a>
36+
</h2>
37+
38+
<div className="flex items-center gap-2">
39+
{labels?.map(
40+
label =>
41+
typeof label === 'object' && (
42+
<Chip
43+
key={label.name}
44+
label={label.name}
45+
style={{ backgroundColor: `#${label.color || 'e0e0e0'}` }}
46+
/>
47+
),
48+
)}
49+
</div>
50+
51+
<article dangerouslySetInnerHTML={{ __html: marked(body || '') }} />
52+
53+
<footer className="flex items-center justify-between">
54+
{user && (
55+
<div className="flex items-center gap-2">
56+
<Avatar src={user.avatar_url} alt={user.name || ''} />
57+
{user.name || ''}
58+
</div>
59+
)}
60+
<div className="flex items-center gap-2">
61+
<SymbolIcon name="chat" />
62+
{comments}
63+
</div>
64+
<time dateTime={created_at}>{new Date(created_at).toLocaleString()}</time>
65+
</footer>
66+
</CardContent>
67+
</Card>
68+
);

components/Icon.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
import { FC, HTMLAttributes, PropsWithRef } from 'react';
1+
import { FC, HTMLAttributes } from 'react';
22

3-
export type IconProps = PropsWithRef<
4-
HTMLAttributes<HTMLSpanElement> & {
5-
name: string;
6-
variant?: 'outlined' | 'rounded' | 'sharp';
7-
}
8-
>;
3+
export interface IconProps extends HTMLAttributes<HTMLSpanElement> {
4+
name: string;
5+
variant?: 'outlined' | 'rounded' | 'sharp';
6+
}
97

10-
export const SymbolIcon: FC<IconProps> = ({ className, name, variant = 'outlined', ...props }) => (
8+
export const SymbolIcon: FC<IconProps> = ({
9+
className = '',
10+
name,
11+
variant = 'outlined',
12+
...props
13+
}) => (
1114
<span
1215
aria-hidden="false"
1316
aria-label={`${name} icon`}

components/LarkImage.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { TableCellValue } from 'mobx-lark';
22
import { ImageProps } from 'next/image';
33
import { FC } from 'react';
44

5-
import { DefaultImage, fileURLOf } from '../pages/api/Lark/file/[id]';
5+
import { fileURLOf } from '../models/Base';
6+
import { DefaultImage } from '../models/configuration';
67

78
export interface LarkImageProps extends Omit<ImageProps, 'src'> {
89
src?: TableCellValue;

components/Layout/MainNavigator.tsx

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,51 @@
1-
import {
2-
AppBar,
3-
Button,
4-
Drawer,
5-
IconButton,
6-
Menu,
7-
MenuItem,
8-
PopoverProps,
9-
Toolbar,
10-
} from '@mui/material';
11-
import { observable } from 'mobx';
1+
import { AppBar, Drawer, IconButton, Menu, MenuItem, PopoverProps, Toolbar } from '@mui/material';
2+
import { computed, observable } from 'mobx';
123
import { observer } from 'mobx-react';
13-
import Image from 'next/image';
4+
import { ObservedComponent, observePropsState } from 'mobx-react-helper';
145
import Link from 'next/link';
156
import { Component } from 'react';
167

17-
import { i18n, LanguageName, t } from '../../models/Translation';
8+
import { i18n, I18nContext, LanguageName } from '../../models/Translation';
189
import { SymbolIcon } from '../Icon';
1910
import { ColorModeIconDropdown } from './ColorModeDropdown';
2011
import { BrandLogo, GithubIcon } from './Svg';
2112

22-
export const mainNavLinks = () => [
23-
{ title: t('latest_projects'), href: '/project' },
24-
{ title: t('member'), href: '/member' },
25-
{ title: t('open_source_project'), href: '/open-source' },
26-
];
13+
export interface MainNavigator extends ObservedComponent<{}, typeof i18n> {}
2714

2815
@observer
16+
@observePropsState
2917
export class MainNavigator extends Component {
18+
static contextType = I18nContext;
19+
3020
@observable accessor menuExpand = false;
3121
@observable accessor menuAnchor: PopoverProps['anchorEl'] = null;
3222

23+
@computed
24+
get links() {
25+
const { t } = this.observedContext!;
26+
27+
return [
28+
{ title: t('latest_projects'), href: '/project' },
29+
{ title: 'GitHub-reward', href: '/project/reward/issue', target: '_top' },
30+
{ title: t('member'), href: '/member' },
31+
{ title: t('open_source_project'), href: '/open-source' },
32+
];
33+
}
34+
3335
switchI18n = (key: string) => {
34-
i18n.changeLanguage(key as keyof typeof LanguageName);
36+
this.observedContext!.loadLanguages(key as keyof typeof LanguageName);
3537
this.menuAnchor = null;
3638
};
3739

3840
renderLinks = () =>
39-
mainNavLinks().map(({ title, href }) => (
40-
<Link key={title} className="py-1" href={href}>
41+
this.links.map(({ title, href, target }) => (
42+
<Link key={title} className="py-1" href={href} target={target}>
4143
{title}
4244
</Link>
4345
));
4446

4547
renderI18nSwitch = () => {
46-
const { currentLanguage } = i18n,
48+
const { currentLanguage } = this.observedContext!,
4749
{ menuAnchor } = this;
4850

4951
return (
@@ -59,12 +61,7 @@ export class MainNavigator extends Component {
5961
<Menu
6062
anchorEl={menuAnchor}
6163
id="i18n-menu"
62-
slotProps={{
63-
paper: {
64-
variant: 'outlined',
65-
sx: { my: '4px' },
66-
},
67-
}}
64+
slotProps={{ paper: { variant: 'outlined', sx: { my: '4px' } } }}
6865
open={Boolean(menuAnchor)}
6966
onClose={() => (this.menuAnchor = null)}
7067
>
@@ -98,7 +95,7 @@ export class MainNavigator extends Component {
9895
variant="temporary"
9996
anchor="top"
10097
ModalProps={{ keepMounted: true }}
101-
PaperProps={{ className: 'w-full bg-transparent shadow-none bg-none' }}
98+
slotProps={{ paper: { className: 'w-full bg-transparent shadow-none bg-none' } }}
10299
open={this.menuExpand}
103100
onClose={() => (this.menuExpand = false)}
104101
>

0 commit comments

Comments
 (0)