From 91fa5a7bf2094d251626dac0db8e811270b4c322 Mon Sep 17 00:00:00 2001 From: Wonder Date: Tue, 24 Mar 2026 11:59:20 +0800 Subject: [PATCH] =?UTF-8?q?=20=E2=9C=A8Feat:=20=E5=A2=9E=E5=8A=A0=20Card?= =?UTF-8?q?=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/App.tsx | 8 +++--- frontend/src/components/Card.tsx | 44 ++++++++++++++++++++++++++++++++ frontend/src/global.css | 2 +- 3 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 frontend/src/components/Card.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1ece96a..57eed1f 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,10 +1,10 @@ -import { Button } from '@heroui/react'; +import Card from "./components/Card" + + function App() { return ( - <> + <> ) } diff --git a/frontend/src/components/Card.tsx b/frontend/src/components/Card.tsx new file mode 100644 index 0000000..20ece61 --- /dev/null +++ b/frontend/src/components/Card.tsx @@ -0,0 +1,44 @@ +import {ScrollShadow} from "@heroui/react"; +import { useEffect, useState } from "react"; + +export default function Card() { + // Data + const [data, setData] = useState(null) + const [loading, setLoading] = useState(true) + + // Load Data + useEffect(() => { + const fetchData = async () => { + try { + const response = await fetch('http://localhost:8080/agent/card/你好') + if (!response.ok) { + throw new Error('API Error'); + } + const result = await response.json(); + setData(result); + } catch (error) { + console.error("Failed to fetch data: ", error); + } finally { + setLoading(false); + } + }; + fetchData(); + }, []); + + + return ( +
+ +
+{loading ? ( + // 3. 加载状态显示 Loading... +

Loading data...

+ ) : ( + // 4. 渲染从 API 获取的数据 +
{data?.message}
+ )} +
+
+
+ ); +} \ No newline at end of file diff --git a/frontend/src/global.css b/frontend/src/global.css index b2160b7..7af4b60 100644 --- a/frontend/src/global.css +++ b/frontend/src/global.css @@ -1,2 +1,2 @@ -@import "tailwindcss/theme" theme(reference); +@import "tailwindcss/theme"; @import "@heroui/styles"; \ No newline at end of file