mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-24 08:19:51 +00:00
Add PromptDialog to replace window.prompt (#1104)
* Save file prompt dialog * Don't download if dialog dismissed * refactor * style dialog * nit * Autofocus
This commit is contained in:
@@ -9,6 +9,7 @@ import SettingDialogHeader from '@/components/dialog/header/SettingDialogHeader.
|
||||
import type { ExecutionErrorWsMessage } from '@/types/apiTypes'
|
||||
import ExecutionErrorDialogContent from '@/components/dialog/content/ExecutionErrorDialogContent.vue'
|
||||
import TemplateWorkflowsContent from '@/components/templates/TemplateWorkflowsContent.vue'
|
||||
import PromptDialogContent from '@/components/dialog/content/PromptDialogContent.vue'
|
||||
import { i18n } from '@/i18n'
|
||||
|
||||
export function showLoadWorkflowWarning(props: {
|
||||
@@ -19,7 +20,10 @@ export function showLoadWorkflowWarning(props: {
|
||||
const dialogStore = useDialogStore()
|
||||
dialogStore.showDialog({
|
||||
component: LoadWorkflowWarning,
|
||||
props
|
||||
props,
|
||||
dialogComponentProps: {
|
||||
maximizable: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -31,7 +35,10 @@ export function showMissingModelsWarning(props: {
|
||||
const dialogStore = useDialogStore()
|
||||
dialogStore.showDialog({
|
||||
component: MissingModelsWarning,
|
||||
props
|
||||
props,
|
||||
dialogComponentProps: {
|
||||
maximizable: true
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -57,3 +64,34 @@ export function showTemplateWorkflowsDialog() {
|
||||
component: TemplateWorkflowsContent
|
||||
})
|
||||
}
|
||||
|
||||
export async function showPromptDialog({
|
||||
title,
|
||||
message,
|
||||
defaultValue = ''
|
||||
}: {
|
||||
title: string
|
||||
message: string
|
||||
defaultValue?: string
|
||||
}): Promise<string | null> {
|
||||
const dialogStore = useDialogStore()
|
||||
|
||||
return new Promise((resolve) => {
|
||||
dialogStore.showDialog({
|
||||
title,
|
||||
component: PromptDialogContent,
|
||||
props: {
|
||||
message,
|
||||
defaultValue,
|
||||
onConfirm: (value: string) => {
|
||||
resolve(value)
|
||||
}
|
||||
},
|
||||
dialogComponentProps: {
|
||||
onClose: () => {
|
||||
resolve(null)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user