electron dialog模块的showMessageBox添加checkBox问题
我想要用electron的showMessagebox实现下面这个图的不再提示选择的功能:
然后查询electron的官方文档的dialog,有这样的说明:
于是按照上面的说明在option
配置了checkboxLabel
,但是没有任何效果,然后按ctrl查看源代码,发现是这样的:
showMessageBox(browserWindow: BrowserWindow, options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
/**
* Shows a message box. It will block until the message box is closed.
* @param callback If supplied, the API call will be asynchronous.
* @returns The index of the clicked button.
*/
showMessageBox(options: ShowMessageBoxOptions, callback?: (response: number) => void): number;
/**
* Displays a modal dialog that shows an error message.
*
* This API can be called safely before the ready event the app module emits,
* it is usually used to report errors in early stage of startup.
* If called before the app readyevent on Linux, the message will be emitted to stderr,
* and no GUI dialog will appear.
*/
再按ctrl查看,发现是这样的:
interface ShowMessageBoxOptions {
/**
* On Windows, "question" displays the same icon as "info", unless you set an icon using the "icon" option.
*/
type?: 'none' | 'info' | 'error' | 'question' | 'warning';
/**
* Texts for buttons. On Windows, an empty array will result in one button labeled "OK".
*/
buttons?: string[];
/**
* Index of the button in the buttons array which will be selected by default when the message box opens.
*/
defaultId?: number;
/**
* Title of the message box (some platforms will not show it).
*/
title?: string;
/**
* Contents of the message box.
*/
message?: string;
/**
* Extra information of the message.
*/
detail?: string;
icon?: NativeImage;
/**
* The value will be returned when user cancels the dialog instead of clicking the buttons of the dialog.
* By default it is the index of the buttons that have "cancel" or "no" as label,
* or 0 if there is no such buttons. On macOS and Windows the index of "Cancel" button
* will always be used as cancelId, not matter whether it is already specified.
*/
cancelId?: number;
/**
* On Windows Electron will try to figure out which one of the buttons are common buttons
* (like "Cancel" or "Yes"), and show the others as command links in the dialog.
* This can make the dialog appear in the style of modern Windows apps.
* If you don’t like this behavior, you can set noLink to true.
*/
noLink?: boolean;
}
上面的属性根本就没有checkboxLabel(跟官方文档不一样?),我的package.json的electron的版本是1.6.2,不知道是不是版本的问题,如果有人知道的话,望告知此问题的解决方法?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在官文FAQ找了下,还真是版本的问题...,因为我用的是electron-quick-start,里面的package.json的electron是^1.6.2的,而官网checkboxLabel的版本是^1.6.8...