本文整理汇总了TypeScript中electron.ipcMain.once方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ipcMain.once方法的具体用法?TypeScript ipcMain.once怎么用?TypeScript ipcMain.once使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.ipcMain
的用法示例。
在下文中一共展示了ipcMain.once方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getCurrentSchedule
getCurrentSchedule((schedule) => {
let posterWindow = new BrowserWindow({width: 795, height: 800, show: debug});
if (debug) {
posterWindow.webContents.openDevTools();
}
posterWindow.setMenu(null);
posterWindow.loadURL(`file://${__dirname}/poster.html`);
ipcMain.once('+main:poster-angular-up', () => {
if (debug) {
posterWindow.webContents.send('+view:debug-enabled');
}
posterWindow.webContents.send('+view:open-schedule', schedule, month);
});
ipcMain.once('+main:poster-ready', () => {
posterWindow.webContents['_printToPDF'](posterPrintingSetting, (err, data) => {
if (err) throw err;
fs.writeFile(filename, data, (err) => {
if (err) throw err;
console.log('Write PDF successfully.');
dialog.showMessageBox({
type: 'info',
title: 'PDF Saved',
message: 'Poster rendered and saved to file.',
buttons: ['OK'],
});
if (!debug) {
posterWindow.close();
}
});
});
});
});
示例2: Promise
return new Promise((resolve: (a: any) => void) => {
window.webContents.send('get-tab-by-web-contents-id', webContentsId);
ipcMain.once('get-tab-by-web-contents-id', (e: any, tab: any) => {
resolve(tab);
});
});
示例3: makeId
const interceptRequest = (
eventName: string,
details: any,
callback: any = null,
): boolean => {
let isIntercepted = false;
if (Array.isArray(eventListeners[eventName])) {
for (const event of eventListeners[eventName]) {
if (!matchesFilter(event.filters, details.url)) continue;
const id = makeId(32);
if (callback) {
ipcMain.once(
`api-webRequest-response-${eventName}-${event.id}-${id}`,
(e: any, res: any) => {
callback(res);
},
);
}
const contents = webContents.fromId(event.webContentsId);
contents.send(
`api-webRequest-intercepted-${eventName}-${event.id}`,
details,
id,
);
isIntercepted = true;
}
}
return isIntercepted;
};
示例4: 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();
});
};
示例5: log
autoUpdater.addListener('update-downloaded', () => {
log('update downloaded')
const notificationWindow = new BrowserWindow(
{parent: mainWindow, width: 400, height: 600, modal: true})
notificationWindow.loadURL(
`file://${__dirname}/ui/update-notification.html`)
ipcMain.once('close-notification-window', () => {
notificationWindow.close()
})
ipcMain.once('quit-and-update', () => {
autoUpdater.quitAndInstall()
})
})
示例6: BrowserWindow
ipcMain.on('preview-invoice', (event, client, invoiceData) => {
const previewWindow = new BrowserWindow(
{parent: mainWindow, width: 800, height: 1000})
previewWindow.loadURL(
`file://${__dirname}/ui/preview-invoice.html`)
//previewWindow.webContents.openDevTools()
ipcMain.once('preview-invoice-ready', (event) => {
event.sender.send('invoice-data', client, invoiceData)
})
})
示例7: c
return new TPromise<boolean>((c) => {
let oneTimeEventToken = this.oneTimeListenerTokenGenerator++;
let oneTimeOkEvent = 'vscode:ok' + oneTimeEventToken;
let oneTimeCancelEvent = 'vscode:cancel' + oneTimeEventToken;
ipc.once(oneTimeOkEvent, () => {
c(false); // no veto
});
ipc.once(oneTimeCancelEvent, () => {
// Any cancellation also cancels a pending quit if present
if (this.pendingQuitPromiseComplete) {
this.pendingQuitPromiseComplete(true /* veto */);
delete this.pendingQuitPromiseComplete;
delete this.pendingQuitPromise;
}
c(true); // veto
});
vscodeWindow.send('vscode:beforeUnload', { okChannel: oneTimeOkEvent, cancelChannel: oneTimeCancelEvent });
});
示例8: Promise
return new Promise((resolve) => {
electron.ipcMain.once(ELECTRON_READY, (ev: any) => {
ev.returnValue = 'ok';
resolve();
});
});