gpt4 book ai didi

javascript - 如何使用Electron.js彼此相邻显示自定义Windows消息框按钮

转载 作者:行者123 更新时间:2023-12-03 12:32:39 25 4
gpt4 key购买 nike

我正在尝试使用Electron.js对话框方法showMessageBoxSync创建一个消息框。我希望按钮为“取消”和“覆盖并继续”。我希望它的显示方式与按钮为“取消”和“确定”时的框显示方式相同。
当按钮为“取消”和“确定”时,按钮并排显示:
Windows message box with OK and Cancel buttons side by side
但是,当我尝试将按钮设置为“取消”和“覆盖并继续”时,消息框显示为不同:
Windows message box with Overwrite and Continue button displaying in a different part of the box to the Cancel button
是否可以将“覆盖并继续”按钮设置为与“确定”按钮相同的显示方式?
我在消息框中的代码是:

const userSelection = dialog.showMessageBoxSync(mainWindow, {
type: 'warning',
title: 'User data already exists in this location',
message: 'User data for the App already exists in this location. Do you want to overwrite it?',
buttons: ['Cancel', 'Overwrite and Continue'],
defaultId: 0,
cancelId: 0
})

最佳答案

您必须使用docs中描述的noLink属性:

noLink Boolean (optional) - 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: true添加到您的options对象。

关于javascript - 如何使用Electron.js彼此相邻显示自定义Windows消息框按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64737997/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com