本文整理匯總了TypeScript中electron.remote.require方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript remote.require方法的具體用法?TypeScript remote.require怎麽用?TypeScript remote.require使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類electron.remote
的用法示例。
在下文中一共展示了remote.require方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: init
(function init() {
const { getPersistentAsJson } = Electron.remote.require("./remote");
const json = JSON.parse(getPersistentAsJson());
const config = json.config as Config;
store.mutations.resetConfig(config);
try {
const recentList = JSON.parse(localStorage.getItem("recentList") || "[]");
if (
recentList instanceof Array &&
recentList.every(v => typeof v === "string")
) {
store.mutations.resetRecentList(recentList);
} else {
console.warn("Failed to load recentList from localStorage");
}
} catch {
console.warn("Failed to load recentList from localStorage");
}
Electron.ipcRenderer.on(
"action",
(_event: string, name: string, payload: any) => {
(store.actions as any)[name](payload);
}
);
})();
示例2: function
this.sampleAction = function (name, ev) {
var request = remote.require('request');
var url = 'http://www.apple.com';
request(url, function (error, response, body) {
if (!error && response.statusCode == 200) {
$scope.message = body;
} else {
}
});
let index = remote.require('./index.js');
let geho = index.add(1,2);
let a = 1;
index.open();
};
示例3: Storage
process.once('loaded', () => {
const g: any = global;
g.WebStorage = new Storage();
g.openInBrowser = function (url) {
shell.openExternal(url);
};
g.isDesktop = true;
try {
g.TransportNodeHid = require('@ledgerhq/hw-transport-node-hid');
} catch (e) {
}
const transferModule = remote.require('./transfer');
g.transfer = transferModule.transfer;
});
示例4:
remote.getCurrentWindow().capturePage(buf => {
remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
console.log(err);
});
});
示例5: homedir
/// <reference path="./keyboard.ts" />
/// <reference path="lib.d.ts" />
/// <reference path="../browser/config.d.ts" />
import * as path from 'path';
import * as fs from 'fs';
import hotexamples_com from 'os';
import {remote, ipcRenderer as ipc} from 'electron';
import * as encoding from 'encoding-japanese';
const config = remote.getGlobal('config') as Config;
const home_dir = config.hide_title_bar ? '' : homedir();
const on_darwin = process.platform === 'darwin';
let watching_path = remote.require('./initial_path.js')();
let onPathButtonPushed = function(){ /* do nothing */ };
let onSearchButtonPushed = function(){ /* do nothing */ };
let onTOCButtonPushed = function(){ /* do nothing */ };
function getMainDrawerPanel() {
return document.getElementById('main-drawer') as MainDrawerPanel;
}
/* tslint:disable no-unused-variable*/
function onPrintButtonPushed(): void {
remote.getCurrentWindow().webContents.print();
}
/* tslint:enable no-unused-variable*/
function getLintArea() {
return document.getElementById('lint-area') as LintResultArea;
}
示例6: require
/* eslint-env node */
import * as _ from "lodash";
import { remote } from "electron";
const app = _.extend({}, require("./app"), remote.require("./appshell/app-menu"));
const fs = _.extend({}, require("fs-extra"), require("./fs-additions"));
const shell = remote.require("./appshell/shell");
// prevent using this alias, rather use .remove
delete fs.delete;
// make sure extensions folder exists
fs.ensureDir(app.getExtensionsFolder());
// this needs to be node-require style export
module.exports = { app, fs, shell, inElectron: true, windowGoingAway: false };
示例7:
key: K,
jsons: StoreDateKeyMap[K],
) => void;
watch: (
name: string,
callback: (
props: any,
action: string,
newValue: any,
oldValue: any,
) => void,
) => void;
};
bridge: {
on: <K extends keyof BridgeDateKeyMap>(
key: K,
callback: (jsons: BridgeDateKeyMap[K]) => void,
) => void;
emit: <K extends keyof BridgeDateKeyMap>(
key: K,
jsons: BridgeDateKeyMap[K],
) => void;
};
open: (windowId: WindowId, ...args: any[]) => any;
get: (windowId: WindowId) => any;
}
export const windowManager: WindowManager = remote.require(
"@lifter/electron-window-manager",
);
示例8: BrowserWindow
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', (arg: any) => {
console.log(arg); // prints "pong"
});
ipcRenderer.send('asynchronous-message', 'ping');
// remote
// https://github.com/atom/electron/blob/master/docs/api/remote.md
var BrowserWindow: typeof Electron.BrowserWindow = remote.require('browser-window');
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.getCurrentWindow().capturePage(buf => {
remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
示例9: homedir
/// <reference path="lib.d.ts" />
/// <reference path="../browser/config.d.ts" />
import * as path from 'path';
import * as fs from 'fs';
import { homedir } from 'os';
import { remote, ipcRenderer as ipc } from 'electron';
import * as encoding from 'encoding-japanese';
const config = remote.getGlobal('config') as Config;
const home_dir = config.hide_title_bar ? '' : homedir();
const on_darwin = process.platform === 'darwin';
function noop() {
/* do nothing */
}
let watching_path = remote.require('./initial_path.js')(config.default_watch_path || '');
let onPathButtonPushed = noop;
let onSearchButtonPushed = noop;
let onTOCButtonPushed = noop;
function getMainDrawerPanel() {
return document.getElementById('main-drawer') as MainDrawerPanel;
}
/* tslint:disable no-unused-variable*/
function onPrintButtonPushed(): void {
remote.getCurrentWindow().webContents.print();
}
/* tslint:enable no-unused-variable*/
function getLintArea() {
示例10: constructor
import {NeovimElement} from 'neovim-component';
import {remote, shell, ipcRenderer as ipc} from 'electron';
import {join} from 'path';
import {readdirSync} from 'fs';
import {Nvim, RPCValue} from 'promised-neovim-client';
const app = remote.require('app');
class ComponentLoader {
initially_loaded: boolean;
component_paths: string[];
nyaovim_plugin_paths: string[];
constructor() {
this.initially_loaded = false;
this.component_paths = [];
}
loadComponent(path: string) {
const link = document.createElement('link') as HTMLLinkElement;
link.rel = 'import';
link.href = path;
document.head.appendChild(link);
this.component_paths.push(path);
}
loadPluginDir(dir: string) {
const nyaovim_plugin_dir = join(dir, 'nyaovim-plugin');
try {
for (const entry of readdirSync(nyaovim_plugin_dir)) {
if (entry.endsWith('.html')) {