Skip to content

Commit e920c2c

Browse files
committed
更新[BoxJs]: 偏好设置增加 http-api 超时时间, 订阅配置增加 script_timeout 自发性
1 parent f7cfa28 commit e920c2c

4 files changed

Lines changed: 37 additions & 15 deletions

File tree

‎Env.js‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ function Env(name, opts) {
3333
})
3434
}
3535

36-
runScript(script) {
36+
runScript(script, runOpts) {
3737
return new Promise((resolve) => {
3838
let httpapi = this.getdata('@chavy_boxjs_userCfgs.httpapi')
3939
httpapi = httpapi ? httpapi.replace(/\n/g, '').trim() : httpapi
40+
let httpapi_timeout = this.getdata('@chavy_boxjs_userCfgs.httpapi_timeout')
41+
httpapi_timeout = httpapi_timeout ? httpapi_timeout * 1 : 20
42+
httpapi_timeout = runOpts && runOpts.timeout ? runOpts.timeout : httpapi_timeout
4043
const [key, addr] = httpapi.split('@')
4144
const opts = {
4245
url: `http://${addr}/v1/scripting/evaluate`,
43-
body: { script_text: script, mock_type: 'cron', timeout: 5 },
46+
body: { script_text: script, mock_type: 'cron', timeout: httpapi_timeout },
4447
headers: { 'X-Key': key, 'Accept': '*/*' }
4548
}
4649
$.post(opts, (err, resp, body) => resolve(body))
47-
})
50+
}).catch((e) => this.logErr(e))
4851
}
4952
loaddata() {
5053
if (this.isNode()) {
@@ -131,12 +134,10 @@ function Env(name, opts) {
131134
const objedval = JSON.parse(objval)
132135
this.lodash_set(objedval, paths, val)
133136
issuc = this.setval(JSON.stringify(objedval), objkey)
134-
console.log(`${objkey}: ${JSON.stringify(objedval)}`)
135137
} catch (e) {
136138
const objedval = {}
137139
this.lodash_set(objedval, paths, val)
138140
issuc = this.setval(JSON.stringify(objedval), objkey)
139-
console.log(`${objkey}: ${JSON.stringify(objedval)}`)
140141
}
141142
} else {
142143
issuc = $.setval(val, key)

‎Env.min.js‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎box/release/box.release.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
11
{
22
"releases": [
3+
{
4+
"version": "0.6.15",
5+
"tags": ["beta"],
6+
"author": "@chavyleung",
7+
"icon": "https://avatars3.githubusercontent.com/u/29748519",
8+
"repo": "https://github.com/chavyleung",
9+
"notes": [
10+
{
11+
"name": "偏好设置",
12+
"descs": ["新增: http-api 超时时间, 默认 20 秒"]
13+
},
14+
{
15+
"name": "订阅配置",
16+
"descs": ["增加 script_timeout 属性, 与 script 同级, 可指定 http-api 超时时间, 单位: 秒"]
17+
}
18+
]
19+
},
320
{
421
"version": "0.6.14",
522
"tags": ["beta"],

0 commit comments

Comments
 (0)