jj.js 0.7.6 → 0.8.0

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 (3) hide show
  1. package/lib/db.js +1 -5
  2. package/lib/view.js +15 -1
  3. package/package.json +1 -1
package/lib/db.js CHANGED
@@ -106,7 +106,6 @@ class Db extends Context
106
106
  try {
107
107
  await fun();
108
108
  await this.commit();
109
- resolve('事务执行成功!');
110
109
  } catch(e) {
111
110
  await this.rollback();
112
111
  throw e;
@@ -450,10 +449,7 @@ class Db extends Context
450
449
  return result;
451
450
  }
452
451
 
453
- async pagination(page, page_size, pagination) {
454
- if(typeof page == 'object' || typeof page == 'function') {
455
- [page, pagination] = [pagination, page];
456
- }
452
+ async pagination({page, page_size, pagination} = {}) {
457
453
  if(!pagination) {
458
454
  pagination = this.$pagination.__node.isClass ? this.$pagination : this.$.pagination;
459
455
  }
package/lib/view.js CHANGED
@@ -56,8 +56,10 @@ class View extends Context
56
56
  let view_file = template;
57
57
  if(view_file.indexOf('/') !== 0) {
58
58
  const temp = view_file.replace(/^\/|\/$/g, '').split('/').reverse().map(u => toLine(u));
59
+ const folder = this._folder;
60
+ const depr = this._depr;
59
61
  if(temp.length <= 3) {
60
- view_file = `${temp[2] || this.ctx.APP}/${cfg_view.view_folder}/${temp[1] || this.ctx.CONTROLLER}${cfg_view.view_depr}${temp[0]}`;
62
+ view_file = `${temp[2] || this.ctx.APP}/${folder || cfg_view.view_folder}/${temp[1] || this.ctx.CONTROLLER}${depr || cfg_view.view_depr}${temp[0]}`;
61
63
  }
62
64
  }
63
65
  path.extname(view_file) || (view_file += cfg_view.view_ext);
@@ -86,6 +88,18 @@ class View extends Context
86
88
  }
87
89
  return this;
88
90
  }
91
+
92
+ //设置模版目录
93
+ setFolder(view_folder) {
94
+ this._folder = view_folder;
95
+ return this;
96
+ }
97
+
98
+ //设置文件分割符
99
+ setDepr(view_depr) {
100
+ this._depr = view_depr;
101
+ return this;
102
+ }
89
103
  }
90
104
 
91
105
  module.exports = View;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jj.js",
3
- "version": "0.7.6",
3
+ "version": "0.8.0",
4
4
  "description": "A simple and lightweight MVC framework built on nodejs+koa2",
5
5
  "main": "jj.js",
6
6
  "scripts": {