q-koa 12.5.5 → 12.5.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.
package/core/app.js CHANGED
@@ -692,24 +692,26 @@ class APP {
692
692
  },
693
693
  this.app[appName]
694
694
  )
695
- const mockObj = _.pickBy(
696
- _attributes,
697
- (item) => item.mock && typeof item.mock === 'function'
698
- )
699
- this.app[appName] = _.defaultsDeep(
700
- {
701
- mock: {
702
- [folder]: () =>
703
- _.zipObject(
704
- Object.keys(mockObj),
705
- Object.keys(mockObj).map((key) =>
706
- _.result(mockObj, `${key}.mock`)
707
- )
708
- ),
695
+ if (is_dev) {
696
+ const mockObj = _.pickBy(
697
+ _attributes,
698
+ (item) => item.mock && typeof item.mock === 'function'
699
+ )
700
+ this.app[appName] = _.defaultsDeep(
701
+ {
702
+ mock: {
703
+ [folder]: () =>
704
+ _.zipObject(
705
+ Object.keys(mockObj),
706
+ Object.keys(mockObj).map((key) =>
707
+ _.result(mockObj, `${key}.mock`)
708
+ )
709
+ ),
710
+ },
709
711
  },
710
- },
711
- this.app[appName]
712
- )
712
+ this.app[appName]
713
+ )
714
+ }
713
715
  } else if (
714
716
  [
715
717
  'config',
package/core/config.js CHANGED
@@ -107,7 +107,7 @@ module.exports = {
107
107
  jwt: {
108
108
  secret: 'token',
109
109
  tokenKey: 'token',
110
- expiresIn: '60480000',
110
+ expiresIn: '172800000',
111
111
  whiteList: [], // 应用覆盖
112
112
  _whiteList: [
113
113
  '/',
@@ -1,5 +1,4 @@
1
- const { Sequelize, Random } = require('q-koa');
2
-
1
+ const { Sequelize, Random } = require('q-koa')
3
2
 
4
3
  exports.name = {
5
4
  type: Sequelize.STRING,
@@ -31,7 +30,7 @@ exports.desc = {
31
30
  defaultValue: '',
32
31
  sortOrder: 3,
33
32
  mock: () => Random.csentence(),
34
- extra: {"type":"markdown"},
33
+ extra: { type: 'markdown' },
35
34
  }
36
35
 
37
36
  exports.role_id = {
@@ -54,7 +53,6 @@ exports.sortOrder = {
54
53
  is_mock: false,
55
54
  defaultValue: 0,
56
55
  sortOrder: 5,
57
-
58
56
  }
59
57
 
60
58
  exports.is_on = {
@@ -65,5 +63,36 @@ exports.is_on = {
65
63
  defaultValue: true,
66
64
  sortOrder: 6,
67
65
  mock: () => Random.boolean(),
68
- extra: {"controlInline":true},
66
+ extra: { controlInline: true },
67
+ }
68
+
69
+ exports.extra = {
70
+ type: Sequelize.JSON,
71
+ comment: '额外数据',
72
+ allowNull: true,
73
+ is_mock: false,
74
+ defaultValue: {},
75
+ sortOrder: 7,
76
+ set: function (value) {
77
+ try {
78
+ const dataValue = typeof value === 'object' ? value : JSON.parse(value)
79
+ this.setDataValue('extra', dataValue)
80
+ } catch {
81
+ throw new Error('extra值不合法')
82
+ }
83
+ },
84
+ get: function () {
85
+ const value = this.getDataValue('extra')
86
+ try {
87
+ const dataValue =
88
+ typeof value === 'object' ? value || {} : JSON.parse(value)
89
+
90
+ return dataValue
91
+ } catch {
92
+ return {
93
+ text: value,
94
+ }
95
+ }
96
+ },
97
+ extra: { type: 'json-editor' },
69
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "12.5.5",
3
+ "version": "12.5.7",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {