【发布时间】:2021-07-26 23:46:40
【问题描述】:
我在电子中使用 react,我有一个删除按钮,提示确认消息。我注意到确认框的标题为“electron.exe”,如下所示。
这里是代码:
<td style={{textAlign:'center' }}><Link title="delete customer"><i className="material-icons" style={{ fontSize: "1.2em"}} title="Delete"
onClick={(event) => {const confirmBox = window.confirm("Do you really want to delete this contact?")
if (confirmBox === true) { handleDelete(event, record._id) }
}}> delete</i></Link></td>
main.js
const {app, BrowserWindow,Menu, shell} = require('electron')
const server = require('../../server.js')
const isDev = require('electron-is-dev')
process.env.NODE_ENV = "development"
const isMac = process.platform === "darwin" ? true : false
let mainWindow
function createMainWindow (){
mainWindow = new BrowserWindow({
width:1366,
height:768,
show: false,
backgroundColor:"#263238"
})
mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`)
mainWindow.once('ready-to-show', () => {
mainWindow.show();
mainWindow.focus();
});
mainWindow.webContents.on('new-window', function(event, url){
event.preventDefault();
shell.openExternal(url);
})
}
function createAboutWindow (){
aboutWindow = new BrowserWindow({
width:300,
height:300,
backgroundColor:"black"
})
aboutWindow.loadFile('http://localhost:3000/test')
}
app.on('ready', () => {
createMainWindow()
const mainMenu = Menu.buildFromTemplate(menu)
Menu.setApplicationMenu(mainMenu)
mainWindow.on('ready', () => mainWindow = null)
})
const menu = [
...(isMac ? [{
label: 'app.name',
submenu:[
{
label:'About',
click: createAboutWindow
}
]}]:[]),
{
role:'fileMenu'
},
...(!isMac ? [
{
label:'Help',
submenu:[
{
label:'About',
click: createAboutWindow
}
]
}
]:[]),
...(isDev ? [
{
label:'Developer',
submenu:[
{role:'reload'},
{role:'forcereload'},
{role:'separator'},
{role:'toggledevtools'},
]
}
]:[])
]
app.on('window-all-closed', function () {
if (isMac) app.quit()
})
app.whenReady().then(() => {
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createMainWindow()
})
})
如何更改确认框中的标题?提前非常感谢,非常感谢任何帮助。再次感谢。
【问题讨论】: