remove lading page
This commit is contained in:
parent
724b8c232d
commit
4980675730
@ -123,7 +123,7 @@ function App() {
|
|||||||
return (
|
return (
|
||||||
<div className="lama-cleaner">
|
<div className="lama-cleaner">
|
||||||
<Header />
|
<Header />
|
||||||
{file ? <Workspace file={file} key={workspaceId} /> : <LandingPage />}
|
<Workspace key={workspaceId} />
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import {
|
|||||||
} from '../../utils'
|
} from '../../utils'
|
||||||
import {
|
import {
|
||||||
croperState,
|
croperState,
|
||||||
|
fileState,
|
||||||
isInpaintingState,
|
isInpaintingState,
|
||||||
isSDState,
|
isSDState,
|
||||||
propmtState,
|
propmtState,
|
||||||
@ -44,14 +45,11 @@ import {
|
|||||||
import useHotKey from '../../hooks/useHotkey'
|
import useHotKey from '../../hooks/useHotkey'
|
||||||
import Croper from '../Croper/Croper'
|
import Croper from '../Croper/Croper'
|
||||||
import emitter, { EVENT_PROMPT } from '../../event'
|
import emitter, { EVENT_PROMPT } from '../../event'
|
||||||
|
import FileSelect from '../FileSelect/FileSelect'
|
||||||
|
|
||||||
const TOOLBAR_SIZE = 200
|
const TOOLBAR_SIZE = 200
|
||||||
const BRUSH_COLOR = '#ffcc00bb'
|
const BRUSH_COLOR = '#ffcc00bb'
|
||||||
|
|
||||||
interface EditorProps {
|
|
||||||
file: File
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Line {
|
interface Line {
|
||||||
size?: number
|
size?: number
|
||||||
pts: { x: number; y: number }[]
|
pts: { x: number; y: number }[]
|
||||||
@ -85,8 +83,8 @@ function mouseXY(ev: SyntheticEvent) {
|
|||||||
return { x: mouseEvent.offsetX, y: mouseEvent.offsetY }
|
return { x: mouseEvent.offsetX, y: mouseEvent.offsetY }
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Editor(props: EditorProps) {
|
export default function Editor() {
|
||||||
const { file } = props
|
const [file, setFile] = useRecoilState(fileState)
|
||||||
const promptVal = useRecoilValue(propmtState)
|
const promptVal = useRecoilValue(propmtState)
|
||||||
const settings = useRecoilValue(settingState)
|
const settings = useRecoilValue(settingState)
|
||||||
const [seedVal, setSeed] = useRecoilState(seedState)
|
const [seedVal, setSeed] = useRecoilState(seedState)
|
||||||
@ -186,6 +184,9 @@ export default function Editor(props: EditorProps) {
|
|||||||
|
|
||||||
const runInpainting = useCallback(
|
const runInpainting = useCallback(
|
||||||
async (prompt?: string, useLastLineGroup?: boolean) => {
|
async (prompt?: string, useLastLineGroup?: boolean) => {
|
||||||
|
if (file === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
// useLastLineGroup 的影响
|
// useLastLineGroup 的影响
|
||||||
// 1. 使用上一次的 mask
|
// 1. 使用上一次的 mask
|
||||||
// 2. 结果替换当前 render
|
// 2. 结果替换当前 render
|
||||||
@ -781,6 +782,9 @@ export default function Editor(props: EditorProps) {
|
|||||||
)
|
)
|
||||||
|
|
||||||
function download() {
|
function download() {
|
||||||
|
if (file === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1')
|
const name = file.name.replace(/(\.[\w\d_-]+)$/i, '_cleanup$1')
|
||||||
const curRender = renders[renders.length - 1]
|
const curRender = renders[renders.length - 1]
|
||||||
downloadImage(curRender.currentSrc, name)
|
downloadImage(curRender.currentSrc, name)
|
||||||
@ -918,13 +922,20 @@ export default function Editor(props: EditorProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
const renderFileSelect = () => {
|
||||||
<div
|
return (
|
||||||
className="editor-container"
|
<div className="landing-file-selector">
|
||||||
aria-hidden="true"
|
<FileSelect
|
||||||
onMouseMove={onMouseMove}
|
onSelection={async f => {
|
||||||
onMouseUp={onPointerUp}
|
setFile(f)
|
||||||
>
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const renderCanvas = () => {
|
||||||
|
return (
|
||||||
<TransformWrapper
|
<TransformWrapper
|
||||||
ref={r => {
|
ref={r => {
|
||||||
if (r) {
|
if (r) {
|
||||||
@ -1024,6 +1035,17 @@ export default function Editor(props: EditorProps) {
|
|||||||
)}
|
)}
|
||||||
</TransformComponent>
|
</TransformComponent>
|
||||||
</TransformWrapper>
|
</TransformWrapper>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="editor-container"
|
||||||
|
aria-hidden="true"
|
||||||
|
onMouseMove={onMouseMove}
|
||||||
|
onMouseUp={onPointerUp}
|
||||||
|
>
|
||||||
|
{file === undefined ? renderFileSelect() : renderCanvas()}
|
||||||
|
|
||||||
{showBrush && !isInpainting && !isPanning && (
|
{showBrush && !isInpainting && !isPanning && (
|
||||||
<div className="brush-shape" style={getBrushStyle(x, y)} />
|
<div className="brush-shape" style={getBrushStyle(x, y)} />
|
||||||
@ -1037,7 +1059,7 @@ export default function Editor(props: EditorProps) {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="editor-toolkit-panel">
|
<div className="editor-toolkit-panel">
|
||||||
{isSD ? (
|
{isSD || file === undefined ? (
|
||||||
<></>
|
<></>
|
||||||
) : (
|
) : (
|
||||||
<SizeSelector
|
<SizeSelector
|
||||||
|
@ -18,7 +18,7 @@ const Header = () => {
|
|||||||
const renderHeader = () => {
|
const renderHeader = () => {
|
||||||
return (
|
return (
|
||||||
<header>
|
<header>
|
||||||
<div style={{ visibility: file ? 'visible' : 'hidden' }}>
|
<div>
|
||||||
<label htmlFor={uploadElemId}>
|
<label htmlFor={uploadElemId}>
|
||||||
<Button icon={<UploadIcon />} style={{ border: 0 }}>
|
<Button icon={<UploadIcon />} style={{ border: 0 }}>
|
||||||
<input
|
<input
|
||||||
|
@ -12,11 +12,7 @@ import {
|
|||||||
} from '../adapters/inpainting'
|
} from '../adapters/inpainting'
|
||||||
import SidePanel from './SidePanel/SidePanel'
|
import SidePanel from './SidePanel/SidePanel'
|
||||||
|
|
||||||
interface WorkspaceProps {
|
const Workspace = () => {
|
||||||
file: File
|
|
||||||
}
|
|
||||||
|
|
||||||
const Workspace = ({ file }: WorkspaceProps) => {
|
|
||||||
const [settings, setSettingState] = useRecoilState(settingState)
|
const [settings, setSettingState] = useRecoilState(settingState)
|
||||||
const [toastVal, setToastState] = useRecoilState(toastState)
|
const [toastVal, setToastState] = useRecoilState(toastState)
|
||||||
const isSD = useRecoilValue(isSDState)
|
const isSD = useRecoilValue(isSDState)
|
||||||
@ -85,7 +81,7 @@ const Workspace = ({ file }: WorkspaceProps) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isSD ? <SidePanel /> : <></>}
|
{isSD ? <SidePanel /> : <></>}
|
||||||
<Editor file={file} />
|
<Editor />
|
||||||
<SettingModal onClose={onSettingClose} />
|
<SettingModal onClose={onSettingClose} />
|
||||||
<ShortcutsModal />
|
<ShortcutsModal />
|
||||||
<Toast
|
<Toast
|
||||||
|
@ -74,11 +74,14 @@ export function loadImage(image: HTMLImageElement, src: string) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useImage(file: File): [HTMLImageElement, boolean] {
|
export function useImage(file?: File): [HTMLImageElement, boolean] {
|
||||||
const [image] = useState(new Image())
|
const [image] = useState(new Image())
|
||||||
const [isLoaded, setIsLoaded] = useState(false)
|
const [isLoaded, setIsLoaded] = useState(false)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (file === undefined) {
|
||||||
|
return
|
||||||
|
}
|
||||||
image.onload = () => {
|
image.onload = () => {
|
||||||
setIsLoaded(true)
|
setIsLoaded(true)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user