mm_os 2.9.5 → 2.9.7

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.
Files changed (2) hide show
  1. package/index.js +47 -44
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -81,6 +81,8 @@ class OS {
81
81
  }
82
82
  }
83
83
 
84
+ OS.prototype.init_mod = function() {}
85
+
84
86
  /**
85
87
  * 初始化数据
86
88
  * @param {Object} config 配置参数
@@ -95,6 +97,14 @@ OS.prototype.initData = function(config) {
95
97
 
96
98
  $.runPath = config.runPath;
97
99
 
100
+ // 初始化公共函数
101
+ $.func = {};
102
+
103
+ // 初始化变量
104
+ $.var = {};
105
+ $.conf = conf(null, '/conf.json'.fullname());
106
+ $.config = config;
107
+
98
108
  // 修改默认模板路径,改为static下,方便读取css和js
99
109
  $.Tpl.prototype.init_main = function(cg) {
100
110
  if (cg) {
@@ -109,33 +119,58 @@ OS.prototype.initData = function(config) {
109
119
  this.set_config(cg);
110
120
  this.dir = cg.default_dir;
111
121
  }
112
-
113
- // 初始化公共函数
114
- $.func = {};
115
-
116
- // 初始化变量
117
- $.var = {};
118
- $.conf = conf(null, '/conf.json'.fullname());
119
- $.config = config;
120
122
  }
121
123
 
122
124
  /**
123
125
  * 加载核心模块
124
- * @param {Object} config 配置参数
126
+ * @param {Object} cg 配置参数
125
127
  */
126
- OS.prototype.loadModule = function(config) {
128
+ OS.prototype.loadModule = function(cg) {
127
129
  $.com = new Com();
128
130
  $.app = new App();
129
131
  this.com = $.com;
130
132
  this.app = $.app;
131
133
 
132
134
  $.task = $.task_admin('sys');
133
- if (config.sys) {
134
- if (config.sys.game) {
135
+ if (cg.sys) {
136
+ if (cg.sys.game) {
135
137
  $.game = new Game();
136
138
  this.game = $.game;
137
139
  }
138
140
  }
141
+
142
+ if (cg.sys) {
143
+ var cache = cg.sys.cache;
144
+ // 选择缓存方式,默认memory缓存
145
+ if (cache === 'redis') {
146
+ // 将Api的缓存改为redis方式,如果不用redis可以将以下4行注释掉
147
+ var redis = $.redis_admin('sys');
148
+ redis.setConfig(cg.redis);
149
+ redis.open();
150
+ $.cache = redis;
151
+ } else if (cache === 'cache') {
152
+ // 将Api的缓存改为cache方式, 本地缓存方式
153
+ $.cache_admin = require('mm_cache').cache_admin;
154
+ $.push($.cache, $.cache_admin('sys'), true);
155
+ } else if (cache === 'mongodb') {
156
+ var mongodb = $.mongodb_admin('sys');
157
+ mongodb.setConfig(cg.mongodb);
158
+ mongodb.open();
159
+ $.cache = mongodb;
160
+ }
161
+ }
162
+
163
+ $.sql = $.mysql_admin('sys', $.runPath);
164
+ if (cg.mysql) {
165
+ $.sql.setConfig(cg.mysql);
166
+ if (cg.mysql.state === 1) {
167
+ $.sql.open();
168
+ }
169
+ }
170
+
171
+ if (!cg.sys.hot_reload) {
172
+ $.mod.config.watch = false;
173
+ }
139
174
  }
140
175
 
141
176
  /**
@@ -146,9 +181,6 @@ OS.prototype.init = function(config) {
146
181
  this.config = Object.assign(this.config, config);
147
182
  this.initData(this.config);
148
183
  this.loadModule(this.config);
149
- if (!this.config.sys.hot_reload) {
150
- $.mod.config.watch = false;
151
- }
152
184
  this.initBase(this.config);
153
185
  }
154
186
 
@@ -181,35 +213,6 @@ OS.prototype.initBase = function(cg) {
181
213
  this.mqtt = mqtt;
182
214
  }
183
215
 
184
- if (cg.sys) {
185
- var cache = cg.sys.cache;
186
- // 选择缓存方式,默认memory缓存
187
- if (cache === 'redis') {
188
- // 将Api的缓存改为redis方式,如果不用redis可以将以下4行注释掉
189
- var redis = $.redis_admin('sys');
190
- redis.setConfig(cg.redis);
191
- redis.open();
192
- $.cache = redis;
193
- } else if (cache === 'cache') {
194
- // 将Api的缓存改为cache方式, 本地缓存方式
195
- $.cache_admin = require('mm_cache').cache_admin;
196
- $.push($.cache, $.cache_admin('sys'), true);
197
- } else if (cache === 'mongodb') {
198
- var mongodb = $.mongodb_admin('sys');
199
- mongodb.setConfig(cg.mongodb);
200
- mongodb.open();
201
- $.cache = mongodb;
202
- }
203
- }
204
-
205
- $.sql = $.mysql_admin('sys', $.runPath);
206
- if (cg.mysql) {
207
- $.sql.setConfig(cg.mysql);
208
- if (cg.mysql.state === 1) {
209
- $.sql.open();
210
- }
211
- }
212
-
213
216
  // 启动计时器
214
217
  $.timer.run();
215
218
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mm_os",
3
- "version": "2.9.5",
3
+ "version": "2.9.7",
4
4
  "description": "这是超级美眉服务端框架,用于快速构建应用程序。",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -45,7 +45,7 @@
45
45
  "mm_machine": "^1.9.7",
46
46
  "mm_mongodb": "^1.4.2",
47
47
  "mm_mqtt": "^1.0.6",
48
- "mm_mysql": "^1.9.3",
48
+ "mm_mysql": "^1.9.4",
49
49
  "mm_redis": "^1.4.2",
50
50
  "mm_ret": "^1.4.0",
51
51
  "mm_session": "^1.4.8",