메인 콘텐츠로 건너뛰기
대화 API는 데스크톱 및 웹 환경에서 일관되게 작동하는 표준화된 대화를 제공합니다. 확장 프로그램 작성자는 프롬프트 및 확인 메서드를 가장 유용하게 사용할 수 있습니다.

기본 사용법

프롬프트 대화

// 프롬프트 대화 표시
app.extensionManager.dialog.prompt({
  title: "사용자 입력",
  message: "이름을 입력해 주세요:",
  defaultValue: "사용자"
}).then(result => {
  if (result !== null) {
    console.log(`입력: ${result}`);
  }
});

확인 대화

// 확인 대화 표시
app.extensionManager.dialog.confirm({
  title: "작업 확인",
  message: "계속하시겠습니까?",
  type: "default"
}).then(result => {
  console.log(result ? "사용자가 확인함" : "사용자가 취소함");
});

API 참조

프롬프트

app.extensionManager.dialog.prompt({
  title: string,             // 대화 제목
  message: string,           // 표시할 메시지/질문
  defaultValue?: string      // 입력란의 초기 값 (옵션)
}).then((result: string | null) => {
  // result는 입력한 텍스트이며, 취소 시 null입니다
});

확인

app.extensionManager.dialog.confirm({
  title: string,             // 대화 제목
  message: string,           // 표시할 메시지
  type?: "default" | "overwrite" | "delete" | "dirtyClose" | "reinstall", // 대화 유형 (옵션)
  itemList?: string[],       // 표시할 항목 목록 (옵션)
  hint?: string              // 표시할 힌트 텍스트 (옵션)
}).then((result: boolean | null) => {
  // result는 확인 시 true, 거부 시 false, 취소 시 null입니다
});
ComfyUI에서 사용 가능한 기타 특수 대화에 대해서는 확장 프로그램 작성자가 소스 코드의 dialogService.ts 파일을 참고할 수 있습니다.