import React, { FormEvent } from 'react' import { useRecoilState, useRecoilValue } from 'recoil' import * as PopoverPrimitive from '@radix-ui/react-popover' import { useToggle } from 'react-use' import { isControlNetState, isInpaintingState, negativePropmtState, propmtState, SDSampler, settingState, } from '../../store/Atoms' import NumberInputSetting from '../Settings/NumberInputSetting' import SettingBlock from '../Settings/SettingBlock' import Selector from '../shared/Selector' import { Switch, SwitchThumb } from '../shared/Switch' import TextAreaInput from '../shared/Textarea' import emitter, { EVENT_PROMPT } from '../../event' import ImageResizeScale from './ImageResizeScale' const INPUT_WIDTH = 30 const SidePanel = () => { const [open, toggleOpen] = useToggle(true) const [setting, setSettingState] = useRecoilState(settingState) const [negativePrompt, setNegativePrompt] = useRecoilState(negativePropmtState) const isInpainting = useRecoilValue(isInpaintingState) const prompt = useRecoilValue(propmtState) const isControlNet = useRecoilValue(isControlNetState) const handleOnInput = (evt: FormEvent) => { evt.preventDefault() evt.stopPropagation() const target = evt.target as HTMLTextAreaElement setNegativePrompt(target.value) } const onKeyUp = (e: React.KeyboardEvent) => { if ( e.key === 'Enter' && (e.ctrlKey || e.metaKey) && prompt.length !== 0 && !isInpainting ) { emitter.emit(EVENT_PROMPT) } } return (
toggleOpen()} > Config { setSettingState(old => { return { ...old, showCroper: value } }) }} > } /> {/* { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, sdNumSamples: val } }) }} /> */} { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, sdSteps: val } }) }} /> { const val = value.length === 0 ? 0 : parseFloat(value) setSettingState(old => { return { ...old, sdGuidanceScale: val } }) }} /> {isControlNet && ( { const val = value.length === 0 ? 0 : parseFloat(value) setSettingState(old => { return { ...old, controlnetConditioningScale: val } }) }} /> )} { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, sdMaskBlur: val } }) }} /> { setSettingState(old => { return { ...old, sdMatchHistograms: value } }) }} > } /> { const sampler = val as SDSampler setSettingState(old => { return { ...old, sdSampler: sampler } }) }} /> } /> {/* 每次会从服务器返回更新该值 */} { const val = value.length === 0 ? 0 : parseInt(value, 10) setSettingState(old => { return { ...old, sdSeed: val } }) }} /> { setSettingState(old => { return { ...old, sdSeedFixed: value } }) }} style={{ marginLeft: '8px' }} >
} /> } /> ) } export default SidePanel