node-webkit应用程序不能在Windows 7上工作32位

问题描述:

我是新的节点webkit和在html中开发桌面应用程序。我创建了一个小项目,并运行使用nw.exe和它在Windows 8.1 64位工作正常,但它不在Windows 7中工作。node-webkit应用程序不能在Windows 7上工作32位

意味着它运行,如果我点击很多次然后突然开始和关闭一次然后不能够再次运行。

的package.json

{ 
"window": { 
"icon": "app.png", 
"toolbar": true, 
"show": false, 
"toolbar": false, 
"frame": true, 
"position": "center", 
"width": 1360, 
"height": 720 
}, 
"apache_port": 81, 
"mysql_port": 3308, 
"name": "My App", 
"version": "1.0.0", 
"author": "Author", 
"email": "[email protected]", 
"phone": "+91-9999999999", 
"url": "http://example.com", 
"main": "index.html" 

}

的Index.html

<script> 
String.prototype.replaceAll = function(search, replacement) { 
var target = this; 
return target.replace(new RegExp(search, 'g'), replacement); 
}; 

var gui = require("nw.gui"); 

var fs = require('fs'); 

if(process.env.PWD) { 
    process.chdir(process.env.PWD); 
} 

/** 
* Base dirpath 
*/ 
var base_path=process.cwd(); 

var i=0; 
while(i!=-1) { 
base_path=base_path.replace("\\","/"); 
i=base_path.indexOf('\\'); 
} 

/** 
* Package.JSON Details 
*/ 
var package; 

//read config file 
fs.readFile('./package.json', 'utf-8', function (error, contents) { 
    package = JSON.parse(contents); 
}); 

function log(str) { 
    //document.getElementById('text').value+= (str+"\n"); 
} 

function proc_config(file,path) { 
    fs.readFile(base_path+'/config/'+file, 'utf-8', function (error, contents) { 

     var substr="%phpbrowserbox%"; 
     var replc=base_path; 
     contents = contents.replaceAll(substr, replc); 

     contents = contents.replaceAll('%mysql_port%', package.mysql_port); 
     contents = contents.replaceAll('%apache_port%', package.apache_port); 


     fs.writeFile(base_path+"/"+path+"/"+file, contents, function(err) { 
     if(err) { 
       return log("error:"+err); 
     } 


     log(file+" was saved to "+base_path+"/"+path+"/"+file); 
    }); 


    }); 

} 
</script> 

<!DOCTYPE html> 
<html> 
<head> 
<title>Please wait...</title> 
<style> 
html,body {height:100%;} 
</style> 

</head> 
<body style="margin:0;padding:0;overflow:hidden;"> 

<img src="splash.jpg" style="width:100%;height:100%;"> 

<script> 
window.onload=function() { 
document.title=package.name; 
proc_config('php.ini','bin/php'); 
proc_config('php.ini','bin/apache/bin'); 

proc_config('my.ini','bin/mysql'); 
proc_config('httpd.conf','bin/apache/conf'); 

var mysqld=base_path+"/bin/mysql/bin/mysqld.exe" 
var httpd=base_path+"/bin/apache/bin/httpd.exe" 

var proc = require('child_process'); 

//start apache server 
proc.spawn(httpd); 

//start mysql server 
proc.spawn(mysqld); 

location.href="http://localhost:"+package.apache_port+"?apache_port="+package.apache_port+"&mysql_port="+package.mysql_port+"&cache="+Math.random()+"&base_path="+base_path; 

gui.Window.get().show(); 
} 
</script> 
</body> 
</html> 

任何一个可以帮助?

+0

你使用的是32位版本的nw.js吗? –

+0

实际上,我使用的是phpbrowser盒子及其在节点webkit中,所以我不知道它们使用的是什么版本! –

64位NW不能在32位系统上工作,但32位应该可以在所有系统上工作。为了节省自己很多麻烦,只需编译并坚持32位。 无论如何,64位应用程序总是比较慢,因为内存寻址模式的大小是双倍的,每个指令(大或小)都必须清除/设置/读取更宽的寄存器。另外,无论何时你的应用第一次运行然后不再运行,通常都是因为它仍然在内存中,并且没有完全/正确退出。若要检查此操作,请按CTRL + ALT + DEL,如果仍存在,则终止进程。

最后,你的package.json似乎有点欠缺所以考虑研究并增加了一些更多的参数,如...

 "nodejs": true, 

“单实例”:真实, “页面缓存”:假

...等等。祝你好运。