登录后判断是否有数据文件夹, 如果没有, 则新建之

This commit is contained in:
life
2015-02-23 22:19:34 +08:00
parent 44fe2926a0
commit 3a179380db
6 changed files with 23 additions and 7 deletions

4
node_modules/common.js generated vendored
View File

@@ -1,6 +1,6 @@
var fs = require('fs');
var User = require('user');
var Evt = require('evt');
// var User = require('user');
// var Evt = require('evt');
var ObjectId = require('objectid');
// var gui = require('nw.gui');

6
node_modules/db.js generated vendored
View File

@@ -1,9 +1,13 @@
var Datastore = require('nedb');
var path = require('path');
var Evt = require('evt');
// 数据库初始化
// var dbPath = require('nw.gui').App.dataPath + '/nedb';
var dbPath = '/Users/life/Library/Application Support/Leanote' + '/nedb';
// var dbPath = Evt.getBasePath() + '/Users/life/Library/Application Support/Leanote' + '/nedb';
var dbPath = Evt.getBasePath() + '/nedb';
console.log(",,,,,,,,,,,,,");
console.log(dbPath);
var db = {};
var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'noteHistories'];
for(var i in dbNames) {

13
node_modules/evt.js generated vendored
View File

@@ -1,5 +1,5 @@
var fs = require('fs');
var User = require('user');
// var User = require('user');
function log(o) {
console.log(o);
@@ -19,6 +19,7 @@ var Evt = {
leanoteUrl: 'http://localhost:9000',
port: 8008,
localUrl: 'http://127.0.0.1:8008',
dataBasePath: '',
getImageLocalUrl: function(fileId) {
return this.localUrl + '/api/file/getImage?fileId=' + fileId;
},
@@ -27,12 +28,20 @@ var Evt = {
},
// 项目绝对地址
getBasePath: function() {
var me = this;
// return dataBasePath; // process.cwd();
return process.cwd();
// return process.cwd();
return me.dataBasePath;
},
getAbsolutePath: function(relative) {
var me = this;
return me.getBasePath() + '/' + relative;
},
setDataBasePath: function(dataBasePath) {
var me = this;
console.log('...........')
console.log(dataBasePath);
me.dataBasePath = dataBasePath;
}
};
module.exports = Evt;

View File

@@ -32,7 +32,6 @@ function ani(callback) {
}
}
// 判断是否登录
UserService.init(function(userInfo) {
if(userInfo) {

View File

@@ -1,5 +1,9 @@
var Common = require('common');
var Evt = require('evt');
var basePath = require('nw.gui').App.dataPath;
Evt.setDataBasePath(basePath);
// 所有service, 与数据库打交道
var Service = {
notebookService: require('notebook'),