This commit is contained in:
pincman 2024-05-11 03:34:25 +08:00
parent e836f35165
commit a1a6a37753
2 changed files with 72 additions and 0 deletions

1
node/README.md Normal file
View File

@ -0,0 +1 @@
临时备份代码

View File

@ -0,0 +1,71 @@
import { PostEntity } from "@3rapp/api/modules/content/entities/post.entity";
import { StyleProvider } from "@ant-design/cssinjs";
import { Button, ConfigProvider, theme, App as AntdApp } from "antd";
// import 'dayjs/locale/zh-cn';
import zhCN from "antd/locale/zh_CN";
import axios from "axios";
import { FC, useEffect, useState } from "react";
import $styles from "./app.module.css";
const getPosts = async () => {
let data: PostEntity[] = [];
try {
const res = await axios.get("/api/posts");
data = res.data;
} catch (err) {
console.log("Error:", err);
}
return data;
};
const App: FC = () => {
const [data, setData] = useState<PostEntity[]>([]);
useEffect(() => {
(async () => {
setData(await getPosts());
})();
}, []);
return (
<ConfigProvider
locale={zhCN}
theme={{
algorithm: theme.defaultAlgorithm,
token: {
colorPrimary: "#00B96B",
},
components: {
Layout: {
colorBgBody: "",
},
},
}}
>
<StyleProvider hashPriority="high">
<AntdApp>
<div className={$styles.app}>
<div className={$styles.container}>
3R教室<span>React课程第一节</span>
<Button
type="primary"
className="!bg-lime-400 !text-emerald-900"
href="https://pincman.com/3r"
target="_blank"
>
</Button>
<h2></h2>
<ul>
{data.map((item) => (
<li key={item.id}>{item.title}</li>
))}
</ul>
</div>
</div>
</AntdApp>
</StyleProvider>
</ConfigProvider>
);
};
export default App;