node-webkit 应用程序无法在 windows 7 32 位上运行

node-webkit app not working on windows 7 32 bit

我是节点 webkit 的新手,在 html 开发桌面应用程序。我已经使用 nw.exe 创建了一个小项目 运行,它在 windows 8.1 64 位中工作正常,但在 windows 7.

中无法正常工作

意思是 运行 如果我点击很多次然后突然开始,关闭一次后就不能再 运行。

我的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": "test@yahoo.com",
"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>

有人能帮忙吗?

64 位 NW 不适用于 32 位系统,但 32 位应该适用于所有系统。为了省去很多麻烦,只需编译并坚持使用 32 位即可。 无论如何,64 位应用程序总是比较慢,因为内存寻址模式的大小是两倍,并且每条指令(大或小)都必须 clear/set/read 更宽的寄存器。

此外,每当您的应用程序第一次运行然后不再运行时,通常是因为它仍在内存中并且尚未 fully/properly 退出。要检查这一点,请执行 CTRL+ALT+DEL 并终止进程(如果进程仍然存在)。

最后,您的 PACKAGE.JSON 似乎有点欠缺,因此请考虑研究并添加更多参数,例如...

     "nodejs": true,

"single-instance":是的, "page-cache" : 假

...等等。祝你好运。