From 76ffb49825b7488e2db1db55cad239a5932e0064 Mon Sep 17 00:00:00 2001 From: yuruo Date: Wed, 5 Jun 2024 15:11:49 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20=E6=B7=BB=E5=8A=A0(ui/autoMate)?= =?UTF-8?q?=EF=BC=9A=E8=B0=83=E6=95=B4=E7=AA=97=E5=8F=A3=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E4=BB=8E500px=E5=88=B0350px=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C=20=F0=9F=93=9D=20=E6=9B=B4?= =?UTF-8?q?=E6=96=B0(ui/autoMate)=EF=BC=9A=E9=87=8D=E6=9E=84CodeContext?= =?UTF-8?q?=EF=BC=8C=E5=B0=86useState=E7=A7=BB=E5=85=A5Provider=EF=BC=8C?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E5=8F=AF=E7=BB=B4=E6=8A=A4=E6=80=A7=20?= =?UTF-8?q?=F0=9F=94=A7=20=E6=9B=B4=E6=96=B0(ui/autoMate)=EF=BC=9A?= =?UTF-8?q?=E5=9C=A8useSearch=20hook=E4=B8=AD=E5=AF=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E8=BF=9B=E8=A1=8C=E9=99=90=E5=88=B6=E5=B9=B6?= =?UTF-8?q?=E6=8F=90=E9=AB=98=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/autoMate/src/main/index.ts | 2 +- ui/autoMate/src/renderer/src/App.tsx | 10 ++++------ ui/autoMate/src/renderer/src/context/CodeContext.tsx | 10 +++++++++- ui/autoMate/src/renderer/src/hooks/useSearch.ts | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/ui/autoMate/src/main/index.ts b/ui/autoMate/src/main/index.ts index 29ce755..fe606da 100644 --- a/ui/autoMate/src/main/index.ts +++ b/ui/autoMate/src/main/index.ts @@ -6,7 +6,7 @@ import icon from '../../resources/icon.png?asset' function createWindow(): void { // Create the browser window. const mainWindow = new BrowserWindow({ width: 600, - height: 500, + height: 350, show: false, // transparent: true, // frame: false, diff --git a/ui/autoMate/src/renderer/src/App.tsx b/ui/autoMate/src/renderer/src/App.tsx index dbf38c4..0ede833 100644 --- a/ui/autoMate/src/renderer/src/App.tsx +++ b/ui/autoMate/src/renderer/src/App.tsx @@ -1,16 +1,14 @@ -import { useState } from "react" import Result from "./components/Result" import Search from "./components/Search" -import { CodeContext } from "./context/CodeContext" -import { DataType } from "@renderer/data" +import { CodeProvider } from "./context/CodeContext" + function App(): JSX.Element { - const [data, setData] = useState([]) return ( - + - + ) } diff --git a/ui/autoMate/src/renderer/src/context/CodeContext.tsx b/ui/autoMate/src/renderer/src/context/CodeContext.tsx index 1b49f83..263a41c 100644 --- a/ui/autoMate/src/renderer/src/context/CodeContext.tsx +++ b/ui/autoMate/src/renderer/src/context/CodeContext.tsx @@ -1,4 +1,4 @@ -import { Dispatch, SetStateAction, createContext } from "react" +import { Dispatch, SetStateAction, createContext, useState } from "react" import { DataType } from "@renderer/data" interface ContextProps { data: DataType[] @@ -6,3 +6,11 @@ interface ContextProps { } export const CodeContext = createContext(undefined) +interface Props { + children: React.ReactNode +} +export const CodeProvider = ({children}:Props)=>{ + const [data, setData] = useState([]) + return {children} +} + diff --git a/ui/autoMate/src/renderer/src/hooks/useSearch.ts b/ui/autoMate/src/renderer/src/hooks/useSearch.ts index 2555895..779db65 100644 --- a/ui/autoMate/src/renderer/src/hooks/useSearch.ts +++ b/ui/autoMate/src/renderer/src/hooks/useSearch.ts @@ -9,7 +9,7 @@ export default()=>{ setData( codes.filter((code) => code.content.toLowerCase().includes(e.target.value.toLowerCase() || '@@@@@@') - ) + ).slice(0, 8) ) } return {search, handleSearch}