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