add --disable-model-switch
This commit is contained in:
@@ -75,6 +75,12 @@ export default async function inpaint(
|
||||
}
|
||||
}
|
||||
|
||||
export function getIsDisableModelSwitch() {
|
||||
return fetch(`${API_ENDPOINT}/is_disable_model_switch`, {
|
||||
method: 'GET',
|
||||
})
|
||||
}
|
||||
|
||||
export function switchModel(name: string) {
|
||||
const fd = new FormData()
|
||||
fd.append('name', name)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import React, { ReactNode } from 'react'
|
||||
import React, { ReactNode, useEffect, useState } from 'react'
|
||||
import { useRecoilState } from 'recoil'
|
||||
import { getIsDisableModelSwitch } from '../../adapters/inpainting'
|
||||
import { AIModel, CV2Flag, SDSampler, settingState } from '../../store/Atoms'
|
||||
import Selector from '../shared/Selector'
|
||||
import { Switch, SwitchThumb } from '../shared/Switch'
|
||||
@@ -10,6 +11,18 @@ import SettingBlock from './SettingBlock'
|
||||
|
||||
function ModelSettingBlock() {
|
||||
const [setting, setSettingState] = useRecoilState(settingState)
|
||||
const [isDisableModelSwitch, setIsDisableModelSwitch] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
const fetchData = async () => {
|
||||
const isDisable: string = await getIsDisableModelSwitch().then(res =>
|
||||
res.text()
|
||||
)
|
||||
setIsDisableModelSwitch(isDisable === 'true')
|
||||
}
|
||||
|
||||
fetchData()
|
||||
}, [])
|
||||
|
||||
const onModelChange = (value: AIModel) => {
|
||||
setSettingState(old => {
|
||||
@@ -250,6 +263,7 @@ function ModelSettingBlock() {
|
||||
value={setting.model as string}
|
||||
options={Object.values(AIModel)}
|
||||
onChange={val => onModelChange(val as AIModel)}
|
||||
disabled={isDisableModelSwitch}
|
||||
/>
|
||||
}
|
||||
optionDesc={renderOptionDesc()}
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
// &:focus-visible {
|
||||
// border-color: var(--yellow-accent);
|
||||
// }
|
||||
|
||||
&:disabled {
|
||||
color: var(--border-color);
|
||||
border-color: var(--border-color);
|
||||
}
|
||||
}
|
||||
|
||||
.select-content {
|
||||
|
||||
@@ -15,6 +15,7 @@ interface Props {
|
||||
chevronDirection?: SelectorChevronDirection
|
||||
autoFocusAfterClose?: boolean
|
||||
onChange: (value: string) => void
|
||||
disabled?: boolean
|
||||
}
|
||||
|
||||
const Selector = (props: Props) => {
|
||||
@@ -25,6 +26,7 @@ const Selector = (props: Props) => {
|
||||
options,
|
||||
autoFocusAfterClose,
|
||||
onChange,
|
||||
disabled,
|
||||
} = props
|
||||
|
||||
const contentRef = useRef<HTMLButtonElement>(null)
|
||||
@@ -52,6 +54,7 @@ const Selector = (props: Props) => {
|
||||
style={{ width }}
|
||||
ref={contentRef}
|
||||
onKeyDown={e => e.preventDefault()}
|
||||
disabled={disabled}
|
||||
>
|
||||
<Select.Value />
|
||||
<Select.Icon>
|
||||
@@ -78,6 +81,7 @@ const Selector = (props: Props) => {
|
||||
const selectorDefaultProps = {
|
||||
chevronDirection: 'down',
|
||||
autoFocusAfterClose: true,
|
||||
disabled: false,
|
||||
}
|
||||
|
||||
Selector.defaultProps = selectorDefaultProps
|
||||
|
||||
Reference in New Issue
Block a user