本文整理汇总了TypeScript中electron.remote.getCurrentWebContents方法的典型用法代码示例。如果您正苦于以下问题:TypeScript remote.getCurrentWebContents方法的具体用法?TypeScript remote.getCurrentWebContents怎么用?TypeScript remote.getCurrentWebContents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.remote
的用法示例。
在下文中一共展示了remote.getCurrentWebContents方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: move
async move(selector: string): TPromise<void> {
const { x, y } = await this._getElementXY(selector);
const webContents = electron.remote.getCurrentWebContents();
webContents.sendInputEvent({ type: 'mouseMove', x, y } as any);
await TPromise.timeout(100);
}
示例2: function
ready: function() {
this.button = document.querySelector('.builtin-search-button') as HTMLButtonElement;
this.button.addEventListener('click', () => {
this.search(this.input.value);
});
this.body = document.querySelector('.builtin-search-body') as HTMLDivElement;
this.body.classList.add('animated');
if (this.displayed) {
this.body.style.display = 'block';
}
this.matches = document.querySelector('.builtin-search-matches') as HTMLDivElement;
remote.getCurrentWebContents().on('found-in-page', (event: Event, result: FoundInPage) => {
if (this.requestId !== result.requestId) {
return;
}
if (result.activeMatchOrdinal) {
this.activeIdx = result.activeMatchOrdinal;
}
if (result.finalUpdate && result.matches) {
this.setResult(this.activeIdx, result.matches);
}
});
this.up_button = document.querySelector('.builtin-search-up') as HTMLButtonElement;
this.up_button.addEventListener('click', () => this.searchNext(this.query, false));
this.down_button = document.querySelector('.builtin-search-down') as HTMLButtonElement;
this.down_button.addEventListener('click', () => this.searchNext(this.query, true));
this.close_button = document.querySelector('.builtin-search-close') as HTMLButtonElement;
this.close_button.addEventListener('click', () => this.dismiss());
},
示例3: _click
private async _click(selector: string, clickCount: number, xoffset?: number, yoffset?: number): TPromise<void> {
const { x, y } = await this._getElementXY(selector, xoffset, yoffset);
const webContents = electron.remote.getCurrentWebContents();
webContents.sendInputEvent({ type: 'mouseDown', x, y, button: 'left', clickCount } as any);
webContents.sendInputEvent({ type: 'mouseUp', x, y, button: 'left', clickCount } as any);
await TPromise.timeout(100);
}
示例4: BrowserWindow
var BrowserWindow = remote.BrowserWindow;
var win = new BrowserWindow({ width: 800, height: 600 });
win.loadURL('https://github.com');
remote.getCurrentWindow().on('close', () => {
// blabla...
});
remote.getCurrentWindow().capturePage(buf => {
fs.writeFile('/tmp/screenshot.png', buf, err => {
console.log(err);
});
});
remote.getCurrentWebContents().print();
remote.getCurrentWindow().capturePage(buf => {
remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
console.log(err);
});
});
// web-frame
// https://github.com/atom/electron/blob/master/docs/api/web-frame.md
webFrame.setZoomFactor(2);
console.log(webFrame.getZoomFactor());
webFrame.setZoomLevel(200);
console.log(webFrame.getZoomLevel());
示例5: ready
ready() {
this.button = document.querySelector('.builtin-search-button');
this.button.addEventListener('click', () => {
this.search(this.input.value);
});
this.body = document.querySelector('.builtin-search-body');
this.body.classList.add('animated');
if (this.displayed) {
this.body.style.display = 'block';
}
this.matches = document.querySelector('.builtin-search-matches');
remote.getCurrentWebContents().on('found-in-page', (_: Event, result: FoundInPage) => {
if (this.requestId !== result.requestId) {
return;
}
if (result.activeMatchOrdinal) {
this.activeIdx = result.activeMatchOrdinal;
}
if (result.finalUpdate && result.matches) {
this.setResult(this.activeIdx, result.matches);
}
});
this.up_button = document.querySelector('.builtin-search-up');
this.up_button.addEventListener('click', () => this.searchNext(this.query, false));
this.down_button = document.querySelector('.builtin-search-down');
this.down_button.addEventListener('click', () => this.searchNext(this.query, true));
示例6:
'nyaovim:open-devtools': (mode: 'right' | 'bottom' | 'undocked' | 'detach') => {
const contents = remote.getCurrentWebContents();
contents.openDevTools({mode});
},
示例7: searchNext
return;
}
// Note: When this.query === word
this.searchNext(word, true);
},
searchNext(text: string, forward: boolean) {
if (text === '') {
return;
}
const options = {
forward,
findNext: true,
};
this.requestId = remote.getCurrentWebContents().findInPage(text, options);
this.focusOnInput();
},
stopSearch: function() {
if (!this.searching) {
return;
}
this.setResult(0, 0);
remote.getCurrentWebContents().stopFindInPage('clearSelection');
this.searching = false;
this.query = '';
this.requestId = undefined;
this.activeIdx = 0;
},