本文整理匯總了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;
},