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


TypeScript ipcRenderer.on方法代码示例

本文整理汇总了TypeScript中electron.ipcRenderer.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript ipcRenderer.on方法的具体用法?TypeScript ipcRenderer.on怎么用?TypeScript ipcRenderer.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在electron.ipcRenderer的用法示例。


在下文中一共展示了ipcRenderer.on方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: AutomatedSingleSignOn

const subscribeToMainProcessEvents = () => {
  ipcRenderer.on(EVENT_TYPE.ACCOUNT.SSO_LOGIN, (event: IpcMessageEvent, code: string) =>
    new AutomatedSingleSignOn().start(code)
  );

  ipcRenderer.on(EVENT_TYPE.UI.SYSTEM_MENU, (event: IpcMessageEvent, action: string) => {
    const selectedWebview = getSelectedWebview();
    if (selectedWebview) {
      selectedWebview.send(action);
    }
  });

  ipcRenderer.on(EVENT_TYPE.WEBAPP.CHANGE_LOCATION_HASH, (event: IpcMessageEvent, hash: string) => {
    const selectedWebview = getSelectedWebview();
    if (selectedWebview) {
      selectedWebview.send(EVENT_TYPE.WEBAPP.CHANGE_LOCATION_HASH, hash);
    }
  });

  ipcRenderer.on(
    EVENT_TYPE.WRAPPER.RELOAD,
    (): void => {
      const webviews = document.querySelectorAll<WebviewTag>('webview');
      webviews.forEach(webview => webview.reload());
    }
  );
};
开发者ID:wireapp,项目名称:wire-desktop,代码行数:27,代码来源:preload.ts

示例2: startup

export function startup(data: ProcessExplorerData): void {
	applyStyles(data.styles);
	applyZoom(data.zoomLevel);

	// Map window process pids to titles, annotate process names with this when rendering to distinguish between them
	ipcRenderer.on('vscode:windowsInfoResponse', (_event: unknown, windows: any[]) => {
		mapPidToWindowTitle = new Map<number, string>();
		windows.forEach(window => mapPidToWindowTitle.set(window.pid, window.title));
	});

	ipcRenderer.on('vscode:listProcessesResponse', (_event: Event, processRoots: [{ name: string, rootProcess: ProcessItem | IRemoteDiagnosticError }]) => {
		updateProcessInfo(processRoots);
		requestProcessList(0);
	});

	lastRequestTime = Date.now();
	ipcRenderer.send('windowsInfoRequest');
	ipcRenderer.send('vscode:listProcesses');

	document.onkeydown = (e: KeyboardEvent) => {
		const cmdOrCtrlKey = platform.isMacintosh ? e.metaKey : e.ctrlKey;

		// Cmd/Ctrl + zooms in
		if (cmdOrCtrlKey && e.keyCode === 187) {
			applyZoom(webFrame.getZoomLevel() + 1);
		}

		// Cmd/Ctrl - zooms out
		if (cmdOrCtrlKey && e.keyCode === 189) {
			applyZoom(webFrame.getZoomLevel() - 1);
		}
	};
}
开发者ID:PKRoma,项目名称:vscode,代码行数:33,代码来源:processExplorerMain.ts

示例3: runAutoUpdaterService

export const runServices = () => {
  ipcRenderer.on(
    FULLSCREEN,
    (e: Electron.IpcMessageEvent, isFullscreen: boolean) => {
      store.isFullscreen = isFullscreen;
    },
  );

  ipcRenderer.on(
    'get-tab-by-web-contents-id',
    (e: any, webContentsId: number) => {
      let sent = false;
      for (const page of store.pagesStore.pages) {
        if (
          page.webview.getWebContents() &&
          page.webview.getWebContents().id === webContentsId
        ) {
          const tab = store.tabsStore.getTabById(page.id).getApiTab();
          ipcRenderer.send('get-tab-by-web-contents-id', tab);
          sent = true;
          break;
        }
      }
      if (!sent) {
        ipcRenderer.send('get-tab-by-web-contents-id', {});
      }
    },
  );

  runAutoUpdaterService();
  runExtensionsService();
};
开发者ID:laquereric,项目名称:wexond,代码行数:32,代码来源:index.ts

示例4: createTweetMessage

