mm_os 2.8.7 → 2.8.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.
Files changed (53) hide show
  1. package/core/base/index.js +28 -28
  2. package/core/base/mqtt/index.js +314 -314
  3. package/core/base/mqtt/lib.js +39 -39
  4. package/core/base/web/index.js +109 -109
  5. package/core/com/mqtt/index.js +2 -6
  6. package/core/com/nav/tpl/admin_pc/page_channel.vue +137 -131
  7. package/core/com/nav/tpl/admin_pc/page_config.vue +280 -279
  8. package/core/com/nav/tpl/admin_pc/page_config_form.vue +194 -194
  9. package/core/com/nav/tpl/admin_pc/page_default.vue +47 -87
  10. package/core/com/nav/tpl/admin_pc/page_form.vue +19 -19
  11. package/core/com/nav/tpl/admin_pc/page_lang.vue +44 -45
  12. package/core/com/nav/tpl/admin_pc/page_nav.vue +140 -132
  13. package/core/com/nav/tpl/admin_pc/page_table.vue +135 -124
  14. package/core/com/nav/tpl/admin_pc/page_type.vue +139 -131
  15. package/core/com/nav/tpl/admin_pc/page_view.vue +124 -0
  16. package/core/com/nav/tpl/dev_pc/page_channel.vue +34 -34
  17. package/core/com/nav/tpl/dev_pc/page_config.vue +26 -26
  18. package/core/com/nav/tpl/dev_pc/page_default.vue +4 -4
  19. package/core/com/nav/tpl/dev_pc/page_form.vue +2 -2
  20. package/core/com/nav/tpl/dev_pc/page_nav.vue +34 -34
  21. package/core/com/nav/tpl/dev_pc/page_table.vue +34 -34
  22. package/core/com/nav/tpl/dev_pc/page_type.vue +131 -71
  23. package/core/com/nav/tpl/home_pc/page_default.vue +2 -2
  24. package/core/com/nav/tpl/home_pc/page_form.vue +2 -2
  25. package/core/com/nav/tpl/home_pc/page_view.vue +2 -2
  26. package/core/com/nav/tpl/home_phone/page_form.vue +2 -2
  27. package/core/com/nav/tpl/home_phone/page_list.vue +2 -2
  28. package/core/com/nav/tpl/home_phone/page_view.vue +2 -2
  29. package/demo/index.js +28 -0
  30. package/middleware/cors/index.js +84 -84
  31. package/middleware/cors/middleware.json +6 -6
  32. package/middleware/log/index.js +20 -20
  33. package/middleware/log/middleware.json +8 -8
  34. package/middleware/mqtt_base/index.js +10 -10
  35. package/middleware/mqtt_base/middleware.json +7 -7
  36. package/middleware/waf/index.js +64 -64
  37. package/middleware/waf/middleware.json +8 -8
  38. package/middleware/waf_ip/index.js +115 -115
  39. package/middleware/waf_ip/middleware.json +9 -9
  40. package/middleware/web_base/index.js +65 -65
  41. package/middleware/web_base/middleware.json +8 -8
  42. package/middleware/web_event/index.js +412 -412
  43. package/middleware/web_event/middleware.json +9 -9
  44. package/middleware/web_proxy/index.js +23 -23
  45. package/middleware/web_proxy/middleware.json +8 -8
  46. package/middleware/web_router/index.js +33 -33
  47. package/middleware/web_router/middleware.json +9 -9
  48. package/middleware/web_socket/index.js +21 -21
  49. package/middleware/web_socket/middleware.json +8 -8
  50. package/middleware/web_static/index.js +25 -25
  51. package/middleware/web_static/middleware.json +8 -8
  52. package/package.json +8 -8
  53. package/static/file/image/user/42/2025_01_02_10_58_15.png +0 -0
