This commit is contained in:
Qing
2023-11-23 16:28:47 +08:00
parent 7463a599a9
commit 43433c50eb
21 changed files with 776 additions and 524 deletions

View File

@@ -1,22 +0,0 @@
import { Options, useHotkeys } from "react-hotkeys-hook"
import { useRecoilValue } from "recoil"
import { appState } from "@/lib/store"
const useHotKey = (
keys: string,
callback: any,
options?: Options,
deps?: any[]
) => {
const app = useRecoilValue(appState)
const ref = useHotkeys(
keys,
callback,
{ ...options, enabled: !app.disableShortCuts },
deps
)
return ref
}
export default useHotKey

View File

@@ -1,11 +1,11 @@
import { useEffect, useState } from "react"
function useImage(file?: File): [HTMLImageElement, boolean] {
function useImage(file: File | null): [HTMLImageElement, boolean] {
const [image] = useState(new Image())
const [isLoaded, setIsLoaded] = useState(false)
useEffect(() => {
if (file === undefined) {
if (!file) {
return
}
image.onload = () => {

View File

@@ -2,7 +2,7 @@ import { API_ENDPOINT } from "@/lib/api"
import { useCallback, useEffect, useState } from "react"
export default function useInputImage() {
const [inputImage, setInputImage] = useState<File>()
const [inputImage, setInputImage] = useState<File | null>(null)
const fetchInputImage = useCallback(() => {
const headers = new Headers()