From 49806757303c9960664cab267b6a975550a462b0 Mon Sep 17 00:00:00 2001 From: Qing Date: Sat, 8 Oct 2022 13:30:35 +0800 Subject: [PATCH] remove lading page --- lama_cleaner/app/src/App.tsx | 2 +- .../app/src/components/Editor/Editor.tsx | 50 +++++++++++++------ .../app/src/components/Header/Header.tsx | 2 +- lama_cleaner/app/src/components/Workspace.tsx | 8 +-- lama_cleaner/app/src/utils.ts | 5 +- 5 files changed, 44 insertions(+), 23 deletions(-) diff --git a/lama_cleaner/app/src/App.tsx b/lama_cleaner/app/src/App.tsx index 198f689..445f2fb 100644 --- a/lama_cleaner/app/src/App.tsx +++ b/lama_cleaner/app/src/App.tsx @@ -123,7 +123,7 @@ function App() { return (
- {file ? : } +
) } diff --git a/lama_cleaner/app/src/components/Editor/Editor.tsx b/lama_cleaner/app/src/components/Editor/Editor.tsx index 2d62915..780e84a 100644 --- a/lama_cleaner/app/src/components/Editor/Editor.tsx +++ b/lama_cleaner/app/src/components/Editor/Editor.tsx @@ -33,6 +33,7 @@ import { } from '../../utils' import { croperState, + fileState, isInpaintingState, isSDState, propmtState, @@ -44,14 +45,11 @@ import { import useHotKey from '../../hooks/useHotkey' import Croper from '../Croper/Croper' import emitter, { EVENT_PROMPT } from '../../event' +import FileSelect from '../FileSelect/FileSelect' const TOOLBAR_SIZE = 200 const BRUSH_COLOR = '#ffcc00bb' -interface EditorProps { - file: File -} - interface Line { size?: number pts: { x: number; y: number }[] @@ -85,8 +83,8 @@ function mouseXY(ev: SyntheticEvent) { return { x: mouseEvent.offsetX, y: mouseEvent.offsetY } } -export default function Editor(props: EditorProps) { - const { file } = props +export default function Editor() { + const [file, setFile] = useRecoilState(fileState) const promptVal = useRecoilValue(propmtState) const settings = useRecoilValue(settingState) const [seedVal, setSeed] = useRecoilState(seedState) @@ -186,6 +184,9 @@ export default function Editor(props: EditorProps) { const runInpainting = useCallback( async (prompt?: string, useLastLineGroup?: boolean) => { + if (file === undefined) { + return + } // useLastLineGroup 的影响 // 1. 使用上一次的 mask // 2. 结果替换当前 render @@ -781,6 +782,9 @@ export default function Editor(props: EditorProps) { ) function download() { + if (file === undefined) { + return + } const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1') const curRender = renders[renders.length - 1] downloadImage(curRender.currentSrc, name) @@ -918,13 +922,20 @@ export default function Editor(props: EditorProps) { } } - return ( -