本文整理匯總了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] });
}
示例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);
}
示例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')
}
示例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);
});
示例5:
this._resolveAuthorityCache[authority].then((r) => {
ipc.send('vscode:remoteAuthorityResolved', {
authority: authority,
host: r.host,
port: r.port
});
});
示例6: openWindow
export function openWindow(url, windowSize?) {
console.log(url)
ipc.send('open-url', {
url,
windowSize,
});
}
示例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)
)
}
示例8: setResolvedAuthority
setResolvedAuthority(resolvedAuthority: ResolvedAuthority) {
if (this._resolveAuthorityRequests[resolvedAuthority.authority]) {
let request = this._resolveAuthorityRequests[resolvedAuthority.authority];
ipc.send('vscode:remoteAuthorityResolved', resolvedAuthority);
request.resolve(resolvedAuthority);
}
}
示例9: save
export function save(name: string, spec: any, pathToSave: string) {
ipcRenderer.send("save", {
name,
spec,
pathToSave
});
}
示例10: function
click: function(){
ipcRenderer.send('open-custom');
let notification = new Notification('Customdialog', {
body: 'This is a custom window created by us'
})
}
示例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);
};
示例12: updatePreferredAppMenuItemLabels
export function updatePreferredAppMenuItemLabels(labels: {
editor?: string
pullRequestLabel?: string
shell: string
}) {
ipcRenderer.send('update-preferred-app-menu-item-labels', labels)
}
示例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);
}
示例14:
ipc.on('render-overlay-icon', (_event: ElectronEvent, messageCount: number) => {
ipc.send(
'update-overlay-icon',
renderOverlayIcon(messageCount).toDataURL(),
String(messageCount)
);
});
示例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();
}
});