diff --git a/login.html b/login.html index 7815e1b9..2c1bb898 100644 --- a/login.html +++ b/login.html @@ -87,11 +87,11 @@ $(function() { return; } } - - $("#loginBtn").html("loading...").addClass("disabled"); + // TODO show loading + // console.log(33); + // $("#loginBtn").html("loading...").addClass("disabled"); ApiService.auth(email, pwd, function(ret) { - $("#loginBtn").html("Sign in").removeClass("disabled"); - // console.log(ret); + // $("#loginBtn").html("Sign in").removeClass("disabled"); if(ret.Ok) { $("#loginBtn").html("Success..."); location.href = 'index.html'; diff --git a/node_modules/api.js b/node_modules/api.js index d12cd157..eb816631 100644 --- a/node_modules/api.js +++ b/node_modules/api.js @@ -9,9 +9,10 @@ var Web = require('web'); var Tags = db.tags; var needle = require('needle'); var fs = require('fs'); +var Evt = require('evt'); function log(o) { - console.log(o); + // console.log(o); } // log(Common); // log(db); @@ -19,9 +20,6 @@ function log(o) { // 远程数据服务 var Api = { - leanoteUrl: 'http://localhost:9000', - baseUrl: 'http://localhost:9000/api', - // 检查错误 checkError: function(error, resp) { var me = this; @@ -53,7 +51,7 @@ var Api = { // 是否断网 unConnected: function(error) { var me = this; - console.log(error); + // console.log(error); if(error && (error.code == "ECONNREFUSED" || error.code == 'ECONNRESET')) { // socket hand up Web.unConnected(); return true; @@ -63,7 +61,7 @@ var Api = { getUrl: function(url, param) { if(!User) { } - var url = this.baseUrl + '/' + url; + var url = Evt.leanoteUrl + '/api/' + url; var token = User.getToken(); param = param || {}; param.token = token; @@ -74,31 +72,35 @@ var Api = { } } if(url.indexOf('?') >= 0) { - return url + '&' + paramStr; + url = url + '&' + paramStr; } - return url + '?' + paramStr; + url = url + '?' + paramStr; + console.log(url); + return url; }, // 登录 auth: function(email, pwd, callback) { var me = this; + // log({emai: email, pwd: pwd}); - // log(this.getUrl('auth/login', {email: email, pwd: pwd})); + console.log(this.getUrl('auth/login', {email: email, pwd: pwd})); + // console.log('????????????') needle.get(this.getUrl('auth/login', {email: email, pwd: pwd}), function(error, response) { me.checkError(error, response); if(error) { return callback && callback(false); } - // needle.get('http://localhost/phpinfo.php?email=xx', {emai: email, pwd: pwd}, function(error, response) { + // needle.get('http://localhost/phpinfo.php?email=xx', {emai: email, pwd: pwd}, function(error, response) { var ret = response.body; // 登录成功, 保存token - // log('login ret'); - // log(ret); + // console.log('login ret'); + // console.log(ret); if(Common.isOk(ret)) { ret.Pwd = pwd; User.setCurUser(ret); callback && callback(ret); } else { - log('log failed'); + // console.log('log failed'); callback && callback(false); } }); diff --git a/node_modules/common.js b/node_modules/common.js index 28e17267..8324a7a8 100644 --- a/node_modules/common.js +++ b/node_modules/common.js @@ -132,7 +132,6 @@ var Common = { } // new Date(); if(typeof goNow == 'object') { - alert(3); return date; } var str = goNow.substr(0, 10) + " " + goNow.substr(11, 8); diff --git a/node_modules/evt.js b/node_modules/evt.js index 94441407..72b07999 100644 --- a/node_modules/evt.js +++ b/node_modules/evt.js @@ -16,7 +16,8 @@ if(!fs.existsSync(dataBasePath)) { dataBasePath = ''; var Evt = { - leanoteUrl: 'http://localhost:9000', + leanoteUrl: 'http://leanote.com', + // leanoteUrl: 'http://127.0.0.1:9000', port: 8008, localUrl: 'http://127.0.0.1:8008', dataBasePath: '', diff --git a/node_modules/note.js b/node_modules/note.js index 1e88eb14..3be50946 100644 --- a/node_modules/note.js +++ b/node_modules/note.js @@ -358,7 +358,10 @@ var Note = { if(!content) { return content; } - + // http://leanote.com/file/outputImage?fileId=54f9079f38f4115c0200001b + var reg0 = new RegExp(Evt.leanoteUrl + '/file/outputImage', 'g'); + content = content.replace(reg0, Server.localUrl + '/api/file/getImage'); + var reg = new RegExp(Evt.leanoteUrl + '/api/file/getImage', 'g'); content = content.replace(reg, Server.localUrl + '/api/file/getImage'); diff --git a/node_modules/notebook.js b/node_modules/notebook.js index 5fbe873f..ce4316c7 100644 --- a/node_modules/notebook.js +++ b/node_modules/notebook.js @@ -2,6 +2,7 @@ var db = require('db'); var async = require('async'); var User = require('user'); var NB = db.notebooks; +var Common = require('common'); function log(o) {console.log(o);} diff --git a/node_modules/sync.js b/node_modules/sync.js index efb0f056..eac4307f 100644 --- a/node_modules/sync.js +++ b/node_modules/sync.js @@ -386,7 +386,7 @@ var Sync = { for(var i in tags) { var tag = tags[i]; // 得到本地的, 与之对比 - Web.syncProcess('tag', tag.Title); + Web.syncProcess('tag', tag.Tag); (function(tag) { diff --git a/node_modules/web.js b/node_modules/web.js index 98572974..e7f2026f 100644 --- a/node_modules/web.js +++ b/node_modules/web.js @@ -109,7 +109,7 @@ var Web = { syncProcess: function(type, title) { var me = this; - me.Note.syncProcess('In sync ' + type + '
' + title); + me.Note.syncProcess('In sync ' + type + '...
' + title); }, /* syncNotebookFinish: function() { diff --git a/package.json b/package.json index 7472ad68..d589a59a 100755 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ "window": { "toolbar": true, - "frame": false, - "transparent": true, + "frame": true, + "transparent": false, "min_width": 400, "min_height": 200, diff --git a/public/js/app/page.js b/public/js/app/page.js index 209eed6d..ada98fa4 100644 --- a/public/js/app/page.js +++ b/public/js/app/page.js @@ -1559,9 +1559,11 @@ function userMenu() { this.switchAccount = new gui.MenuItem({ label: 'Switch account', click: function(e) { - window.open('login.html'); - win.close(); - // location.href = 'login.html'; + // window.open('login.html'); + // win.close(); + + // 这样, 不能window.open(), 不然needle有问题 + location.href = 'login.html'; } }); this.theme = new gui.MenuItem({ diff --git a/test.js b/test.js index 5c0d52fc..1577fb1b 100755 --- a/test.js +++ b/test.js @@ -28,6 +28,7 @@ User.userId = '54f6e72899c37b6e20000044'; // var reg = new RegExp(Evt.localUrl + '/api/file/getImage', 'g'); // content = content.replace(reg, Evt.leanoteUrl + '/api/file/getImage'); +Api.auth('leanote@leanote.com', 'myleanotelife121'); User.init(function() {