window.onload = () => {
	const tweetButtonElement = document.getElementById('tweet-button')
	const trackNameElement = document.getElementById('track-name')
	const artworkImageElement = document.getElementById('artwork')

	ipcRenderer.on('twitter-auth-reply', (event, arg) => {
		ipcRenderer.send('itunes-get-track')
	})

	ipcRenderer.on('itunes-get-track-reply', (event, arg) => {
		nowPlayingTrack = arg as NowPlayingTrack
		console.log('get track success')
		console.log(nowPlayingTrack)
		trackNameElement.innerHTML = createTweetMessage(nowPlayingTrack)
		artworkImageElement.style.backgroundImage = `url(${fileUrl(nowPlayingTrack.artworkPath)})`
	})

	tweetButtonElement.addEventListener('click', () => {
		if (!nowPlayingTrack) {
			console.log('nowplaying track not found')
			return
		}
		const tweet: NowPlayingTweet = {
			message: createTweetMessage(nowPlayingTrack),
			artworkPath: nowPlayingTrack.artworkPath,
		}
		ipcRenderer.send('twitter-post', tweet)
	})

	// first, twitter auth
	ipcRenderer.send('twitter-auth')
}
开发者ID:castaneai,项目名称:nowpl,代码行数:32,代码来源:index.ts

示例5: setup

    /**
     * @brief   Initialize image import events.
     */
    private setup() : void {
        const eventName: string = IPCEventType[IPCEventType.OpenDialogLoadImage] ;
        const eventSuccess: string  = eventName + EventSuffix.Success ;
        const eventFail: string     = eventName + EventSuffix.Fail ;

        var self: ImageImportHandler = this ;

        // On success, send data to controller before displaying it in view.
        IPCRenderer.on(eventSuccess, function(
                                              event,
                                              parentNodeKey: string,
                                              hashes: string[],
                                              files: string[],
                                              basenames: string[]
                                             ) {
            hashes.forEach(
                           function(
                                    hash: string,
                                    index: number,
                                    array: string[]
                                   ) {
                self.sendImportImageEvent(
                                          parentNodeKey,
                                          basenames[index],
                                          hash,
                                          files[index]
                                         ) ;
            }) ;
        }) ;

        // On fail, abort import.
        IPCRenderer.on(eventFail, function() {}) ;
    }
开发者ID:dcarlus,项目名称:2D-Animation-Editor,代码行数:36,代码来源:ImageImportHandler.ts

示例6: init

export function init() {
    ipcRenderer.on('executeForegroundAction', (event, callId, action, params) => {
        executeForegroundAction(action, params)
            .then(result => {
                ipcRenderer.send('onForegroundActionDone', callId, null, result)
            },
            error => {
                const msg = (error instanceof Error) ? error.message : error
                ipcRenderer.send('onForegroundActionDone', callId, msg, null)
            })
    })

    ipcRenderer.on('start-import', () => store.dispatch(startImportAction()))
    ipcRenderer.on('progress', (event, progress: ImportProgress) => store.dispatch(setImportProgressAction(progress)))

    ipcRenderer.on('finish-import', () => {
        fetchTotalPhotoCount()
        fetchSections()
        fetchDates()
        fetchTags()
    })

    ipcRenderer.on('new-version', (event, version: any /* Type should be `Version`, but it doesn't work */) => updatePhotoVersion(version))
    ipcRenderer.on('scanned-devices', (event, devices: Device[]) => store.dispatch(initDevicesAction(devices)))
    ipcRenderer.on('add-device', (event, device: Device) => store.dispatch(addDeviceAction(device)))
    ipcRenderer.on('remove-device', (event, device: Device) => store.dispatch(removeDeviceAction(device)))
    ipcRenderer.on('photos-trashed', (event, photoIds: PhotoId[]) => store.dispatch(emptyTrashAction(photoIds)))
}
开发者ID:m0g,项目名称:ansel,代码行数:28,代码来源:ForegroundService.ts

示例7: initIPC

function initIPC() {
    ipcRenderer.on('openFile', (e, path) => {
        readFile(path, 'utf-8', (err, context) => {
            filePath = path;
            session.setValue(context);
            updateTitle();
        });
    });
    ipcRenderer.on('saveFile', (e, path) => {
        filePath = path;
        saveFile();
    });
}
开发者ID:finderL,项目名称:node-party,代码行数:13,代码来源:main.ts

