[Refactor] improve type safety in dialog service (#2283)

This commit is contained in:
bymyself
2025-01-18 13:46:57 -07:00
committed by GitHub
parent 1a4e77a3ab
commit 816574e0ab
2 changed files with 16 additions and 18 deletions

View File

@@ -942,7 +942,7 @@ export class ComfyApp {
api.addEventListener('execution_error', ({ detail }) => {
this.lastExecutionError = detail
useDialogService().showExecutionErrorDialog(detail)
useDialogService().showExecutionErrorDialog({ error: detail })
this.canvas.draw(true, true)
})

View File

@@ -8,8 +8,6 @@ import SettingDialogHeader from '@/components/dialog/header/SettingDialogHeader.
import TemplateWorkflowsContent from '@/components/templates/TemplateWorkflowsContent.vue'
import { t } from '@/i18n'
import { type ShowDialogOptions, useDialogStore } from '@/stores/dialogStore'
import type { ExecutionErrorWsMessage } from '@/types/apiTypes'
import type { MissingNodeType } from '@/types/comfy'
export type ConfirmationDialogType =
| 'default'
@@ -20,10 +18,9 @@ export type ConfirmationDialogType =
export const useDialogService = () => {
const dialogStore = useDialogStore()
function showLoadWorkflowWarning(props: {
missingNodeTypes: MissingNodeType[]
[key: string]: any
}) {
function showLoadWorkflowWarning(
props: InstanceType<typeof LoadWorkflowWarning>['$props']
) {
dialogStore.showDialog({
key: 'global-load-workflow-warning',
component: LoadWorkflowWarning,
@@ -31,11 +28,9 @@ export const useDialogService = () => {
})
}
function showMissingModelsWarning(props: {
missingModels: any[]
paths: Record<string, string[]>
[key: string]: any
}) {
function showMissingModelsWarning(
props: InstanceType<typeof MissingModelsWarning>['$props']
) {
dialogStore.showDialog({
key: 'global-missing-models-warning',
component: MissingModelsWarning,
@@ -67,21 +62,24 @@ export const useDialogService = () => {
})
}
function showExecutionErrorDialog(error: ExecutionErrorWsMessage) {
function showExecutionErrorDialog(
props: InstanceType<typeof ExecutionErrorDialogContent>['$props']
) {
dialogStore.showDialog({
key: 'global-execution-error',
component: ExecutionErrorDialogContent,
props: {
error
}
props
})
}
function showTemplateWorkflowsDialog() {
function showTemplateWorkflowsDialog(
props: InstanceType<typeof TemplateWorkflowsContent>['$props'] = {}
) {
dialogStore.showDialog({
key: 'global-template-workflows',
title: t('templateWorkflows.title'),
component: TemplateWorkflowsContent
component: TemplateWorkflowsContent,
props
})
}