我试图打开一个由Electron
API提供的对话框,点击UI中的按钮(使用react
)
这是我的代码
// @flow
import React, { Component, PropTypes } from 'react';
import { ipcRenderer, ipcMain, dialog } from 'electron'
ipcMain.on('open-information-dialog', function (event) {
const options = {
type: 'info',
title: 'Information',
message: "This is an information dialog. Isn't it nice?",
buttons: ['Yes', 'No']
}
dialog.showMessageBox(options, function (index) {
event.sender.send('information-dialog-selection', index)
})
})
export default class App extends Component {
static propTypes = {
children: PropTypes.element.isRequired
};
handleClick() {
console.log("test");
ipc.send('open-information-dialog');
}
render() {
return (
<div>
<button onClick={this.handleClick}>test</button>
{this.props.children}
</div>
);
}
}
我错过了什么吗?