當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。