q-koa 10.7.1 → 10.7.3

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.
@@ -32,13 +32,15 @@ exports.header = {
32
32
  }
33
33
  },
34
34
  get: function () {
35
+ const value = this.getDataValue('header')
35
36
  try {
36
- const value = this.getDataValue('header')
37
37
  const dataValue =
38
38
  typeof value === 'object' ? value || {} : JSON.parse(value)
39
39
  return dataValue
40
40
  } catch {
41
- return {}
41
+ return {
42
+ text: value,
43
+ }
42
44
  }
43
45
  },
44
46
  extra: {
@@ -56,17 +58,21 @@ exports.body = {
56
58
  const dataValue = typeof value === 'object' ? value : JSON.parse(value)
57
59
  this.setDataValue('body', dataValue)
58
60
  } catch {
59
- throw new Error('body值不合法')
61
+ this.setDataValue('body', {
62
+ text: value,
63
+ })
60
64
  }
61
65
  },
62
66
  get: function () {
67
+ const value = this.getDataValue('body')
63
68
  try {
64
- const value = this.getDataValue('body')
65
69
  const dataValue =
66
70
  typeof value === 'object' ? value || {} : JSON.parse(value)
67
71
  return dataValue
68
72
  } catch {
69
- return {}
73
+ return {
74
+ text: value,
75
+ }
70
76
  }
71
77
  },
72
78
  extra: {
@@ -29,7 +29,8 @@ exports.type = {
29
29
  'rich-text',
30
30
  'date',
31
31
  'datetime',
32
- 'list'
32
+ 'list',
33
+ 'json'
33
34
  ),
34
35
  comment: 'type类型',
35
36
  allowNull: true,
@@ -50,6 +51,15 @@ exports.value = {
50
51
  switch (type) {
51
52
  case 'switch':
52
53
  return Boolean(Number(this.getDataValue('value')))
54
+ case 'json':
55
+ try {
56
+ const value = JSON.parse(this.getDataValue('value'))
57
+ return value
58
+ } catch (e) {
59
+ return {
60
+ text: this.getDataValue('value'),
61
+ }
62
+ }
53
63
  case 'list':
54
64
  try {
55
65
  const value = JSON.parse(this.getDataValue('value'))
@@ -47,23 +47,6 @@ exports.refund = async ({
47
47
  }/${appName}/toutiao/refund_notify`,
48
48
  }
49
49
 
50
- const signResult = (params, salt) => {
51
- var skip_arr = ['thirdparty_id', 'app_id', 'sign']
52
- var paramArray = new Array()
53
- for (var k in params) {
54
- if (skip_arr.indexOf(k) != -1) {
55
- continue
56
- }
57
- if (params[k] == '') {
58
- continue
59
- }
60
- paramArray.push(params[k])
61
- }
62
- paramArray.push(salt)
63
- paramArray.sort()
64
- var signStr = paramArray.join('&')
65
- return md5(signStr)
66
- }
67
50
  const res = await axios
68
51
  .post(url, {
69
52
  ...data,
@@ -18,7 +18,15 @@ exports.getName = (config) => (type) => {
18
18
 
19
19
  exports.getList = (config) => (type) => {
20
20
  const obj = config.find((i) => i.code === type)
21
- if (!obj) throw new Error(`找不到${type}相关设置`)
21
+ if (!obj) {
22
+ if (process.env.NODE_ENV === 'production') {
23
+ throw new Error(`找不到${type}相关设置`)
24
+ } else {
25
+ console.error(`找不到${type}相关设置`)
26
+ }
27
+ return []
28
+ }
29
+
22
30
  const list = config.filter((i) => i.parent_id === obj.id)
23
31
  return list
24
32
  }
@@ -72,7 +80,14 @@ exports.getObject = (config, app) => async (type) => {
72
80
  }
73
81
  }
74
82
  }
75
- if (!flag) throw new Error(`找不到${type}相关设置`)
83
+ if (!flag) {
84
+ if (process.env.NODE_ENV === 'production') {
85
+ throw new Error(`找不到${type}相关设置`)
86
+ } else {
87
+ console.error(`找不到${type}相关设置`)
88
+ }
89
+ return temObj
90
+ }
76
91
  return temObj
77
92
  }
78
93
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "q-koa",
3
- "version": "10.7.1",
3
+ "version": "10.7.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {