当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript remote.require方法代码示例

本文整理汇总了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);
    }
  );
})();
开发者ID:wonderful-panda,项目名称:inazuma,代码行数:27,代码来源:index.ts

示例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();
        };
开发者ID:7thCode,项目名称:electron-material,代码行数:20,代码来源:controller.ts

示例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;
});
开发者ID:wavesplatform,项目名称:WavesGUI,代码行数:17,代码来源:preload.ts

示例4:

remote.getCurrentWindow().capturePage(buf => {
	remote.require('fs').writeFile('/tmp/screenshot.png', buf, (err: Error) => {
		console.log(err);
	});
});
开发者ID:longlho,项目名称:DefinitelyTyped,代码行数:5,代码来源:github-electron-renderer-tests.ts

示例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;
}
开发者ID:WondermSwift,项目名称:Shiba,代码行数:31,代码来源:index.ts

示例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 };
开发者ID:Real-Currents,项目名称:brackets,代码行数:17,代码来源:index.ts

示例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",
);
开发者ID:kyo-ago,项目名称:lifter,代码行数:30,代码来源:get-window-manager.ts

示例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) => {
开发者ID:Benefex,项目名称:DefinitelyTyped,代码行数:30,代码来源:github-electron-renderer-tests.ts

示例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() {
开发者ID:Sheshouzuo,项目名称:Shiba,代码行数:31,代码来源:index.ts

示例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')) {
开发者ID:AnujKosambi,项目名称:NyaoVim,代码行数:31,代码来源:nyaovim-app.ts


注:本文中的electron.remote.require方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。