图片显示不出的情况!

https://github.com/leanote/desktop-app/issues/51
This commit is contained in:
life
2015-09-22 14:39:22 +08:00
parent d787a8c259
commit 0eec3cdd67
2 changed files with 31 additions and 6 deletions

34
src/node_modules/server.js generated vendored
View File

@@ -5,6 +5,7 @@ var http = require('http');
var url = require('url');
var path = require('path');
var fs = require('fs');
var Common = require('common');
// http server, 处理笔记图片
var Server = {
@@ -86,13 +87,36 @@ var Server = {
});
});
server.listen(Evt.port);
console.log("Server runing at port: " + Evt.port + ".");
// kill 端口占用的pid
var child_process = require('child_process');
function killPort(callback) {
if (Common.isWin()) {
// & EXIT 表示只循环一次
// Leanote会有两个pid绑定端口, 另一个和electron相关, kill掉也会把自己kill掉
var sh1 = 'FOR /F "tokens=4 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
var sh2 = 'FOR /F "tokens=5 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
child_process.exec(sh1, function () {
child_process.exec(sh2, callback);
});
}
else {
var sh = 'kill -9 $(lsof -i:' + Evt.port + ' -t)';
child_process.exec(sh, callback);
}
}
killPort(function (error, stdout, stderr) {
if (error !== null) {
console.log('kill port error: ' + error);
}
me.localUrl = Evt.localUrl;
me._started = true;
server.listen(Evt.port);
console.log("Server runing at port: " + Evt.port + ".");
me.server = server;
me.localUrl = Evt.localUrl;
me._started = true;
me.server = server;
});
},
// 关闭服务

View File

@@ -1382,8 +1382,9 @@ function initPage(initedCallback) {
function _init() {
$(function() {
// 很奇怪, 当port被占用后, notebook不能获取, 其它的可以
// 获取笔记本
Service.notebookService.getNotebooks(function(notebooks) {
NotebookService.getNotebooks(function(notebooks) {
Notebook.renderNotebooks(notebooks);
ok();
});