當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ipcMain.on方法代碼示例

本文整理匯總了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();
        }
    });
}
開發者ID:TheColorRed,項目名稱:photo-editor,代碼行數:32,代碼來源:new.ts

示例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();
  });
};
開發者ID:molisani,項目名稱:fcp-schedule,代碼行數:31,代碼來源:electron-main.ts

示例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;
   });
 };
開發者ID:richardy2012,項目名稱:cafe-pitch,代碼行數:7,代碼來源:presentation_window.ts

示例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/
}
開發者ID:solpie,項目名稱:yqbe,代碼行數:34,代碼來源:main.ts

示例5: ready

	public ready(): void {
		ipcMain.on('app:reloadWindow', () => {
            this.window.reload();
        });

        ipcMain.on('app:toggleDevTools', () => {
            this.window.webContents.openDevTools();
        });
	}
開發者ID:f111fei,項目名稱:react-demo,代碼行數:9,代碼來源:ipc.ts

示例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);
 }
開發者ID:Sheshouzuo,項目名稱:Shiba,代碼行數:10,代碼來源:watcher.ts

示例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;
        });
    }
開發者ID:sarthakfx,項目名稱:BotFramework-Emulator,代碼行數:11,代碼來源:windowManager.ts

示例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));
            });
        });
    }
開發者ID:zlepper,項目名稱:go-modpack-packer,代碼行數:52,代碼來源:IpcHandlers.ts

示例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();
    }
  });
};
開發者ID:laquereric,項目名稱:wexond,代碼行數:15,代碼來源:auto-updater.ts

示例10:

const checkForUpdate = () => {
  if (EnvironmentUtil.platform.IS_WINDOWS) {
    Squirrel.handleSquirrelEvent(isFirstInstance);

    ipcMain.on(EVENT_TYPE.WRAPPER.UPDATE, () => Squirrel.installUpdate());
  }
};
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:7,代碼來源:lifecycle.ts


注:本文中的electron.ipcMain.on方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。