5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-06 07:01:15 +08:00
wails/v3/internal/runtime/desktop/api/dialogs.js
2023-06-24 12:11:48 +10:00

75 lines
2.1 KiB
JavaScript

/*
_ __ _ __
| | / /___ _(_) /____
| | /| / / __ `/ / / ___/
| |/ |/ / /_/ / / (__ )
|__/|__/\__,_/_/_/____/
The electron alternative for Go
(c) Lea Anthony 2019-present
*/
/* jshint esversion: 9 */
/**
* @typedef {import("./types").MessageDialogOptions} MessageDialogOptions
* @typedef {import("./types").OpenDialogOptions} OpenDialogOptions
* @typedef {import("./types").SaveDialogOptions} SaveDialogOptions
*/
/**
* The Dialog API provides methods to interact with system dialogs.
*/
export const Dialog = {
/**
* Shows an info dialog
* @param {MessageDialogOptions} options - options for the dialog
* @returns {Promise<string>}
*/
Info: (options) => {
return wails.Dialog.Info(options);
},
/**
* Shows a warning dialog
* @param {MessageDialogOptions} options - options for the dialog
* @returns {Promise<string>}
*/
Warning: (options) => {
return wails.Dialog.Warning(options);
},
/**
* Shows an error dialog
* @param {MessageDialogOptions} options - options for the dialog
* @returns {Promise<string>}
*/
Error: (options) => {
return wails.Dialog.Error(options);
},
/**
* Shows a question dialog
* @param {MessageDialogOptions} options - options for the dialog
* @returns {Promise<string>}
*/
Question: (options) => {
return wails.Dialog.Question(options);
},
/**
* Shows a file open dialog and returns the files selected by the user.
* A blank string indicates that the dialog was cancelled.
* @param {OpenDialogOptions} options - options for the dialog
* @returns {Promise<string[]>|Promise<string>}
*/
OpenFile: (options) => {
return wails.Dialog.OpenFile(options);
},
/**
* Shows a file save dialog and returns the filename given by the user.
* A blank string indicates that the dialog was cancelled.
* @param {SaveDialogOptions} options - options for the dialog
* @returns {Promise<string>}
*/
SaveFile: (options) => {
return wails.Dialog.SaveFile(options);
},
};