fix is_disable_switch_model
This commit is contained in:
@@ -5,11 +5,11 @@ import useInputImage from './hooks/useInputImage'
|
|||||||
import LandingPage from './components/LandingPage/LandingPage'
|
import LandingPage from './components/LandingPage/LandingPage'
|
||||||
import { themeState } from './components/Header/ThemeChanger'
|
import { themeState } from './components/Header/ThemeChanger'
|
||||||
import Workspace from './components/Workspace'
|
import Workspace from './components/Workspace'
|
||||||
import { fileState, toastState } from './store/Atoms'
|
import { fileState, isDisableModelSwitchState, toastState } from './store/Atoms'
|
||||||
import { keepGUIAlive } from './utils'
|
import { keepGUIAlive } from './utils'
|
||||||
import Header from './components/Header/Header'
|
import Header from './components/Header/Header'
|
||||||
import useHotKey from './hooks/useHotkey'
|
import useHotKey from './hooks/useHotkey'
|
||||||
import { isDesktop } from './adapters/inpainting'
|
import { getIsDisableModelSwitch, isDesktop } from './adapters/inpainting'
|
||||||
|
|
||||||
const SUPPORTED_FILE_TYPE = [
|
const SUPPORTED_FILE_TYPE = [
|
||||||
'image/jpeg',
|
'image/jpeg',
|
||||||
@@ -24,8 +24,9 @@ function App() {
|
|||||||
const [theme, setTheme] = useRecoilState(themeState)
|
const [theme, setTheme] = useRecoilState(themeState)
|
||||||
const [toastVal, setToastState] = useRecoilState(toastState)
|
const [toastVal, setToastState] = useRecoilState(toastState)
|
||||||
const userInputImage = useInputImage()
|
const userInputImage = useInputImage()
|
||||||
const [openPasteImageAlertDialog, setOpenPasteImageAlertDialog] =
|
const [isDisableModelSwitch, setIsDisableModelSwitch] = useRecoilState(
|
||||||
useState(false)
|
isDisableModelSwitchState
|
||||||
|
)
|
||||||
|
|
||||||
// Set Input Image
|
// Set Input Image
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -43,6 +44,17 @@ function App() {
|
|||||||
fetchData()
|
fetchData()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const fetchData = async () => {
|
||||||
|
const isDisable: string = await getIsDisableModelSwitch().then(res =>
|
||||||
|
res.text()
|
||||||
|
)
|
||||||
|
setIsDisableModelSwitch(isDisable === 'true')
|
||||||
|
}
|
||||||
|
|
||||||
|
fetchData()
|
||||||
|
}, [])
|
||||||
|
|
||||||
// Dark Mode Hotkey
|
// Dark Mode Hotkey
|
||||||
useHotKey(
|
useHotKey(
|
||||||
'shift+d',
|
'shift+d',
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
import React, { ReactNode, useEffect, useState } from 'react'
|
import React, { ReactNode, useEffect, useState } from 'react'
|
||||||
import { useRecoilState } from 'recoil'
|
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||||
import { getIsDisableModelSwitch } from '../../adapters/inpainting'
|
import { getIsDisableModelSwitch } from '../../adapters/inpainting'
|
||||||
import { AIModel, CV2Flag, SDSampler, settingState } from '../../store/Atoms'
|
import {
|
||||||
|
AIModel,
|
||||||
|
CV2Flag,
|
||||||
|
isDisableModelSwitchState,
|
||||||
|
SDSampler,
|
||||||
|
settingState,
|
||||||
|
} from '../../store/Atoms'
|
||||||
import Selector from '../shared/Selector'
|
import Selector from '../shared/Selector'
|
||||||
import { Switch, SwitchThumb } from '../shared/Switch'
|
import { Switch, SwitchThumb } from '../shared/Switch'
|
||||||
import Tooltip from '../shared/Tooltip'
|
import Tooltip from '../shared/Tooltip'
|
||||||
@@ -11,18 +17,7 @@ import SettingBlock from './SettingBlock'
|
|||||||
|
|
||||||
function ModelSettingBlock() {
|
function ModelSettingBlock() {
|
||||||
const [setting, setSettingState] = useRecoilState(settingState)
|
const [setting, setSettingState] = useRecoilState(settingState)
|
||||||
const [isDisableModelSwitch, setIsDisableModelSwitch] = useState(false)
|
const isDisableModelSwitch = useRecoilValue(isDisableModelSwitchState)
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const fetchData = async () => {
|
|
||||||
const isDisable: string = await getIsDisableModelSwitch().then(res =>
|
|
||||||
res.text()
|
|
||||||
)
|
|
||||||
setIsDisableModelSwitch(isDisable === 'true')
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchData()
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const onModelChange = (value: AIModel) => {
|
const onModelChange = (value: AIModel) => {
|
||||||
setSettingState(old => {
|
setSettingState(old => {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export interface Rect {
|
|||||||
interface AppState {
|
interface AppState {
|
||||||
disableShortCuts: boolean
|
disableShortCuts: boolean
|
||||||
isInpainting: boolean
|
isInpainting: boolean
|
||||||
|
isDisableModelSwitch: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export const appState = atom<AppState>({
|
export const appState = atom<AppState>({
|
||||||
@@ -41,6 +42,7 @@ export const appState = atom<AppState>({
|
|||||||
default: {
|
default: {
|
||||||
disableShortCuts: false,
|
disableShortCuts: false,
|
||||||
isInpainting: false,
|
isInpainting: false,
|
||||||
|
isDisableModelSwitch: false,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -66,6 +68,18 @@ export const isInpaintingState = selector({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const isDisableModelSwitchState = selector({
|
||||||
|
key: 'isDisableModelSwitchState',
|
||||||
|
get: ({ get }) => {
|
||||||
|
const app = get(appState)
|
||||||
|
return app.isDisableModelSwitch
|
||||||
|
},
|
||||||
|
set: ({ get, set }, newValue: any) => {
|
||||||
|
const app = get(appState)
|
||||||
|
set(appState, { ...app, isDisableModelSwitch: newValue })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
export const croperState = atom<Rect>({
|
export const croperState = atom<Rect>({
|
||||||
key: 'croperState',
|
key: 'croperState',
|
||||||
default: {
|
default: {
|
||||||
|
|||||||
@@ -204,6 +204,9 @@ def get_is_desktop():
|
|||||||
|
|
||||||
@app.route("/model", methods=["POST"])
|
@app.route("/model", methods=["POST"])
|
||||||
def switch_model():
|
def switch_model():
|
||||||
|
if is_disable_model_switch:
|
||||||
|
return "Switch model is disabled", 400
|
||||||
|
|
||||||
new_name = request.form.get("name")
|
new_name = request.form.get("name")
|
||||||
if new_name == model.name:
|
if new_name == model.name:
|
||||||
return "Same model", 200
|
return "Same model", 200
|
||||||
|
|||||||
Reference in New Issue
Block a user