本文整理汇总了TypeScript中electron.remote.getGlobal方法的典型用法代码示例。如果您正苦于以下问题:TypeScript remote.getGlobal方法的具体用法?TypeScript remote.getGlobal怎么用?TypeScript remote.getGlobal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类electron.remote
的用法示例。
在下文中一共展示了remote.getGlobal方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getGlobal
export function getGlobal(attributeName: string, defaultValue?: any): any {
if (global[attributeName]) {
return global[attributeName];
} else if (Electron.remote && Electron.remote.getGlobal(attributeName)) {
return Electron.remote.getGlobal(attributeName)
} else {
return defaultValue;
}
}
示例2: parse
process.once('loaded', () => {
const extensions = remote.getGlobal('extensions');
const extensionId = parse(window.location.href).hostname;
const manifest = extensions[extensionId];
const api = getAPI(manifest);
interface Global extends NodeJS.Global {
wexond?: typeof api;
chrome?: typeof api;
browser?: typeof api;
}
const globalObject = global as Global;
globalObject.wexond = api;
globalObject.chrome = api;
globalObject.browser = api;
});
示例3: getGlobalVar
export function getGlobalVar(globalVarName:string):any
{
let globalVar = null;
if (isBrowserProcess())
{
globalVar = global[GLOBAL_VAR_NAME];
}
if (isRendererProcess())
{
let remote = require('electron').remote;
globalVar = remote.getGlobal(GLOBAL_VAR_NAME);
}
if (globalVar != null && globalVar[globalVarName] != null)
{
return globalVar[globalVarName];
}
else
{
return null;
}
}
示例4: if
import * as connect from './connect';
import * as $ from 'jquery';
import {ipcRenderer, remote} from 'electron';
var socket = remote.getGlobal("socket");
socket.on("receive", function(msg) {
console.log(msg);
if (msg.type == connect.MessageType.RESPONSE) {
console.log("Respuesta para:", connect.MessageType[msg.content.type]);
console.log("Codigo de respuesta:", connect.ResponseCode[msg.content.code]);
}
else if (msg.type == connect.MessageType.NEW_CHAT && msg.content.room == 'default') {
$('#chat').append(`<li><b>${msg.content.user}: </b>${msg.content.message}</li>`);
}
});
$(function() {
var user = "";
$.getJSON('../../tmp/data.json', function(data) {
user = data.user;
});
$('#send').click(function() {
sendMsj(user);
});
$('#msj').keypress(function(ev) {
var msj = $(this).val().trim();
if (ev.which == 13 && msj.length > 0)
sendMsj(user);
示例5: getMainDrawerPanel
/// <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: createSplitter
//.........这里部分代码省略.........
const result = createResult(m, pubsub)
const editConnection = createEditConnection(m, pubsub, settings)
const bookmarkModule = createBookmarkModel(
m,
fs,
pubsub,
editor,
createPopupmenu
)
const historyModule = createHistoryView(
m,
pubsub,
createPopupmenu,
getHistoryModel
)
const columnsPrompt = createColumnsPrompt(
m,
editor,
getTables,
pubsub,
createPopupmenu
)
let connected = false
window.addEventListener(
'beforeunload',
() => {
pubsub.emit('disconnect')
},
false
)
createExecuter(pubsub, editor, m)
createSchemaHandler(fs, pubsub)
createSqlHint(pubsub, editor, getTables, CodeMirror)
pubsub.on('new-window', () => {
console.log('emit new-window')
ipcRenderer.send('new-window')
})
pubsub.on('connected', connection => {
document.body.className =
'theme--' + (connection.settings().theme || 'dark-orange')
connected = true
document.title =
'Gandalf - connected to ' + connection.settings().name
m.route('/sql/' + connection.settings().name)
})
function Controller() {
const connName = m.route.param('conn')
if (!connected && connName) {
const connSettings = settings.connections.find(
c => c.name === connName
)
if (connSettings && connSettings.host === 'hsql:inmemory') {
console.log('reconnect to hsql:inmemory!!')
connect(
{ host: connSettings.host },
connSettings
).then(connection => {
pubsub.emit('connected', connection)
})
} else {
pubsub.emit('login')
}
}
}
const sqlModule = {
controller: Controller,
view() {
return [
loginModule.view(),
editor.view(),
splitter(),
result.view(),
statusbar.view(),
actions.view(),
tableSearch.view(),
bookmarkModule.view(),
historyModule.view(),
columnsPrompt.view(),
errorHandler.view(),
editConnection.view(),
]
},
}
m.route(
document.getElementById('body'),
'/sql/' +
(remote.getGlobal('sharedObject').dev ? 'Gandalf dev' : ''),
{
'/sql': sqlModule,
'/sql/:conn': sqlModule,
}
)
})
示例7: require
import { createResult } from './views/result'
import { createSplitter } from './views/splitter'
import { createStatusbar } from './views/statusbar'
import { createTableSearch } from './views/tableSearch'
const { ipcRenderer, remote } = require('electron')
const m = require('mithril')
const CodeMirror = require('codemirror')
require('codemirror/addon/hint/show-hint.js')
require('codemirror/addon/search/searchcursor.js')
require('codemirror/addon/dialog/dialog.js')
require('codemirror/keymap/sublime.js')
require('codemirror/mode/sql/sql.js')
require('./modules/sql-hint.js')
if (remote.getGlobal('sharedObject').dev) {
require('electron-connect').client.create()
require('electron-css-reload')()
}
getSettings()
.then(settings => {
const splitter = createSplitter(m)
const pubsub = new EventEmitter()
createGlobalShortcuts(pubsub)
createCommitControl(pubsub)
const errorHandler = createErrorHandler(m)
const loginModule = createLoginModule(m, pubsub, connect, settings)
const actions = createActions(m, pubsub, createPopupmenu)
const tableSearch = createTableSearch(m, pubsub, createPopupmenu)
示例8:
import {remote} from 'electron';
if (process.env.PATH.indexOf('/usr/local/bin') === -1 && process.platform !== 'win32') {
// Note:
// This solves the problem that $PATH is not set up when app is
// started via clicking NyaoVim.app.
//
// XXX:
// This is just a workaround.
// If nvim is installed to other directory, we can't know that.
process.env.PATH += ':/usr/local/bin';
}
const nyaovimrc_path: string = remote.getGlobal('nyaovimrc_path');
if (!nyaovimrc_path) {
console.error('nyaovimrc is not found in renderer process');
}
const link = document.createElement('link') as HTMLLinkElement;
link.rel = 'import';
link.href = nyaovimrc_path;
document.head.appendChild(link);
示例9: loadContent
webFrame.registerURLSchemeAsSecure('wexond-extension');
const pages: any = {
newtab: 'newtab',
testField: 'test-field',
history: 'history',
};
for (const page in pages) {
if (
window.location.href.startsWith(`wexond://${pages[page]}`) ||
window.location.href.startsWith(`http://localhost:8080/${pages[page]}.html`)
) {
const globalObject = global as GlobalAPI;
globalObject.dictionary = dictionaries[remote.getGlobal('locale')];
globalObject.getHistory = getHistory;
loadContent(page);
}
}
const matchesPattern = (pattern: string, url: string) => {
if (pattern === '<all_urls>') {
return true;
}
const regexp = new RegExp(`^${pattern.replace(/\*/g, '.*')}$`);
return url.match(regexp);
};
示例10:
import {remote} from 'electron'
declare var window: any;
const args = remote.getGlobal('args')
window.commandLineArgs = JSON.parse(args[2]);