@@ -1,40 +1,40 @@
1
- var urilib = require('url');
2
- var scanSchema = require('jsonschema/lib/scan').scan;
3
- var Validator = require("jsonschema/lib/validator.js");
4
- var helpers = require('jsonschema/lib/helpers');
5
- var SchemaContext = helpers.SchemaContext;
6
- var anonymousBase = '/';
7
-
8
- // 重构校验函数,解决error问题
9
- Validator.prototype.validate = function validate(instance, schema, options, ctx) {
10
- if (!options) {
11
- options = {};
12
- }
13
- // This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
14
- // This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
15
- var id = schema.$id || schema.id;
16
- var base = urilib.resolve(options.base || anonymousBase, id || '');
17
- if (!ctx) {
18
- ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas));
19
- if (!ctx.schemas[base]) {
20
- ctx.schemas[base] = schema;
21
- }
22
- var found = scanSchema(base, schema);
23
- for (var n in found.id) {
24
- var sch = found.id[n];
25
- ctx.schemas[n] = sch;
26
- }
27
- }
28
- if (options.required && instance === undefined) {
29
- var result = new ValidatorResult(instance, schema, options, ctx);
30
- result.addError('is required, but is undefined');
31
- return result;
32
- }
33
- var result = this.validateSchema(instance, schema, options, ctx);
34
- if (!result) {
35
- throw new Error('Result undefined');
36
- } else if (options.throwAll && result.errors.length) {
37
- throw new ValidatorResultError(result);
38
- }
39
- return result;
1
+ var urilib = require('url');
2
+ var scanSchema = require('jsonschema/lib/scan').scan;
3
+ var Validator = require("jsonschema/lib/validator.js");
4
+ var helpers = require('jsonschema/lib/helpers');
5
+ var SchemaContext = helpers.SchemaContext;
6
+ var anonymousBase = '/';
7
+
8
+ // 重构校验函数,解决error问题
9
+ Validator.prototype.validate = function validate(instance, schema, options, ctx) {
10
+ if (!options) {
11
+ options = {};
12
+ }
13
+ // This section indexes subschemas in the provided schema, so they don't need to be added with Validator#addSchema
14
+ // This will work so long as the function at uri.resolve() will resolve a relative URI to a relative URI
15
+ var id = schema.$id || schema.id;
16
+ var base = urilib.resolve(options.base || anonymousBase, id || '');
17
+ if (!ctx) {
18
+ ctx = new SchemaContext(schema, options, [], base, Object.create(this.schemas));
19
+ if (!ctx.schemas[base]) {
20
+ ctx.schemas[base] = schema;
21
+ }
22
+ var found = scanSchema(base, schema);
23
+ for (var n in found.id) {
24
+ var sch = found.id[n];
25
+ ctx.schemas[n] = sch;
26
+ }
27
+ }
28
+ if (options.required && instance === undefined) {
29
+ var result = new ValidatorResult(instance, schema, options, ctx);
30
+ result.addError('is required, but is undefined');
31
+ return result;
32
+ }
33
+ var result = this.validateSchema(instance, schema, options, ctx);
34
+ if (!result) {
35
+ throw new Error('Result undefined');
36
+ } else if (options.throwAll && result.errors.length) {
37
+ throw new ValidatorResultError(result);
38
+ }
39
+ return result;
40
40
  };
