本文整理匯總了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])
}