本文整理汇总了TypeScript中remote.require函数的典型用法代码示例。如果您正苦于以下问题:TypeScript require函数的具体用法?TypeScript require怎么用?TypeScript require使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了require函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: buildMenu
function buildMenu(platform: string) {
var remote = require('remote');
var Menu = remote.require('menu');
var MenuItem = remote.require('menu-item');
var osModifier = modifier(platform);
var template = [
{
label: 'Electron',
submenu: [
{
label: 'About Electron',
selector: 'orderFrontStandardAboutPanel:'
},
{
type: 'separator'
},
{
label: 'Quit',
accelerator: osModifier('Q'),
selector: 'terminate:'
},
]
},
{
label: 'Edit',
submenu: [
{
label: 'Cut',
accelerator: osModifier('X'),
selector: 'cut:'
},
{
label: 'Copy',
accelerator: osModifier('C'),
selector: 'copy:'
},
{
label: 'Paste',
accelerator: osModifier('V'),
selector: 'paste:'
}
]
}
];
var menu = Menu.buildFromTemplate(template);
Menu.setApplicationMenu(menu);
}
示例2: require
(function () {
'use strict';
var remote = require('remote');
var Menu = remote.require('menu');
var MenuItem = remote.require('menu-item');
var cut = new MenuItem({
label: "Cut",
click: function () {
document.execCommand("cut");
}
});
var copy = new MenuItem({
label: "Copy",
click: function () {
document.execCommand("copy");
}
});
var paste = new MenuItem({
label: "Paste",
click: function () {
document.execCommand("paste");
}
});
var textMenu = new Menu();
textMenu.append(cut);
textMenu.append(copy);
textMenu.append(paste);
document.addEventListener('contextmenu', function(e:any) {
switch (e.target.nodeName) {
case 'TEXTAREA':
case 'INPUT':
e.preventDefault();
textMenu.popup(remote.getCurrentWindow());
break;
}
}, false);
}());
示例3: changeThema
export function changeThema(themaId: string) {
var cfg: config.Config = remote.getGlobal('cfg')
cfg.thema = themaId
remote.require('./services/config').writeConfig(remote.process.execPath, cfg)
switch(themaId) {
case 'thema-normal':
changeThemaMenu(themaId)
changeCssThemaFile('./css/thema-normal.css')
break
case 'thema-dark':
changeThemaMenu(themaId)
changeCssThemaFile('./css/thema-dark.css')
break
}
}
示例4: openFullscreened
export function openFullscreened(url) {
if (window['mbe_config'] && mbe_config.isElectron) {
url = new URL(url, location.href).toString();
var remote = require('remote');
var BrowserWindow = remote.require('browser-window');
var wind = new BrowserWindow({
// fullscreen: true, // 不是 HTML5 全屏,并没有什么用处
resizable: true,
width: screen.availWidth,
height: screen.availHeight,
'web-preferences': {
'plugins': true
}
});
wind.loadUrl(url);
// wind.openDevTools();
} else {
window.open(url);
}
}
示例5: require
import Session from "../Session";
import PluginManager from "../PluginManager";
const remote = require("remote");
const app = remote.require("app");
PluginManager.registerEnvironmentObserver({
currentWorkingDirectoryWillChange: () => { /* do nothing */ },
currentWorkingDirectoryDidChange: (session: Session, directory: string) => {
app.addRecentDocument(directory);
remote.getCurrentWindow().setRepresentedFilename(directory);
},
});
示例6: require
declare function require(name:string):any
declare var process:any;
var remote = require("remote");
var dialog = remote.require("dialog");
/**
* In example : { name: 'Images', extensions: ['jpg', 'png', 'gif'] }
*/
export interface ExtensionFilter {
name : string
extensions : string[]
}
interface FileDialogOptions {
title : string
properties : string[]
defaultPath? : string
filters? : ExtensionFilter[]
}
export function openFileDialogModal(title : string, defaultPath? : string, filters? : ExtensionFilter[]) : string {
var options = constructOptions(title, defaultPath, filters, ['openFile']);
return dialog.showOpenDialog(options);
}
export function openFileDialog(title : string, callBack : (path:string)=>void, defaultPath? : string,
filters? : ExtensionFilter[]) : void {
var options = constructOptions(title, defaultPath, filters, ['openFile']);
dialog.showOpenDialog(options, resultPath=> {
if(resultPath) callBack(resultPath[0])
}