本文整理匯總了TypeScript中electron.ipcRenderer.sendSync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ipcRenderer.sendSync方法的具體用法?TypeScript ipcRenderer.sendSync怎麽用?TypeScript ipcRenderer.sendSync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.ipcRenderer
的用法示例。
在下文中一共展示了ipcRenderer.sendSync方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: do_ping
do_ping() {
if (this.has_ipc) {
console.log(ipcRenderer.sendSync('synchronous-message', 'sync ping')); // prints "pong"
ipcRenderer.send('asynchronous-message', 'async ping');
} else {
console.log("There isn't Electron main process.");
}
}
示例2: Player
process.once('loaded', () => {
let themeConfig = ipcRenderer.sendSync('get-theme-settings');
let themeSettings: BowtiePlist = themeConfig && themeConfig.settings ? themeConfig.settings : {};
let player = new Player(themeSettings);
let bowtie = new Bowtie();
global.iTunes = player;
global.Player = player;
global.Bowtie = bowtie;
global.onload = () => {
global.document.body.addEventListener('contextmenu', (e) => {
e.preventDefault();
menu.popup(remote.getCurrentWindow());
});
global.document.body.addEventListener('mousewheel', (e) => {
e.preventDefault();
handleScroll(e);
});
};
ipcRenderer.on('error', (...args) => {
handleError('Unknown', args);
});
});
示例3: BrowserWindow
import {
ipcRenderer,
remote,
webFrame,
clipboard,
crashReporter,
nativeImage,
screen,
shell
} from 'electron';
import * as fs from 'fs';
// In renderer process (web page).
// https://github.com/atom/electron/blob/master/docs/api/ipc-renderer.md
console.log(ipcRenderer.sendSync('synchronous-message', 'ping')); // prints "pong"
ipcRenderer.on('asynchronous-reply', (event: Electron.IpcRendererEvent, arg: any) => {
console.log(arg); // prints "pong"
event.sender.send('another-message', 'Hello World!');
});
ipcRenderer.send('asynchronous-message', 'ping');
// remote
// https://github.com/atom/electron/blob/master/docs/api/remote.md
var BrowserWindow = remote.BrowserWindow;
var win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL('https://github.com');
示例4: startGame
import {Module} from 'vuex'
import {IRootState} from '../index'
import {IRunningGame} from '../../../main/service/game'
import {ipcRenderer} from 'electron'
export interface IProcessState {
processes: IRunningGame[]
}
const store: Module<IProcessState, IRootState> = {
namespaced: true,
state: {
processes: ipcRenderer.sendSync('game:running'),
},
mutations: {
startGame(state, {name, json, id}) {
state.processes.push({
name, json, id, launcher: null,
})
},
onGameStop(state, {id}) {
const index = state.processes.findIndex((value) => {
if (value.id === id) return true
})
if (index === -1) return
state.processes.splice(index, 1)
}
},
}
示例5: sendWillQuitSync
export function sendWillQuitSync() {
// eslint-disable-next-line no-sync
ipcRenderer.sendSync('will-quit')
}
示例6: platform
export const bootstrapElectronRenderer = () => {
electron.ipcRenderer.sendSync(ELECTRON_READY);
platform([WORKER_RENDER_PLATFORM]).application([WORKER_RENDER_APPLICATION])
}
示例7: ngOnInit
ngOnInit() {
this.slideServie.setText(ipcRenderer.sendSync('RequestPrintText'));
this.pages = _.range(1, this.slideServie.getMaxPage() + 1);
}
示例8:
import { ipcRenderer } from "electron";
interface IElectron {
electron: {
ipc: Electron.IpcRenderer
app: {
version: string
userDataPath: string
}
}
}
const w: any = window
const obj: IElectron = {
electron: {
ipc: ipcRenderer,
app: {
version: ipcRenderer.sendSync('pitboom', 'get-app-version'),
userDataPath: ipcRenderer.sendSync('pitboom', 'get-app-user-data-path'),
},
}
}
w.electron = obj.electron