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:
Chenlei Hu
2024-10-04 15:33:27 -04:00
committed by GitHub
parent 39d68bcdc4
commit ebc71b0e46
12 changed files with 148 additions and 76 deletions

View File

@@ -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)
}
}
})
})
}