@@ -1,110 +1,110 @@
1
- const Koa = require('koa');
2
-
3
- /**
4
- * Web http 通讯类
5
- */
6
- class WEB {
7
- /**
8
- * 构造函数
9
- * @param {Object} config 配置参数
10
- */
11
- constructor(config) {
12
- /**
13
- * 配置参数
14
- */
15
- this.config = Object.assign({
16
- // 访问地址
17
- "host": "0.0.0.0",
18
- // 访问端口号
19
- "port": 5000,
20
- // 是否启用websocket
21
- "socket": true,
22
- // 是否启用压缩
23
- "compress": true,
24
- // 是否启用事件
25
- "event": true,
26
- // 是否启用事件
27
- "log": true,
28
- // 是否启用静态文件
29
- "static": true,
30
- // 静态文件路径
31
- "static_path": "./static".fullname($.runPath),
32
- // 代理转发
33
- "proxy": {}
34
- }, config);
35
-
36
- /**
37
- * web服务器
38
- */
39
- this.server = null;
40
- this.list = [];
41
- }
42
- }
43
-
44
- /**
45
- * 初始化
46
- * @param {Object} config
47
- */
48
- WEB.prototype.init = function(config) {
49
- if (config) {
50
- this.config = Object.assign(this.config, config);
51
- }
52
- this.server = new Koa();
53
- return this;
54
- };
55
-
56
- /**
57
- * 引用
58
- * @param {Function} 函数
59
- */
60
- WEB.prototype.use = function(func) {
61
- this.server.use(func);
62
- };
63
-
64
- /**
65
- * 运行主程序
66
- * @param {String} state 状态
67
- */
68
- WEB.prototype.main = function(state) {
69
- var cg = this.config;
70
- var host = cg.host;
71
- if (host == '0.0.0.0') {
72
- host = '127.0.0.1'
73
- }
74
- this.server.listen(cg.port, cg.host, () => {
75
- console.info(`HTTP访问 http://${host}:${cg.port}`);
76
- });
77
- };
78
-
79
- /**
80
- * 运行主程序前
81
- * @param {String} state 状态
82
- */
83
- WEB.prototype.before = async function(state) {
84
- var list = this.list;
85
- for (var i = 0; i < list.length; i++) {
86
- var o = list[i];
87
- o.func = require(o.func_file);
88
- if (o.func) {
89
- o.func(this.server, this.config);
90
- }
91
- }
92
- };
93
-
94
- /**
95
- * 运行主程序后
96
- * @param {String} state 状态
97
- */
98
- WEB.prototype.after = async function(state) {};
99
-
100
- /**
101
- * 运行
102
- * @param {String} state 状态
103
- */
104
- WEB.prototype.run = async function(state = 'start') {
105
- await this.before(state);
106
- await this.main(state);
107
- await this.after(state);
108
- };
109
-
1
+ const Koa = require('koa');
2
+
3
+ /**
4
+ * Web http 通讯类
5
+ */
6
+ class WEB {
7
+ /**
8
+ * 构造函数
9
+ * @param {Object} config 配置参数
10
+ */
11
+ constructor(config) {
12
+ /**
13
+ * 配置参数
14
+ */
15
+ this.config = Object.assign({
16
+ // 访问地址
17
+ "host": "0.0.0.0",
18
+ // 访问端口号
19
+ "port": 5000,
20
+ // 是否启用websocket
21
+ "socket": true,
22
+ // 是否启用压缩
23
+ "compress": true,
24
+ // 是否启用事件
25
+ "event": true,
26
+ // 是否启用事件
27
+ "log": true,
28
+ // 是否启用静态文件
29
+ "static": true,
30
+ // 静态文件路径
31
+ "static_path": "./static".fullname($.runPath),
32
+ // 代理转发
33
+ "proxy": {}
34
+ }, config);
35
+
36
+ /**
37
+ * web服务器
38
+ */
39
+ this.server = null;
40
+ this.list = [];
41
+ }
42
+ }
43
+
44
+ /**
45
+ * 初始化
46
+ * @param {Object} config
47
+ */
48
+ WEB.prototype.init = function(config) {
49
+ if (config) {
50
+ this.config = Object.assign(this.config, config);
51
+ }
52
+ this.server = new Koa();
53
+ return this;
54
+ };
55
+
56
+ /**
57
+ * 引用
58
+ * @param {Function} 函数
59
+ */
60
+ WEB.prototype.use = function(func) {
61
+ this.server.use(func);
62
+ };
63
+
64
+ /**
65
+ * 运行主程序
66
+ * @param {String} state 状态
67
+ */
68
+ WEB.prototype.main = function(state) {
69
+ var cg = this.config;
70
+ var host = cg.host;
71
+ if (host == '0.0.0.0') {
72
+ host = '127.0.0.1'
73
+ }
74
+ this.server.listen(cg.port, cg.host, () => {
75
+ console.info(`HTTP访问 http://${host}:${cg.port}`);
76
+ });
77
+ };
78
+
79
+ /**
80
+ * 运行主程序前
81
+ * @param {String} state 状态
82
+ */
83
+ WEB.prototype.before = async function(state) {
84
+ var list = this.list;
85
+ for (var i = 0; i < list.length; i++) {
86
+ var o = list[i];
87
+ o.func = require(o.func_file);
88
+ if (o.func) {
89
+ o.func(this.server, this.config);
90
+ }
91
+ }
92
+ };
93
+
94
+ /**
95
+ * 运行主程序后
96
+ * @param {String} state 状态
97
+ */
98
+ WEB.prototype.after = async function(state) {};
99
+
100
+ /**
101
+ * 运行
102
+ * @param {String} state 状态
103
+ */
104
+ WEB.prototype.run = async function(state = 'start') {
105
+ await this.before(state);
106
+ await this.main(state);
107
+ await this.after(state);
108
+ };
109
+
110
110
  module.exports = WEB;
@@ -426,9 +426,7 @@ MQTT.prototype.save_online = async function(arr, online = 1) {
426
426
  var body = {
427
427
  online
428
428
  }
429
- var sql = $.mysql_admin('sys');
430
- sql.open();
431
- var db = sql.db();
429
+ var db = $.sql.db();
432
430
  db.table = this.config.table || "iot_device";
433
431
  db.size = 0;
434
432
  var query = {};
@@ -442,9 +440,7 @@ MQTT.prototype.save_online = async function(arr, online = 1) {
442
440
  * 获取所有设备
443
441
  */
444
442
  MQTT.prototype.get_drives = async function() {
445
- var sql = $.mysql_admin('sys');
446
- sql.open();
447
- var db = sql.db();
443
+ var db = $.sql.db();
448
444
  db.table = this.config.table || "iot_device";
449
445
  db.size = 0;
450
446
  return await db.get({}, "", "clientid, online");