本文整理匯總了TypeScript中electron.ipcMain.on方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ipcMain.on方法的具體用法?TypeScript ipcMain.on怎麽用?TypeScript ipcMain.on使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.ipcMain
的用法示例。
在下文中一共展示了ipcMain.on方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: BrowserWindow
export = (mainWindow) => {
let newFileWindow: Electron.BrowserWindow;
ipcMain.on('new-file', () => {
newFileWindow = new BrowserWindow({
width: 500,
height: 300,
modal: true,
parent: mainWindow,
minimizable: false,
resizable: false,
show: false
});
newFileWindow.loadURL(`file://${__dirname}/../../resources/views/newFile.html`);
newFileWindow.setMenu(null);
newFileWindow.on('ready-to-show', () => {
newFileWindow.show();
});
newFileWindow.on('closed', function () {
newFileWindow = null;
});
});
// Close the file window when the 'OK' button is pressed
ipcMain.on('new-file-create', (event, settings) => {
mainWindow.webContents.send('new-file', settings);
if (newFileWindow) {
newFileWindow.close();
}
});
}
示例2: createWindow
function createWindow() {
mainWindow = new BrowserWindow({height: 650, width: 900, show: debug});
if (debug) {
mainWindow.webContents.openDevTools();
}
mainWindow.loadURL(`file://${__dirname}/index.html`);
if (process.platform === 'darwin') {
Menu.setApplicationMenu(createMenu());
} else {
mainWindow.setMenu(createMenu());
}
ipcMain.once('+main:angular-up', () => {
if (debug) {
mainWindow.webContents.send('+view:debug-enabled');
}
if (startFile) {
openScheduleFromFile(startFile);
}
mainWindow.show();
});
ipcMain.on('+main:new-schedule', () => {
createNewSchedule();
});
ipcMain.on('+main:open-schedule', () => {
openScheduleFileDialog();
});
mainWindow.on('closed', () => {
mainWindow = null;
app.quit();
});
};
示例3: constructor
constructor() {
if (PresentationWindow.instance) throw new Error('must use the getInstance.');
electron.ipcMain.on(EVENTS.PRESENTATION_WINDOW.RENDERER.REQUEST_START_PRESENTATION, this.hanldRequestStartPresentation.bind( this ) );
electron.ipcMain.on(EVENTS.PRESENTATION_WINDOW.RENDERER.REQUEST_MESSAGE, (ev) => {
ev.returnValue = this.text;
});
};
示例4: openWin
function openWin(serverConf?:any) {
ipcMain.on('open-devtool', (event:any, status:any) => {
win.toggleDevTools({mode: 'detach'});
});
ipcMain.on('devWatch', (event:any, arg:any) => {
sender = event.sender;
devWatch();
});
win = new BrowserWindow({
width: 950, height: 540,
// width: 500, height: 540,
resizable: false,
frame: true,
autoHideMenuBar: false,
webaudio: false
});
// win.setMenu(null);
win.setMenuBarVisibility(false);
// win.loadURL('http://127.0.0.1');
if (isDev)
win.loadURL(`file://${__dirname}app/reload.html`);
else
win.loadURL(`file:///resources/app/reload.html`);
// win.loadURL(`file:///app/reload.html`);
win.on('closed', function () {
win = null;
});
//todo print
// http://electron.atom.io/docs/api/web-contents/
}
示例5: ready
public ready(): void {
ipcMain.on('app:reloadWindow', () => {
this.window.reload();
});
ipcMain.on('app:toggleDevTools', () => {
this.window.webContents.openDevTools();
});
}
示例6: wakeup
wakeup(sender: Electron.WebContents) {
this.sender = sender;
ipc.on('shiba:notify-path', (_: any, new_path: string) => {
this.setWatchingPath(new_path);
});
ipc.on('shiba:request-path', () => {
this.sender.send('shiba:return-path', this.watching_path);
});
this.linter = new Linter(this.sender, this.config.linter, this.config.lint_options);
}
示例7: constructor
constructor() {
this.windows = [];
Electron.ipcMain.on('createCheckoutWindow', (event, args) => {
this.createCheckoutWindow(args.payload, args.settings, args.serviceUrl);
});
Electron.ipcMain.on('getCheckoutState', (event, args) => {
let state = event.sender['checkoutState'];
event.returnValue = state;
});
}
示例8: bindListeners
public static bindListeners():void {
ipcMain.on("open-input-directory-dialog", (event: Electron.IpcMessageEvent) => {
dialog.showOpenDialog({
properties: ["openDirectory"]
}, function (dirs:string[]) {
if (dirs) {
event.sender.send("selected-input-directory", dirs[0]);
}
});
}
);
ipcMain.on("open-output-directory-dialog", (event: Electron.IpcMessageEvent) => {
dialog.showOpenDialog({
properties: ["openDirectory"]
}, function (dirs:string[]) {
if (dirs) {
event.sender.send("selected-output-directory", dirs[0]);
}
});
}
);
ipcMain.on("restart", () => {
autoUpdater.quitAndInstall();
});
ipcMain.on("save-languages", (event: Electron.IpcMessageEvent, languages: any) => {
console.log("Saving languages");
var folder = app.getPath("userData");
var file = join(folder, "languages.json");
writeFile(file, JSON.stringify(languages), {encoding: "utf8"}, function(err) {
err && console.error(err);
console.log("Saved languages.");
});
});
ipcMain.on("get-languages", (event: Electron.IpcMessageEvent) => {
var folder = app.getPath("userData");
var file = join(folder, "languages.json");
readFile(file, "utf8", function(err, data) {
if(err) {
event.sender.send("got-languages", "{}");
return console.error(err);
}
event.sender.send("got-languages", JSON.parse(data));
});
});
}
示例9:
export const runAutoUpdaterService = (window: BrowserWindow) => {
autoUpdater.on('update-downloaded', ({ version }) => {
window.webContents.send(UPDATE_AVAILABLE, version);
});
ipcMain.on(UPDATE_RESTART_AND_INSTALL, () => {
autoUpdater.quitAndInstall();
});
ipcMain.on(UPDATE_CHECK, () => {
if (process.env.ENV !== 'dev') {
autoUpdater.checkForUpdates();
}
});
};
示例10:
const checkForUpdate = () => {
if (EnvironmentUtil.platform.IS_WINDOWS) {
Squirrel.handleSquirrelEvent(isFirstInstance);
ipcMain.on(EVENT_TYPE.WRAPPER.UPDATE, () => Squirrel.installUpdate());
}
};