diff --git a/src/login.html b/src/login.html index 675c47f9..bbf27586 100644 --- a/src/login.html +++ b/src/login.html @@ -5,30 +5,12 @@ - + Leanote login - - + - + + diff --git a/src/main.js b/src/main.js index e659ee86..6a8ebf66 100644 --- a/src/main.js +++ b/src/main.js @@ -4,6 +4,8 @@ var BrowserWindow = require('browser-window'); // Module to create native brows // Report crashes to our server. require('crash-reporter').start(); +var debug = false; + // Keep a global reference of the window object, if you don't, the window will // be closed automatically when the javascript object is GCed. var mainWindow = null; @@ -16,7 +18,7 @@ app.on('window-all-closed', function() { // 避免可以启动多个app app.on('open-file', function(e) { - console.log('reopen'); + // console.log('reopen'); if(mainWindow) { mainWindow.show(); mainWindow.focus(); @@ -218,10 +220,12 @@ function openIt() { // require('leanote_protocol'); // Create the browser window. - mainWindow = new BrowserWindow({width: 1050, - height: 595, - frame: process.platform != 'darwin', - transparent: false } + mainWindow = new BrowserWindow({ + width: 1050, + height: 595, + frame: debug || process.platform != 'darwin', + transparent: false + } ); // and load the index.html of the app. @@ -265,5 +269,5 @@ function openIt() { }); // 作为调试 - // setMenu(); + debug && setMenu(); } diff --git a/src/node_modules/db.js b/src/node_modules/db.js index c33d25d6..aaf8198f 100644 --- a/src/node_modules/db.js +++ b/src/node_modules/db.js @@ -17,12 +17,16 @@ if(dbPath.length < 6) { // console.log(dbPath); // g, 表全局环境 var db = {}; -var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'noteHistories', 'g']; +var dbNames = ['users', 'notebooks', 'notes', 'tags', 'images', 'attachs', 'noteHistories', 'g']; for(var i in dbNames) { var name = dbNames[i]; var p = path.join(dbPath, name + '.db'); - // console.log(p); - db[name] = new Datastore({ filename: p, autoload: true }); + (function (name) { + // 这部分非常慢!, 会卡界面 + db[name] = new Datastore({ filename: p, autoload: true , onload: function () { + console.log(name + ' is loaded'); + }}); + })(name); } module.exports = db; console.log('db inited'); \ No newline at end of file diff --git a/src/node_modules/user.js b/src/node_modules/user.js index 6f86d89d..ed4e46b1 100644 --- a/src/node_modules/user.js +++ b/src/node_modules/user.js @@ -51,12 +51,12 @@ User = { //FIXME 鉴于服务器端也是明文密码,暂时用明文,安全性堪忧 db.users.count({Username: username, Pwd: password}, function(err, count) { - log('login failed: ' + count); - log(err); + // log('login failed: ' + count); + // log(err); callback && callback(count == 1); }); }, - saveNew: function(user, callback) { + createLocalUser: function(user, callback) { // 当前用户是否在数据库中 db.users.count({Username: user.Username}, function(err, count) { if(count == 0) { @@ -65,9 +65,9 @@ User = { callback && callback(!err, doc); }); } else { - log('save new user failed: username exists') - log(err); - callback && callback(false); + // log('save new user failed: username exists') + // log(err); + callback && callback(false, 'User exists'); } }); }, diff --git a/src/public/css/index.css b/src/public/css/index.css index 71c975e0..3370a479 100644 --- a/src/public/css/index.css +++ b/src/public/css/index.css @@ -337,6 +337,14 @@ input, margin-bottom: 30px; width: 248px; color: #eee; + height: 102px; + text-align: center; +} +#box h1 span { + display: none; + font-size: 24px; + color: #000; + line-height: 102px; } #boxHeader { border-color: #e8e8e8; @@ -772,11 +780,12 @@ form { #loginMsg { margin: auto; padding: 0; + padding-bottom: 5px; text-align: center; } .bottom { position: absolute; - bottom: 5px; + bottom: 10px; left: 0; right: 0; text-align: center; @@ -784,9 +793,46 @@ form { .bottom a { color: #666; font-size: 85%; + display: block; } -.decolour { - -webkit-filter: grayscale(100%); +.bottom .loginWithLeanote { + display: none; +} +.host-group, +.local-form { + display: none; +} +.local-account .bottom a, +.custom-server .bottom a { + display: none; +} +.local-account .bottom .loginWithLeanote, +.custom-server .bottom .loginWithLeanote { + display: block; +} +.custom-server .host-group { + display: block; +} +.custom-server .btns { + display: none; +} +.custom-server #loadingLogo { + display: none; +} +.custom-server #box h1 span.customServer { + display: block; +} +.local-account .local-form { + display: block; +} +.local-account .leanote-form { + display: none; +} +.local-account #loadingLogo { + display: none; +} +.local-account #box h1 span.localAccount { + display: block; } .win-tool { padding: 5px; @@ -844,3 +890,17 @@ form { .blur .win-tool a { background: url(icon/traffic-disabled@2x.png); } +body #container { + margin: 0 auto; + border-radius: 0; + box-shadow: none; + border: none; +} +html, +body { + overflow: hidden; + background-color: rgba(247, 249, 250, 0.99); +} +.drag { + left: 50px; +} diff --git a/src/public/css/index.less b/src/public/css/index.less index 3a88070f..cedda4ac 100644 --- a/src/public/css/index.less +++ b/src/public/css/index.less @@ -344,6 +344,15 @@ input, .form-control { margin-bottom: 30px; width: @boxWidth;; color: #eee; + + height: 102px; + text-align: center; + span { + display: none; + font-size: 24px; + color: #000; + line-height: 102px; + } } } @@ -849,23 +858,90 @@ form { //position: absolute; margin: auto; padding: 0; + padding-bottom: 5px; text-align: center; } .bottom { position: absolute; - bottom: 5px; + bottom: 10px; left: 0; right: 0; text-align: center; a { color: #666; font-size: 85%; + display: block; + } + + .loginWithLeanote { + display: none; } } -.decolour { - -webkit-filter: grayscale(100%); +.host-group, .local-form { + display: none; +} + +.local-account, .custom-server { + .bottom { + a { + display: none; + } + .loginWithLeanote { + display: block; + } + } +} + +.custom-server { + .host-group { + display: block; + } + .btns { + display: none; + } + + #loadingLogo { + display: none; + } + #box h1 span.customServer { + display: block; + } +} +.local-account { + .local-form { + display: block; + } + .leanote-form { + display: none; + } + + // #loadingLogo { + // -webkit-filter: grayscale(100%); + // } + + #loadingLogo { + display: none; + } + #box h1 span.localAccount { + display: block; + } } @import "traffic.less"; + +body #container { + margin: 0 auto; + border-radius: 0; + box-shadow: none; + border: none; +} + +html, body { + overflow: hidden; + background-color: rgba(247, 249, 250, 0.99); +} +.drag { + left: 50px; +} diff --git a/src/public/js/app/service.js b/src/public/js/app/service.js index 9e346f64..06e9495f 100644 --- a/src/public/js/app/service.js +++ b/src/public/js/app/service.js @@ -15,7 +15,6 @@ if(!/login.html/.test(location.href)) { var Service = { notebookService: require('notebook'), noteService: require('note'), - tagService: require('tag'), userService: require('user'), tagService: require('tag'), apiService: require('api'), diff --git a/src/public/js/app/service_login.js b/src/public/js/app/service_login.js new file mode 100644 index 00000000..962fdef2 --- /dev/null +++ b/src/public/js/app/service_login.js @@ -0,0 +1,20 @@ +var Common = require('common'); + +var Evt = require('evt'); +var app = require('remote').require('app'); +var basePath = app.getPath('appData') + '/leanote'; // /Users/life/Library/Application Support/Leanote'; // require('nw.gui').App.dataPath; +Evt.setDataBasePath(basePath); + +// 所有service, 与数据库打交道 +var Service = { + userService: require('user'), + apiService: require('api'), +}; + +// 全局变量 +var ApiService = Service.apiService; +var UserService = Service.userService; +var EvtService = require('evt'); +var CommonService = Common; + +var gui = require('gui'); \ No newline at end of file diff --git a/src/public/js/common.js b/src/public/js/common.js index b70b7992..06b67127 100644 --- a/src/public/js/common.js +++ b/src/public/js/common.js @@ -984,7 +984,7 @@ var email2LoginAddress = { 'eyou.com': 'http://www.eyou.com/', '21cn.com': 'http://mail.21cn.com/', '188.com': 'http://www.188.com/', - 'foxmail.coom': 'http://www.foxmail.com' + 'foxmail.com': 'http://www.foxmail.com' }; function getEmailLoginAddress(email) { @@ -1466,13 +1466,12 @@ function goToMainPage() { function switchAccount() { SyncService.stop(); // location.href = 'login.html'; - // var BrowserWindow = gui.remote.require('browser-window'); if(isMac()) { - var win = new BrowserWindow({ width: 278, height: 316, show: true, frame: false, resizable: false }); + var win = new BrowserWindow({ width: 278, height: 326, show: true, frame: false, resizable: false }); win.loadUrl('file://' + __dirname + '/login.html'); } else { - var win = new BrowserWindow({ width: 278, height: 416, show: true, frame: true, resizable: false }); + var win = new BrowserWindow({ width: 278, height: 426, show: true, frame: true, resizable: false }); win.loadUrl('file://' + __dirname + '/login.html'); } gui.getCurrentWindow().close();