Tag: nw.js

console.log()没有出现在我的terminal(nwjs)

在我的nwjs应用程序中,我从HTML文件加载一个_launch.js文件: <html> <body> <script type="text/javascript" src="_launch.js"></script> </body> </html> 在我的_launch.js文件中,我启动了一个快速服务器和socketIO所需的Node进程。 var express = require('express'), app = express(), server = require('http').Server(app), io = require('socket.io')(server), gui = require('nw.gui'), __curDir = process.cwd(), //keep the logic for the IO connections separate ioServer = require(__curDir + '/server.js'); //configure Express to default web requests to /workspace/ folder app.use(express.static(__curDir + '/workspace')); ioServer.init(io, console); […]

为什么在没有Internet连接的情况下,Node Webkit中的require('child-process')不起作用?

在最新的稳定版本(v0.18.8)上运行的Node-Webkit应用程序中,我有这三行: console.log("Check 1"); var spawn = require('child_process').spawn; console.log("Check 2"); 当我有互联网,我得到预期的输出: Check 1 Check 2 当我从互联网上断开连接,或者没有networking时,我得到: Check 1 net.js:10 Uncaught Error: EFILE at net.js:10:23 at NativeModule.compile (bootstrap_node.js:531:7) at NativeModule.require (bootstrap_node.js:472:18) at internal/child_process.js:6:13 at NativeModule.compile (bootstrap_node.js:531:7) at NativeModule.require (bootstrap_node.js:472:18) at child_process.js:12:23 at NativeModule.compile (bootstrap_node.js:531:7) at Function.NativeModule.require (bootstrap_node.js:472:18) at Function.Module._load (module.js:446:25) console.log("Check 2")从不运行,脚本的其余部分将被忽略。 我不应该需要互联网连接来需要的东西,所以我很困惑,这里有什么问题。 一些其他的require()语句也会发生这个错误,但不是全部。 例如, require('nw.gui')工作正常。 我如何在没有Internet连接的情况下使用require() […]

我可以使用Node-Webkit(NW.js)的游戏手柄吗?

我正在构build一个NW.js(Node-Webkit)仪表板应用程序,我希望能够使用游戏控制器(例如:XBox 360控制器或Logitech控制器)进行控制。 我打电话给下面的准备,但是当我debugging它不识别任何游戏手柄。 angular.element(document).ready(function() { if(canGame()) { var prompt = "To begin using your gamepad, connect it and press any button!"; $("#gamepadPrompt").text(prompt); $(window).on("gamepadconnected", function() { $("#gamepadPrompt").html("Gamepad connected!"); console.log("connection event"); }); $(window).on("gamepaddisconnected", function() { console.log("disconnection event"); $("#gamepadPrompt").text(prompt); }); } }); function canGame() { return "getGamepads" in navigator; } 当我debugging代码时,它似乎没有检测到任何游戏手柄。 我也尝试: navigator.webkitGetGamepads() 但是并不显示任何游戏手柄。 有没有人成功地使用NW.js应用程序的游戏手柄? 我将不胜感激一些帮助得到这个工作。

在OS X上创build类似窗口的菜单

我想创build一个像这个应用程序一样的托盘菜单。 因为它在使用node-webkit / nw.js的应用程序列表中,所以我认为这是可能的。 我浏览了所有的文档,找不到任何有关如何实现的信息。 search谷歌也不是很有成效。 也许你们中的一个人之前做过这样的事情,可以让我朝着正确的方向发展?

从NW.JS的程序切换器隐藏窗口

我正在用NW.JS(node-webkit)编写桌面应用程序。 在我的应用程序用户可能会打开很多窗口,我想隐藏他们从程序切换器(ALT +标签)和任务栏。 我已经find了从taksbar隐藏窗口的选项,但无法find任何方法来隐藏程序切换器。 这甚至有可能吗? 或者至less是可以将所有窗口分组为一个(就像在Windows上的便利贴)?

在NW.js中检查WebKit上下文何时可用

当在节点上下文( node-main )中执行时, setTimeout(function () { console.log(nw); }, 20); 投 nw没有定义 因为WebKit上下文尚未准备就绪(从开始window开始,NW.js <= 0.12,NW.js> = 0.13中的window.nw不可用)。 和 setTimeout(function () { console.log(nw); }, 200); 工作得很好,但setTimeout看起来像一个黑客,将其设置为安全延迟值可能会导致不必要的滞后。 如何从Node上下文中检查WebKit上下文和nw的可用性? 有没有合理的方法,就像一个可以处理的事件?

Electron.js如何最小化/closures窗口到系统托盘和从托盘恢复窗口?

我希望Electron.js应用程序能够在系统托盘上运行,并且每当用户想要执行某些操作时,都可以从系统托盘中进行恢复,并将其最小化/closures回系统托盘。 我怎么做? 我已经从文档中看到了tray部分,但是对于实现我想要的却没有多大帮助。 这是我到目前为止在main.js文件 var application = require('app'), BrowserWindow = require('browser-window'), Menu = require('menu'), Tray = require('tray'); application.on('ready', function () { var mainWindow = new BrowserWindow({ width: 650, height: 450, 'min-width': 500, 'min-height': 200, 'accept-first-mouse': true, // 'title-bar-style': 'hidden', icon:'./icon.png' }); mainWindow.loadUrl('file://' + __dirname + '/src/index.html'); mainWindow.on('closed', function () { mainWindow = null; }); mainWindow.setMenu(null); […]