mirror of
https://github.com/yuruotong1/autoMate.git
synced 2026-03-22 04:57:18 +08:00
📝 更新(shortCut.ts, App.tsx, index.tsx):删除无用的导入和函数调用
♻️ 重构(Home/index.tsx):更新快捷键注册的调用方式
This commit is contained in:
@@ -1,12 +1,10 @@
|
||||
import { IpcMainInvokeEvent } from "electron"
|
||||
import { ipcMain } from "electron"
|
||||
import { getWindowByName } from "./windows"
|
||||
import { findOne } from "./db/query"
|
||||
const { app, globalShortcut } = require('electron')
|
||||
|
||||
ipcMain.handle("shortCut", (_event: IpcMainInvokeEvent, shortCut: string) => {
|
||||
|
||||
// react 严格模式会执行两次,可能会导致快捷键重复注册,这里在注册前会删除旧快捷键,也用户注册过快捷键想修改成其他快捷键
|
||||
// react 严格模式会执行两次,可能会导致快捷键重复注册,这里在注册前会删除旧快捷键
|
||||
return registerSearchShortCut(shortCut)
|
||||
|
||||
})
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import Result from "./components/Result"
|
||||
import Search from "./components/Search"
|
||||
import { CodeProvider } from "./context/CodeContext"
|
||||
import useShortCut from "./hooks/useShortCut"
|
||||
import Error from "./components/Error"
|
||||
import { MutableRefObject, useEffect, useRef } from "react"
|
||||
import useIgnoreMouseEvents from "./hooks/useIgnoreMouseEvents"
|
||||
|
||||
@@ -16,8 +16,8 @@ function Home(): JSX.Element {
|
||||
// window.api.openConfigWindow()
|
||||
}, [])
|
||||
// // 注册快捷键
|
||||
const shortCut = useShortCut()
|
||||
shortCut.register()
|
||||
const {register} = useShortCut()
|
||||
register()
|
||||
return (
|
||||
<CodeProvider>
|
||||
<main className="relative" ref={mainRef}>
|
||||
|
||||
Reference in New Issue
Block a user