From cb260aad5754f6a28ed2ef76245470401a517a06 Mon Sep 17 00:00:00 2001 From: ruotongyu Date: Tue, 4 Jun 2024 23:14:08 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0(App.tsx)?= =?UTF-8?q?=EF=BC=9A=E6=B7=BB=E5=8A=A0CodeContext=E4=B8=8A=E4=B8=8B?= =?UTF-8?q?=E6=96=87=E5=8F=8A=E7=9B=B8=E5=85=B3=E6=95=B0=E6=8D=AE=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E9=80=BB=E8=BE=91=20=E2=9C=A8=20=E6=B7=BB=E5=8A=A0(Co?= =?UTF-8?q?deContext.tsx)=EF=BC=9A=E5=88=9B=E5=BB=BACodeContext=E4=B8=8A?= =?UTF-8?q?=E4=B8=8B=E6=96=87=EF=BC=8C=E5=B9=B6=E5=AE=9A=E4=B9=89=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=B1=BB=E5=9E=8B=E5=92=8C=E6=95=B0=E6=8D=AE=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=96=B9=E6=B3=95=20=E2=9C=A8=20=E6=B7=BB=E5=8A=A0(da?= =?UTF-8?q?ta.ts)=EF=BC=9A=E5=B0=86data=E6=95=B0=E7=BB=84=E9=87=8D?= =?UTF-8?q?=E5=91=BD=E5=90=8D=E4=B8=BAcodes=EF=BC=8C=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=8E=A5=E5=8F=A3DataType?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/autoMate/src/renderer/src/App.tsx | 9 ++++++--- ui/autoMate/src/renderer/src/context/CodeContext.tsx | 8 ++++++++ ui/autoMate/src/renderer/src/data.ts | 4 ++-- 3 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 ui/autoMate/src/renderer/src/context/CodeContext.tsx diff --git a/ui/autoMate/src/renderer/src/App.tsx b/ui/autoMate/src/renderer/src/App.tsx index 57c6f8d..dfa650f 100644 --- a/ui/autoMate/src/renderer/src/App.tsx +++ b/ui/autoMate/src/renderer/src/App.tsx @@ -1,13 +1,16 @@ +import { useState } from "react" import Result from "./components/Result" import Search from "./components/Search" +import { CodeContext } from "./context/CodeContext" +import { codes } from "@renderer/data" function App(): JSX.Element { - + const [data, setData] = useState(codes) return ( - <> + - + ) } diff --git a/ui/autoMate/src/renderer/src/context/CodeContext.tsx b/ui/autoMate/src/renderer/src/context/CodeContext.tsx new file mode 100644 index 0000000..1b49f83 --- /dev/null +++ b/ui/autoMate/src/renderer/src/context/CodeContext.tsx @@ -0,0 +1,8 @@ +import { Dispatch, SetStateAction, createContext } from "react" +import { DataType } from "@renderer/data" +interface ContextProps { + data: DataType[] + setData: Dispatch> +} +export const CodeContext = createContext(undefined) + diff --git a/ui/autoMate/src/renderer/src/data.ts b/ui/autoMate/src/renderer/src/data.ts index a64266d..a269979 100644 --- a/ui/autoMate/src/renderer/src/data.ts +++ b/ui/autoMate/src/renderer/src/data.ts @@ -1,8 +1,8 @@ -interface DataType { +export interface DataType { id: number, content: string } -export const data = [ +export const codes = [ {id:1, content: "Hello, how are you?"}, {id:2, content: "I am fine, thank you"}, {id:3, content: "How are you?"},