mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 13:07:17 +08:00
✨ 添加(ui/autoMate):调整窗口高度从500px到350px,优化用户体验
📝 更新(ui/autoMate):重构CodeContext,将useState移入Provider,提高可维护性 🔧 更新(ui/autoMate):在useSearch hook中对搜索结果进行限制并提高性能
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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<DataType[]>([])
|
||||
return (
|
||||
<CodeContext.Provider value={{data, setData}}>
|
||||
<CodeProvider>
|
||||
<Search />
|
||||
<Result />
|
||||
</CodeContext.Provider>
|
||||
</CodeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -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<ContextProps|undefined>(undefined)
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode
|
||||
}
|
||||
export const CodeProvider = ({children}:Props)=>{
|
||||
const [data, setData] = useState<DataType[]>([])
|
||||
return <CodeContext.Provider value={{data, setData}}>{children}</CodeContext.Provider>
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ export default()=>{
|
||||
setData(
|
||||
codes.filter((code) =>
|
||||
code.content.toLowerCase().includes(e.target.value.toLowerCase() || '@@@@@@')
|
||||
)
|
||||
).slice(0, 8)
|
||||
)
|
||||
}
|
||||
return {search, handleSearch}
|
||||
|
||||
Reference in New Issue
Block a user