jj.js 0.7.2 → 0.7.5

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/controller.js CHANGED
@@ -2,13 +2,6 @@ const Middleware = require('./middleware');
2
2
 
3
3
  class Controller extends Middleware
4
4
  {
5
- constructor(...args) {
6
- super(...args);
7
- if(!this.$view.__node.isClass) {
8
- this.$view = this.$.view;
9
- }
10
- }
11
-
12
5
  // 赋值模版数据
13
6
  $assign(name, value) {
14
7
  this.$view.assign(name, value);
package/lib/ctx.js CHANGED
@@ -3,37 +3,43 @@ const loader = require('./loader');
3
3
  const Ctx = new Proxy(class {}, {
4
4
  construct() {
5
5
  return new Proxy({__proto__: arguments[2].prototype}, {
6
- get: (target, prop) => {
6
+ get: (target, prop, receiver) => {
7
7
  if(prop in target || typeof prop == 'symbol' || prop == 'inspect') {
8
- return target[prop];
8
+ return Reflect.get(target, prop, receiver);
9
9
  }
10
10
  if(prop == '$' || prop == '_') {
11
11
  return target.ctx && target.ctx[prop]
12
12
  || prop == '$' && (target.$ || (target.$ = loader('../'))) && target.$
13
13
  || undefined;
14
14
  }
15
+ if(prop.slice(0, 1) != '$') {
16
+ return undefined;
17
+ }
15
18
  const pp = prop.slice(1);
16
- if(target.ctx && target.ctx._) {
17
- const _ = target.ctx._;
18
- const ctx_app = target.ctx.APP;
19
- const common_app = _.config.app.common_app;
20
- const $ = target.ctx.$;
21
- if(_[ctx_app][prop] === undefined) {
22
- if(_[ctx_app][pp] && _[common_app] && _[common_app][pp]) {
23
- _[ctx_app][prop] = new Proxy({}, {
19
+ const ctx = target.ctx;
20
+ if(ctx && ctx._) {
21
+ const _ = ctx._;
22
+ const APP = ctx.APP;
23
+ const COMMON = _.config.app.common_app;
24
+ if(_[APP][prop] === undefined) {
25
+ if(_[APP][pp] && _[COMMON] && _[COMMON][pp]) {
26
+ _[APP][prop] = new Proxy({}, {
24
27
  get: (...args) => {
25
- return _[ctx_app][pp][args[1]] || _[common_app][pp][args[1]];
28
+ return _[APP][pp][args[1]] || _[COMMON][pp][args[1]];
26
29
  }
27
30
  });
28
- } else if(_[ctx_app][pp]) {
29
- _[ctx_app][prop] = _[ctx_app][pp];
30
- } else if(_[common_app] && _[common_app][pp]) {
31
- _[ctx_app][prop] = _[common_app][pp];
31
+ } else if(_[APP][pp]) {
32
+ _[APP][prop] = _[APP][pp];
33
+ } else if(_[COMMON] && _[COMMON][pp]) {
34
+ _[APP][prop] = _[COMMON][pp];
32
35
  } else {
33
- _[ctx_app][prop] = null;
36
+ _[APP][prop] = null;
37
+ }
38
+ if(~['view', 'response'].indexOf(pp) && _[APP][prop] && _[APP][prop].__node && !_[APP][prop].__node.isClass && ctx.$ && ctx.$[pp]) {
39
+ _[APP][prop] = ctx.$[pp];
34
40
  }
35
41
  }
36
- return _[ctx_app][prop] || _[pp] || $[pp] || undefined;
42
+ return _[APP][prop] || _[pp] || (ctx.$ && ctx.$[pp]) || undefined;
37
43
  } else {
38
44
  return (target.$ || (target.$ = loader('../'))) && target.$[pp];
39
45
  }
package/lib/loader.js CHANGED
@@ -17,9 +17,9 @@ function loader(dir='./', ...args) {
17
17
 
18
18
  function creatLoader(node) {
19
19
  return new Proxy(node, {
20
- get: (node, prop) => {
20
+ get: (node, prop, receiver) => {
21
21
  if(prop in node || typeof prop == 'symbol' || prop == 'inspect') {
22
- return node[prop];
22
+ return Reflect.get(node, prop, receiver);
23
23
  }
24
24
  const nodeInfo = info.get(node);
25
25
  if(nodeInfo.isClass) {
package/lib/upload.js CHANGED
@@ -37,7 +37,7 @@ class Upload extends Context
37
37
 
38
38
  try {
39
39
  const filePath = pt.join(this.$config.app.base_dir, dir, savename);
40
- await utils.fs.mkdirs(filePath);
40
+ await utils.fs.mkdirs(pt.dirname(filePath));
41
41
  const reader = fs.createReadStream(this._file.path);
42
42
  const writer = fs.createWriteStream(filePath);
43
43
  reader.pipe(writer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jj.js",
3
- "version": "0.7.2",
3
+ "version": "0.7.5",
4
4
  "description": "A simple and lightweight MVC framework built on nodejs+koa2",
5
5
  "main": "jj.js",
6
6
  "scripts": {
@@ -22,12 +22,12 @@
22
22
  },
23
23
  "homepage": "https://github.com/yafoo/jj.js#readme",
24
24
  "dependencies": {
25
- "@koa/router": "^10.1.0",
25
+ "@koa/router": "^10.1.1",
26
26
  "art-template": "^4.13.2",
27
27
  "escape-html": "^1.0.3",
28
28
  "is-class": "0.0.9",
29
- "koa": "^2.13.1",
30
- "koa-body": "^4.2.0",
29
+ "koa": "^2.13.4",
30
+ "koa-body": "^5.0.0",
31
31
  "koa-static": "^5.0.0",
32
32
  "mysql": "^2.18.1"
33
33
  }