Skip to content

Commit a37b691

Browse files
author
bestGao
committed
feat(m): 新增删除
1 parent 4ab7750 commit a37b691

File tree

11 files changed

+105
-134
lines changed

11 files changed

+105
-134
lines changed

src/components/articleCom/articleCom.module.less

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/components/articleCom/index.tsx

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Typography, List } from "antd";
2+
import { useNavigate } from "react-router-dom";
3+
import { memo } from "react";
4+
interface IProps {
5+
item: {
6+
title: string;
7+
download_url: string;
8+
path: string;
9+
};
10+
}
11+
function ArticleLink({ item }: IProps) {
12+
const nav = useNavigate();
13+
return (
14+
<List.Item>
15+
<Typography.Link
16+
onClick={() => {
17+
nav(`/user/write`, {
18+
state: {
19+
url: item.download_url,
20+
title: item.title,
21+
path: item.path,
22+
},
23+
});
24+
}}
25+
>
26+
{item.title}
27+
</Typography.Link>
28+
</List.Item>
29+
);
30+
}
31+
32+
export default memo(ArticleLink);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { List, Skeleton } from "antd";
2+
import { memo } from "react";
3+
import ArticleLink from "../articleLink";
4+
5+
function ArticleList({ postList }: any) {
6+
return postList?.length ? (
7+
<List
8+
size="large"
9+
bordered
10+
dataSource={postList}
11+
renderItem={(item: any) => <ArticleLink item={item} />}
12+
/>
13+
) : (
14+
<Skeleton />
15+
);
16+
}
17+
18+
export default memo(ArticleList);

src/components/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
export { default as ArticleCom } from "./articleCom";
1+
export { default as ArticleLink } from "./articleLink";
2+
export { default as ArticleList } from "./articleList";

src/pages/ai/index.module.less

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,3 @@
33
height: 64px;
44
}
55
}
6-
.bigMe {
7-
position: absolute;
8-
bottom: 0;
9-
right: 16px;
10-
width: 200px;
11-
height: 100px;
12-
background-repeat: no-repeat;
13-
background-image: url("../../assets/me.png");
14-
background-size: 100%;
15-
}

src/pages/ai/index.tsx

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { useEffect } from "react";
2-
import { List, Typography } from "antd";
32
import { post } from "@/utils/request";
43
import style from "./index.module.less";
54
import useCustomReducer from "@/hooks/useCusReducer";
6-
import { useNavigate } from "react-router-dom";
5+
import ArticleList from "@/components/articleList";
76
export default function AI() {
8-
const nav = useNavigate();
97
const [state, dispatch] = useCustomReducer({
108
article: [],
119
});
@@ -21,25 +19,7 @@ export default function AI() {
2119
}, []);
2220
return (
2321
<div className={style.aiContainer}>
24-
<List
25-
size="large"
26-
bordered
27-
dataSource={state.article}
28-
renderItem={(item: any) => (
29-
<List.Item>
30-
<Typography.Link
31-
onClick={() => {
32-
nav(`/user/write`, {
33-
state: { url: item.download_url },
34-
});
35-
}}
36-
>
37-
{item.title}
38-
</Typography.Link>
39-
</List.Item>
40-
)}
41-
/>
42-
<div className={style.bigMe} />
22+
<ArticleList postList={state.article} />
4323
</div>
4424
);
4525
}

src/pages/arch/index.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { useEffect } from "react";
2-
import { List, Typography } from "antd";
32
import style from "./index.module.less";
3+
import ArticleList from "@/components/articleList";
44
import { post } from "@/utils/request";
55
import useCustomReducer from "@/hooks/useCusReducer";
6-
import { useNavigate } from "react-router-dom";
76
export default function BFE() {
8-
const nav = useNavigate();
97
const [state, dispatch] = useCustomReducer({
108
article: [],
119
});
@@ -23,24 +21,7 @@ export default function BFE() {
2321
}, []);
2422
return (
2523
<div className={style.archWP}>
26-
<List
27-
size="large"
28-
bordered
29-
dataSource={state.article}
30-
renderItem={(item: any) => (
31-
<List.Item>
32-
<Typography.Link
33-
onClick={() => {
34-
nav(`/user/write`, {
35-
state: { url: item.download_url },
36-
});
37-
}}
38-
>
39-
{item.title}
40-
</Typography.Link>
41-
</List.Item>
42-
)}
43-
/>
24+
<ArticleList postList={state.article} />
4425
</div>
4526
);
4627
}

src/pages/be/index.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { useEffect } from "react";
2-
import { List, Typography } from "antd";
32
import style from "./index.module.less";
3+
import ArticleList from "@/components/articleList";
44
import { post } from "@/utils/request";
55
import useCustomReducer from "@/hooks/useCusReducer";
6-
import { useNavigate } from "react-router-dom";
76
export default function BFE() {
8-
const nav = useNavigate();
97
const [state, dispatch] = useCustomReducer({
108
article: [],
119
});
@@ -21,24 +19,7 @@ export default function BFE() {
2119
}, []);
2220
return (
2321
<div className={style.BEWP}>
24-
<List
25-
size="large"
26-
bordered
27-
dataSource={state.article}
28-
renderItem={(item: any) => (
29-
<List.Item>
30-
<Typography.Link
31-
onClick={() => {
32-
nav(`/user/write`, {
33-
state: { url: item.download_url },
34-
});
35-
}}
36-
>
37-
{item.title}
38-
</Typography.Link>
39-
</List.Item>
40-
)}
41-
/>
22+
<ArticleList postList={state.article} />
4223
</div>
4324
);
4425
}

src/pages/bfe/index.tsx

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { useEffect } from "react";
2-
import { Typography, List } from "antd";
32
import style from "./index.module.less";
3+
import ArticleList from "@/components/articleList";
44
import { post } from "@/utils/request";
55
import useCustomReducer from "@/hooks/useCusReducer";
6-
import { useNavigate } from "react-router-dom";
76
export default function BFE() {
8-
const nav = useNavigate();
97
const [state, dispatch] = useCustomReducer({
108
article: [],
119
});
@@ -21,24 +19,7 @@ export default function BFE() {
2119
}, []);
2220
return (
2321
<div className={style.BFEWP}>
24-
<List
25-
size="large"
26-
bordered
27-
dataSource={state.article}
28-
renderItem={(item: any) => (
29-
<List.Item>
30-
<Typography.Link
31-
onClick={() => {
32-
nav(`/user/write`, {
33-
state: { url: item.download_url },
34-
});
35-
}}
36-
>
37-
{item.title}
38-
</Typography.Link>
39-
</List.Item>
40-
)}
41-
/>
22+
<ArticleList postList={state.article} />
4223
</div>
4324
);
4425
}

0 commit comments

Comments
 (0)