示例8: dispatchContext

 dispatchContext().then(ctx => {
     const keymaps = receivedKeymaps.then(k => {
         const handlers = new KeymapsHandler(k, ctx);
         handlers.subscribeKeydown();
         console.log('Tui: Now handling keymaps:', handlers);
         return handlers;
     });
     Promise.all([pluginPaths, keymaps])
         .then(([paths, handlers]) => PluginManager.create(paths, ctx, handlers))
         .then(manager => {
             console.log('Tui: Plugin manager created:', manager);
             console.log('Tui: Application launched. Memory(KB):', process.getProcessMemoryInfo());
         });
     keymaps.then(k => {
         ipc.on('tuitter:new-tweet', () => {
             console.log('Tui: Received tuitter:new-tweet');
             k['new-tweet']();
         });
     });
     ipc.on('tuitter:will-suspend', (_: any, threshold: number) => {
         const memKB = process.getProcessMemoryInfo().privateBytes;
         console.log('Tui: Will suspend', threshold, memKB);
         const memMB = memKB / 1000;
         if (memMB > threshold) {
             console.log('Tui: Memory usage exceeds the threshold. Request refreshing:', threshold, memMB);
             ipc.sendToHost('tuitter:refresh-me', memKB);
         }
     });
 }).catch(e => {
开发者ID:rhysd,项目名称:Tui,代码行数:29,代码来源:index.ts

示例9:

        editor.on('process-attached', () => {
            const client = editor.getClient();

            client.listRuntimePaths()
                  .then((rtp: string[]) => {
                      component_loader.loadFromRTP(rtp);
                      component_loader.initially_loaded = true;
                  });

            runtime_api.subscribe(client);

            element.addEventListener('drop', e => {
                e.preventDefault();
                const f = e.dataTransfer.files[0];
                if (f) {
                    client.command('edit! ' + f.path);
                }
            });

            app.on('open-file', (e: Event, p: string) => {
                e.preventDefault();
                client.command('edit! ' + p);
            });

            ipc.on('nyaovim:exec-commands', (_: Event, cmds: string[]) => {
                console.log('ipc: nyaovim:exec-commands', cmds);
                for (const c of cmds) {
                    client.command(c);
                }
            });
        });
开发者ID:AnujKosambi,项目名称:NyaoVim,代码行数:31,代码来源:nyaovim-app.ts

示例10: init

(function init() {
  const { getPersistentAsJson } = Electron.remote.require("./remote");
  const json = JSON.parse(getPersistentAsJson());
  const config = json.config as Config;
  store.mutations.resetConfig(config);

  try {
    const recentList = JSON.parse(localStorage.getItem("recentList") || "[]");
    if (
      recentList instanceof Array &&
      recentList.every(v => typeof v === "string")
    ) {
      store.mutations.resetRecentList(recentList);
    } else {
      console.warn("Failed to load recentList from localStorage");
    }
  } catch {
    console.warn("Failed to load recentList from localStorage");
  }

  Electron.ipcRenderer.on(
    "action",
    (_event: string, name: string, payload: any) => {
      (store.actions as any)[name](payload);
    }
  );
})();
开发者ID:wonderful-panda,项目名称:inazuma,代码行数:27,代码来源:index.ts

示例11:

>(observer => {
  ipc.on("kernel_specs_reply", (event: any, specs: Kernelspecs) => {
    observer.next(specs);
    observer.complete();
  });
  ipc.send("kernel_specs_request");
});
开发者ID:nteract,项目名称:nteract,代码行数:7,代码来源:zeromq-kernels.ts

示例12: constructor

    constructor(private readonly config: Config) {
        this.switchTo(this.getFirstScreenName());

        // After hiding window, <webview> loses its focus.
        // So when window is shown again, need to give <webview> focus again.
        // Note:
        // remove.getCurrentWindow().on('focus', ...) is unavailable
        // because callback remains after this web contents reloaded.
        // Remained callback causes a 'trying to send message to removed web contents'
        // error.
        ipc.on('tuitter:window-focused', () => this.wv.focus());
        ipc.on('tuitter:menu:new-tweet', () => this.wv.sendIpc('tuitter:new-tweet'));
        ipc.on('tuitter:will-suspend', (__: any, threshold: number) => {
            log.debug('Refresh app because system will be suspended. Threshold:', threshold, this.wv);
            this.wv.sendIpc('tuitter:will-suspend', threshold);
        });
    }
开发者ID:rhysd,项目名称:Tui,代码行数:17,代码来源:app.ts

示例13: RendererApp

ipc.once('tuitter:config', (_: any, config: Config) => {
    log.debug('Config was sent from main:', config);
    const app = new RendererApp(config);
    ipc.on('tuitter:account', (__: any, index: number, screenName: string) => {
        log.debug('Will switch to account', index, screenName);
        app.switchTo(screenName.slice(1)); // Strip '@'
    });
});
开发者ID:rhysd,项目名称:Tui,代码行数:8,代码来源:index.ts

示例14: subscribe

  subscribe(channel: string, listener: (event: any, args: any) => void) {
    const wrappedListener = (event: any, args: any) => {
      listener(event, args)
      this.appRef.tick()
    }

    ipcRenderer.on(channel, wrappedListener)
    return this
  }
开发者ID:makaria,项目名称:GReader,代码行数:9,代码来源:ipc.service.ts

示例15: constructor

	constructor() {
		this.has_ipc = (typeof ipcRenderer != 'undefined');
		// Set listener
		if (this.has_ipc) {
			ipcRenderer.on('asynchronous-reply', (event, arg) => {
				console.log(arg); // prints "pong"
			});
		}
	}
开发者ID:aracen74,项目名称:tsng2,代码行数:9,代码来源:homepage.component.ts


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