当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript ipcMain.once方法代码示例

本文整理汇总了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();
         }
       });
     });
   });
 });
开发者ID:molisani,项目名称:fcp-schedule,代码行数:32,代码来源:electron-main.ts

示例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);
    });
  });
开发者ID:laquereric,项目名称:wexond,代码行数:7,代码来源:extensions.ts

示例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;
};
开发者ID:laquereric,项目名称:wexond,代码行数:35,代码来源:web-request.ts

示例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();
  });
};
开发者ID:molisani,项目名称:fcp-schedule,代码行数:31,代码来源:electron-main.ts

示例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()
    })
  })
开发者ID:ilmaria,项目名称:laskutus-electron,代码行数:16,代码来源:main.ts

示例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)
  })
})
开发者ID:ilmaria,项目名称:laskutus-electron,代码行数:12,代码来源:main.ts

示例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 });
		});
开发者ID:carhero,项目名称:vscode,代码行数:23,代码来源:lifecycle.ts

示例8: Promise

 return new Promise((resolve) => {
   electron.ipcMain.once(ELECTRON_READY, (ev: any) => {
     ev.returnValue = 'ok';
     resolve();
   });
 });
开发者ID:micaelgallego,项目名称:electron-node-java,代码行数:6,代码来源:electron_app.ts


注:本文中的electron.ipcMain.once方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。