only call keepGUIAlive when run as gui

This commit is contained in:
Qing
2022-11-16 17:59:39 +08:00
parent 51daa8d02e
commit 30e205a5f8
3 changed files with 24 additions and 3 deletions

View File

@@ -9,6 +9,7 @@ import { fileState, toastState } from './store/Atoms'
import { keepGUIAlive } from './utils'
import Header from './components/Header/Header'
import useHotKey from './hooks/useHotkey'
import { isDesktop } from './adapters/inpainting'
const SUPPORTED_FILE_TYPE = [
'image/jpeg',
@@ -18,9 +19,6 @@ const SUPPORTED_FILE_TYPE = [
'image/tiff',
]
// Keeping GUI Window Open
keepGUIAlive()
function App() {
const [file, setFile] = useRecoilState(fileState)
const [theme, setTheme] = useRecoilState(themeState)
@@ -34,6 +32,17 @@ function App() {
setFile(userInputImage)
}, [userInputImage, setFile])
// Keeping GUI Window Open
useEffect(() => {
const fetchData = async () => {
const isRunDesktop = await isDesktop().then(res => res.text())
if (isRunDesktop === 'True') {
keepGUIAlive()
}
}
fetchData()
}, [])
// Dark Mode Hotkey
useHotKey(
'shift+d',

View File

@@ -102,6 +102,12 @@ export function currentModel() {
})
}
export function isDesktop() {
return fetch(`${API_ENDPOINT}/is_desktop`, {
method: 'GET',
})
}
export function modelDownloaded(name: string) {
return fetch(`${API_ENDPOINT}/model_downloaded/${name}`, {
method: 'GET',