login.html不能通过window.open, 不然会有问题

This commit is contained in:
life
2015-03-06 01:55:47 +08:00
parent 0e6fc7ac2b
commit fe29869cc8
11 changed files with 36 additions and 27 deletions

View File

@@ -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';

28
node_modules/api.js generated vendored
View File

@@ -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);
}
});

1
node_modules/common.js generated vendored
View File

@@ -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);

3
node_modules/evt.js generated vendored
View File

@@ -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: '',

5
node_modules/note.js generated vendored
View File

@@ -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');

1
node_modules/notebook.js generated vendored
View File

@@ -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);}

2
node_modules/sync.js generated vendored
View File

@@ -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) {

2
node_modules/web.js generated vendored
View File

@@ -109,7 +109,7 @@ var Web = {
syncProcess: function(type, title) {
var me = this;
me.Note.syncProcess('In sync ' + type + ' <br /> ' + title);
me.Note.syncProcess('In sync ' + type + '... <br /> ' + title);
},
/*
syncNotebookFinish: function() {

View File

@@ -6,8 +6,8 @@
"window": {
"toolbar": true,
"frame": false,
"transparent": true,
"frame": true,
"transparent": false,
"min_width": 400,
"min_height": 200,

View File

@@ -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({

View File

@@ -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() {