q-koa 8.6.7 → 8.7.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.
package/core/file/utils/index.js
CHANGED
|
@@ -16,11 +16,32 @@ exports.getList = (config) => (type) => {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
exports.getObject = (config, app) => async (type) => {
|
|
19
|
+
const obj = config.find((i) => i.code === type)
|
|
20
|
+
if (!obj) throw new Error(`找不到${type}相关设置`)
|
|
21
|
+
const list = config.filter((i) => i.parent_id === obj.id)
|
|
22
|
+
const temObj = {}
|
|
23
|
+
for (let i = 0; i < list.length; i++) {
|
|
24
|
+
if (list[i].type === 'decimal') {
|
|
25
|
+
temObj[list[i].code] = Number(list[i].value)
|
|
26
|
+
} else if (list[i].type === 'switch') {
|
|
27
|
+
temObj[list[i].code] = Boolean(Number(list[i].value))
|
|
28
|
+
} else {
|
|
29
|
+
temObj[list[i].code] = list[i].value
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
19
33
|
const findConfig = (item) => item.config === type || item.pay_config === type
|
|
20
34
|
if (app) {
|
|
21
35
|
const applicationList = app.cache.get('application')
|
|
22
|
-
if (
|
|
23
|
-
|
|
36
|
+
if (
|
|
37
|
+
applicationList &&
|
|
38
|
+
applicationList.find(findConfig) &&
|
|
39
|
+
applicationList.find(findConfig)
|
|
40
|
+
) {
|
|
41
|
+
return {
|
|
42
|
+
...applicationList.find(findConfig),
|
|
43
|
+
...temObj,
|
|
44
|
+
}
|
|
24
45
|
}
|
|
25
46
|
|
|
26
47
|
if (!applicationList) {
|
|
@@ -32,25 +53,16 @@ exports.getObject = (config, app) => async (type) => {
|
|
|
32
53
|
|
|
33
54
|
const target = result.find(findConfig)
|
|
34
55
|
if (target) {
|
|
35
|
-
return
|
|
56
|
+
return {
|
|
57
|
+
...target,
|
|
58
|
+
...temObj,
|
|
59
|
+
}
|
|
36
60
|
}
|
|
37
61
|
}
|
|
38
62
|
}
|
|
39
63
|
}
|
|
40
64
|
}
|
|
41
|
-
|
|
42
|
-
if (!obj) throw new Error(`找不到${type}相关设置`)
|
|
43
|
-
const list = config.filter((i) => i.parent_id === obj.id)
|
|
44
|
-
const temObj = {}
|
|
45
|
-
for (let i = 0; i < list.length; i++) {
|
|
46
|
-
if (list[i].type === 'decimal') {
|
|
47
|
-
temObj[list[i].code] = Number(list[i].value)
|
|
48
|
-
} else if (list[i].type === 'switch') {
|
|
49
|
-
temObj[list[i].code] = Boolean(Number(list[i].value))
|
|
50
|
-
} else {
|
|
51
|
-
temObj[list[i].code] = list[i].value
|
|
52
|
-
}
|
|
53
|
-
}
|
|
65
|
+
|
|
54
66
|
return temObj
|
|
55
67
|
}
|
|
56
68
|
|