mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-17 16:45:21 +00:00
登录后判断是否有数据文件夹, 如果没有, 则新建之
This commit is contained in:
4
node_modules/common.js
generated
vendored
4
node_modules/common.js
generated
vendored
@@ -1,6 +1,6 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var User = require('user');
|
// var User = require('user');
|
||||||
var Evt = require('evt');
|
// var Evt = require('evt');
|
||||||
var ObjectId = require('objectid');
|
var ObjectId = require('objectid');
|
||||||
|
|
||||||
// var gui = require('nw.gui');
|
// var gui = require('nw.gui');
|
||||||
|
6
node_modules/db.js
generated
vendored
6
node_modules/db.js
generated
vendored
@@ -1,9 +1,13 @@
|
|||||||
var Datastore = require('nedb');
|
var Datastore = require('nedb');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var Evt = require('evt');
|
||||||
|
|
||||||
// 数据库初始化
|
// 数据库初始化
|
||||||
// var dbPath = require('nw.gui').App.dataPath + '/nedb';
|
// 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 db = {};
|
||||||
var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'noteHistories'];
|
var dbNames = ['notebooks', 'notes', 'users', 'tags', 'images', 'attachs', 'noteHistories'];
|
||||||
for(var i in dbNames) {
|
for(var i in dbNames) {
|
||||||
|
13
node_modules/evt.js
generated
vendored
13
node_modules/evt.js
generated
vendored
@@ -1,5 +1,5 @@
|
|||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var User = require('user');
|
// var User = require('user');
|
||||||
|
|
||||||
function log(o) {
|
function log(o) {
|
||||||
console.log(o);
|
console.log(o);
|
||||||
@@ -19,6 +19,7 @@ var Evt = {
|
|||||||
leanoteUrl: 'http://localhost:9000',
|
leanoteUrl: 'http://localhost:9000',
|
||||||
port: 8008,
|
port: 8008,
|
||||||
localUrl: 'http://127.0.0.1:8008',
|
localUrl: 'http://127.0.0.1:8008',
|
||||||
|
dataBasePath: '',
|
||||||
getImageLocalUrl: function(fileId) {
|
getImageLocalUrl: function(fileId) {
|
||||||
return this.localUrl + '/api/file/getImage?fileId=' + fileId;
|
return this.localUrl + '/api/file/getImage?fileId=' + fileId;
|
||||||
},
|
},
|
||||||
@@ -27,12 +28,20 @@ var Evt = {
|
|||||||
},
|
},
|
||||||
// 项目绝对地址
|
// 项目绝对地址
|
||||||
getBasePath: function() {
|
getBasePath: function() {
|
||||||
|
var me = this;
|
||||||
// return dataBasePath; // process.cwd();
|
// return dataBasePath; // process.cwd();
|
||||||
return process.cwd();
|
// return process.cwd();
|
||||||
|
return me.dataBasePath;
|
||||||
},
|
},
|
||||||
getAbsolutePath: function(relative) {
|
getAbsolutePath: function(relative) {
|
||||||
var me = this;
|
var me = this;
|
||||||
return me.getBasePath() + '/' + relative;
|
return me.getBasePath() + '/' + relative;
|
||||||
|
},
|
||||||
|
setDataBasePath: function(dataBasePath) {
|
||||||
|
var me = this;
|
||||||
|
console.log('...........')
|
||||||
|
console.log(dataBasePath);
|
||||||
|
me.dataBasePath = dataBasePath;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
module.exports = Evt;
|
module.exports = Evt;
|
||||||
|
@@ -32,7 +32,6 @@ function ani(callback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 判断是否登录
|
// 判断是否登录
|
||||||
UserService.init(function(userInfo) {
|
UserService.init(function(userInfo) {
|
||||||
if(userInfo) {
|
if(userInfo) {
|
||||||
|
@@ -1,5 +1,9 @@
|
|||||||
var Common = require('common');
|
var Common = require('common');
|
||||||
|
|
||||||
|
var Evt = require('evt');
|
||||||
|
var basePath = require('nw.gui').App.dataPath;
|
||||||
|
Evt.setDataBasePath(basePath);
|
||||||
|
|
||||||
// 所有service, 与数据库打交道
|
// 所有service, 与数据库打交道
|
||||||
var Service = {
|
var Service = {
|
||||||
notebookService: require('notebook'),
|
notebookService: require('notebook'),
|
||||||
|
Reference in New Issue
Block a user