mm_machine 3.4.7 → 3.4.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/lib/drive.js +25 -2
- package/package.json +1 -1
package/lib/drive.js
CHANGED
|
@@ -62,6 +62,24 @@ class Drive extends Mod {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* 监听初始化事件
|
|
67
|
+
*/
|
|
68
|
+
Drive.prototype._onInit = function () {
|
|
69
|
+
// 初始化
|
|
70
|
+
this.on('init:before', async (ctx) => {
|
|
71
|
+
this.setState('initing');
|
|
72
|
+
this._initOptions();
|
|
73
|
+
await this._initCore(...ctx.params);
|
|
74
|
+
});
|
|
75
|
+
this.on('init:success', (ctx) => {
|
|
76
|
+
this.isInited(true);
|
|
77
|
+
});
|
|
78
|
+
this.on('init:after', (ctx) => {
|
|
79
|
+
this.setState('inited');
|
|
80
|
+
});
|
|
81
|
+
};
|
|
82
|
+
|
|
65
83
|
/**
|
|
66
84
|
* 监听加载事件
|
|
67
85
|
* @param {object} ctx 上下文对象
|
|
@@ -152,7 +170,6 @@ Drive.prototype.setConfig = function (config) {
|
|
|
152
170
|
this.isLoaded(false);
|
|
153
171
|
}
|
|
154
172
|
this._preset();
|
|
155
|
-
this._initOptions();
|
|
156
173
|
return this.config;
|
|
157
174
|
};
|
|
158
175
|
|
|
@@ -250,6 +267,7 @@ Drive.prototype._getOptionsFileName = function () {
|
|
|
250
267
|
*/
|
|
251
268
|
Drive.prototype._getOptionsDirName = function () {
|
|
252
269
|
let parent = this.getParent();
|
|
270
|
+
if (!parent) return '';
|
|
253
271
|
var current_name = parent.constructor.name + '_' + (parent.config.name || 'default');
|
|
254
272
|
return current_name.toLowerCase();
|
|
255
273
|
};
|
|
@@ -288,7 +306,9 @@ Drive.prototype.getOption = function (key) {
|
|
|
288
306
|
* @param {object} options 所有选项
|
|
289
307
|
*/
|
|
290
308
|
Drive.prototype.setOptions = function (options) {
|
|
291
|
-
|
|
309
|
+
if (!options) return;
|
|
310
|
+
$.push(this._options, options || {});
|
|
311
|
+
this.setOptionsToFile();
|
|
292
312
|
};
|
|
293
313
|
|
|
294
314
|
/**
|
|
@@ -304,7 +324,10 @@ Drive.prototype.setOption = function (key, value) {
|
|
|
304
324
|
this._options = {};
|
|
305
325
|
}
|
|
306
326
|
this._options[key] = value;
|
|
327
|
+
this.setOptionsToFile();
|
|
328
|
+
};
|
|
307
329
|
|
|
330
|
+
Drive.prototype.setOptionsToFile = function () {
|
|
308
331
|
let cache_file = this._getOptionsFile();
|
|
309
332
|
if (cache_file) {
|
|
310
333
|
// 确保目录存在
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_machine",
|
|
3
|
-
"version": "3.4.
|
|
3
|
+
"version": "3.4.9",
|
|
4
4
|
"description": "A flexible Node.js plugin mechanism system for dynamic loading, management and execution of modules. Supports hot reload, lifecycle management, and modern JavaScript features.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|