ee-core 1.2.9-bate.2 → 1.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/config.default.js +7 -0
- package/core/lib/loader/ee_loader.js +1 -5
- package/lib/application.js +2 -0
- package/lib/baseApp.js +15 -0
- package/lib/eeApp.js +0 -5
- package/package.json +1 -1
- package/utils/index.js +12 -68
package/config/config.default.js
CHANGED
|
@@ -196,11 +196,7 @@ class EeLoader {
|
|
|
196
196
|
home: this.getHomedir(),
|
|
197
197
|
|
|
198
198
|
/**
|
|
199
|
-
* The directory whether is
|
|
200
|
-
* it's good for test when you want to write some file to HOME,
|
|
201
|
-
* but don't want to write to the real directory,
|
|
202
|
-
* so use root to write file to baseDir instead of HOME when unittest.
|
|
203
|
-
* keep root directory in baseDir when local and unittest
|
|
199
|
+
* The directory whether is homeDir or appUserData depend on env.
|
|
204
200
|
* @member {String} AppInfo#root
|
|
205
201
|
*/
|
|
206
202
|
root: env === 'local' || env === 'unittest' ? this.getHomedir() : this.options.appUserData,
|
package/lib/application.js
CHANGED
package/lib/baseApp.js
CHANGED
|
@@ -19,6 +19,9 @@ class BaseApp extends EeAppCore {
|
|
|
19
19
|
|
|
20
20
|
this.loader.loadConfig();
|
|
21
21
|
|
|
22
|
+
// todo
|
|
23
|
+
//this.setDatabaseDir();
|
|
24
|
+
|
|
22
25
|
// 缓存配置
|
|
23
26
|
this.getCoreDB().setItem('config', this.config);
|
|
24
27
|
|
|
@@ -108,6 +111,18 @@ class BaseApp extends EeAppCore {
|
|
|
108
111
|
return this[HTTPCLIENT];
|
|
109
112
|
}
|
|
110
113
|
|
|
114
|
+
/**
|
|
115
|
+
* todo 设置db存储目录
|
|
116
|
+
*/
|
|
117
|
+
setDatabaseDir (dirPath) {
|
|
118
|
+
if (dirPath) {
|
|
119
|
+
assert(typeof dirPath === 'string', ` ${dirPath} dirPath required, and must be a string`);
|
|
120
|
+
process.env.EE_DATABASE_DIR = dirPath;
|
|
121
|
+
} else {
|
|
122
|
+
process.env.EE_DATABASE_DIR = this.config.database.dir;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
111
126
|
/**
|
|
112
127
|
* core app have been loaded
|
|
113
128
|
*/
|
package/lib/eeApp.js
CHANGED
|
@@ -100,11 +100,6 @@ class EeApp extends BaseApp {
|
|
|
100
100
|
const winOptions = this.config.windowsOption;
|
|
101
101
|
this.electron.mainWindow = new BrowserWindow(winOptions);
|
|
102
102
|
let win = this.electron.mainWindow;
|
|
103
|
-
if (winOptions.show === false) {
|
|
104
|
-
win.once('ready-to-show', () => {
|
|
105
|
-
win.show();
|
|
106
|
-
})
|
|
107
|
-
}
|
|
108
103
|
|
|
109
104
|
// 菜单显示/隐藏
|
|
110
105
|
if (this.config.openAppMenu === 'dev-show'
|
package/package.json
CHANGED
package/utils/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const fs = require('fs');
|
|
4
3
|
const path = require('path');
|
|
5
4
|
const constant = require('../lib/constant');
|
|
6
5
|
const convert = require('koa-convert');
|
|
@@ -8,51 +7,21 @@ const is = require('is-type-of');
|
|
|
8
7
|
const co = require('co');
|
|
9
8
|
const utility = require('utility');
|
|
10
9
|
const eis = require('electron-is');
|
|
10
|
+
const utilsCommon = require('./common');
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* 创建文件夹
|
|
14
14
|
*/
|
|
15
|
-
exports.mkdir = function(dirpath, dirname) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (fs.existsSync(dirpath)) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
this.mkdir(dirpath, path.dirname(dirpath));
|
|
22
|
-
} else {
|
|
23
|
-
// 判断第二个参数是否正常,避免调用时传入错误参数
|
|
24
|
-
if (dirname !== path.dirname(dirpath)) {
|
|
25
|
-
this.mkdir(dirpath);
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
if (fs.existsSync(dirname)) {
|
|
29
|
-
fs.mkdirSync(dirpath);
|
|
30
|
-
} else {
|
|
31
|
-
this.mkdir(dirname, path.dirname(dirname));
|
|
32
|
-
fs.mkdirSync(dirpath);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
15
|
+
exports.mkdir = function (dirpath, dirname) {
|
|
16
|
+
return utilsCommon.mkdir(dirpath, dirname);
|
|
17
|
+
}
|
|
36
18
|
|
|
37
19
|
/**
|
|
38
20
|
* 修改文件权限
|
|
39
21
|
*/
|
|
40
|
-
exports.chmodPath = function(path, mode) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
files = fs.readdirSync(path);
|
|
44
|
-
files.forEach((file, index) => {
|
|
45
|
-
const curPath = path + '/' + file;
|
|
46
|
-
if (fs.statSync(curPath).isDirectory()) {
|
|
47
|
-
this.chmodPath(curPath, mode); // 递归删除文件夹
|
|
48
|
-
} else {
|
|
49
|
-
fs.chmodSync(curPath, mode);
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
fs.chmodSync(path, mode);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
22
|
+
exports.chmodPath = function (path, mode) {
|
|
23
|
+
return utilsCommon.chmodPath(path, mode);
|
|
24
|
+
}
|
|
56
25
|
|
|
57
26
|
/**
|
|
58
27
|
* 获取项目根目录package.json
|
|
@@ -97,10 +66,7 @@ exports.getEggConfig = function() {
|
|
|
97
66
|
* 获取 数据库存储路径
|
|
98
67
|
*/
|
|
99
68
|
exports.getStorageDir = function() {
|
|
100
|
-
|
|
101
|
-
const dirPath = cdb.getStorageDir();
|
|
102
|
-
|
|
103
|
-
return dirPath;
|
|
69
|
+
return utilsCommon.getStorageDir();
|
|
104
70
|
}
|
|
105
71
|
|
|
106
72
|
/**
|
|
@@ -118,7 +84,8 @@ exports.getAppUserDataDir = function() {
|
|
|
118
84
|
* 获取 日志目录
|
|
119
85
|
*/
|
|
120
86
|
exports.getLogDir = function() {
|
|
121
|
-
const
|
|
87
|
+
const cdb = this.getCoreDB();
|
|
88
|
+
const logPath = cdb.getItem('config').logger.dir;
|
|
122
89
|
return logPath;
|
|
123
90
|
}
|
|
124
91
|
|
|
@@ -180,28 +147,5 @@ exports.middleware = function (fn) {
|
|
|
180
147
|
* 版本号比较
|
|
181
148
|
*/
|
|
182
149
|
exports.compareVersion = function (v1, v2) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
const len = Math.max(v1.length, v2.length)
|
|
186
|
-
|
|
187
|
-
while (v1.length < len) {
|
|
188
|
-
v1.push('0')
|
|
189
|
-
}
|
|
190
|
-
while (v2.length < len) {
|
|
191
|
-
v2.push('0')
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
for (let i = 0; i < len; i++) {
|
|
195
|
-
const num1 = parseInt(v1[i])
|
|
196
|
-
const num2 = parseInt(v2[i])
|
|
197
|
-
|
|
198
|
-
if (num1 > num2) {
|
|
199
|
-
return 1
|
|
200
|
-
} else if (num1 < num2) {
|
|
201
|
-
return -1
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return 0
|
|
206
|
-
}
|
|
207
|
-
|
|
150
|
+
return utilsCommon.compareVersion(v1, v2);
|
|
151
|
+
}
|