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


TypeScript ipcRenderer.send方法代码示例

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


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

示例1: attachTo

function attachTo(item: ProcessItem) {
	const config: any = {
		type: 'node',
		request: 'attach',
		name: `process ${item.pid}`
	};

	let matches = DEBUG_FLAGS_PATTERN.exec(item.cmd);
	if (matches && matches.length >= 2) {
		// attach via port
		if (matches.length === 4 && matches[3]) {
			config.port = parseInt(matches[3]);
		}
		config.protocol = matches[1] === 'debug' ? 'legacy' : 'inspector';
	} else {
		// no port -> try to attach via pid (send SIGUSR1)
		config.processId = String(item.pid);
	}

	// a debug-port=n or inspect-port=n overrides the port
	matches = DEBUG_PORT_PATTERN.exec(item.cmd);
	if (matches && matches.length === 3) {
		// override port
		config.port = parseInt(matches[2]);
	}

	ipcRenderer.send('vscode:workbenchCommand', { id: 'workbench.action.debug.start', from: 'processExplorer', args: [config] });
}
开发者ID:donaldpipowitch,项目名称:vscode,代码行数:28,代码来源:processExplorerMain.ts

示例2: popup

export function popup(items: IContextMenuItem[], options?: IPopupOptions): void {
	const processedItems: IContextMenuItem[] = [];

	const contextMenuId = contextMenuIdPool++;
	const onClickChannel = `vscode:onContextMenu${contextMenuId}`;
	const onClickChannelHandler = (_event: Event, itemId: number, context: IContextMenuEvent) => {
		const item = processedItems[itemId];
		if (item.click) {
			item.click(context);
		}
	};

	ipcRenderer.once(onClickChannel, onClickChannelHandler);
	ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: Event, closedContextMenuId: number) => {
		if (closedContextMenuId !== contextMenuId) {
			return;
		}

		ipcRenderer.removeListener(onClickChannel, onClickChannelHandler);

		if (options && options.onHide) {
			options.onHide();
		}
	});

	ipcRenderer.send(CONTEXT_MENU_CHANNEL, contextMenuId, items.map(item => createItem(item, processedItems)), onClickChannel, options);
}
开发者ID:PKRoma,项目名称:vscode,代码行数:27,代码来源:contextmenu.ts

示例3: 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

示例4: getNextIpcId

    }, (err) => {
      if (err != null) { callback(err, null); return; }

      const ipcId = getNextIpcId();
      ipcCallbacks[ipcId] = () => { callback(null, tempFolderPath); };
      electron.ipcRenderer.send("authorize-folder", secretKey, ipcId, window.location.origin, tempFolderPath);
    });
开发者ID:nitpum,项目名称:superpowers-app,代码行数:7,代码来源:index.ts

示例5:

			this._resolveAuthorityCache[authority].then((r) => {
				ipc.send('vscode:remoteAuthorityResolved', {
					authority: authority,
					host: r.host,
					port: r.port
				});
			});
开发者ID:,项目名称:,代码行数:7,代码来源:

示例6: openWindow

export function openWindow(url, windowSize?) {
  console.log(url)
  ipc.send('open-url', {
    url,
    windowSize,
  });
}
开发者ID:ryota0624,项目名称:electron_twitter,代码行数:7,代码来源:ipc.ts

示例7: log

/**
 * Dispatches the given log entry to the main process where it will be picked
 * written to all log transports. See initializeWinston in logger.ts for more
 * details about what transports we set up.
 */
function log(level: LogLevel, message: string, error?: Error) {
  ipcRenderer.send(
    'log',
    level,
    formatLogMessage(`[${__PROCESS_KIND__}] ${message}`, error)
  )
}
开发者ID:Ahskys,项目名称:desktop,代码行数:12,代码来源:install.ts

示例8: setResolvedAuthority

	setResolvedAuthority(resolvedAuthority: ResolvedAuthority) {
		if (this._resolveAuthorityRequests[resolvedAuthority.authority]) {
			let request = this._resolveAuthorityRequests[resolvedAuthority.authority];
			ipc.send('vscode:remoteAuthorityResolved', resolvedAuthority);
			request.resolve(resolvedAuthority);
		}
	}
开发者ID:eamodio,项目名称:vscode,代码行数:7,代码来源:remoteAuthorityResolverService.ts

