當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript remote.getCurrentWebContents方法代碼示例

本文整理匯總了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);
	}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:7,代碼來源:driver.ts

示例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());
    },
開發者ID:WondermSwift,項目名稱:Shiba,代碼行數:33,代碼來源:builtin-search.ts

示例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);
	}
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:8,代碼來源:driver.ts

示例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());
開發者ID:longlho,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:github-electron-renderer-tests.ts

示例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));
開發者ID:Sheshouzuo,項目名稱:Shiba,代碼行數:30,代碼來源:builtin-search.ts

示例6:

 'nyaovim:open-devtools': (mode: 'right' | 'bottom' | 'undocked' | 'detach') => {
     const contents = remote.getCurrentWebContents();
     contents.openDevTools({mode});
 },
開發者ID:haifengkao,項目名稱:NyaoVim-Unofficial,代碼行數:4,代碼來源:nyaovim-app.ts

示例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;
    },
開發者ID:WondermSwift,項目名稱:Shiba,代碼行數:30,代碼來源:builtin-search.ts


注:本文中的electron.remote.getCurrentWebContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。