make plugin work

This commit is contained in:
Qing
2023-03-25 09:53:22 +08:00
parent 996a264797
commit 6e54f77ed6
16 changed files with 528 additions and 284 deletions

View File

@@ -52,6 +52,8 @@ interface AppState {
gifImage: HTMLImageElement | undefined
brushSize: number
isControlNet: boolean
plugins: string[]
isPluginRunning: boolean
}
export const appState = atom<AppState>({
@@ -72,6 +74,8 @@ export const appState = atom<AppState>({
gifImage: undefined,
brushSize: 40,
isControlNet: false,
plugins: [],
isPluginRunning: false,
},
})
@@ -97,6 +101,36 @@ export const isInpaintingState = selector({
},
})
export const isPluginRunningState = selector({
key: 'isPluginRunningState',
get: ({ get }) => {
const app = get(appState)
return app.isPluginRunning
},
set: ({ get, set }, newValue: any) => {
const app = get(appState)
set(appState, { ...app, isPluginRunning: newValue })
},
})
export const serverConfigState = selector({
key: 'serverConfigState',
get: ({ get }) => {
const app = get(appState)
return {
isControlNet: app.isControlNet,
isDisableModelSwitchState: app.isDisableModelSwitch,
isEnableAutoSaving: app.isEnableAutoSaving,
enableFileManager: app.enableFileManager,
plugins: app.plugins,
}
},
set: ({ get, set }, newValue: any) => {
const app = get(appState)
set(appState, { ...app, ...newValue })
},
})
export const brushSizeState = selector({
key: 'brushSizeState',
get: ({ get }) => {
@@ -217,6 +251,16 @@ export const isInteractiveSegRunningState = selector({
},
})
export const isProcessingState = selector({
key: 'isProcessingState',
get: ({ get }) => {
const app = get(appState)
return (
app.isInteractiveSegRunning || app.isPluginRunning || app.isInpainting
)
},
})
export const interactiveSegClicksState = selector({
key: 'interactiveSegClicksState',
get: ({ get }) => {