示例9: save

export function save(name: string, spec: any, pathToSave: string) {
  ipcRenderer.send("save", {
    name,
    spec,
    pathToSave
  });
}
开发者ID:Raathigesh,项目名称:Atmo,代码行数:7,代码来源:MessageHandler.ts

示例10: function

 click: function(){
   ipcRenderer.send('open-custom');
       let notification = new Notification('Customdialog', {
           body: 'This is a custom window created by us'
       })
     
 }
开发者ID:rajayogan,项目名称:angular2-desktop,代码行数:7,代码来源:app.ts

示例11: next

export const forwardToMain: Middleware = (store: MiddlewareAPI<AppState>) => (next: Dispatch<AppState>) => (action: AppAction) =>
{
    if (action.scope === "local")
        return next(action);

    ipcRenderer.send(REDUX_SYNC, action);
};
开发者ID:foxable,项目名称:app-manager,代码行数:7,代码来源:forwardToMain.ts

示例12: updatePreferredAppMenuItemLabels

export function updatePreferredAppMenuItemLabels(labels: {
  editor?: string
  pullRequestLabel?: string
  shell: string
}) {
  ipcRenderer.send('update-preferred-app-menu-item-labels', labels)
}
开发者ID:soslanashkhotov,项目名称:desktop,代码行数:7,代码来源:main-process-proxy.ts

示例13: sendConversationList

async function sendConversationList(): Promise<void> {
	const conversations: Conversation[] = await Promise.all(
		([...(await elementReady(listSelector)).children] as HTMLElement[])
			.splice(0, 10)
			.map(async (el: HTMLElement) => {
				const profilePic = el.querySelector<HTMLImageElement>('._55lt img');
				const groupPic = el.querySelector<HTMLImageElement>('._4ld- div');

				// This is only for group chats
				if (groupPic) {
					// Slice image source from background-image style property of div
					const bgImage = groupPic.style.backgroundImage!;
					groupPic.src = bgImage.slice(5, bgImage.length - 2);
				}

				const isConversationMuted = el.classList.contains('_569x');

				return {
					label: el.querySelector<HTMLElement>('._1ht6')!.textContent!,
					selected: el.classList.contains('_1ht2'),
					unread: el.classList.contains('_1ht3') && !isConversationMuted,
					icon: await getDataUrlFromImg(
						profilePic ? profilePic : groupPic!,
						el.classList.contains('_1ht3')
					)
				};
			})
	);

	ipc.send('conversations', conversations);
}
开发者ID:nikteg,项目名称:caprine,代码行数:31,代码来源:browser.ts

示例14:

ipc.on('render-overlay-icon', (_event: ElectronEvent, messageCount: number) => {
	ipc.send(
		'update-overlay-icon',
		renderOverlayIcon(messageCount).toDataURL(),
		String(messageCount)
	);
});
开发者ID:nikteg,项目名称:caprine,代码行数:7,代码来源:browser.ts

示例15: async

ipc.on('toggle-mute-notifications', async (_event: ElectronEvent, defaultStatus: boolean) => {
	const preferencesAreOpen = isPreferencesOpen();

	if (!preferencesAreOpen) {
		const style = document.createElement('style');
		// Hide both the backdrop and the preferences dialog
		style.textContent = `${preferencesSelector} ._3ixn, ${preferencesSelector} ._59s7 { opacity: 0 !important }`;
		document.body.append(style);

		await openPreferences();

		// Will clean up itself after the preferences are closed
		document.querySelector<HTMLElement>(preferencesSelector)!.append(style);
	}

	const notificationCheckbox = document.querySelector<HTMLInputElement>(
		'._374b:nth-of-type(4) ._4ng2 input'
	)!;

	if (defaultStatus === undefined) {
		notificationCheckbox.click();
	} else if (
		(defaultStatus && notificationCheckbox.checked) ||
		(!defaultStatus && !notificationCheckbox.checked)
	) {
		notificationCheckbox.click();
	}

	ipc.send('mute-notifications-toggled', !notificationCheckbox.checked);

	if (!preferencesAreOpen) {
		closePreferences();
	}
});
开发者ID:nikteg,项目名称:caprine,代码行数:34,代码来源:browser.ts


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